static gboolean ap_validate_menu (GnomeDruidPage *druidpage, GtkWidget *druid, gpointer user_data) { GDate date_now; AcctPeriodInfo *info = user_data; ENTER("info=%p", info); /* Pull info from widget, push into freq spec */ //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date); recurrenceListFree(&info->period); gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date); if (0 <= g_date_compare(&info->prev_closing_date, &info->closing_date)) { const char *msg = _("You must select closing date that " "is greater than the closing date " "of the previous book."); gnc_error_dialog (info->window, "%s", msg); return TRUE; } g_date_clear (&date_now, 1); g_date_set_time_t (&date_now, time(NULL)); if (0 < g_date_compare(&info->closing_date, &date_now)) { const char *msg = _("You must select closing date " "that is not in the future."); gnc_error_dialog (info->window, "%s", msg); return TRUE; } return FALSE; }
/** This function is called when the Apply button is clicked on the * Finish Page of the assistant. It determines whether or not there * is any work to be performed by Gnucash, and if so it calls other * functions to carry out the work. */ void assistant_gconf_finish (GtkAssistant *assistant, gpointer user_data) { gconf_data *data = user_data; GtkWidget *window; gint value, value2; GError *error = NULL; gboolean keep_going = TRUE; /* What to do... what to do... */ value = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(assistant), WHO_DOES)); switch (value) { case WHO_ALREADY_DONE: break; case WHO_USER: keep_going = FALSE; break; default: value2 = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(assistant), HOW)); switch (value2) { case HOW_INSTALL: if (!assistant_gconf_install_keys(&error)) { keep_going = FALSE; gnc_error_dialog(NULL, "%s", error->message); g_error_free(error); } break; default: if (!assistant_gconf_update_path(&error)) { keep_going = FALSE; gnc_error_dialog(NULL, "%s", error->message); g_error_free(error); } break; } break; } /* Hide the Assistant */ gtk_widget_hide(GTK_WIDGET(data->dialog)); if (keep_going) { gtk_main_quit(); } else { exit(42); } }
static gboolean gnc_job_verify_ok (JobWindow *jw) { const char *res; gchar *string; /* Check for valid name */ res = gtk_entry_get_text (GTK_ENTRY (jw->name_entry)); if (g_strcmp0 (res, "") == 0) { const char *message = _("The Job must be given a name."); gnc_error_dialog(jw->dialog, "%s", message); return FALSE; } /* Check for owner */ gnc_owner_get_owner (jw->cust_edit, &(jw->owner)); res = gncOwnerGetName (&(jw->owner)); if (res == NULL || g_strcmp0 (res, "") == 0) { const char *message = _("You must choose an owner for this job."); gnc_error_dialog(jw->dialog, "%s", message); return FALSE; } /* Set a valid id if one was not created */ res = gtk_entry_get_text (GTK_ENTRY (jw->id_entry)); if (g_strcmp0 (res, "") == 0) { string = gncJobNextID(jw->book); gtk_entry_set_text (GTK_ENTRY (jw->id_entry), string); g_free(string); } /* Now save it off */ { GncJob *job = jw_get_job (jw); if (job) { gnc_ui_to_job (jw, job); } } /* Ok, it's been saved... Change to an editor.. */ jw->dialog_type = EDIT_JOB; return TRUE; }
gboolean gnc_hbci_multijob_execute(GtkWidget *parent, AB_BANKING *api, GList *job_list, GNCInteractor *interactor) { gboolean successful; g_assert(api); successful = gnc_AB_BANKING_execute (parent, api, NULL, interactor); /*printf("dialog-hbcitrans: Ok, result of api_execute was %d.\n", successful);*/ if (!successful) { /* AB_BANKING_executeOutbox failed. */ gnc_error_dialog (GNCInteractor_dialog (interactor), "%s", _("Executing the Online Banking outbox failed. Please check the log window.")); GNCInteractor_show_nodelete(interactor); g_list_foreach (job_list, multijob_cb, GNCInteractor_dialog (interactor)); } /* Watch out! The job *has* to be removed from the queue here because otherwise it might be executed again. */ /* AB_Banking_DequeueJob(api, job); is done in the calling function. */ return successful; }
/******************************************************************** * get_custom_report_selection * * this helper function is called to get the selection when the user * clicks on "Run" or "Delete". Includes calling a dialog when there * is no selection. * * const gchar* message -- the message to provide user if there is no * actual selection found. *********************************************************************/ static SCM get_custom_report_selection(CustomReportDialog *crd, const gchar* message) { GtkTreeSelection *sel; GtkTreeModel *model; GtkTreeIter iter; GncGUID *guid = guid_malloc (); gchar *guid_str; sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(crd->reportview)); if (gtk_tree_selection_get_selected(sel, &model, &iter)) { gtk_tree_model_get(model, &iter, COL_NUM, &guid, -1); guid_str = g_new0 (gchar, GUID_ENCODING_LENGTH+1 ); guid_to_string_buff (guid, guid_str); } else { /* no selection, notify user */ gnc_error_dialog (GTK_WINDOW (crd->dialog), "%s", message); return SCM_EOL; } return scm_from_utf8_string (guid_str); }
void tax_table_delete_entry_cb (GtkButton *button, TaxTableWindow *ttw) { g_return_if_fail (ttw); if (!ttw->current_table || !ttw->current_entry) return; if (g_list_length (gncTaxTableGetEntries (ttw->current_table)) <= 1) { char *message = _("You cannot remove the last entry from the tax table. " "Try deleting the tax table if you want to do that."); gnc_error_dialog (ttw->dialog, "%s", message); return; } if (gnc_verify_dialog (ttw->dialog, FALSE, "%s", _("Are you sure you want to delete this entry?"))) { /* Ok, let's remove it */ gnc_suspend_gui_refresh (); gncTaxTableBeginEdit (ttw->current_table); gncTaxTableRemoveEntry (ttw->current_table, ttw->current_entry); gncTaxTableEntryDestroy (ttw->current_entry); gncTaxTableChanged (ttw->current_table); gncTaxTableCommitEdit (ttw->current_table); ttw->current_entry = NULL; gnc_resume_gui_refresh (); } }
static void sxftd_ok_clicked(SXFromTransInfo *sxfti) { QofBook *book; SchedXactions *sxes; guint sx_error = sxftd_compute_sx(sxfti); if (sx_error != 0 && sx_error != SXFTD_ERRNO_UNBALANCED_XACTION) { g_critical("sxftd_compute_sx after ok_clicked [%d]", sx_error); } else { if ( sx_error == SXFTD_ERRNO_UNBALANCED_XACTION ) { gnc_error_dialog( gnc_ui_get_toplevel(), "%s", _( "The Scheduled Transaction is unbalanced. " "You are strongly encouraged to correct this situation." ) ); } book = gnc_get_current_book (); sxes = gnc_book_get_schedxactions(book); gnc_sxes_add_sx(sxes, sxfti->sx); } sxftd_close(sxfti, FALSE); return; }
void tax_table_delete_table_cb (GtkButton *button, TaxTableWindow *ttw) { g_return_if_fail (ttw); if (!ttw->current_table) return; if (gncTaxTableGetRefcount (ttw->current_table) > 0) { char *message = g_strdup_printf (_("Tax table \"%s\" is in use. You cannot delete it."), gncTaxTableGetName (ttw->current_table)); gnc_error_dialog (ttw->dialog, "%s", message); g_free (message); return; } if (gnc_verify_dialog (ttw->dialog, FALSE, _("Are you sure you want to delete \"%s\"?"), gncTaxTableGetName (ttw->current_table))) { /* Ok, let's remove it */ gnc_suspend_gui_refresh (); gncTaxTableBeginEdit (ttw->current_table); gncTaxTableDestroy (ttw->current_table); ttw->current_table = NULL; ttw->current_entry = NULL; gnc_resume_gui_refresh (); } }
void multijob_cb (gpointer element, gpointer user_data) { AB_JOB *job = element; GtkWidget *parent = user_data; if ((AB_Job_GetStatus (job) == AB_Job_StatusPending) || (AB_Job_GetStatus (job) == AB_Job_StatusError)) { /* There was some error in this job. */ if (AB_Job_GetType (job) == AB_Job_TypeDebitNote) { const AB_TRANSACTION *h_trans = AB_JobSingleDebitNote_GetTransaction (job); gchar *descr_name = gnc_hbci_descr_tognc (h_trans); gchar *value = gnc_AB_VALUE_toReadableString (AB_Transaction_GetValue (h_trans)); gchar *errortext; errortext = g_strdup_printf(_("A debit note has been refused by the bank. The refused debit note has the following data:\n" "Remote bank code: \"%s\"\n" "Remote account number: \"%s\"\n" "Description and remote name: \"%s\"\n" "Value: \"%s\"\n"), AB_Transaction_GetRemoteBankCode (h_trans), AB_Transaction_GetRemoteAccountNumber (h_trans), descr_name, value); g_warning ("%s", errortext); gnc_error_dialog (parent, "%s", errortext); g_free (errortext); g_free (descr_name); } else { gnc_error_dialog (parent, "%s", _("One of the jobs was sent to the bank successfully, but the " "bank is refusing to execute the job. Please check " "the log window for the exact error message of the " "bank. The line with the error message contains a " "code number that is greater than 9000.\n" "\n" "The job has been removed from the queue.")); /* FIXME: Might make more useful user feedback here. */ } } }
void gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data) { DialogDateClose *ddc = user_data; if (ddc->acct_combo) { Account *acc; acc = gnc_account_sel_get_account( GNC_ACCOUNT_SEL(ddc->acct_combo) ); if (!acc) { gnc_error_dialog (GTK_WINDOW (ddc->dialog), "%s", _("No Account selected. Please try again.")); return; } if (xaccAccountGetPlaceholder (acc)) { gnc_error_dialog (GTK_WINDOW (ddc->dialog), "%s", _("Placeholder account selected. Please try again.")); return; } ddc->acct = acc; } if (ddc->post_date) *(ddc->ts2) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->post_date)); if (ddc->date) { if (ddc->terms) ddc->ts->tv_sec = gncBillTermComputeDueDate (ddc->terms, ddc->ts2->tv_sec); else *(ddc->ts) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->date)); } if (ddc->memo_entry && ddc->memo) *(ddc->memo) = gtk_editable_get_chars (GTK_EDITABLE (ddc->memo_entry), 0, -1); if (ddc->question_check) ddc->answer = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ddc->question_check)); ddc->retval = TRUE; }
static void gxi_add_encoding (GncXmlImportData *data, gpointer encoding_ptr) { GIConv iconv; const gchar *message; gchar *enc_string; GtkListStore *store; GtkTreeIter iter; enc_string = g_ascii_strup ( g_quark_to_string (GPOINTER_TO_UINT (encoding_ptr)), -1); encoding_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string)); if (g_list_find (data->encodings, encoding_ptr)) { message = _("This encoding has been added to the list already."); gnc_error_dialog (data->encodings_dialog, "%s", message); return; } /* test whether we like this encoding */ iconv = g_iconv_open ("UTF-8", enc_string); if (iconv == (GIConv) - 1) { g_iconv_close (iconv); g_free (enc_string); message = _("This is an invalid encoding."); gnc_error_dialog (data->encodings_dialog, "%s", message); return; } g_iconv_close (iconv); /* add to the list */ data->encodings = g_list_append (data->encodings, encoding_ptr); store = GTK_LIST_STORE (gtk_tree_view_get_model (data->selected_encs_view)); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, ENC_COL_STRING, enc_string, ENC_COL_QUARK, encoding_ptr, -1); g_free (enc_string); if (!data->encodings->next) gtk_dialog_set_response_sensitive (GTK_DIALOG (data->encodings_dialog), GTK_RESPONSE_OK, TRUE); }
static const AB_TRANSACTION * translist_cb (const AB_TRANSACTION *element, void *user_data) { AB_JOB *job; AB_TRANSACTION *trans = (AB_TRANSACTION*)element; GtkWidget *parent = NULL; struct import_data *data = user_data; struct trans_list_data hbci_userdata; /* This callback in the hbci module will add the imported transaction to gnucash's importer. */ hbci_userdata.gnc_acc = data->gnc_acc; hbci_userdata.importer_generic = data->importer_generic; /* The call will use "trans" only as const* */ gnc_hbci_trans_list_cb((AB_TRANSACTION*) trans, &hbci_userdata); if (data->hbci_account) { /* NEW: The imported transaction has been imported into gnucash. Now also add it as a job to aqbanking. */ AB_Transaction_SetLocalBankCode (trans, AB_Account_GetBankCode (data->hbci_account)); AB_Transaction_SetLocalAccountNumber (trans, AB_Account_GetAccountNumber (data->hbci_account)); AB_Transaction_SetLocalCountry (trans, "DE"); job = gnc_hbci_trans_dialog_enqueue(trans, data->ab, data->hbci_account, SINGLE_DEBITNOTE); /* Check whether we really got a job */ if (!job) { /* Oops, no job, probably not supported by bank. */ if (gnc_verify_dialog (parent, FALSE, "%s", _("The backend found an error during the preparation " "of the job. It is not possible to execute this job. \n" "\n" "Most probable the bank does not support your chosen " "job or your Online Banking account does not have the permission " "to execute this job. More error messages might be " "visible on your console log.\n" "\n" "Do you want to enter the job again?"))) { gnc_error_dialog (parent, "Sorry, not implemented yet."); } /* else break; */ } data->job_list = g_list_append(data->job_list, job); } return NULL; }
static gboolean check_entry_nonempty (GtkWidget *dialog, GtkWidget *entry, const char * error_message) { const char *res = gtk_entry_get_text (GTK_ENTRY (entry)); if (g_strcmp0 (res, "") == 0) { if (error_message) gnc_error_dialog (dialog, "%s", error_message); return TRUE; } return FALSE; }
/********************* * Create the dialog * ********************/ void gnc_sx_create_from_trans( GtkWindow *parent, Transaction *trans ) { #ifndef __MINGW32__ int errno; #endif SXFromTransInfo *sxfti = g_new0( SXFromTransInfo, 1); GtkBuilder *builder; GtkWidget *dialog; builder = gtk_builder_new(); gnc_builder_add_from_file (builder , "dialog-sx.glade", "freq_liststore"); gnc_builder_add_from_file (builder , "dialog-sx.glade", "sx_from_real_trans_dialog"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "sx_from_real_trans_dialog")); // Set the style context for this dialog so it can be easily manipulated with css gnc_widget_set_style_context (GTK_WIDGET(dialog), "GncSxFromTransDialog"); gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); sxfti->builder = builder; sxfti->dialog = dialog; sxfti->trans = trans; sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_book ()); if ( (errno = sxftd_init( sxfti )) < 0 ) { if ( errno == SXFTD_ERRNO_OPEN_XACTION ) { gnc_error_dialog (NULL, "%s", _( "Cannot create a Scheduled Transaction " "from a Transaction currently " "being edited. Please Enter the " "Transaction before Scheduling." ) ); sxftd_close( sxfti, TRUE ); return; } else { g_error("sxftd_init: %d", errno); } } gtk_widget_show_all(GTK_WIDGET(sxfti->dialog)); gtk_builder_connect_signals(builder, sxfti); g_object_unref(G_OBJECT(builder)); }
static void calc_value(FinCalcDialog *fcd, FinCalcValue value) { const char *string; int error_item = 0; if (fcd == NULL) return; string = can_calc_value(fcd, value, &error_item); if (string != NULL) { GtkWidget *entry; gnc_error_dialog (GTK_WINDOW (fcd->dialog), "%s", string); if (error_item == 0) entry = fcd->amounts[0]; else entry = fcd->amounts[error_item]; gtk_widget_grab_focus (entry); return; } gui_to_fi(fcd); switch (value) { case PAYMENT_PERIODS: fi_calc_num_payments(&fcd->financial_info); break; case INTEREST_RATE: fi_calc_interest(&fcd->financial_info); break; case PRESENT_VALUE: fi_calc_present_value(&fcd->financial_info); break; case PERIODIC_PAYMENT: fi_calc_payment(&fcd->financial_info); break; case FUTURE_VALUE: fi_calc_future_value(&fcd->financial_info); break; default: PERR("Unknown financial variable"); break; } fi_to_gui(fcd); gtk_widget_set_sensitive(GTK_WIDGET(fcd->calc_button), FALSE); }
static gboolean check_edit_amount (GtkWidget *dialog, GtkWidget *amount, gnc_numeric *min, gnc_numeric *max, const char * error_message) { if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (amount))) { if (error_message) gnc_error_dialog (dialog, "%s", error_message); return TRUE; } /* We've got a valid-looking number; check mix/max */ if (min || max) { gnc_numeric val = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (amount)); if ((min && gnc_numeric_compare (*min, val) > 0) || (max && gnc_numeric_compare (val, *max) > 0)) { if (error_message) gnc_error_dialog (dialog, "%s", error_message); return TRUE; } } return FALSE; }
static void gnc_search_dialog_select_cb (GtkButton *button, GNCSearchWindow *sw) { g_return_if_fail (sw->selected_cb); if (sw->selected_item == NULL && sw->allow_clear == FALSE) { char *msg = _("You must select an item from the list"); gnc_error_dialog (sw->dialog, "%s", msg); return; } (sw->selected_cb)(sw->selected_item, sw->select_arg); gnc_search_dialog_destroy (sw); }
void gnc_employee_window_ok_cb (GtkWidget *widget, gpointer data) { EmployeeWindow *ew = data; gchar *string; /* Check for valid username */ if (check_entry_nonempty (ew->dialog, ew->username_entry, _("You must enter a username."))) return; /* Check for valid username */ if (check_entry_nonempty (ew->dialog, ew->name_entry, _("You must enter the employee's name."))) return; /* Make sure we have an address */ if (check_entry_nonempty (ew->dialog, ew->addr1_entry, NULL) && check_entry_nonempty (ew->dialog, ew->addr2_entry, NULL) && check_entry_nonempty (ew->dialog, ew->addr3_entry, NULL) && check_entry_nonempty (ew->dialog, ew->addr4_entry, NULL)) { const char *msg = _("You must enter an address."); gnc_error_dialog (ew->dialog, "%s", msg); return; } /* Set the employee id if one has not been chosen */ if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (ew->id_entry)), "") == 0) { string = gncEmployeeNextID (ew->book); gtk_entry_set_text (GTK_ENTRY (ew->id_entry), string); g_free(string); } /* Now save it off */ { GncEmployee *employee = ew_get_employee (ew); if (employee) { gnc_ui_to_employee (ew, employee); } ew->created_employee = employee; ew->employee_guid = *guid_null (); } gnc_close_gui_component (ew->component_id); }
void gnc_tree_util_split_reg_set_value_for (GncTreeViewSplitReg *view, Transaction *trans, Split *split, gnc_numeric input, gboolean force) { GncTreeModelSplitReg *model; GtkWidget *window; Account *anchor; Account *acct = xaccSplitGetAccount (split); gnc_commodity *currency; gnc_numeric value, amount, rate; ENTER("set_value_for trans %p and split %p input %s force %d", trans, split, gnc_numeric_to_string (input), force); currency = xaccTransGetCurrency (trans); model = gnc_tree_view_split_reg_get_model_from_view (view); anchor = gnc_tree_model_split_reg_get_anchor (model); if (gnc_numeric_zero_p (input)) { xaccSplitSetValue (split, input); xaccSplitSetAmount (split, input); LEAVE("input is zero"); return; } window = gnc_tree_view_split_reg_get_parent (view); if (gtu_sr_needs_exchange_rate (view, trans, split)) { if (gtu_sr_handle_exchange_rate (view, input, trans, split, force)) { ; //FIXME ?????? } else { gnc_error_dialog (window, "%s", _("Exchange Rate Canceled, using existing rate or default 1 to 1 rate if this is a new transaction.")); } LEAVE("used exchange rate"); return; } gnc_tree_util_split_reg_save_amount_values (view, trans, split, input); LEAVE(" "); }
void custom_report_name_edited_cb(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer data) { CustomReportDialog *crd = data; SCM guid = get_custom_report_selection(crd, _("Unable to change report configuration name.")); SCM unique_name_func = scm_c_eval_string("gnc:report-template-has-unique-name?"); SCM new_name_scm = scm_from_utf8_string(new_text); g_object_set(G_OBJECT(crd->namerenderer), "editable", FALSE, NULL); if (scm_is_null (guid)) return; if (scm_is_true (scm_call_2 (unique_name_func, guid, new_name_scm))) custom_report_edit_report_name (guid, crd, new_text); else gnc_error_dialog (GTK_WINDOW (crd->dialog), "%s", _("A saved report configuration with this name already exists, please choose another name.") ); }
/********************* * Create the dialog * ********************/ void gnc_sx_create_from_trans( Transaction *trans ) { int errno; SXFromTransInfo *sxfti = g_new0( SXFromTransInfo, 1); GtkBuilder *builder; GtkWidget *dialog; builder = gtk_builder_new(); gnc_builder_add_from_file (builder , "dialog-sx.glade", "freq_liststore"); gnc_builder_add_from_file (builder , "dialog-sx.glade", "sx_from_real_trans"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "sx_from_real_trans")); sxfti->builder = builder; sxfti->dialog = dialog; sxfti->trans = trans; sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_book ()); if ( (errno = sxftd_init( sxfti )) < 0 ) { if ( errno == SXFTD_ERRNO_OPEN_XACTION ) { gnc_error_dialog( gnc_ui_get_toplevel(), "%s", _( "Cannot create a Scheduled Transaction " "from a Transaction currently " "being edited. Please Enter the " "Transaction before Scheduling." ) ); sxftd_close( sxfti, TRUE ); return; } else { g_error("sxftd_init: %d", errno); } } gtk_widget_show_all(GTK_WIDGET(sxfti->dialog)); gtk_builder_connect_signals(builder, sxfti); g_object_unref(G_OBJECT(builder)); }
/************************************************** * csv_file_chooser_confirm_cb * * call back for ok button in file chooser widget **************************************************/ void csv_import_file_chooser_confirm_cb (GtkWidget *button, CsvImportInfo *info) { GtkAssistant *assistant = GTK_ASSISTANT(info->window); gint num = gtk_assistant_get_current_page (assistant); GtkWidget *page = gtk_assistant_get_nth_page (assistant, num); gchar *file_name; csv_import_result res; gtk_assistant_set_page_complete (assistant, page, FALSE); file_name = gtk_file_chooser_get_filename ( GTK_FILE_CHOOSER(info->file_chooser )); if (file_name) { gchar *filepath = gnc_uri_get_path ( file_name ); gchar *filedir = g_path_get_dirname( filepath ); info->starting_dir = g_strdup(filedir); g_free ( filedir ); g_free ( filepath ); info->file_name = g_strdup(file_name); // generate preview gtk_list_store_clear (info->store); res = csv_import_read_file (info->file_name, info->regexp->str, info->store, 1 ); if (res == RESULT_OPEN_FAILED) gnc_error_dialog (info->window, _("The input file can not be opened.")); else if (res == RESULT_OK) gtk_assistant_set_page_complete (assistant, page, TRUE); else if (res == MATCH_FOUND) gtk_assistant_set_page_complete (assistant, page, TRUE); } g_free(file_name); DEBUG("file_name selected is %s", info->file_name); DEBUG("starting directory is %s", info->starting_dir); /* Step to next page if page is complete */ if(gtk_assistant_get_page_complete(assistant, page)) gtk_assistant_set_current_page (assistant, num + 1); }
static AB_IMEXPORTER_ACCOUNTINFO * accountinfolist_cb(AB_IMEXPORTER_ACCOUNTINFO *accinfo, void *user_data) { Account *gnc_acc; struct import_data *data = user_data; const char *bank_code = AB_ImExporterAccountInfo_GetBankCode(accinfo); const char *account_number = AB_ImExporterAccountInfo_GetAccountNumber(accinfo); const char *account_name = AB_ImExporterAccountInfo_GetAccountName(accinfo); gchar *online_id = g_strconcat (bank_code, account_number, NULL); gnc_acc = gnc_import_select_account(NULL, online_id, 1, account_name, NULL, ACCT_TYPE_NONE, NULL, NULL); g_free(online_id); if (gnc_acc) { /* Store chosen gnucash account in callback data */ data->gnc_acc = gnc_acc; if (data->execute_transactions) { /* Retrieve the aqbanking account that belongs to this gnucash account */ data->hbci_account = gnc_hbci_get_hbci_acc (data->ab, gnc_acc); if (data->hbci_account == NULL) { gnc_error_dialog (NULL, _("No Online Banking account found for this gnucash account. These transactions will not be executed by Online Banking.")); } } else { data->hbci_account = NULL; } /* Iterate through all transactions. */ AB_ImExporterAccountInfo_TransactionsForEach (accinfo, translist_cb, data); /* all transactions finished. */ } return NULL; }
static gboolean gncs_validate (GNCSearchCoreType *fe) { GNCSearchAccount *fi = (GNCSearchAccount *)fe; GNCSearchAccountPrivate *priv; gboolean valid = TRUE; g_return_val_if_fail (fi, FALSE); g_return_val_if_fail (IS_GNCSEARCH_ACCOUNT (fi), FALSE); priv = _PRIVATE(fi); if (priv->selected_accounts == NULL && fi->how ) { valid = FALSE; gnc_error_dialog (NULL, "%s", _("You have not selected any accounts")); } /* XXX */ return valid; }
void gnc_bi_import_gui_ok_cb (GtkWidget *widget, gpointer data) { BillImportGui *gui = data; gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) ); bi_import_stats stats; bi_import_result res; guint n_fixed, n_deleted, n_invoices_created, n_invoices_updated; GString *info; // import info = g_string_new(""); gtk_list_store_clear (gui->store); res = gnc_bi_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats); if (res == RESULT_OK) { gnc_bi_import_fix_bis (gui->store, &n_fixed, &n_deleted, info, gui->type); if (info->len > 0) gnc_info_dialog (gui->dialog, "%s", info->str); g_string_free( info, TRUE ); gnc_bi_import_create_bis (gui->store, gui->book, &n_invoices_created, &n_invoices_updated, gui->type, gui->open_mode); gnc_info_dialog (gui->dialog, _("Import results:\n%i lines were ignored\n%i lines imported:\n %u fixes\n %u ignored (not fixable)\n\n %u created\n %u updated (based on id)"), stats.n_ignored, stats.n_imported, n_fixed, n_deleted, n_invoices_created, n_invoices_updated); if (stats.n_ignored > 0) gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str); g_string_free (stats.ignored_lines, TRUE); gnc_close_gui_component (gui->component_id); } else if (res == RESULT_OPEN_FAILED) { gnc_error_dialog (gui->dialog, _("The input file can not be opened.")); } else if (res == RESULT_ERROR_IN_REGEXP) { //gnc_error_dialog (gui->dialog, "The regular expression is faulty:\n\n%s", stats.err->str); } }
static gboolean gnc_entry_ledger_verify_acc_cell_ok (GncEntryLedger *ledger, const char *cell_name, const char *cell_msg) { ComboCell *cell; const char *name; cell = (ComboCell *) gnc_table_layout_get_cell (ledger->table->layout, cell_name); g_return_val_if_fail (cell, TRUE); name = cell->cell.value; if (!name || *name == '\0') { const char *format = ("%s %s"); const char *gen_msg = _("Invalid Entry: You need to supply an account in the right currency for this position."); gnc_error_dialog (ledger->parent, format, gen_msg, cell_msg); return FALSE; } return TRUE; }
void gnc_customer_import_gui_ok_cb (GtkWidget *widget, gpointer data) { CustomerImportGui *gui = data; gchar *filename = g_strdup( gtk_entry_get_text( GTK_ENTRY(gui->entryFilename) ) ); customer_import_stats stats; customer_import_result res; guint n_fixed, n_deleted, n_customers_created, n_customers_updated; gchar *cv_type_text; // import if (g_ascii_strcasecmp (gui->type, "CUSTOMER") == 0) cv_type_text = _("customers"); else cv_type_text = _("vendors"); gtk_list_store_clear (gui->store); res = gnc_customer_import_read_file (filename, gui->regexp->str, gui->store, 0, &stats); if (res == CI_RESULT_OK) { gnc_customer_import_fix_customers (gui->store, &n_fixed, &n_deleted, gui->type); gnc_customer_import_create_customers (gui->store, gui->book, &n_customers_created, &n_customers_updated, gui->type); gnc_info_dialog (GTK_WINDOW (gui->dialog), _("Import results:\n%i lines were ignored\n%i lines imported:\n %u %s fixed\n %u %s ignored (not fixable)\n\n %u %s created\n %u %s updated (based on id)"), \ stats.n_ignored, stats.n_imported, n_fixed, cv_type_text, n_deleted, cv_type_text, n_customers_created, cv_type_text, n_customers_updated, cv_type_text); if (stats.n_ignored > 0) gnc_info2_dialog (gui->dialog, _("These lines were ignored during import"), stats.ignored_lines->str); g_string_free (stats.ignored_lines, TRUE); gnc_close_gui_component (gui->component_id); } else if (res == CI_RESULT_OPEN_FAILED) { gnc_error_dialog (GTK_WINDOW (gui->dialog), _("The input file can not be opened.")); } else if (res == CI_RESULT_ERROR_IN_REGEXP) { //gnc_error_dialog (GTK_WINDOW (gui->dialog), "The regular expression is faulty:\n\n%s", stats.err->str); } }
void gnc_sx_create_from_trans( Transaction *trans ) { int errno; SXFromTransInfo *sxfti = g_new0( SXFromTransInfo, 1); sxfti->gxml = gnc_glade_xml_new(SX_GLADE_FILE, SXFTD_DIALOG_GLADE_NAME); sxfti->dialog = glade_xml_get_widget(sxfti->gxml, SXFTD_DIALOG_GLADE_NAME); sxfti->trans = trans; sxfti->sx = xaccSchedXactionMalloc(gnc_get_current_book ()); if ( (errno = sxftd_init( sxfti )) < 0 ) { if ( errno == SXFTD_ERRNO_OPEN_XACTION ) { gnc_error_dialog( gnc_ui_get_toplevel(), "%s", _( "Cannot create a Scheduled Transaction " "from a Transaction currently " "being edited. Please Enter the " "Transaction before Scheduling." ) ); sxftd_close( sxfti, TRUE ); return; } else { g_error("sxftd_init: %d", errno); } } gtk_widget_show_all(GTK_WIDGET(sxfti->dialog)); }
void gnc_gnome_init (int argc, char **argv, const char * version) { GError *error = NULL; gchar *prefix = gnc_path_get_prefix (); gchar *pkgsysconfdir = gnc_path_get_pkgsysconfdir (); gchar *pkgdatadir = gnc_path_get_pkgdatadir (); gchar *pkglibdir = gnc_path_get_pkglibdir (); gboolean installation_ok = TRUE; /* Verify all the various directory before proceeding */ if (!g_file_test(pkgdatadir, G_FILE_TEST_IS_DIR)) { g_critical("The installation data directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkgdatadir); installation_ok = FALSE; } if (!g_file_test(pkglibdir, G_FILE_TEST_IS_DIR)) { g_critical("The installation lib directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkglibdir); installation_ok = FALSE; } if (!g_file_test(pkgsysconfdir, G_FILE_TEST_IS_DIR)) { g_critical("The installation sysconf directory \"%s\" was not found. Your installation is incomplete and cannot be run.", pkgsysconfdir); installation_ok = FALSE; } gnc_gtk_add_rc_file(); gnucash_program = gnome_program_init( "gnucash", version, LIBGNOMEUI_MODULE, argc, argv, GNOME_PARAM_APP_PREFIX, prefix, GNOME_PARAM_APP_SYSCONFDIR, pkgsysconfdir, GNOME_PARAM_APP_DATADIR, pkgdatadir, GNOME_PARAM_APP_LIBDIR, pkglibdir, GNOME_PARAM_NONE); if (!installation_ok) { /* The following string does not need translation because if * it shows up, the program is unusable anyway. */ gnc_error_dialog(NULL, "The installation directories were not found.\n\ndatadir=%s\nlibdir=%s\nsysconfdir=%s\n\nYour installation is incomplete and cannot be run.", pkgdatadir, pkglibdir, pkgsysconfdir); /* gnc_error_dialog must not be called before gnome_program_init. */ } g_free (prefix); g_free (pkgsysconfdir); g_free (pkgdatadir); g_free (pkglibdir); /* Did the installation directory check fail? Terminate * immediately because it will inevitably fail in the glade file * lookup. */ if (!installation_ok) { /* No correct installation? Shut down immediately. */ exit(-1); } #ifdef G_OS_WIN32 /* workaround for bug #421792 */ xmlCleanupInputCallbacks(); #endif /* initialization required for gtkhtml (is it also needed for webkit?) */ gtk_widget_set_default_colormap (gdk_rgb_get_colormap ()); /* use custom icon */ { int idx; char *icon_filenames[] = {"gnucash-icon-16x16.png", "gnucash-icon-32x32.png", "gnucash-icon-48x48.png", NULL }; GList *icons = NULL; char *fullname, *name_iter; for (idx = 0; icon_filenames[idx] != NULL; idx++) { GdkPixbuf *buf = NULL; fullname = gnc_gnome_locate_pixmap(icon_filenames[idx]); if (fullname == NULL) { g_warning("couldn't find icon file [%s]", icon_filenames[idx]); continue; } buf = gnc_gnome_get_gdkpixbuf(fullname); if (buf == NULL) { g_warning("error loading image from [%s]", fullname); g_free(fullname); continue; } g_free(fullname); icons = g_list_append(icons, buf); } gtk_window_set_default_icon_list(icons); g_list_foreach(icons, (GFunc)g_object_unref, NULL); g_list_free(icons); } assistant_gconf_install_check_schemas(); return; }
void gnc_stock_split_assistant_finish (GtkAssistant *assistant, gpointer user_data) { StockSplitInfo *info = user_data; GList *account_commits; GList *node; gnc_numeric amount; Transaction *trans; Account *account; Split *split; time64 date; account = info->acct; g_return_if_fail (account != NULL); amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->distribution_edit)); g_return_if_fail (!gnc_numeric_zero_p (amount)); gnc_suspend_gui_refresh (); trans = xaccMallocTransaction (gnc_get_current_book ()); xaccTransBeginEdit (trans); xaccTransSetCurrency (trans, gnc_default_currency ()); date = gnc_date_edit_get_date (GNC_DATE_EDIT (info->date_edit)); xaccTransSetDatePostedSecsNormalized (trans, date); { const char *description; description = gtk_entry_get_text (GTK_ENTRY (info->description_entry)); xaccTransSetDescription (trans, description); } split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (NULL, account); xaccTransAppendSplit (trans, split); xaccAccountInsertSplit (account, split); xaccSplitSetAmount (split, amount); xaccSplitMakeStockSplit (split); /* Set split-action with gnc_set_num_action which is the same as * xaccSplitSetAction with these arguments */ /* Translators: This string has a disambiguation prefix */ gnc_set_num_action (NULL, split, NULL, Q_("Action Column|Split")); amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->price_edit)); if (gnc_numeric_positive_p (amount)) { QofBook *book; GNCPrice *price; GNCPriceDB *pdb; GNCCurrencyEdit *ce; Timespec ts; ce = GNC_CURRENCY_EDIT (info->price_currency_edit); ts.tv_sec = date; ts.tv_nsec = 0; price = gnc_price_create (gnc_get_current_book ()); gnc_price_begin_edit (price); gnc_price_set_commodity (price, xaccAccountGetCommodity (account)); gnc_price_set_currency (price, gnc_currency_edit_get_currency (ce)); gnc_price_set_time (price, ts); gnc_price_set_source (price, PRICE_SOURCE_STOCK_SPLIT); gnc_price_set_typestr (price, PRICE_TYPE_UNK); gnc_price_set_value (price, amount); gnc_price_commit_edit (price); book = gnc_get_current_book (); pdb = gnc_pricedb_get_db (book); if (!gnc_pricedb_add_price (pdb, price)) gnc_error_dialog (info->window, "%s", _("Error adding price.")); } amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (info->cash_edit)); if (gnc_numeric_positive_p (amount)) { const char *memo; memo = gtk_entry_get_text (GTK_ENTRY (info->memo_entry)); /* asset split */ account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(info->asset_tree)); split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (account_commits, account); xaccAccountInsertSplit (account, split); xaccTransAppendSplit (trans, split); xaccSplitSetAmount (split, amount); xaccSplitSetValue (split, amount); xaccSplitSetMemo (split, memo); /* income split */ account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT(info->income_tree)); split = xaccMallocSplit (gnc_get_current_book ()); xaccAccountBeginEdit (account); account_commits = g_list_prepend (account_commits, account); xaccAccountInsertSplit (account, split); xaccTransAppendSplit (trans, split); xaccSplitSetAmount (split, gnc_numeric_neg (amount)); xaccSplitSetValue (split, gnc_numeric_neg (amount)); xaccSplitSetMemo (split, memo); } xaccTransCommitEdit (trans); for (node = account_commits; node; node = node->next) xaccAccountCommitEdit (node->data); g_list_free (account_commits); gnc_resume_gui_refresh (); gnc_close_gui_component_by_data (ASSISTANT_STOCK_SPLIT_CM_CLASS, info); }