Add two more alternatives for the option-menu based dropdowns.

And improve the code efficiency a little bit.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21493 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens
2011-10-27 21:07:55 +00:00
parent aac8fb2ccb
commit 6bee8b5bcf
2 changed files with 39 additions and 7 deletions
@@ -720,7 +720,7 @@ gnc_simple_combo_destroy_cb (GtkWidget *widget, gpointer data)
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_make (GtkComboBox *cbox, QofBook *book,
gnc_simple_combo_generate_liststore (lsd);
gnc_simple_combo_set_value (cbox, initial_choice);
return lsd;
}
/***********************************************************
@@ -789,6 +787,40 @@ gnc_billterms_combo (GtkComboBox *cbox, QofBook *book,
(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 */
@@ -110,12 +110,12 @@ void gnc_billterms_combo (GtkComboBox *cbox, QofBook *book,
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