From 0313539a88910deff4bb0eb732ce70cd6443bb41 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 17 Nov 2011 22:24:03 +0000 Subject: [PATCH] Convert payment dialog to gtkbuilder git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21572 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-gnome/dialog-payment.c | 33 +- src/business/business-gnome/glade/Makefile.am | 3 +- .../business-gnome/gtkbuilder/Makefile.am | 4 +- .../dialog-payment.glade} | 307 ++++++++++-------- src/gnome-utils/gnc-gtk-utils.c | 2 +- 5 files changed, 198 insertions(+), 151 deletions(-) rename src/business/business-gnome/{glade/payment.glade => gtkbuilder/dialog-payment.glade} (65%) diff --git a/src/business/business-gnome/dialog-payment.c b/src/business/business-gnome/dialog-payment.c index 715ed85d88..22c94154b9 100644 --- a/src/business/business-gnome/dialog-payment.c +++ b/src/business/business-gnome/dialog-payment.c @@ -551,6 +551,7 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice) { PaymentWindow *pw; GladeXML *xml; + GtkBuilder *builder; GtkWidget *box, *label; char * cm_class = (gncOwnerGetType (owner) == GNC_OWNER_CUSTOMER ? DIALOG_PAYMENT_CUSTOMER_CM_CLASS : @@ -588,35 +589,38 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice) pw->acct_commodities = gncOwnerGetCommoditiesList (owner); /* Open and read the XML */ - xml = gnc_glade_xml_new ("payment.glade", "Payment Dialog"); - pw->dialog = glade_xml_get_widget (xml, "Payment Dialog"); + builder = gtk_builder_new(); + gnc_builder_add_from_file (builder, "dialog-payment.glade", "post_combo_model"); + gnc_builder_add_from_file (builder, "dialog-payment.glade", "Payment Dialog"); + pw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "Payment Dialog")); /* Grab the widgets and build the dialog */ - pw->num_entry = glade_xml_get_widget (xml, "num_entry"); - pw->memo_entry = glade_xml_get_widget (xml, "memo_entry"); - pw->post_combo = glade_xml_get_widget (xml, "post_combo"); + pw->num_entry = GTK_WIDGET (gtk_builder_get_object (builder, "num_entry")); + pw->memo_entry = GTK_WIDGET (gtk_builder_get_object (builder, "memo_entry")); + pw->post_combo = GTK_WIDGET (gtk_builder_get_object (builder, "post_combo")); + gtk_combo_box_entry_set_text_column( GTK_COMBO_BOX_ENTRY( pw->post_combo ), 0 ); gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(pw->post_combo)); - label = glade_xml_get_widget (xml, "owner_label"); - box = glade_xml_get_widget (xml, "owner_box"); + label = GTK_WIDGET (gtk_builder_get_object (builder, "owner_label")); + box = GTK_WIDGET (gtk_builder_get_object (builder, "owner_box")); pw->owner_choice = gnc_owner_select_create (label, box, book, owner); - label = glade_xml_get_widget (xml, "invoice_label"); - box = glade_xml_get_widget (xml, "invoice_box"); + label = GTK_WIDGET (gtk_builder_get_object (builder, "invoice_label")); + box = GTK_WIDGET (gtk_builder_get_object (builder, "invoice_box")); pw->invoice_choice = gnc_invoice_select_create (box, book, owner, invoice, label); - box = glade_xml_get_widget (xml, "amount_box"); + box = GTK_WIDGET (gtk_builder_get_object (builder, "amount_box")); pw->amount_edit = gnc_amount_edit_new (); gtk_box_pack_start (GTK_BOX (box), pw->amount_edit, TRUE, TRUE, 0); gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (pw->amount_edit), TRUE); gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (pw->amount_edit), gnc_numeric_zero()); - box = glade_xml_get_widget (xml, "date_box"); + box = GTK_WIDGET (gtk_builder_get_object (builder, "date_box")); pw->date_edit = gnc_date_edit_new (time(NULL), FALSE, FALSE); gtk_box_pack_start (GTK_BOX (box), pw->date_edit, TRUE, TRUE, 0); - box = glade_xml_get_widget (xml, "acct_window"); + box = GTK_WIDGET (gtk_builder_get_object (builder, "acct_window")); pw->acct_tree = GTK_WIDGET(gnc_tree_view_account_new (FALSE)); gtk_container_add (GTK_CONTAINER (box), pw->acct_tree); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(pw->acct_tree), FALSE); @@ -630,8 +634,8 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice) gnc_payment_dialog_invoice_changed(pw); /* Setup signals */ - glade_xml_signal_autoconnect_full( xml, - gnc_glade_autoconnect_full_func, + gtk_builder_connect_signals_full( builder, + gnc_builder_connect_full_func, pw); g_signal_connect (G_OBJECT (pw->owner_choice), "changed", @@ -672,6 +676,7 @@ new_payment_window (GncOwner *owner, QofBook *book, GncInvoice *invoice) /* Show it all */ gtk_widget_show_all (pw->dialog); + g_object_unref(G_OBJECT(builder)); /* Warn the user if they have no valid post-to accounts */ { diff --git a/src/business/business-gnome/glade/Makefile.am b/src/business/business-gnome/glade/Makefile.am index 96e9e9a829..991ad3706b 100644 --- a/src/business/business-gnome/glade/Makefile.am +++ b/src/business/business-gnome/glade/Makefile.am @@ -5,8 +5,7 @@ glade_DATA = \ date-close.glade \ employee.glade \ job.glade \ - order.glade \ - payment.glade + order.glade EXTRA_DIST = \ ${glade_DATA} diff --git a/src/business/business-gnome/gtkbuilder/Makefile.am b/src/business/business-gnome/gtkbuilder/Makefile.am index 9ca79a967b..06d38ae3a9 100644 --- a/src/business/business-gnome/gtkbuilder/Makefile.am +++ b/src/business/business-gnome/gtkbuilder/Makefile.am @@ -4,14 +4,14 @@ gtkbuilder_DATA = \ business-prefs.glade \ dialog-customer.glade \ dialog-invoice.glade \ + dialog-payment.glade \ dialog-vendor.glade # billterms.glade \ # choose-owner.glade \ # date-close.glade \ # employee.glade \ # job.glade \ -# order.glade \ -# payment.glade +# order.glade EXTRA_DIST = \ ${gtkbuilder_DATA} diff --git a/src/business/business-gnome/glade/payment.glade b/src/business/business-gnome/gtkbuilder/dialog-payment.glade similarity index 65% rename from src/business/business-gnome/glade/payment.glade rename to src/business/business-gnome/gtkbuilder/dialog-payment.glade index 4abfd0645f..dd4545b422 100644 --- a/src/business/business-gnome/glade/payment.glade +++ b/src/business/business-gnome/gtkbuilder/dialog-payment.glade @@ -1,45 +1,97 @@ - - - - - + + + + True + False dialog - + - + True + False vertical 8 - - + + True + False + end + + + gtk-cancel + True + True + True + False + False + True + + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + False + True + + + + False + False + 1 + + + + + False + True + end + 0 + + + + + True + False 3 - + True - vertical + False - + True + False 0 - + True + False - + True + False 3 - vertical True - + True - The company associated with this payment. + False + The company associated with this payment. 1 (owner) right - + False False @@ -47,15 +99,16 @@ - + True - The invoice being paid. + False + The invoice being paid. Note that is field is optional. If you leave it blank, GnuCash will automatically assign the payment to the first unpaid invoice for this company. 1 (invoice) right - + False False @@ -63,12 +116,13 @@ Note that is field is optional. If you leave it blank, GnuCash will automaticall - + True + False 1 Date right - + False False @@ -76,9 +130,10 @@ Note that is field is optional. If you leave it blank, GnuCash will automaticall - + True - The amount to pay for this invoice. + False + The amount to pay for this invoice. If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment. @@ -86,7 +141,7 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic 1 Amount right - + False False @@ -94,12 +149,13 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic - + True + False 1 Num right - + False False @@ -107,63 +163,72 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic - + True + False 1 Memo right - + False False 5 - + False + True 0 - + True + False 3 - vertical True - + True - The company associated with this payment. + False + The company associated with this payment. - + + True + True 0 - + True - The invoice being paid. + False + The invoice being paid. Note that is field is optional. If you leave it blank, GnuCash will automatically assign the payment to the first unpaid invoice for this company. - + + True + True 1 - + True + False - + False False @@ -171,9 +236,10 @@ Note that is field is optional. If you leave it blank, GnuCash will automaticall - + True - The amount to pay for this invoice. + False + The amount to pay for this invoice. If you have selected an invoice, GnuCash will propose the amount still due for it. You can change this amount to create a partial payment or an over-payment. @@ -181,16 +247,18 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic - + + True + True 3 - + True True - + False False @@ -198,33 +266,33 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic - + True True - + False False 5 - + + True + True 1 - + - - + + True + False Payment Information - - - label_item - + - + False False @@ -232,118 +300,93 @@ In case of an over-payment or if no invoice was selected, GnuCash will automatic - + True + False 0 + none - + True - Dummy Entry - + False + post_combo_model + - - + + True + False Post To - - - label_item - + True + - + - False - False + True + True 1 - + + True + True 0 - + True + False 0 - + 250 True False 3 - automatic - automatic - + - - + + True + False Transfer Account - - - label_item - + - + + True + True 1 - + + False + True 2 - - - True - end - - - gtk-cancel - -6 - True - True - True - False - True - - - - False - False - 0 - - - - - gtk-ok - -5 - True - True - True - False - True - - - - False - False - 1 - - - - - False - end - 0 - - - + - - + + cancelbutton + okbutton + + + + + + + + + + Dummy Entry + + + + diff --git a/src/gnome-utils/gnc-gtk-utils.c b/src/gnome-utils/gnc-gtk-utils.c index fdc6a5889e..1d0f55313a 100644 --- a/src/gnome-utils/gnc-gtk-utils.c +++ b/src/gnome-utils/gnc-gtk-utils.c @@ -213,7 +213,7 @@ gnc_cbe_require_list_item (GtkComboBoxEntry *cbe) g_object_set_data(G_OBJECT(cbe), LAST_INDEX, GINT_TO_POINTER(index)); /* Now the signals to make sure the user can't leave the - widget without a valid currency. */ + widget without a valid match. */ id = g_signal_connect(cbe, "changed", G_CALLBACK(gnc_cbe_changed_cb), cbe); g_signal_connect(completion, "match_selected",