r21503 - gnucash/trunk/src/business/business-gnome - Remove the deprecated optionmenu widget based convenience functions.

Geert Janssens gjanssens at code.gnucash.org
Fri Oct 28 10:14:03 EDT 2011


Author: gjanssens
Date: 2011-10-28 10:14:03 -0400 (Fri, 28 Oct 2011)
New Revision: 21503
Trac: http://svn.gnucash.org/trac/changeset/21503

Modified:
   gnucash/trunk/src/business/business-gnome/business-gnome-utils.c
   gnucash/trunk/src/business/business-gnome/business-gnome-utils.h
Log:
Remove the deprecated optionmenu widget based convenience functions.
They are no longer used in the GnuCash code base.

Modified: gnucash/trunk/src/business/business-gnome/business-gnome-utils.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-gnome-utils.c	2011-10-28 14:13:54 UTC (rev 21502)
+++ gnucash/trunk/src/business/business-gnome/business-gnome-utils.c	2011-10-28 14:14:03 UTC (rev 21503)
@@ -370,295 +370,12 @@
         g_free (text);
 }
 
-/*********************************************************************/
-/* Option Menu creation                                              */
-
-typedef const char * (*GenericLookup_t)(gpointer);
-
-typedef struct
-{
-    gint         component_id;
-    GtkWidget    *omenu;
-    QofBook      *book;
-    gboolean     none_ok;
-    const char * (*get_name)(gpointer);
-    GList *      (*get_list)(QofBook*);
-
-    gboolean     building_menu;
-    gpointer     result;
-    gpointer     *result_p;
-
-    void         (*changed_cb)(GtkWidget*, gpointer);
-    gpointer     cb_arg;
-} OpMenuData;
-
-#define DO_ADD_ITEM(s,o) { \
-    add_menu_item (menu, (s), omd, (o)); \
-    if (omd->result == (o)) current = index; \
-    index++; \
-}
-
-static void
-business_option_changed (GtkWidget *widget, gpointer data)
-{
-    OpMenuData *omd = data;
-
-    g_return_if_fail (omd);
-    omd->result = g_object_get_data (G_OBJECT (widget), "this_item");
-
-    if (!omd->building_menu)
-    {
-        if (omd->result_p)
-            *(omd->result_p) = omd->result;
-
-        if (omd->changed_cb)
-            (omd->changed_cb)(omd->omenu, omd->cb_arg);
-    }
-}
-
-static void
-add_menu_item (GtkWidget *menu, const char *label, OpMenuData *omd,
-               gpointer this_item)
-{
-    GtkWidget *item = gtk_menu_item_new_with_label (label);
-    g_object_set_data (G_OBJECT (item), "this_item", this_item);
-    g_signal_connect (G_OBJECT (item), "activate",
-                      G_CALLBACK (business_option_changed), omd);
-    gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
-    gtk_widget_show (item);
-}
-
-static void
-generic_omenu_destroy_cb (GtkWidget *widget, gpointer data)
-{
-    OpMenuData *omd = data;
-
-    gnc_unregister_gui_component (omd->component_id);
-    g_free (omd);
-}
-
-static void
-build_generic_optionmenu (OpMenuData *omd)
-{
-    GList *items;
-    GtkWidget *menu;
-    int current = 0, index = 0;
-
-    /* Make sure we can "get_list" */
-    if (omd->get_list == NULL)
-        return;
-
-    /* Get the list of items */
-    items = (omd->get_list)(omd->book);
-
-    /* Make a menu */
-    menu = gtk_menu_new ();
-
-    omd->building_menu = TRUE;
-
-    if (omd->none_ok || items == NULL)
-        DO_ADD_ITEM (_("None"), NULL);
-
-    for ( ; items; items = items->next)
-        DO_ADD_ITEM ((omd->get_name)(items->data), items->data);
-
-    gtk_option_menu_set_menu (GTK_OPTION_MENU (omd->omenu), menu);
-    gtk_option_menu_set_history (GTK_OPTION_MENU (omd->omenu), current);
-    gtk_widget_show (menu);
-
-    omd->building_menu = FALSE;
-}
-
-static void
-generic_omenu_refresh_handler (GHashTable *changes, gpointer user_data)
-{
-    OpMenuData *omd = user_data;
-    build_generic_optionmenu (omd);
-}
-
-static OpMenuData *
-make_generic_optionmenu (GtkWidget *omenu, QofBook *book,
-                         gboolean none_ok, QofIdType type_name,
-                         GList * (*get_list)(QofBook*),
-                         GenericLookup_t get_name,
-                         gpointer *result)
-{
-    OpMenuData *omd;
-
-    omd = g_object_get_data (G_OBJECT (omenu), "menu-data");
-
-    /* If this is the first time we've been called, then build the
-     * Option Menu Data object, register with the component manager, and
-     * watch for changed items.  Then register for deletion, so we can
-     * unregister and free the data when this menu is destroyed.
-     */
-    if (!omd)
-    {
-        omd = g_new0 (OpMenuData, 1);
-        omd->omenu = omenu;
-        omd->book = book;
-        omd->result_p = result;
-        omd->none_ok = none_ok;
-        omd->get_name = get_name;
-        omd->get_list = get_list;
-        g_object_set_data (G_OBJECT (omenu), "menu-data", omd);
-
-        if (result)
-            omd->result = *result;
-
-        omd->component_id =
-            gnc_register_gui_component ("generic-omenu-refresh-hook",
-                                        generic_omenu_refresh_handler,
-                                        NULL, omd);
-
-
-        if (type_name)
-            gnc_gui_component_watch_entity_type (omd->component_id,
-                                                 type_name,
-                                                 QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);
-
-        g_signal_connect (G_OBJECT (omenu), "destroy",
-                          G_CALLBACK (generic_omenu_destroy_cb), omd);
-
-    }
-
-    build_generic_optionmenu (omd);
-
-    return omd;
-}
-
-void
-gnc_ui_optionmenu_set_changed_callback (GtkWidget *omenu,
-                                        void (*changed_cb)(GtkWidget*, gpointer),
-                                        gpointer cb_arg)
-{
-    OpMenuData *omd;
-
-    if (!omenu) return;
-
-    omd = g_object_get_data (G_OBJECT (omenu), "menu-data");
-    g_return_if_fail (omd);
-
-    omd->changed_cb = changed_cb;
-    omd->cb_arg = cb_arg;
-}
-
-gpointer
-gnc_ui_optionmenu_get_value (GtkWidget *omenu)
-{
-    OpMenuData *omd;
-
-    if (!omenu) return NULL;
-
-    omd = g_object_get_data (G_OBJECT (omenu), "menu-data");
-    g_return_val_if_fail (omd, NULL);
-
-    return omd->result;
-}
-
-void
-gnc_ui_optionmenu_set_value (GtkWidget *omenu, gpointer data)
-{
-    OpMenuData *omd;
-    GtkWidget *menu;
-    GList *node;
-    gint counter;
-
-    if (!omenu) return;
-
-    omd = g_object_get_data (G_OBJECT (omenu), "menu-data");
-    g_return_if_fail (omd);
-
-    menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (omenu));
-    g_return_if_fail (menu);
-
-    /* now walk all the children until we find our object */
-    for (counter = 0, node = ((GTK_MENU_SHELL (menu))->children);
-            node;
-            node = node->next, counter++)
-    {
-        GObject *menuitem = node->data;
-        gpointer this_object = g_object_get_data (menuitem, "this_item");
-
-        if (this_object == data)
-        {
-            gtk_option_menu_set_history (GTK_OPTION_MENU (omd->omenu), counter);
-            return;
-        }
-    }
-}
-
-/* Create an optionmenu of available billing terms and attach it to
- * the menu passed in.  If none_ok is true, then add "none" as a
- * choice (with data set to NULL).  Any time the menu changes,
- * 'choice' will be set to the chosen option.  If *choice is non-NULL,
- * then that will be the default option setting when the menu is
- * created.
- */
-void
-gnc_ui_billterms_optionmenu (GtkWidget *omenu, QofBook *book,
-                             gboolean none_ok, GncBillTerm **choice)
-{
-    if (!omenu || !book) return;
-
-    make_generic_optionmenu (omenu, book, none_ok, GNC_BILLTERM_MODULE_NAME,
-                             gncBillTermGetTerms,
-                             (GenericLookup_t)gncBillTermGetName,
-                             (gpointer *)choice);
-}
-
-void
-gnc_ui_taxtables_optionmenu (GtkWidget *omenu, QofBook *book,
-                             gboolean none_ok, GncTaxTable **choice)
-{
-    if (!omenu || !book) return;
-
-    make_generic_optionmenu (omenu, book, none_ok, GNC_TAXTABLE_MODULE_NAME,
-                             gncTaxTableGetTables,
-                             (GenericLookup_t)gncTaxTableGetName,
-                             (gpointer *)choice);
-}
-
-void
-gnc_ui_taxincluded_optionmenu (GtkWidget *omenu, GncTaxIncluded *choice)
-{
-    GtkWidget *menu;
-    OpMenuData *omd;
-    int current = 0, index = 0;
-
-    if (!omenu) return;
-
-    omd = make_generic_optionmenu (omenu, NULL, FALSE, NULL, NULL, NULL,
-                                   (gpointer *)choice);
-
-    g_return_if_fail (omd);
-
-    menu = gtk_menu_new ();
-
-    add_menu_item (menu, _("Yes"), omd,
-                   GINT_TO_POINTER (GNC_TAXINCLUDED_YES));
-    if (*choice == GNC_TAXINCLUDED_YES) current = index;
-    index++;
-
-    add_menu_item (menu, _("No"), omd,
-                   GINT_TO_POINTER (GNC_TAXINCLUDED_NO));
-    if (*choice == GNC_TAXINCLUDED_NO) current = index;
-    index++;
-
-    add_menu_item (menu, _("Use Global"), omd,
-                   GINT_TO_POINTER (GNC_TAXINCLUDED_USEGLOBAL));
-    if (*choice == GNC_TAXINCLUDED_USEGLOBAL) current = index;
-    index++;
-
-    gtk_option_menu_set_menu (GTK_OPTION_MENU (omenu), menu);
-    gtk_option_menu_set_history (GTK_OPTION_MENU (omenu), current);
-    gtk_widget_show (menu);
-}
-
 /***********************************************************************
  * gnc_simple_combo implementation functions
  */
 
+typedef const char * (*GenericLookup_t)(gpointer);
+
 typedef struct
 {
     gint         component_id;

Modified: gnucash/trunk/src/business/business-gnome/business-gnome-utils.h
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-gnome-utils.h	2011-10-28 14:13:54 UTC (rev 21502)
+++ gnucash/trunk/src/business/business-gnome/business-gnome-utils.h	2011-10-28 14:14:03 UTC (rev 21503)
@@ -63,38 +63,6 @@
                                     GList *acct_types,
                                     GList *acct_commodities);
 
-
-/* Create an optionmenu of available billing terms and attach it to
- * the menu passed in.  If none_ok is true, then add "none" as a
- * choice (with data set to NULL).  Any time the menu changes,
- * 'choice' will be set to the chosen option.  If *choice is non-NULL,
- * then that will be the default option setting when the menu is
- * created.
- */
-void gnc_ui_billterms_optionmenu (GtkWidget *omenu, QofBook *book,
-                                  gboolean none_ok, GncBillTerm **choice);
-
-/* Same thing except for the tax tables */
-void
-gnc_ui_taxtables_optionmenu (GtkWidget *omenu, QofBook *book,
-                             gboolean none_ok, GncTaxTable **choice);
-
-/* Build an option menu for choosing a GncTaxIncluded */
-void gnc_ui_taxincluded_optionmenu (GtkWidget *omenu, GncTaxIncluded *choice);
-
-
-/* Here are some "generic option menu" utilities that can be used with
- * ANY of the above option-menu types.  In particular the following
- * functions are useful for hooking the above option menus into the
- * GNC Option infrastructure.
- */
-
-void gnc_ui_optionmenu_set_changed_callback (GtkWidget *omenu,
-        void (*changed_cb)(GtkWidget*, gpointer),
-        gpointer cb_arg);
-gpointer gnc_ui_optionmenu_get_value (GtkWidget *omenu);
-void gnc_ui_optionmenu_set_value (GtkWidget *omenu, gpointer data);
-
 /* Create a combo box of available billing terms based on
  * the combo box If none_ok is true, then add "none" as a
  * choice (with data set to NULL).  If inital_choice is non-NULL,



More information about the gnucash-changes mailing list