delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2012/02/07/11:22:10

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
Message-ID: <4F314AFF.50201@x-eike.de>
Date: Tue, 07 Feb 2012 17:02:07 +0100
From: Eike Krumbacher <eike DOT krumbacher AT x-eike DOT de>
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0
MIME-Version: 1.0
To: geda-user AT delorie DOT com
Subject: [geda-user] Patch: change GtkoptionMenu to GtkComboBoxText (part one)
X-bounce-key: webpack.hosteurope.de;eike DOT krumbacher AT x-eike DOT de;1328631644;5dd5e8d4;
Reply-To: geda-user AT delorie DOT com

This is a multi-part message in MIME format.
--------------020503030403060707060709
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi folks!

GtkOptionMenu is deprecated in GTK+. gschem/src/x_attribedit.c is one of 
those places where we find GtkOptionMenu. I replaced this just in this 
file with GtkComboBoxText.

The patch is against git/HEAD and made with
$ git diff > filename.


There are some more places, where I could change the same issue. This 
issue came to my mind, as I tried to compile gschem with gtk+-3.x 
libraries and headers, so I try to port it step by step.

Please tell me, if something is wrong, I try to correct it then.


Best regards

Eike


--------------020503030403060707060709
Content-Type: text/x-diff;
 name="replaced-gtk_option_menu-by-gtk_combo_box_text-1.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="replaced-gtk_option_menu-by-gtk_combo_box_text-1.diff"

diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index 42be9e0..fa966d2 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -703,7 +703,6 @@ GList *s_stretch_remove(GList *list, OBJECT *object);
 void s_stretch_print_all(GList *list);
 void s_stretch_destroy_all(GList *list);
 /* x_attribedit.c */
-gint option_menu_get_history(GtkOptionMenu *option_menu);
 void attrib_edit_dialog_ok(GtkWidget *w, GSCHEM_TOPLEVEL *w_current);
 void attrib_edit_dialog(GSCHEM_TOPLEVEL *w_current, OBJECT *attr_obj, int flag);
 /* x_autonumber.c */
diff --git a/gschem/src/x_attribedit.c b/gschem/src/x_attribedit.c
index 70f7514..10870ea 100644
--- a/gschem/src/x_attribedit.c
+++ b/gschem/src/x_attribedit.c
@@ -38,25 +38,6 @@
 /***************** Start of Attrib Edit dialog box ********************/
 /*! \section attrib-edit-dialog-box Atrib Edit Dialog Box */
 
-/*! \todo Finish function documentation!!!
- *  \brief
- *  \par Function Documentation
- *
- */
-gint option_menu_get_history (GtkOptionMenu *option_menu) 
-{ 
-  GtkWidget *active_widget; 
-         
-  g_return_val_if_fail (GTK_IS_OPTION_MENU (option_menu), -1); 
-         
-  active_widget = gtk_menu_get_active (GTK_MENU (option_menu->menu)); 
-
-  if (active_widget) 
-    return g_list_index (GTK_MENU_SHELL (option_menu->menu)->children, 
-			 active_widget); 
-  else 
-    return -1; 
-} 
 
 /*! \todo Finish function documentation!!!
  *  \brief
@@ -80,7 +61,6 @@ void attrib_edit_dialog_ok(GtkWidget * w, GSCHEM_TOPLEVEL *w_current)
   int vis, show;
   int invocation_flag;
   int nsel=0, addto=0, replace=0, addmask=0;
-  int option_index;
   gint wx, wy;
 
   i_set_state(w_current, SELECT);
@@ -109,25 +89,8 @@ void attrib_edit_dialog_ok(GtkWidget * w, GSCHEM_TOPLEVEL *w_current)
   else
   vis = INVISIBLE;
 
-  option_index = option_menu_get_history(GTK_OPTION_MENU (show_options));
-  switch(option_index) {
-    case(0):
-      show = SHOW_VALUE;
-      break;
-
-    case(1):
-      show = SHOW_NAME;
-      break;
-
-    case(2):
-      show = SHOW_NAME_VALUE;
-      break;
-
-    default:
-      fprintf(stderr, _("Got invalid show option; defaulting to show both\n"));
-      show = SHOW_NAME_VALUE;
-      break;
-  }
+  /* we are synchronized with libgeda/include/libgeda/defines.h */
+  show = gtk_combo_box_get_active (GTK_COMBO_BOX (show_options));
 
   attribptr =
   gtk_object_get_data(GTK_OBJECT(w_current->aewindow), "attrib");
@@ -291,8 +254,6 @@ void attrib_edit_dialog (GSCHEM_TOPLEVEL *w_current, OBJECT *attr_obj, int flag)
   GtkWidget *aewindow;
   GtkWidget *vbox, *label, *table, *alignment;
   GtkWidget *show_options;
-  GtkWidget *show_options_menu;
-  GtkWidget *glade_menuitem;
   GtkWidget *attrib_combo_box_entry;
   GtkWidget *attrib_combo_entry;
   GtkWidget *value_entry;
@@ -417,7 +378,8 @@ void attrib_edit_dialog (GSCHEM_TOPLEVEL *w_current, OBJECT *attr_obj, int flag)
                     (GtkAttachOptions) (GTK_FILL),
                     (GtkAttachOptions) (0), 0, 0);
 
-  show_options = gtk_option_menu_new ();
+
+  show_options = gtk_combo_box_text_new();
   gtk_widget_ref (show_options);
   gtk_object_set_data_full (GTK_OBJECT (aewindow), "show_options",
                             show_options,
@@ -426,15 +388,12 @@ void attrib_edit_dialog (GSCHEM_TOPLEVEL *w_current, OBJECT *attr_obj, int flag)
   gtk_table_attach (GTK_TABLE (table), show_options, 1, 2, 2, 3,
                     (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
                     (GtkAttachOptions) (0), 0, 0);
-  show_options_menu = gtk_menu_new ();
-  glade_menuitem = gtk_menu_item_new_with_label (_("Show Value Only"));
-  gtk_menu_append (GTK_MENU (show_options_menu), glade_menuitem);
-  glade_menuitem = gtk_menu_item_new_with_label (_("Show Name Only"));
-  gtk_menu_append (GTK_MENU (show_options_menu), glade_menuitem);
-  glade_menuitem = gtk_menu_item_new_with_label (_("Show Name & Value"));
-  gtk_menu_append (GTK_MENU (show_options_menu), glade_menuitem);
-  gtk_option_menu_set_menu (GTK_OPTION_MENU (show_options), show_options_menu);
-  gtk_option_menu_set_history (GTK_OPTION_MENU (show_options), 0);
+
+  /* Be careful, the order reflects the numbered order of SHOW_NAME_VALUE and
+    friends in libgeda/include/libgeda/defines.h */
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (show_options), _("Show Name & Value"));
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (show_options), _("Show Value Only"));
+  gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (show_options), _("Show Name Only"));
   
   if (nsel > 1) { /* gschem specific */
     
@@ -496,13 +455,8 @@ void attrib_edit_dialog (GSCHEM_TOPLEVEL *w_current, OBJECT *attr_obj, int flag)
       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(visbutton), FALSE);
     }
 
-    if (attrib->show_name_value == SHOW_VALUE) {
-      gtk_option_menu_set_history (GTK_OPTION_MENU (show_options), 0);
-    } else if (attrib->show_name_value == SHOW_NAME) {
-      gtk_option_menu_set_history (GTK_OPTION_MENU (show_options), 1);
-    } else {
-      gtk_option_menu_set_history (GTK_OPTION_MENU (show_options), 2);
-    }
+    gtk_combo_box_set_active (GTK_COMBO_BOX (show_options), attrib->show_name_value);
+
   } else {
     OBJECT *object;
 
@@ -515,7 +469,7 @@ void attrib_edit_dialog (GSCHEM_TOPLEVEL *w_current, OBJECT *attr_obj, int flag)
 
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(visbutton), TRUE);
     /* show value only */
-    gtk_option_menu_set_history (GTK_OPTION_MENU (show_options), 0);
+    gtk_combo_box_set_active (GTK_COMBO_BOX (show_options), SHOW_VALUE);
   }
   gtk_object_set_data(GTK_OBJECT(aewindow), "attrib", attrib);
   if (name) {
diff --git a/gschem/src/x_multiattrib.c b/gschem/src/x_multiattrib.c
index c9ad9b6..792ea9c 100644
--- a/gschem/src/x_multiattrib.c
+++ b/gschem/src/x_multiattrib.c
@@ -35,6 +35,27 @@
 #endif
 
 
+/*! \todo Finish function documentation!!!
+ *  \brief
+ *  \par Function Documentation
+ *
+ */
+static gint option_menu_get_history (GtkOptionMenu *option_menu) 
+{ 
+  GtkWidget *active_widget; 
+         
+  g_return_val_if_fail (GTK_IS_OPTION_MENU (option_menu), -1); 
+         
+  active_widget = gtk_menu_get_active (GTK_MENU (option_menu->menu)); 
+
+  if (active_widget) 
+    return g_list_index (GTK_MENU_SHELL (option_menu->menu)->children, 
+			 active_widget); 
+  else 
+    return -1; 
+} 
+
+
 /*! \brief Update the multiattrib editor dialog when the page's
  *         selection changes.
  *  \par Function Description

--------------020503030403060707060709--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019