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 post_date_changed_cb (GNCDateEdit *gde, gpointer d) { DialogDateClose *ddc = d; Timespec post_date; Timespec due_date = {0,0}; post_date = gnc_date_edit_get_date_ts (gde); due_date.tv_sec = gncBillTermComputeDueDate (ddc->terms, post_date.tv_sec); gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), due_date); }
void gnc_payment_ok_cb (GtkWidget *widget, gpointer data) { PaymentWindow *pw = data; const char *text = NULL; if (!pw) return; /* The gnc_payment_window_check_payment function * ensures we have valid owner, post account, transfer account * and amount so we can proceed with the payment. * Note: make sure it's called before all entry points to this function ! */ gnc_suspend_gui_refresh (); { const char *memo, *num; Timespec date; gnc_numeric exch = gnc_numeric_create(1, 1); //default to "one to one" rate GList *selected_lots = NULL; GtkTreeSelection *selection; gboolean auto_pay; /* Obtain all our ancillary information */ memo = gtk_entry_get_text (GTK_ENTRY (pw->memo_entry)); num = gtk_entry_get_text (GTK_ENTRY (pw->num_entry)); date = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (pw->date_edit)); /* Obtain the list of selected lots (documents/payments) from the dialog */ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view)); gtk_tree_selection_selected_foreach (selection, get_selected_lots, &selected_lots); /* When the payment amount is 0, the selected documents cancel each other out * so no money is actually transferred. * For non-zero payments money will be transferred between the post account * and the transfer account. In that case if these two accounts don't have * the same currency the user is asked to enter the exchange rate. */ if (!gnc_numeric_zero_p (pw->amount_tot) && !gnc_commodity_equal(xaccAccountGetCommodity(pw->xfer_acct), xaccAccountGetCommodity(pw->post_acct))) { XferDialog* xfer; text = _("The transfer and post accounts are associated with different currencies. Please specify the conversion rate."); xfer = gnc_xfer_dialog(pw->dialog, pw->xfer_acct); gnc_info_dialog(pw->dialog, "%s", text); gnc_xfer_dialog_select_to_account(xfer, pw->post_acct); gnc_xfer_dialog_set_amount(xfer, pw->amount_tot); /* All we want is the exchange rate so prevent the user from thinking it makes sense to mess with other stuff */ gnc_xfer_dialog_set_from_show_button_active(xfer, FALSE); gnc_xfer_dialog_set_to_show_button_active(xfer, FALSE); gnc_xfer_dialog_hide_from_account_tree(xfer); gnc_xfer_dialog_hide_to_account_tree(xfer); gnc_xfer_dialog_is_exchange_dialog(xfer, &exch); gnc_xfer_dialog_run_until_done(xfer); } /* Perform the payment */ if (gncOwnerGetType (&(pw->owner)) == GNC_OWNER_CUSTOMER) auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_INVOICE, GNC_PREF_AUTO_PAY); else auto_pay = gnc_prefs_get_bool (GNC_PREFS_GROUP_BILL, GNC_PREF_AUTO_PAY); gncOwnerApplyPayment (&pw->owner, pw->pre_existing_txn, selected_lots, pw->post_acct, pw->xfer_acct, pw->amount_tot, exch, date, memo, num, auto_pay); } gnc_resume_gui_refresh (); /* Save the transfer account, xfer_acct */ gnc_payment_dialog_remember_account(pw, pw->xfer_acct); gnc_ui_payment_window_destroy (pw); }
gboolean gnc_ab_enter_daterange(GtkWidget *parent, const char *heading, Timespec *from_date, gboolean *last_retv_date, gboolean *first_possible_date, Timespec *to_date, gboolean *to_now) { GtkBuilder *builder; GtkWidget *dialog; GtkWidget *heading_label; GtkWidget *first_button; GtkWidget *last_retrieval_button; GtkWidget *now_button; DaterangeInfo info; gint result; ENTER(""); builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "dialog-ab.glade", "aqbanking_date_range_dialog"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "aqbanking_date_range_dialog")); /* Connect the signals */ gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, &info ); if (parent) gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent)); heading_label = GTK_WIDGET(gtk_builder_get_object (builder, "heading_label")); first_button = GTK_WIDGET(gtk_builder_get_object (builder, "first_button")); last_retrieval_button = GTK_WIDGET(gtk_builder_get_object (builder, "last_retrieval_button")); info.enter_from_button = GTK_WIDGET(gtk_builder_get_object (builder, "enter_from_button")); now_button = GTK_WIDGET(gtk_builder_get_object (builder, "now_button")); info.enter_to_button = GTK_WIDGET(gtk_builder_get_object (builder, "enter_to_button")); info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE); gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_from_box")), info.from_dateedit); gtk_widget_show(info.from_dateedit); info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE); gtk_container_add(GTK_CONTAINER(gtk_builder_get_object (builder, "enter_to_box")), info.to_dateedit); gtk_widget_show(info.to_dateedit); if (*last_retv_date) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button), TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE); gtk_widget_set_sensitive(last_retrieval_button, FALSE); } gtk_widget_set_sensitive(info.from_dateedit, FALSE); gtk_widget_set_sensitive(info.to_dateedit, FALSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); if (heading) gtk_label_set_text(GTK_LABEL(heading_label), heading); gtk_widget_show(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_hide(dialog); if (result == GTK_RESPONSE_OK) { *from_date = gnc_date_edit_get_date_ts( GNC_DATE_EDIT(info.from_dateedit)); *last_retv_date = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(last_retrieval_button)); *first_possible_date = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(first_button)); *to_date = gnc_date_edit_get_date_ts( GNC_DATE_EDIT(info.to_dateedit)); *to_now = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(now_button)); } g_object_unref(G_OBJECT(builder)); gtk_widget_destroy(dialog); LEAVE(""); return result == GTK_RESPONSE_OK; }
gboolean gnc_ab_enter_daterange(GtkWidget *parent, const char *heading, Timespec *from_date, gboolean *last_retv_date, gboolean *first_possible_date, Timespec *to_date, gboolean *to_now) { GladeXML *xml; GtkWidget *dialog; GtkWidget *heading_label; GtkWidget *first_button; GtkWidget *last_retrieval_button; GtkWidget *now_button; DaterangeInfo info; gint result; xml = gnc_glade_xml_new("aqbanking.glade", "Date Range Dialog"); dialog = glade_xml_get_widget(xml, "Date Range Dialog"); g_object_set_data_full(G_OBJECT(dialog), "xml", xml, g_object_unref); glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, &info); if (parent) gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent)); heading_label = glade_xml_get_widget(xml, "heading_label"); first_button = glade_xml_get_widget(xml, "first_button"); last_retrieval_button = glade_xml_get_widget(xml, "last_retrieval_button"); info.enter_from_button = glade_xml_get_widget(xml, "enter_from_button"); now_button = glade_xml_get_widget(xml, "now_button"); info.enter_to_button = glade_xml_get_widget(xml, "enter_to_button"); info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE); gtk_container_add(GTK_CONTAINER(glade_xml_get_widget(xml, "enter_from_box")), info.from_dateedit); gtk_widget_show(info.from_dateedit); info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE); gtk_container_add(GTK_CONTAINER(glade_xml_get_widget(xml, "enter_to_box")), info.to_dateedit); gtk_widget_show(info.to_dateedit); if (*last_retv_date) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button), TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE); gtk_widget_set_sensitive(last_retrieval_button, FALSE); } gtk_widget_set_sensitive(info.from_dateedit, FALSE); gtk_widget_set_sensitive(info.to_dateedit, FALSE); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); if (heading) gtk_label_set_text(GTK_LABEL(heading_label), heading); gtk_widget_show(dialog); result = gtk_dialog_run(GTK_DIALOG(dialog)); gtk_widget_hide(dialog); if (result == GTK_RESPONSE_OK) { *from_date = gnc_date_edit_get_date_ts( GNC_DATE_EDIT(info.from_dateedit)); *last_retv_date = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(last_retrieval_button)); *first_possible_date = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(first_button)); *to_date = gnc_date_edit_get_date_ts( GNC_DATE_EDIT(info.to_dateedit)); *to_now = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(now_button)); } gtk_widget_destroy(dialog); return result == GTK_RESPONSE_OK; }