From 8ba2af23c666d356133cb00f02f8f3c2b82140f7 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 27 Oct 2011 21:08:05 +0000 Subject: [PATCH] Convert customer dialog to gtkbuilder git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21494 57a11ea4-9604-0410-9ed3-97b8803252fd --- po/POTFILES.in | 5 +- src/business/business-gnome/dialog-customer.c | 127 ++- src/business/business-gnome/glade/Makefile.am | 1 - .../business-gnome/gtkbuilder/Makefile.am | 2 +- .../dialog-customer.glade} | 746 ++++++++++-------- 5 files changed, 499 insertions(+), 382 deletions(-) rename src/business/business-gnome/{glade/customer.glade => gtkbuilder/dialog-customer.glade} (68%) diff --git a/po/POTFILES.in b/po/POTFILES.in index 11bc46a8032..2e418c7a1f3 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -103,7 +103,6 @@ src/business/business-gnome/dialog-vendor.c src/business/business-gnome/glade/billterms.glade src/business/business-gnome/glade/businessprefs.glade src/business/business-gnome/glade/choose-owner.glade -src/business/business-gnome/glade/customer.glade src/business/business-gnome/glade/date-close.glade src/business/business-gnome/glade/employee.glade src/business/business-gnome/glade/job.glade @@ -114,7 +113,9 @@ src/business/business-gnome/gncmod-business-gnome.c src/business/business-gnome/gnc-plugin-business.c src/business/business-gnome/gnc-plugin-page-invoice.c src/business/business-gnome/gnc-plugin-page-owner-tree.c -src/business/business-gnome/gtkbuilder/invoice.glade +src/business/business-gnome/gtkbuilder/dialog-customer.glade +src/business/business-gnome/gtkbuilder/dialog-invoice.glade +src/business/business-gnome/gtkbuilder/dialog-vendor.glade src/business/business-gnome/schemas/apps_gnucash_dialog_business_common.schemas.in src/business/business-gnome/search-owner.c src/business/business-ledger/gncEntryLedger.c diff --git a/src/business/business-gnome/dialog-customer.c b/src/business/business-gnome/dialog-customer.c index 8bf57a1bccb..0e21dee0cc0 100644 --- a/src/business/business-gnome/dialog-customer.c +++ b/src/business/business-gnome/dialog-customer.c @@ -65,6 +65,9 @@ void gnc_customer_window_cancel_cb (GtkWidget *widget, gpointer data); void gnc_customer_window_help_cb (GtkWidget *widget, gpointer data); void gnc_customer_window_destroy_cb (GtkWidget *widget, gpointer data); void gnc_customer_name_changed_cb (GtkWidget *widget, gpointer data); +void gnc_customer_terms_changed_cb (GtkWidget *widget, gpointer data); +void gnc_customer_taxincluded_changed_cb (GtkWidget *widget, gpointer data); +void gnc_customer_taxtable_changed_cb (GtkWidget *widget, gpointer data); void gnc_customer_addr2_insert_cb(GtkEditable *editable, gchar *new_text, gint new_text_length, gint *position, gpointer user_data); @@ -443,6 +446,45 @@ gnc_customer_name_changed_cb (GtkWidget *widget, gpointer data) g_free (title); } +void +gnc_customer_terms_changed_cb (GtkWidget *widget, gpointer data) +{ + GtkComboBox *cbox = GTK_COMBO_BOX (widget); + CustomerWindow *cw = data; + gchar *title; + + if (!cw) return; + if (!cbox) return; + + cw->terms = gnc_simple_combo_get_value (cbox); +} + +void +gnc_customer_taxincluded_changed_cb (GtkWidget *widget, gpointer data) +{ + GtkComboBox *cbox = GTK_COMBO_BOX (widget); + CustomerWindow *cw = data; + gchar *title; + + if (!cw) return; + if (!cbox) return; + + cw->taxincluded = GPOINTER_TO_INT (gnc_simple_combo_get_value (cbox)); +} + +void +gnc_customer_taxtable_changed_cb (GtkWidget *widget, gpointer data) +{ + GtkComboBox *cbox = GTK_COMBO_BOX (widget); + CustomerWindow *cw = data; + gchar *title; + + if (!cw) return; + if (!cbox) return; + + cw->taxtable = gnc_simple_combo_get_value (cbox); +} + static void gnc_customer_window_close_handler (gpointer user_data) { @@ -492,7 +534,7 @@ static CustomerWindow * gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) { CustomerWindow *cw; - GladeXML *xml; + GtkBuilder *builder; GtkWidget *hbox, *edit; gnc_commodity *currency; GNCPrintAmountInfo print_info; @@ -529,48 +571,52 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) cw->book = bookp; /* Find the dialog */ - xml = gnc_glade_xml_new ("customer.glade", "Customer Dialog"); - cw->dialog = glade_xml_get_widget (xml, "Customer Dialog"); + builder = gtk_builder_new(); + gnc_builder_add_from_file (builder, "dialog-customer.glade", "terms_store"); + gnc_builder_add_from_file (builder, "dialog-customer.glade", "tax_included_store"); + gnc_builder_add_from_file (builder, "dialog-customer.glade", "taxtable_store"); + gnc_builder_add_from_file (builder, "dialog-customer.glade", "Customer Dialog"); + cw->dialog = GTK_WIDGET (gtk_builder_get_object (builder, "Customer Dialog")); g_object_set_data (G_OBJECT (cw->dialog), "dialog_info", cw); /* Get entry points */ - cw->id_entry = glade_xml_get_widget (xml, "id_entry"); - cw->company_entry = glade_xml_get_widget (xml, "company_entry"); - - cw->name_entry = glade_xml_get_widget (xml, "name_entry"); - cw->addr1_entry = glade_xml_get_widget (xml, "addr1_entry"); - cw->addr2_entry = glade_xml_get_widget (xml, "addr2_entry"); - cw->addr3_entry = glade_xml_get_widget (xml, "addr3_entry"); - cw->addr4_entry = glade_xml_get_widget (xml, "addr4_entry"); - cw->phone_entry = glade_xml_get_widget (xml, "phone_entry"); - cw->fax_entry = glade_xml_get_widget (xml, "fax_entry"); - cw->email_entry = glade_xml_get_widget (xml, "email_entry"); - - cw->shipname_entry = glade_xml_get_widget (xml, "shipname_entry"); - cw->shipaddr1_entry = glade_xml_get_widget (xml, "shipaddr1_entry"); - cw->shipaddr2_entry = glade_xml_get_widget (xml, "shipaddr2_entry"); - cw->shipaddr3_entry = glade_xml_get_widget (xml, "shipaddr3_entry"); - cw->shipaddr4_entry = glade_xml_get_widget (xml, "shipaddr4_entry"); - cw->shipphone_entry = glade_xml_get_widget (xml, "shipphone_entry"); - cw->shipfax_entry = glade_xml_get_widget (xml, "shipfax_entry"); - cw->shipemail_entry = glade_xml_get_widget (xml, "shipemail_entry"); - - cw->active_check = glade_xml_get_widget (xml, "active_check"); - cw->taxincluded_menu = glade_xml_get_widget (xml, "tax_included_menu"); - cw->notes_text = glade_xml_get_widget (xml, "notes_text"); - - cw->terms_menu = glade_xml_get_widget (xml, "terms_menu"); - - cw->taxtable_check = glade_xml_get_widget (xml, "taxtable_button"); - cw->taxtable_menu = glade_xml_get_widget (xml, "taxtable_menu"); + cw->id_entry = GTK_WIDGET (gtk_builder_get_object (builder, "id_entry")); + cw->company_entry = GTK_WIDGET (gtk_builder_get_object (builder, "company_entry")); + + cw->name_entry = GTK_WIDGET (gtk_builder_get_object (builder, "name_entry")); + cw->addr1_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr1_entry")); + cw->addr2_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr2_entry")); + cw->addr3_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr3_entry")); + cw->addr4_entry = GTK_WIDGET (gtk_builder_get_object (builder, "addr4_entry")); + cw->phone_entry = GTK_WIDGET (gtk_builder_get_object (builder, "phone_entry")); + cw->fax_entry = GTK_WIDGET (gtk_builder_get_object (builder, "fax_entry")); + cw->email_entry = GTK_WIDGET (gtk_builder_get_object (builder, "email_entry")); + + cw->shipname_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipname_entry")); + cw->shipaddr1_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr1_entry")); + cw->shipaddr2_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr2_entry")); + cw->shipaddr3_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr3_entry")); + cw->shipaddr4_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipaddr4_entry")); + cw->shipphone_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipphone_entry")); + cw->shipfax_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipfax_entry")); + cw->shipemail_entry = GTK_WIDGET (gtk_builder_get_object (builder, "shipemail_entry")); + + cw->active_check = GTK_WIDGET (gtk_builder_get_object (builder, "active_check")); + cw->taxincluded_menu = GTK_WIDGET (gtk_builder_get_object (builder, "tax_included_menu")); + cw->notes_text = GTK_WIDGET (gtk_builder_get_object (builder, "notes_text")); + + cw->terms_menu = GTK_WIDGET (gtk_builder_get_object (builder, "terms_menu")); + + cw->taxtable_check = GTK_WIDGET (gtk_builder_get_object (builder, "taxtable_button")); + cw->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); cw->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); /* DISCOUNT: Percentage Value */ @@ -583,7 +629,7 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) cw->discount_amount = edit; gtk_widget_show (edit); - hbox = glade_xml_get_widget (xml, "discount_box"); + hbox = GTK_WIDGET (gtk_builder_get_object (builder, "discount_box")); gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0); /* CREDIT: Monetary Value */ @@ -596,12 +642,12 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) cw->credit_amount = edit; gtk_widget_show (edit); - hbox = glade_xml_get_widget (xml, "credit_box"); + hbox = GTK_WIDGET (gtk_builder_get_object (builder, "credit_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, cw); /* Setup initial values */ @@ -675,11 +721,11 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) /* I know that cust exists here -- either passed in or just created */ cw->taxincluded = gncCustomerGetTaxIncluded (cust); - gnc_ui_taxincluded_optionmenu (cw->taxincluded_menu, &cw->taxincluded); - gnc_ui_billterms_optionmenu (cw->terms_menu, bookp, TRUE, &cw->terms); + gnc_taxincluded_combo (GTK_COMBO_BOX(cw->taxincluded_menu), cw->taxincluded); + gnc_billterms_combo (GTK_COMBO_BOX(cw->terms_menu), bookp, TRUE, cw->terms); cw->taxtable = gncCustomerGetTaxTable (cust); - gnc_ui_taxtables_optionmenu (cw->taxtable_menu, bookp, TRUE, &cw->taxtable); + gnc_taxtables_combo (GTK_COMBO_BOX(cw->taxtable_menu), bookp, TRUE, cw->taxtable); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cw->taxtable_check), gncCustomerGetTaxTableOverride (cust)); gnc_customer_taxtable_check_cb (GTK_TOGGLE_BUTTON (cw->taxtable_check), cw); @@ -700,6 +746,7 @@ gnc_customer_new_window (QofBook *bookp, GncCustomer *cust) QOF_EVENT_MODIFY | QOF_EVENT_DESTROY); gtk_widget_show_all (cw->dialog); + g_object_unref(G_OBJECT(builder)); return cw; } diff --git a/src/business/business-gnome/glade/Makefile.am b/src/business/business-gnome/glade/Makefile.am index 4062c8f5277..99a37d94b67 100644 --- a/src/business/business-gnome/glade/Makefile.am +++ b/src/business/business-gnome/glade/Makefile.am @@ -3,7 +3,6 @@ glade_DATA = \ billterms.glade \ businessprefs.glade \ choose-owner.glade \ - customer.glade \ date-close.glade \ employee.glade \ job.glade \ diff --git a/src/business/business-gnome/gtkbuilder/Makefile.am b/src/business/business-gnome/gtkbuilder/Makefile.am index c677285db0b..a884d9e3620 100644 --- a/src/business/business-gnome/gtkbuilder/Makefile.am +++ b/src/business/business-gnome/gtkbuilder/Makefile.am @@ -1,10 +1,10 @@ gtkbuilderdir = $(GNC_GTKBUILDER_DIR) gtkbuilder_DATA = \ + dialog-customer.glade \ dialog-invoice.glade # billterms.glade \ # businessprefs.glade \ # choose-owner.glade \ -# customer.glade \ # date-close.glade \ # employee.glade \ # job.glade \ diff --git a/src/business/business-gnome/glade/customer.glade b/src/business/business-gnome/gtkbuilder/dialog-customer.glade similarity index 68% rename from src/business/business-gnome/glade/customer.glade rename to src/business/business-gnome/gtkbuilder/dialog-customer.glade index e774c451708..5c6cabbf2cd 100644 --- a/src/business/business-gnome/glade/customer.glade +++ b/src/business/business-gnome/gtkbuilder/dialog-customer.glade @@ -1,46 +1,115 @@ - - - - - + + + + True + False New Customer dialog - + - + True + False vertical 8 + + + True + False + end + + + gtk-help + True + True + True + False + False + True + + + + False + False + 0 + + + + + gtk-cancel + True + True + True + False + False + True + + + + False + False + 1 + + + + + gtk-ok + True + True + True + True + False + False + True + + + + False + False + 2 + + + + + False + True + end + 0 + + - + True True - + True - vertical + False - + True + False 3 0 - + True + False 2 - + True - vertical + False True - + True + False 1 Customer Number: right - + False False @@ -48,12 +117,13 @@ - + True + False 1 Company Name: right - + False False @@ -61,22 +131,23 @@ - + Active True True False + False True True True - + False False 2 - + False False @@ -84,18 +155,18 @@ - + True - vertical + False True - + True True - The customer ID number. If left blank a reasonable number will be chosen for you + The customer ID number. If left blank a reasonable number will be chosen for you True - - + + False False @@ -103,46 +174,48 @@ - + True True True True - - + + + True False 1 - + True + False center - + False False 2 - + + True + True 1 - + - - + + True + False Identification - - - label_item - + - + False False @@ -150,26 +223,29 @@ - + True + False 3 0 - + True + False - + True + False 3 - vertical True - + True + False 1 Name: right - + False False @@ -177,12 +253,13 @@ - + True + False 1 Address: right - + False False @@ -190,10 +267,11 @@ - + True + False center - + False False @@ -201,10 +279,11 @@ - + True + False center - + False False @@ -212,10 +291,11 @@ - + True + False center - + False False @@ -223,12 +303,13 @@ - + True + False 1 Phone: right - + False False @@ -236,12 +317,13 @@ - + True + False 1 Fax: right - + False False @@ -249,37 +331,39 @@ - + True + False 1 Email: right - + False False 7 - + False + True 3 0 - + True + False 3 - vertical True - + True True True - + False False @@ -287,11 +371,11 @@ - + True True True - + False False @@ -299,13 +383,13 @@ - + True True True - - - + + + False False @@ -313,13 +397,13 @@ - + True True True - - - + + + False False @@ -327,13 +411,13 @@ - + True True True - - - + + + False False @@ -341,11 +425,11 @@ - + True True True - + False False @@ -353,11 +437,11 @@ - + True True True - + False False @@ -365,34 +449,34 @@ - + True True True - + False False 7 - + + True + True 1 - + - - + + True + False Billing Address - - - label_item - + - + False False @@ -400,77 +484,81 @@ - + True + False 3 0 - + True False 3 never in - + True True word - + - + - - + + True + False Notes - - - label_item - + - + + True + True 2 - + - - + + True + False Customer center - + False - tab - + True - vertical + False - + True + False 3 0 - + True + False - + True - vertical + False True - + True + False 1 Currency: right - + False False @@ -478,12 +566,13 @@ - + True + False 1 Terms: right - + False False @@ -491,12 +580,13 @@ - + True + False 1 Discount: right - + False False @@ -504,12 +594,13 @@ - + True + False 1 Credit Limit: right - + False False @@ -517,12 +608,13 @@ - + True + False 1 Tax Included: right - + False False @@ -530,19 +622,20 @@ - + True + False 1 Tax Table: right - + False False 5 - + False False @@ -550,53 +643,52 @@ - + True + False 3 - vertical True - + True + False - + + True + True 0 - + True - True - False - - - True - - - True - (terms) - True - - - + False + terms_store + + + + + 0 + - + - False - False + True + True 1 - + True + False - + False False @@ -604,53 +696,53 @@ - + True + False - + + True + True 3 - + True - True - False - - - True - - - True - (taxincluded) - True - - - + False + tax_included_store + + + + + 0 + - + - False - False + True + True 4 - + True + False - + True True False - Override the global Tax Table? + Override the global Tax Table? + False True True - - + + False False @@ -658,100 +750,102 @@ - + True - True - False - What Tax Table should be applied to this customer? - - - True - - - True - (taxtables) - True - - - - - + False + taxtable_store + + + + + 0 + + + + True + True 1 - + + True + True 5 - + + True + True 1 - + - - + + True + False Billing Information - - - label_item - + - + False + True 0 - + 1 - - + + True + False Billing Information center - + 1 False - tab - + True - vertical + False - + True + False 3 0 - + True + False - + True + False 4 - vertical True - + True + False 1 Name: right - + False False @@ -759,12 +853,13 @@ - + True + False 1 Address: right - + False False @@ -772,10 +867,11 @@ - + True + False center - + False False @@ -783,10 +879,11 @@ - + True + False center - + False False @@ -794,10 +891,11 @@ - + True + False center - + False False @@ -805,12 +903,13 @@ - + True + False 1 Phone: right - + False False @@ -818,12 +917,13 @@ - + True + False 1 Fax: right - + False False @@ -831,37 +931,39 @@ - + True + False 1 Email: right - + False False 7 - + False + True 3 0 - + True + False 3 - vertical True - + True True True - + False False @@ -869,11 +971,11 @@ - + True True True - + False False @@ -881,13 +983,13 @@ - + True True True - - - + + + False False @@ -895,13 +997,13 @@ - + True True True - - - + + + False False @@ -909,13 +1011,13 @@ - + True True True - - - + + + False False @@ -923,11 +1025,11 @@ - + True True True - + False False @@ -935,11 +1037,11 @@ - + True True True - + False False @@ -947,35 +1049,35 @@ - + True True True - + False False 7 - + + True + True 3 1 - + - - + + True + False Shipping Information - - - label_item - + - + False False @@ -988,92 +1090,60 @@ - + 2 - - + + True + False Shipping Address center - + 2 False - tab - - - - - 2 - - - - - True - end - - - gtk-help - -11 - True - True - True - False - True - - - - False - False - 0 - - - gtk-cancel - -6 - True - True - True - False - True - - - - False - False - 1 - - - - - gtk-ok - -5 - True - True - True - True - False - True - - - - False - False - 2 - - - + False - end - 0 + True + 2 - + - - + + helpbutton + cancelbutton + okbutton + + + + + + + + + + + + + + + + + + + + + + + + + + +