r21493 - gnucash/trunk/src/business/business-gnome - Add two more alternatives for the option-menu based dropdowns.

Geert Janssens gjanssens at code.gnucash.org
Thu Oct 27 17:07:55 EDT 2011


Author: gjanssens
Date: 2011-10-27 17:07:55 -0400 (Thu, 27 Oct 2011)
New Revision: 21493
Trac: http://svn.gnucash.org/trac/changeset/21493

Modified:
   gnucash/trunk/src/business/business-gnome/business-gnome-utils.c
   gnucash/trunk/src/business/business-gnome/business-gnome-utils.h
Log:
Add two more alternatives for the option-menu based dropdowns.
And improve the code efficiency a little bit.

Modified: gnucash/trunk/src/business/business-gnome/business-gnome-utils.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-gnome-utils.c	2011-10-27 18:33:10 UTC (rev 21492)
+++ gnucash/trunk/src/business/business-gnome/business-gnome-utils.c	2011-10-27 21:07:55 UTC (rev 21493)
@@ -720,7 +720,7 @@
     g_free (lsd);
 }
 
-static ListStoreData *
+static void
 gnc_simple_combo_make (GtkComboBox *cbox, QofBook *book,
                        gboolean none_ok, QofIdType type_name,
                        GList * (*get_list)(QofBook*),
@@ -763,8 +763,6 @@
 
     gnc_simple_combo_generate_liststore (lsd);
     gnc_simple_combo_set_value (cbox, initial_choice);
-
-    return lsd;
 }
 
 /***********************************************************
@@ -789,6 +787,40 @@
                            (gpointer)initial_choice);
 }
 
+void
+gnc_taxtables_combo (GtkComboBox *cbox, QofBook *book,
+                     gboolean none_ok, GncTaxTable *initial_choice)
+{
+    if (!cbox || !book) return;
+
+    gnc_simple_combo_make (cbox, book, none_ok, GNC_TAXTABLE_MODULE_NAME,
+                           gncTaxTableGetTables,
+                           (GenericLookup_t)gncTaxTableGetName,
+                           (gpointer)initial_choice);
+}
+
+void
+gnc_taxincluded_combo (GtkComboBox *cbox, GncTaxIncluded initial_choice)
+{
+    GtkWidget *menu;
+    GtkListStore *liststore;
+
+    if (!cbox) return;
+
+    gnc_simple_combo_make (cbox, NULL, FALSE, NULL, NULL, NULL,
+                           GINT_TO_POINTER(initial_choice));
+    liststore = GTK_LIST_STORE (gtk_combo_box_get_model (cbox));
+
+    gnc_simple_combo_add_item (liststore, _("Yes"),
+                               GINT_TO_POINTER (GNC_TAXINCLUDED_YES));
+    gnc_simple_combo_add_item (liststore, _("No"),
+                               GINT_TO_POINTER (GNC_TAXINCLUDED_NO));
+    gnc_simple_combo_add_item (liststore, _("Use Global"),
+                               GINT_TO_POINTER (GNC_TAXINCLUDED_USEGLOBAL));
+
+    gnc_simple_combo_set_value (cbox, GINT_TO_POINTER(initial_choice));
+}
+
 /* Convenience functions for the above simple combo box types.  */
 
 /** Get the value of the item that is currently selected in the combo box */

Modified: gnucash/trunk/src/business/business-gnome/business-gnome-utils.h
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-gnome-utils.h	2011-10-27 18:33:10 UTC (rev 21492)
+++ gnucash/trunk/src/business/business-gnome/business-gnome-utils.h	2011-10-27 21:07:55 UTC (rev 21493)
@@ -110,12 +110,12 @@
                           gboolean none_ok, GncBillTerm *initial_choice);
 
 /* Same thing except for the tax tables */
-//void
-//gnc_ui_taxtables_optionmenu (GtkComboBox *cbox, QofBook *book,
-//                             gboolean none_ok, GncTaxTable **choice);
+void
+gnc_taxtables_combo (GtkComboBox *cbox, QofBook *book,
+                     gboolean none_ok, GncTaxTable *initial_choice);
 
 /* Build an option menu for choosing a GncTaxIncluded */
-//void gnc_ui_taxincluded_optionmenu (GtkComboBox *cbox, GncTaxIncluded *choice);
+void gnc_taxincluded_combo (GtkComboBox *cbox, GncTaxIncluded initial_choice);
 
 
 /* Here are some "simple combo box" utilities that can be used with



More information about the gnucash-changes mailing list