From 11b5fff44ac7c8777060082dd274254334784bf9 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Fri, 28 Oct 2011 12:27:08 +0000 Subject: [PATCH] Convert vendor dialog to gtkbuilder git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21500 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-gnome/dialog-vendor.c | 97 +- src/business/business-gnome/glade/Makefile.am | 3 +- .../business-gnome/gtkbuilder/Makefile.am | 6 +- .../dialog-vendor.glade} | 1427 +++++++++-------- 4 files changed, 816 insertions(+), 717 deletions(-) rename src/business/business-gnome/{glade/vendor.glade => gtkbuilder/dialog-vendor.glade} (67%) diff --git a/src/business/business-gnome/dialog-vendor.c b/src/business/business-gnome/dialog-vendor.c index dcd2a35054..3d7139424d 100644 --- a/src/business/business-gnome/dialog-vendor.c +++ b/src/business/business-gnome/dialog-vendor.c @@ -58,6 +58,9 @@ void gnc_vendor_window_cancel_cb (GtkWidget *widget, gpointer data); void gnc_vendor_window_help_cb (GtkWidget *widget, gpointer data); void gnc_vendor_window_destroy_cb (GtkWidget *widget, gpointer data); void gnc_vendor_name_changed_cb (GtkWidget *widget, gpointer data); +void gnc_vendor_terms_changed_cb (GtkWidget *widget, gpointer data); +void gnc_vendor_taxincluded_changed_cb (GtkWidget *widget, gpointer data); +void gnc_vendor_taxtable_changed_cb (GtkWidget *widget, gpointer data); typedef enum { @@ -312,6 +315,45 @@ gnc_vendor_name_changed_cb (GtkWidget *widget, gpointer data) g_free (title); } +void +gnc_vendor_terms_changed_cb (GtkWidget *widget, gpointer data) +{ + GtkComboBox *cbox = GTK_COMBO_BOX (widget); + VendorWindow *vw = data; + gchar *title; + + if (!vw) return; + if (!cbox) return; + + vw->terms = gnc_simple_combo_get_value (cbox); +} + +void +gnc_vendor_taxincluded_changed_cb (GtkWidget *widget, gpointer data) +{ + GtkComboBox *cbox = GTK_COMBO_BOX (widget); + VendorWindow *vw = data; + gchar *title; + + if (!vw) return; + if (!cbox) return; + + vw->taxincluded = GPOINTER_TO_INT (gnc_simple_combo_get_value (cbox)); +} + +void +gnc_vendor_taxtable_changed_cb (GtkWidget *widget, gpointer data) +{ + GtkComboBox *cbox = GTK_COMBO_BOX (widget); + VendorWindow *vw = data; + gchar *title; + + if (!vw) return; + if (!cbox) return; + + vw->taxtable = gnc_simple_combo_get_value (cbox); +} + static void gnc_vendor_window_close_handler (gpointer user_data) { @@ -359,7 +401,7 @@ static VendorWindow * gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor) { VendorWindow *vw; - GladeXML *xml; + GtkBuilder *builder; GtkWidget *edit, *hbox; gnc_commodity *currency; @@ -395,41 +437,45 @@ gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor) vw->book = bookp; /* Find the dialog */ - xml = gnc_glade_xml_new ("vendor.glade", "Vendor Dialog"); - vw->dialog = glade_xml_get_widget (xml, "Vendor Dialog"); + builder = gtk_builder_new(); + gnc_builder_add_from_file (builder, "dialog-vendor.glade", "terms_store"); + gnc_builder_add_from_file (builder, "dialog-vendor.glade", "tax_included_store"); + gnc_builder_add_from_file (builder, "dialog-vendor.glade", "taxtable_store"); + gnc_builder_add_from_file (builder, "dialog-vendor.glade", "Vendor Dialog"); + vw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "Vendor Dialog")); /* Get entry points */ - vw->id_entry = glade_xml_get_widget (xml, "id_entry"); - vw->company_entry = glade_xml_get_widget (xml, "company_entry"); + vw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder, "id_entry")); + vw->company_entry = GTK_WIDGET (gtk_builder_get_object (builder, "company_entry")); - vw->name_entry = glade_xml_get_widget (xml, "name_entry"); - vw->addr1_entry = glade_xml_get_widget (xml, "addr1_entry"); - vw->addr2_entry = glade_xml_get_widget (xml, "addr2_entry"); - vw->addr3_entry = glade_xml_get_widget (xml, "addr3_entry"); - vw->addr4_entry = glade_xml_get_widget (xml, "addr4_entry"); - vw->phone_entry = glade_xml_get_widget (xml, "phone_entry"); - vw->fax_entry = glade_xml_get_widget (xml, "fax_entry"); - vw->email_entry = glade_xml_get_widget (xml, "email_entry"); + vw->name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry")); + vw->addr1_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr1_entry")); + vw->addr2_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr2_entry")); + vw->addr3_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr3_entry")); + vw->addr4_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr4_entry")); + vw->phone_entry = GTK_WIDGET (gtk_builder_get_object (builder, "phone_entry")); + vw->fax_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fax_entry")); + vw->email_entry = GTK_WIDGET (gtk_builder_get_object (builder, "email_entry")); - vw->active_check = glade_xml_get_widget (xml, "active_check"); - vw->taxincluded_menu = glade_xml_get_widget (xml, "tax_included_menu"); - vw->notes_text = glade_xml_get_widget (xml, "notes_text"); - vw->terms_menu = glade_xml_get_widget (xml, "terms_menu"); + vw->active_check = GTK_WIDGET (gtk_builder_get_object (builder, "active_check")); + vw->taxincluded_menu = GTK_WIDGET (gtk_builder_get_object (builder, "tax_included_menu")); + vw->notes_text = GTK_WIDGET (gtk_builder_get_object (builder, "notes_text")); + vw->terms_menu = GTK_WIDGET (gtk_builder_get_object (builder, "terms_menu")); - vw->taxtable_check = glade_xml_get_widget (xml, "taxtable_button"); - vw->taxtable_menu = glade_xml_get_widget (xml, "taxtable_menu"); + vw->taxtable_check = GTK_WIDGET (gtk_builder_get_object (builder, "taxtable_button")); + vw->taxtable_menu = GTK_WIDGET (gtk_builder_get_object (builder, "taxtable_menu")); /* Currency */ edit = gnc_currency_edit_new(); gnc_currency_edit_set_currency (GNC_CURRENCY_EDIT(edit), currency); vw->currency_edit = edit; - hbox = glade_xml_get_widget (xml, "currency_box"); + hbox = GTK_WIDGET (gtk_builder_get_object (builder, "currency_box")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* Setup signals */ - glade_xml_signal_autoconnect_full( xml, - gnc_glade_autoconnect_full_func, + gtk_builder_connect_signals_full( builder, + gnc_builder_connect_full_func, vw); /* Setup initial values */ @@ -493,11 +539,11 @@ gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor) /* I know that vendor exists here -- either passed in or just created */ vw->taxincluded = gncVendorGetTaxIncluded (vendor); - gnc_ui_taxincluded_optionmenu (vw->taxincluded_menu, &vw->taxincluded); - gnc_ui_billterms_optionmenu (vw->terms_menu, bookp, TRUE, &vw->terms); + gnc_taxincluded_combo (GTK_COMBO_BOX(vw->taxincluded_menu), vw->taxincluded); + gnc_billterms_combo (GTK_COMBO_BOX(vw->terms_menu), bookp, TRUE, vw->terms); vw->taxtable = gncVendorGetTaxTable (vendor); - gnc_ui_taxtables_optionmenu (vw->taxtable_menu, bookp, TRUE, &vw->taxtable); + gnc_taxtables_combo (GTK_COMBO_BOX(vw->taxtable_menu), bookp, TRUE, vw->taxtable); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (vw->taxtable_check), gncVendorGetTaxTableOverride (vendor)); gnc_vendor_taxtable_check_cb (GTK_TOGGLE_BUTTON (vw->taxtable_check), vw); @@ -507,6 +553,7 @@ gnc_vendor_new_window (QofBook *bookp, GncVendor *vendor) QOF_EVENT_MODIFY | QOF_EVENT_DESTROY); gtk_widget_show_all (vw->dialog); + g_object_unref(G_OBJECT(builder)); return vw; } diff --git a/src/business/business-gnome/glade/Makefile.am b/src/business/business-gnome/glade/Makefile.am index 99a37d94b6..49dcad2a5f 100644 --- a/src/business/business-gnome/glade/Makefile.am +++ b/src/business/business-gnome/glade/Makefile.am @@ -7,8 +7,7 @@ glade_DATA = \ employee.glade \ job.glade \ order.glade \ - payment.glade \ - vendor.glade + payment.glade EXTRA_DIST = \ ${glade_DATA} diff --git a/src/business/business-gnome/gtkbuilder/Makefile.am b/src/business/business-gnome/gtkbuilder/Makefile.am index a884d9e362..8c8f373215 100644 --- a/src/business/business-gnome/gtkbuilder/Makefile.am +++ b/src/business/business-gnome/gtkbuilder/Makefile.am @@ -1,7 +1,8 @@ gtkbuilderdir = $(GNC_GTKBUILDER_DIR) gtkbuilder_DATA = \ dialog-customer.glade \ - dialog-invoice.glade + dialog-invoice.glade \ + dialog-vendor.glade # billterms.glade \ # businessprefs.glade \ # choose-owner.glade \ @@ -9,8 +10,7 @@ gtkbuilder_DATA = \ # employee.glade \ # job.glade \ # order.glade \ -# payment.glade \ -# vendor.glade +# payment.glade EXTRA_DIST = \ ${gtkbuilder_DATA} diff --git a/src/business/business-gnome/glade/vendor.glade b/src/business/business-gnome/gtkbuilder/dialog-vendor.glade similarity index 67% rename from src/business/business-gnome/glade/vendor.glade rename to src/business/business-gnome/gtkbuilder/dialog-vendor.glade index 58ba3f8c74..bdeae6441e 100644 --- a/src/business/business-gnome/glade/vendor.glade +++ b/src/business/business-gnome/gtkbuilder/dialog-vendor.glade @@ -1,697 +1,35 @@ - - + + - - + True + False New Vendor dialog - + - + True + False vertical 8 - - - True - True - - - True - vertical - - - True - 3 - 0 - - - True - 2 - - - True - vertical - True - - - True - 1 - Vendor Number: - right - - - False - False - 0 - - - - - True - 1 - Company Name: - right - - - False - False - 1 - - - - - Active - True - True - False - True - True - True - - - False - False - 2 - - - - - False - False - 0 - - - - - True - vertical - True - - - True - True - The vendor ID number. If left blank a reasonable number will be chosen for you - True - - - - False - False - 0 - - - - - True - True - True - True - - - - False - 1 - - - - - True - center - - - False - False - 2 - - - - - 1 - - - - - - - True - Identification - - - label_item - - - - - False - False - 0 - - - - - True - 3 - 0 - - - True - - - True - 3 - vertical - True - - - True - 1 - Name: - right - - - False - False - 0 - - - - - True - 1 - Address: - right - - - False - False - 1 - - - - - True - center - - - False - False - 2 - - - - - True - center - - - False - False - 3 - - - - - True - center - - - False - False - 4 - - - - - True - 1 - Phone: - right - - - False - False - 5 - - - - - True - 1 - Fax: - right - - - False - False - 6 - - - - - True - 1 - Email: - right - - - False - False - 7 - - - - - False - 3 - 0 - - - - - True - 3 - vertical - True - - - True - True - True - - - False - False - 0 - - - - - True - True - True - - - False - False - 1 - - - - - True - True - True - - - False - False - 2 - - - - - True - True - True - - - False - False - 3 - - - - - True - True - True - - - False - False - 4 - - - - - True - True - True - - - False - False - 5 - - - - - True - True - True - - - False - False - 6 - - - - - True - True - True - - - False - False - 7 - - - - - 1 - - - - - - - True - Payment Address - - - label_item - - - - - False - False - 1 - - - - - True - 3 - 0 - - - True - False - 3 - never - in - - - True - True - word - - - - - - - True - Notes - - - label_item - - - - - 2 - - - - - - - True - Vendor - center - - - False - tab - - - - - True - vertical - - - True - 3 - 0 - - - True - - - True - vertical - True - - - True - 1 - Currency: - right - - - False - False - 0 - - - - - True - 1 - Terms: - right - - - False - False - 1 - - - - - True - 1 - Tax Included: - right - - - False - False - 2 - - - - - True - 1 - Tax Table: - right - - - False - False - 3 - - - - - False - False - 0 - - - - - True - 3 - vertical - True - - - True - - - - - - 0 - - - - - True - True - False - - - True - - - True - (terms) - True - - - - - - - False - False - 1 - - - - - True - True - False - - - True - - - True - (taxincluded) - True - - - - - - - False - False - 2 - - - - - True - - - True - True - False - Override the global Tax Table? - True - True - - - - False - False - 0 - - - - - True - True - False - What Tax Table should be applied to this vendor? - - - True - - - True - (taxtables) - True - - - - - - - 1 - - - - - 3 - - - - - 1 - - - - - - - True - Payment Information - - - label_item - - - - - False - 0 - - - - - - - - 1 - - - - - True - Payment Information - center - - - 1 - False - tab - - - - - 2 - - - + True + False end - + gtk-help - -11 True True True True False + False True - - + + False False @@ -699,16 +37,16 @@ - + gtk-cancel - -6 True True True False + False True - - + + False False @@ -716,31 +54,746 @@ - + gtk-ok - -5 True True True True False + False True - - + + False False 2 - + False + True end 0 - + + + True + True + + + True + False + + + True + False + 3 + 0 + + + True + False + 2 + + + True + False + True + + + True + False + 1 + Vendor Number: + right + + + False + False + 0 + + + + + True + False + 1 + Company Name: + right + + + False + False + 1 + + + + + Active + True + True + False + False + True + True + True + + + False + False + 2 + + + + + False + False + 0 + + + + + True + False + True + + + True + True + The vendor ID number. If left blank a reasonable number will be chosen for you + True + + + + False + False + 0 + + + + + True + True + True + True + + + + True + False + 1 + + + + + True + False + center + + + False + False + 2 + + + + + True + True + 1 + + + + + + + True + False + Identification + + + + + False + False + 0 + + + + + True + False + 3 + 0 + + + True + False + + + True + False + 3 + True + + + True + False + 1 + Name: + right + + + False + False + 0 + + + + + True + False + 1 + Address: + right + + + False + False + 1 + + + + + True + False + center + + + False + False + 2 + + + + + True + False + center + + + False + False + 3 + + + + + True + False + center + + + False + False + 4 + + + + + True + False + 1 + Phone: + right + + + False + False + 5 + + + + + True + False + 1 + Fax: + right + + + False + False + 6 + + + + + True + False + 1 + Email: + right + + + False + False + 7 + + + + + False + True + 3 + 0 + + + + + True + False + 3 + True + + + True + True + True + + + False + False + 0 + + + + + True + True + True + + + False + False + 1 + + + + + True + True + True + + + False + False + 2 + + + + + True + True + True + + + False + False + 3 + + + + + True + True + True + + + False + False + 4 + + + + + True + True + True + + + False + False + 5 + + + + + True + True + True + + + False + False + 6 + + + + + True + True + True + + + False + False + 7 + + + + + True + True + 1 + + + + + + + True + False + Payment Address + + + + + False + False + 1 + + + + + True + False + 3 + 0 + + + True + False + 3 + never + in + + + True + True + word + + + + + + + True + False + Notes + + + + + True + True + 2 + + + + + + + True + False + Vendor + center + + + False + + + + + True + False + + + True + False + 3 + 0 + + + True + False + + + True + False + True + + + True + False + 1 + Currency: + right + + + False + False + 0 + + + + + True + False + 1 + Terms: + right + + + False + False + 1 + + + + + True + False + 1 + Tax Included: + right + + + False + False + 2 + + + + + True + False + 1 + Tax Table: + right + + + False + False + 3 + + + + + False + False + 0 + + + + + True + False + 3 + True + + + True + False + + + + + + True + True + 0 + + + + + True + False + terms_store + + + + + 0 + + + + + True + True + 1 + + + + + True + False + tax_included_store + + + + + 0 + + + + + True + True + 2 + + + + + True + False + + + True + True + False + Override the global Tax Table? + False + True + True + + + + False + False + 0 + + + + + True + False + taxtable_store + + + + + 0 + + + + + True + True + 1 + + + + + True + True + 3 + + + + + True + True + 1 + + + + + + + True + False + Payment Information + + + + + False + True + 0 + + + + + + + + 1 + + + + + True + False + Payment Information + center + + + 1 + False + + + + + False + True + 2 + + + - - + + helpbutton + cancelbutton + okbutton + + + + + + + + + + + + + + + + + + + + + + + + + + +