[dia] sheet-editor: use GtkComboBox



commit 066965a5e965b26caca6073fd80e826e1c42eadc
Author: Zander Brown <zbrown gnome org>
Date:   Sat Nov 30 15:32:59 2019 +0000

    sheet-editor: use GtkComboBox
    
    Removes the final uses of GtkOptionMenu
    
    Hoovered up a few icon rendering bugs as well, realistically the whole thing wants rewritten

 app/app_procs.c                            |  12 +-
 app/sheet-editor/sheets.c                  | 232 +++++++++++++++--------------
 app/sheet-editor/sheets.h                  |  18 ++-
 app/sheet-editor/sheets_dialog.c           |  34 +++--
 app/sheet-editor/sheets_dialog_callbacks.c |  40 ++---
 app/sheet-editor/sheets_dialog_callbacks.h |   2 +-
 app/toolbox.c                              |   4 +-
 data/ui/sheets-main-dialog.xml             |  40 ++++-
 8 files changed, 217 insertions(+), 165 deletions(-)
---
diff --git a/app/app_procs.c b/app/app_procs.c
index 53f8b8c3..342583a9 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -78,8 +78,8 @@ static gboolean         handle_all_diagrams    (GSList     *files,
                                                 char       *export_file_format,
                                                 char       *size,
                                                 char       *show_layers,
-                                                const char *input_directory,
-                                                const char *output_directory);
+                                                const char *input_dir,
+                                                const char *output_dir);
 static void             print_credits          (void);
 static void             print_filters_list     (gboolean verbose);
 
@@ -1098,21 +1098,21 @@ handle_all_diagrams (GSList     *files,
                      char       *export_file_format,
                      char       *size,
                      char       *show_layers,
-                     const char *input_directory,
-                     const char *output_directory)
+                     const char *input_dir,
+                     const char *output_dir)
 {
   GSList *node = NULL;
   gboolean made_conversions = FALSE;
 
   for (node = files; node; node = node->next) {
-    gchar *inpath = input_directory ? g_build_filename (input_directory, node->data, NULL) : node->data;
+    gchar *inpath = input_dir ? g_build_filename (input_dir, node->data, NULL) : node->data;
     made_conversions |=
       handle_initial_diagram (inpath,
                               export_file_name,
                               export_file_format,
                               size,
                               show_layers,
-                              output_directory);
+                              output_dir);
     if (inpath != node->data) {
       g_free (inpath);
     }
diff --git a/app/sheet-editor/sheets.c b/app/sheet-editor/sheets.c
index 8e2d5ff2..ade3d933 100644
--- a/app/sheet-editor/sheets.c
+++ b/app/sheet-editor/sheets.c
@@ -23,7 +23,6 @@
 
 #include <string.h>
 
-#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu */
 #include <gtk/gtk.h>
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
@@ -43,6 +42,7 @@
 #include "preferences.h"
 #include "toolbox.h"  /* just for interface_current_sheet_name */
 #include "commands.h" /* sheets_dialog_show_callback */
+#include "widgets.h"
 
 GtkWidget *sheets_dialog = NULL;
 GSList *sheets_mods_list = NULL;
@@ -108,45 +108,78 @@ sheets_append_sheet_mods (Sheet *sheet)
   return sheet_mod;
 }
 
-static gint
-menu_item_compare_labels (gconstpointer a, gconstpointer b)
+
+struct FindSheetData {
+  GtkWidget  *combo;
+  const char *find;
+};
+
+
+static gboolean
+find_sheet (GtkTreeModel *model,
+            GtkTreePath  *path,
+            GtkTreeIter  *iter,
+            gpointer      udata)
 {
-  GList *a_list;
-  const gchar *label;
+  struct FindSheetData *data = udata;
+  char *item;
+  gboolean res = FALSE;
+
+  gtk_tree_model_get (model,
+                      iter,
+                      SO_COL_NAME, &item,
+                      -1);
+
+  res = g_strcmp0 (data->find, item) == 0;
+  if (res) {
+    gtk_combo_box_set_active_iter (GTK_COMBO_BOX (data->combo), iter);
+  }
 
-  a_list = gtk_container_get_children (GTK_CONTAINER (GTK_MENU_ITEM (a)));
-  g_assert (g_list_length (a_list) == 1);
+  g_free (item);
+
+  return res;
+}
 
-  label = gtk_label_get_text (GTK_LABEL (a_list->data));
-  g_list_free (a_list);
 
-  if (!strcmp (label, (gchar *) b)) {
-    return 0;
+void
+select_sheet (GtkWidget *combo,
+              gchar     *sheet_name)
+{
+  GtkListStore *store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo)));
+  GtkTreeIter iter;
+
+  /* If we were passed a sheet_name, then make the optionmenu point to that
+     name after creation */
+
+  if (sheet_name) {
+    struct FindSheetData data;
+
+    data.combo = combo;
+    data.find = sheet_name;
+
+    gtk_tree_model_foreach (GTK_TREE_MODEL (store), find_sheet, &data);
   } else {
-    return 1;
+    if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter)) {
+      gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter);
+    }
   }
 }
 
+
 void
-sheets_optionmenu_create (GtkWidget *option_menu,
-                          GtkWidget *wrapbox,
-                          gchar     *sheet_name)
+populate_store (GtkListStore *store)
 {
-  GtkWidget *optionmenu_menu;
+  GtkTreeIter iter;
   GSList *sheets_list;
-  GList *menu_item_list;
 
   /* Delete the contents, if any, of this optionemnu first */
 
-  optionmenu_menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (option_menu));
-  gtk_container_foreach (GTK_CONTAINER (optionmenu_menu),
-                         (GtkCallback) gtk_widget_destroy, NULL);
+  gtk_list_store_clear (store);
 
   for (sheets_list = sheets_mods_list; sheets_list;
        sheets_list = g_slist_next (sheets_list)) {
     SheetMod *sheet_mod;
-    GtkWidget *menu_item;
-    gchar *tip;
+    gchar *location;
 
     sheet_mod = sheets_list->data;
 
@@ -156,57 +189,20 @@ sheets_optionmenu_create (GtkWidget *option_menu,
       continue;
     }
 
-    {
-      //                                        *sigh*
-      menu_item = gtk_menu_item_new_with_label (gettext (sheet_mod->sheet.name));
-
-      gtk_menu_append (GTK_MENU (optionmenu_menu), menu_item);
-
-      if (sheet_mod->sheet.scope == SHEET_SCOPE_SYSTEM) {
-        tip = g_strdup_printf (_("%s\nSystem sheet"), sheet_mod->sheet.description);
-      } else {
-        tip = g_strdup_printf (_("%s\nUser sheet"), sheet_mod->sheet.description);
-      }
-
-      gtk_widget_set_tooltip_text (menu_item, tip);
-      g_free (tip);
-    }
-
-    gtk_widget_show (menu_item);
-
-    g_object_set_data (G_OBJECT (menu_item), "wrapbox", wrapbox);
+    location = sheet_mod->sheet.scope == SHEET_SCOPE_SYSTEM ? _("System")
+                                                            : _("User");
 
-    g_signal_connect (G_OBJECT (menu_item), "activate",
-                      G_CALLBACK (on_sheets_dialog_optionmenu_activate),
-                      (gpointer) sheet_mod);
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store,
+                        &iter,
+                        SO_COL_NAME, gettext (sheet_mod->sheet.name),
+                        SO_COL_LOCATION, location,
+                        SO_COL_MOD, sheet_mod,
+                        -1);
   }
-
-  menu_item_list = gtk_container_get_children (GTK_CONTAINER (optionmenu_menu));
-
-  /* If we were passed a sheet_name, then make the optionmenu point to that
-     name after creation */
-
-  if (sheet_name) {
-    gint index = 0;
-    GList *list;
-
-    list = g_list_find_custom (menu_item_list,
-                               sheet_name,
-                               menu_item_compare_labels);
-    if (list) {
-      index = g_list_position (menu_item_list, list);
-    }
-    gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), index);
-    gtk_menu_item_activate (GTK_MENU_ITEM (g_list_nth_data (menu_item_list,
-                                                            index)));
-  } else {
-    gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), 0);
-    gtk_menu_item_activate (GTK_MENU_ITEM (menu_item_list->data));
-  }
-
-  g_list_free (menu_item_list);
 }
 
+
 gboolean
 sheets_dialog_create (void)
 {
@@ -227,6 +223,34 @@ sheets_dialog_create (void)
   }
   sheets_mods_list = NULL;
 
+  if (custom_type_symbol == NULL) {
+    /* This little bit identifies a custom object symbol so we can tell the
+       difference later between a SVG shape and a Programmed shape */
+
+    custom_type_symbol = NULL;
+    for (plugin_list = dia_list_plugins (); plugin_list != NULL;
+         plugin_list = g_list_next (plugin_list)) {
+      PluginInfo *info = plugin_list->data;
+
+      custom_type_symbol = (gpointer) dia_plugin_get_symbol (info,
+                                                              "custom_type");
+      if (custom_type_symbol) {
+        break;
+      }
+    }
+  }
+
+  if (!custom_type_symbol) {
+    message_warning (_("Can't get symbol 'custom_type' from any module.\n"
+                       "Editing shapes is disabled."));
+    return FALSE;
+  }
+
+  for (sheets_list = get_sheets_list (); sheets_list;
+       sheets_list = g_slist_next (sheets_list)) {
+    sheets_append_sheet_mods (sheets_list->data);
+  }
+
   if (sheets_dialog == NULL) {
     sheets_dialog = create_sheets_main_dialog ();
     if (!sheets_dialog) {
@@ -242,11 +266,11 @@ sheets_dialog_create (void)
     sheet_left = NULL;
     sheet_right = NULL;
   } else {
-    option_menu = lookup_widget (sheets_dialog, "optionmenu_left");
+    option_menu = lookup_widget (sheets_dialog, "combo_left");
     sheet_left = g_object_get_data (G_OBJECT (option_menu),
                                     "active_sheet_name");
 
-    option_menu = lookup_widget (sheets_dialog, "optionmenu_right");
+    option_menu = lookup_widget (sheets_dialog, "combo_right");
     sheet_right = g_object_get_data (G_OBJECT (option_menu),
                                      "active_sheet_name");
 
@@ -261,34 +285,6 @@ sheets_dialog_create (void)
     }
   }
 
-  if (custom_type_symbol == NULL) {
-    /* This little bit identifies a custom object symbol so we can tell the
-       difference later between a SVG shape and a Programmed shape */
-
-    custom_type_symbol = NULL;
-    for (plugin_list = dia_list_plugins (); plugin_list != NULL;
-         plugin_list = g_list_next (plugin_list)) {
-      PluginInfo *info = plugin_list->data;
-
-      custom_type_symbol = (gpointer) dia_plugin_get_symbol (info,
-                                                              "custom_type");
-      if (custom_type_symbol) {
-        break;
-      }
-    }
-  }
-
-  if (!custom_type_symbol) {
-    message_warning (_("Can't get symbol 'custom_type' from any module.\n"
-                       "Editing shapes is disabled."));
-    return FALSE;
-  }
-
-  for (sheets_list = get_sheets_list (); sheets_list;
-       sheets_list = g_slist_next (sheets_list)) {
-    sheets_append_sheet_mods (sheets_list->data);
-  }
-
   sw = lookup_widget (sheets_dialog, "scrolledwindow_right");
   /* In case glade already add a child to scrolledwindow */
   wrapbox = gtk_bin_get_child (GTK_BIN (sw));
@@ -303,8 +299,9 @@ sheets_dialog_create (void)
   gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (wrapbox), GTK_JUSTIFY_LEFT);
   gtk_widget_show (wrapbox);
   g_object_set_data (G_OBJECT (wrapbox), "is_left", FALSE);
-  option_menu = lookup_widget (sheets_dialog, "optionmenu_right");
-  sheets_optionmenu_create (option_menu, wrapbox, sheet_right);
+  option_menu = lookup_widget (sheets_dialog, "combo_right");
+  g_object_set_data (G_OBJECT (option_menu), "wrapbox", wrapbox);
+  select_sheet (option_menu, sheet_right);
 
   sw = lookup_widget (sheets_dialog, "scrolledwindow_left");
   /* In case glade already add a child to scrolledwindow */
@@ -320,8 +317,9 @@ sheets_dialog_create (void)
   gtk_wrap_box_set_line_justify (GTK_WRAP_BOX (wrapbox), GTK_JUSTIFY_LEFT);
   gtk_widget_show (wrapbox);
   g_object_set_data (G_OBJECT (wrapbox), "is_left", (gpointer) TRUE);
-  option_menu = lookup_widget (sheets_dialog, "optionmenu_left");
-  sheets_optionmenu_create (option_menu, wrapbox, sheet_left);
+  option_menu = lookup_widget (sheets_dialog, "combo_left");
+  g_object_set_data (G_OBJECT (option_menu), "wrapbox", wrapbox);
+  select_sheet (option_menu, sheet_left);
 
   return TRUE;
 }
@@ -341,12 +339,21 @@ create_object_pixmap (SheetObject  *so,
   style = gtk_widget_get_style (parent);
 
   if (so->pixmap != NULL) {
-    *pixmap =
-      gdk_pixmap_colormap_create_from_xpm_d (NULL,
-                                             gtk_widget_get_colormap (parent),
-                                             mask,
-                                             &style->bg[GTK_STATE_NORMAL],
-                                             (gchar **) so->pixmap);
+    if (g_str_has_prefix ((char *) so->pixmap, "res:")) {
+      GdkPixbuf *pixbuf;
+
+      pixbuf = pixbuf_from_resource (((char *) so->pixmap) + 4);
+
+      gdk_pixbuf_render_pixmap_and_mask (pixbuf, pixmap, mask, 1.0);
+      g_object_unref (pixbuf);
+    } else {
+      *pixmap =
+        gdk_pixmap_colormap_create_from_xpm_d (NULL,
+                                                gtk_widget_get_colormap (parent),
+                                                mask,
+                                                &style->bg[GTK_STATE_NORMAL],
+                                                (gchar **) so->pixmap);
+    }
   } else {
     if (so->pixmap_file != NULL) {
       GdkPixbuf *pixbuf;
@@ -425,7 +432,6 @@ lookup_widget (GtkWidget   *widget,
 void
 sheets_dialog_show_callback (GtkAction *action)
 {
-  GtkWidget *wrapbox;
   GtkWidget *option_menu;
 
   if (!sheets_dialog) {
@@ -435,9 +441,8 @@ sheets_dialog_show_callback (GtkAction *action)
     return;
   }
 
-  wrapbox = g_object_get_data (G_OBJECT (sheets_dialog), "wrapbox_left");
-  option_menu = lookup_widget (sheets_dialog, "optionmenu_left");
-  sheets_optionmenu_create (option_menu, wrapbox, interface_current_sheet_name);
+  option_menu = lookup_widget (sheets_dialog, "combo_left");
+  select_sheet (option_menu, interface_current_sheet_name);
 
   g_assert (GTK_IS_WIDGET (sheets_dialog));
   gtk_widget_show (sheets_dialog);
@@ -451,6 +456,7 @@ sheet_object_mod_get_type_string (SheetObjectMod *som)
       return _("SVG Shape");
     case OBJECT_TYPE_PROGRAMMED:
       return _("Programmed DiaObject");
+    case OBJECT_TYPE_UNASSIGNED:
     default:
       g_assert_not_reached();
       return "";
diff --git a/app/sheet-editor/sheets.h b/app/sheet-editor/sheets.h
index f00d534e..af7f99bd 100644
--- a/app/sheet-editor/sheets.h
+++ b/app/sheet-editor/sheets.h
@@ -20,7 +20,7 @@
  *
  */
 
-#ifndef SHEETS_H
+#pragma once
 
 #include <gtk/gtk.h>
 
@@ -28,6 +28,14 @@
 
 #include "sheets_dialog_callbacks.h"
 
+
+enum {
+  SO_COL_NAME,
+  SO_COL_LOCATION,
+  SO_COL_MOD,
+  SO_N_COL,
+};
+
 /* The theory behind these structures is simple.  Sheets and SheetObjects
    are wrapped in SheetMod's and SheetObjectMod's respectively.  Any changes
    made by the user to the Sheet or SheetObject is reflected in the *Mod
@@ -72,9 +80,6 @@ extern GtkWidget *sheets_dialog_optionmenu_menu;
 SheetObjectMod *sheets_append_sheet_object_mod   (SheetObject     *so,
                                                   SheetMod        *sm);
 SheetMod       *sheets_append_sheet_mods         (Sheet           *sheet);
-void            sheets_optionmenu_create         (GtkWidget       *option_menu,
-                                                  GtkWidget       *wrapbox,
-                                                  char            *sheet_name);
 void            create_object_pixmap             (SheetObject     *so,
                                                   GtkWidget       *parent,
                                                   GdkPixmap      **pixmap,
@@ -83,5 +88,6 @@ gchar          *sheet_object_mod_get_type_string (SheetObjectMod  *som);
 gboolean        sheets_dialog_create             (void);
 GtkWidget      *lookup_widget                    (GtkWidget       *widget,
                                                   const gchar     *widget_name);
-
-#endif /* SHEETS_H */
+void            populate_store                   (GtkListStore    *store);
+void            select_sheet                     (GtkWidget       *combo,
+                                                  gchar           *sheet_name);
diff --git a/app/sheet-editor/sheets_dialog.c b/app/sheet-editor/sheets_dialog.c
index cfbf4c4f..cb88be9c 100644
--- a/app/sheet-editor/sheets_dialog.c
+++ b/app/sheet-editor/sheets_dialog.c
@@ -29,7 +29,6 @@
 #endif
 #include <string.h>
 
-#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu, ... */
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
@@ -55,9 +54,8 @@ GtkWidget*
 create_sheets_main_dialog (void)
 {
   GtkWidget *sheets_main_dialog;
-  GtkWidget *optionmenu_left, *optionmenu_right;
-  GtkWidget *optionmenu_left_menu, *optionmenu_right_menu;
-  GtkWidget *glade_menuitem;
+  GtkWidget *combo_left, *combo_right;
+  GtkListStore *store;
   GtkBuilder *builder;
 
   builder = builder_new_from_file ("ui/sheets-main-dialog.xml");
@@ -67,16 +65,26 @@ create_sheets_main_dialog (void)
   g_signal_connect (G_OBJECT (sheets_main_dialog), "destroy",
                     G_CALLBACK (sheets_dialog_destroyed), NULL);
 
-  optionmenu_right = GTK_WIDGET (gtk_builder_get_object (builder, "optionmenu_right"));
-  optionmenu_right_menu = gtk_menu_new ();
-  gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu_right), optionmenu_right_menu);
+  store = gtk_list_store_new (SO_N_COL,
+                              G_TYPE_STRING,
+                              G_TYPE_STRING,
+                              G_TYPE_POINTER);
 
-  optionmenu_left = GTK_WIDGET (gtk_builder_get_object (builder, "optionmenu_left"));
-  optionmenu_left_menu = gtk_menu_new ();
-  glade_menuitem = gtk_menu_item_new_with_label ("");
-  gtk_widget_show (glade_menuitem);
-  gtk_menu_append (GTK_MENU (optionmenu_left_menu), glade_menuitem);
-  gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu_left), optionmenu_left_menu);
+  populate_store (store);
+
+  combo_left = GTK_WIDGET (gtk_builder_get_object (builder, "combo_left"));
+  gtk_combo_box_set_model (GTK_COMBO_BOX (combo_left), GTK_TREE_MODEL (store));
+  g_signal_connect (combo_left,
+                    "changed",
+                    G_CALLBACK (on_sheets_dialog_combo_changed),
+                    NULL);
+
+  combo_right = GTK_WIDGET (gtk_builder_get_object (builder, "combo_right"));
+  gtk_combo_box_set_model (GTK_COMBO_BOX (combo_right), GTK_TREE_MODEL (store));
+  g_signal_connect (combo_right,
+                    "changed",
+                    G_CALLBACK (on_sheets_dialog_combo_changed),
+                    NULL);
 
   g_signal_connect (gtk_builder_get_object (builder, "sheets_main_dialog"), "delete_event",
                     G_CALLBACK (on_sheets_main_dialog_delete_event),
diff --git a/app/sheet-editor/sheets_dialog_callbacks.c b/app/sheet-editor/sheets_dialog_callbacks.c
index 849eff6b..aaa2daf0 100644
--- a/app/sheet-editor/sheets_dialog_callbacks.c
+++ b/app/sheet-editor/sheets_dialog_callbacks.c
@@ -45,7 +45,6 @@
 #include <glib/gstdio.h>
 #include <gmodule.h>
 
-#undef GTK_DISABLE_DEPRECATED /* GtkOptionMenu */
 #include <gtk/gtk.h>
 
 #include <libxml/tree.h>
@@ -148,11 +147,11 @@ on_sheets_dialog_object_button_toggled (GtkToggleButton *togglebutton,
   table_sheets = lookup_widget (sheets_dialog, "table_sheets");
   g_object_set_data (G_OBJECT (table_sheets), "active_wrapbox", ud_wrapbox);
 
-  optionmenu_left = lookup_widget (sheets_dialog, "optionmenu_left");
+  optionmenu_left = lookup_widget (sheets_dialog, "combo_left");
   sheet_left = g_object_get_data (G_OBJECT (optionmenu_left),
                                   "active_sheet_name");
 
-  optionmenu_right = lookup_widget (sheets_dialog, "optionmenu_right");
+  optionmenu_right = lookup_widget (sheets_dialog, "combo_right");
   sheet_right = g_object_get_data (G_OBJECT (optionmenu_right),
                                    "active_sheet_name");
 
@@ -298,6 +297,7 @@ sheets_dialog_object_set_tooltip (SheetObjectMod *som, GtkWidget *button)
     case OBJECT_TYPE_PROGRAMMED:
       tip = g_strdup_printf (_("%s\nObject"), som->sheet_object.description);
       break;
+    case OBJECT_TYPE_UNASSIGNED:
     default:
       tip = g_strdup_printf (_("%s\nUnassigned type"), som->sheet_object.description);
       break;
@@ -341,19 +341,27 @@ sheets_dialog_create_object_button (SheetObjectMod *som,
 gboolean optionmenu_activate_first_pass = TRUE;
 
 void
-on_sheets_dialog_optionmenu_activate   (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
+on_sheets_dialog_combo_changed (GtkComboBox *widget,
+                                gpointer     udata)
 {
   GtkWidget *wrapbox;
+  SheetMod *mod;
   Sheet *sheet;
   GtkWidget *optionmenu;
   GSList *object_mod_list;
   GtkWidget *hidden_button;
   GList *button_list;
+  GtkTreeIter iter;
+
+  gtk_combo_box_get_active_iter (widget, &iter);
+  gtk_tree_model_get (gtk_combo_box_get_model (widget),
+                      &iter,
+                      SO_COL_MOD, &mod,
+                      -1);
 
-  sheet = &(((SheetMod *) (user_data))->sheet);
+  sheet = &mod->sheet;
 
-  wrapbox = g_object_get_data (G_OBJECT (menuitem), "wrapbox");
+  wrapbox = g_object_get_data (G_OBJECT (widget), "wrapbox");
   g_assert (wrapbox);
 
   /* The hidden button is necessary to keep track of radio_group
@@ -373,12 +381,12 @@ on_sheets_dialog_optionmenu_activate   (GtkMenuItem     *menuitem,
   g_object_set_data (G_OBJECT (hidden_button), "is_hidden_button",
                      (gpointer) TRUE);
   g_object_set_data (G_OBJECT (wrapbox), "hidden_button", hidden_button);
-  g_object_set_data (G_OBJECT (hidden_button), "sheet_mod", user_data);
+  g_object_set_data (G_OBJECT (hidden_button), "sheet_mod", mod);
 
   if (g_object_get_data (G_OBJECT (wrapbox), "is_left")) {
-    optionmenu = lookup_widget (sheets_dialog, "optionmenu_left");
+    optionmenu = lookup_widget (sheets_dialog, "combo_left");
   } else {
-    optionmenu = lookup_widget (sheets_dialog, "optionmenu_right");
+    optionmenu = lookup_widget (sheets_dialog, "combo_right");
   }
   g_object_set_data (G_OBJECT (optionmenu), "active_sheet_name", sheet->name);
 
@@ -390,7 +398,7 @@ on_sheets_dialog_optionmenu_activate   (GtkMenuItem     *menuitem,
   gtk_wrap_box_set_aspect_ratio (GTK_WRAP_BOX (wrapbox), 4 * 1.0 / 9);
                                                 /* MCNFIXME: calculate this */
 
-  g_object_set_data (G_OBJECT (wrapbox), "sheet_mod", user_data);
+  g_object_set_data (G_OBJECT (wrapbox), "sheet_mod", mod);
 
   for (object_mod_list = sheet->objects; object_mod_list;
        object_mod_list = g_slist_next (object_mod_list)) {
@@ -406,7 +414,7 @@ on_sheets_dialog_optionmenu_activate   (GtkMenuItem     *menuitem,
       sheets_dialog_wrapbox_add_line_break (wrapbox);
     }
 
-    button = sheets_dialog_create_object_button (som, user_data, wrapbox);
+    button = sheets_dialog_create_object_button (som, mod, wrapbox);
 
     gtk_wrap_box_pack_wrapped (GTK_WRAP_BOX (wrapbox), button,
                                FALSE, TRUE, FALSE, TRUE, som->sheet_object.line_break);
@@ -725,8 +733,6 @@ on_sheets_new_dialog_button_ok_clicked (GtkButton       *button,
     typedef gboolean (*CustomObjectLoadFunc) (gchar*, DiaObjectType **);
     CustomObjectLoadFunc custom_object_load_fn;
     gint pos;
-    GtkWidget *active_button;
-    GList *button_list;
     SheetObjectMod *som;
     SheetMod *sm;
     SheetObject *sheet_obj;
@@ -871,7 +877,7 @@ on_sheets_new_dialog_button_ok_clicked (GtkButton       *button,
         optionmenu = g_object_get_data (G_OBJECT (table_sheets),
                                         "active_optionmenu");
         g_assert (optionmenu);
-        sheets_optionmenu_create (optionmenu, wrapbox, sheet_name);
+        select_sheet (optionmenu, sheet_name);
       }
       break;
 
@@ -1046,8 +1052,6 @@ on_sheets_dialog_button_remove_clicked (GtkButton       *button,
             be rare, to say the least... */
 
   if (sm->sheet.shadowing == NULL && sm->sheet.scope == SHEET_SCOPE_SYSTEM) {
-    GtkWidget *radio_button;
-
     radio_button = lookup_widget (sheets_remove_dialog, "radiobutton_sheet");
     gtk_widget_set_sensitive (radio_button, FALSE);
     gtk_widget_set_sensitive (entry, FALSE);
@@ -1226,7 +1230,7 @@ on_sheets_remove_dialog_button_ok_clicked (GtkButton *button,
       optionmenu = g_object_get_data (G_OBJECT (table_sheets),
                                       "active_optionmenu");
       g_assert (optionmenu);
-      sheets_optionmenu_create (optionmenu, wrapbox, NULL);
+      select_sheet (optionmenu, NULL);
       break;
 
     default:
diff --git a/app/sheet-editor/sheets_dialog_callbacks.h b/app/sheet-editor/sheets_dialog_callbacks.h
index 6b0ee244..600c4ed5 100644
--- a/app/sheet-editor/sheets_dialog_callbacks.h
+++ b/app/sheet-editor/sheets_dialog_callbacks.h
@@ -25,7 +25,7 @@
 gboolean    on_sheets_main_dialog_delete_event                     (GtkWidget       *widget,
                                                                     GdkEvent        *event,
                                                                     gpointer         user_data);
-void        on_sheets_dialog_optionmenu_activate                   (GtkMenuItem     *menuitem,
+void        on_sheets_dialog_combo_changed                         (GtkComboBox     *widget,
                                                                     gpointer         user_data);
 void        on_sheets_dialog_button_move_up_clicked                (GtkButton       *button,
                                                                     gpointer         user_data);
diff --git a/app/toolbox.c b/app/toolbox.c
index a07d96e4..17e170d7 100644
--- a/app/toolbox.c
+++ b/app/toolbox.c
@@ -445,7 +445,7 @@ get_current_sheet (void)
   char *sheet = NULL;
   GtkTreeIter iter;
 
-  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (sheet_menu.store), &iter)) {
+  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (sheet_menu.combo), &iter)) {
     gtk_tree_model_get (GTK_TREE_MODEL (sheet_menu.store),
                         &iter,
                         COL_SHEET, &sheet,
@@ -600,7 +600,7 @@ create_sheet_dropdown_menu(GtkWidget *parent)
   // Sigh
   if (sheet_menu.combo) {
     gtk_container_remove (GTK_CONTAINER (parent), sheet_menu.combo);
-    g_clear_object (&sheet_menu.combo);
+    sheet_menu.combo = NULL;
   }
 
   gtk_tree_store_clear (sheet_menu.store);
diff --git a/data/ui/sheets-main-dialog.xml b/data/ui/sheets-main-dialog.xml
index 8fd7bb18..f5c11fca 100644
--- a/data/ui/sheets-main-dialog.xml
+++ b/data/ui/sheets-main-dialog.xml
@@ -172,10 +172,24 @@
               </packing>
             </child>
             <child>
-              <object class="GtkOptionMenu" id="optionmenu_right">
+              <object class="GtkComboBox" id="combo_right">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkCellRendererText" id="cr_t1"/>
+                  <attributes>
+                    <attribute name="text">0</attribute>
+                  </attributes>
+                </child>
+                <child>
+                  <object class="GtkCellRendererText" id="cr_t2">
+                    <property name="xalign">1</property>
+                    <property name="scale">0.8</property>
+                  </object>
+                  <attributes>
+                    <attribute name="text">1</attribute>
+                  </attributes>
+                </child>
               </object>
               <packing>
                 <property name="left_attach">2</property>
@@ -201,10 +215,24 @@
               </packing>
             </child>
             <child>
-              <object class="GtkOptionMenu" id="optionmenu_left">
+              <object class="GtkComboBox" id="combo_left">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkCellRendererText" id="cl_t1"/>
+                  <attributes>
+                    <attribute name="text">0</attribute>
+                  </attributes>
+                </child>
+                <child>
+                  <object class="GtkCellRendererText" id="cl_t2">
+                    <property name="xalign">1</property>
+                    <property name="scale">0.8</property>
+                  </object>
+                  <attributes>
+                    <attribute name="text">1</attribute>
+                  </attributes>
+                </child>
               </object>
               <packing>
                 <property name="x_options">GTK_FILL</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]