[pan2: 7/23] Update compatibility with Gtk 2.24.



commit 75d2cd65cdbf0c0bf934c03863d1c002b223e40e
Author: K. Haley <haleykd users sf net>
Date:   Tue May 10 13:07:38 2011 -0600

    Update compatibility with Gtk 2.24.

 pan/gui/group-prefs-dialog.cc |   17 ++++++++-------
 pan/gui/gtk_compat.h          |   44 +++++++++++++++++++++++++++++++++++++++++
 pan/gui/gui.cc                |    3 +-
 pan/gui/post-ui.cc            |   17 ++++++++-------
 pan/gui/prefs-ui.cc           |    9 ++++---
 5 files changed, 69 insertions(+), 21 deletions(-)
---
diff --git a/pan/gui/group-prefs-dialog.cc b/pan/gui/group-prefs-dialog.cc
index 70fd3f5..589787b 100644
--- a/pan/gui/group-prefs-dialog.cc
+++ b/pan/gui/group-prefs-dialog.cc
@@ -30,6 +30,7 @@ extern "C" {
 #include "hig.h"
 #include "pad.h"
 #include "pan-file-entry.h"
+#include "gtk_compat.h"
 
 using namespace pan;
 
@@ -47,7 +48,7 @@ namespace
   }
 #endif
 }
-
+  
 void
 GroupPrefsDialog :: save_from_gui ()
 {
@@ -58,7 +59,7 @@ GroupPrefsDialog :: save_from_gui ()
   // posting profile...
   std::string profile;
   if (gtk_widget_get_sensitive (_profile)) {
-    char * pch (gtk_combo_box_get_active_text (GTK_COMBO_BOX(_profile)));
+    char * pch (gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(_profile)));
     _group_prefs.set_string (_group, "posting-profile", pch);
     g_free (pch);
   }
@@ -84,16 +85,16 @@ namespace
                              const Quark      & group,
                              const GroupPrefs & group_prefs)
   {
-    GtkWidget * w = gtk_combo_box_new_text ();
-    GtkComboBox * combo (GTK_COMBO_BOX (w));
+    GtkWidget * w = gtk_combo_box_text_new ();
+    GtkComboBoxText * combo (GTK_COMBO_BOX_TEXT (w));
 
     typedef std::set<std::string> unique_strings_t;
     const unique_strings_t profiles (data.get_profile_names ());
 
     if (profiles.empty())
     {
-      gtk_combo_box_append_text (combo, _("No Profiles defined in Edit|Posting Profiles."));
-      gtk_combo_box_set_active (combo, 0);
+      gtk_combo_box_text_append_text (combo, _("No Profiles defined in Edit|Posting Profiles."));
+      gtk_combo_box_set_active (GTK_COMBO_BOX(combo), 0);
       gtk_widget_set_sensitive (w, false);
     }
     else
@@ -104,9 +105,9 @@ namespace
         if (*it == s)
           sel_index = i;
         ++i;
-        gtk_combo_box_append_text (combo, it->c_str());
+        gtk_combo_box_text_append_text (combo, it->c_str());
       }
-      gtk_combo_box_set_active (combo, sel_index);
+      gtk_combo_box_set_active (GTK_COMBO_BOX(combo), sel_index);
     }
 
     return w;
diff --git a/pan/gui/gtk_compat.h b/pan/gui/gtk_compat.h
new file mode 100644
index 0000000..ed024b2
--- /dev/null
+++ b/pan/gui/gtk_compat.h
@@ -0,0 +1,44 @@
+//========================================================================
+/** file	pan/pan/gui/gtk_compat.h
+ * @author	kid
+ * @date
+ * 	Created:	Mon 09 May 2011 04:42:46 PM MDT \n
+ * 	Last Update:	Mon 09 May 2011 04:42:46 PM MDT
+ */
+/*------------------------------------------------------------------------
+ * Description:	«description»
+ * 
+ *========================================================================
+ */
+
+#ifndef PAN_GTK_COMPAT_H
+#define PAN_GTK_COMPAT_H
+
+namespace {
+#if !GTK_CHECK_VERSION(2,24,0)
+#define GTK_COMBO_BOX_TEXT(cb) GTK_COMBO_BOX(cb)
+  typedef GtkComboBox GtkComboBoxText;
+  GtkWidget* gtk_combo_box_text_new()
+  {
+    return gtk_combo_box_new_text();
+  }
+  GtkWidget* gtk_combo_box_text_new_with_entry()
+  {
+    return gtk_combo_box_entry_new_text();
+  }
+  void gtk_combo_box_text_append_text(GtkComboBoxText *cb, const gchar *t)
+  {
+    gtk_combo_box_append_text(cb,t);
+  }
+  gchar *gtk_combo_box_text_get_active_text(GtkComboBoxText *cb)
+  {
+    return gtk_combo_box_get_active_text(cb);
+  }
+  void gtk_combo_box_text_remove(GtkComboBoxText *cb, int p)
+  {
+    gtk_combo_box_remove_text(cb, p);
+  }
+#endif
+}
+  
+#endif
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 7743777..0c0a33d 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1407,7 +1407,8 @@ void GUI :: do_tabbed_layout (bool tabbed)
     vpane = 0;
   }
 
-  gtk_widget_hide_all (_workarea_bin);
+  //gtk_widget_hide_all (_workarea_bin);
+  gtk_widget_hide (_workarea_bin);
 
   GtkWidget * group_w (_group_pane->root());
   GtkWidget * header_w (_header_pane->root());
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 493458d..1312ced 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -47,6 +47,7 @@ extern "C" {
 #include "post.ui.h"
 #include "profiles-dialog.h"
 #include "url.h"
+#include "gtk_compat.h"
 
 #ifdef HAVE_GTKSPELL
 #define DEFAULT_SPELLCHECK_FLAG true
@@ -1158,8 +1159,8 @@ void
 PostUI :: update_profile_combobox ()
 {
   // get the old selection
-  GtkComboBox * combo (GTK_COMBO_BOX (_from_combo));
-  char * active_text = gtk_combo_box_get_active_text (combo);
+  GtkComboBoxText * combo (GTK_COMBO_BOX_TEXT (_from_combo));
+  char * active_text = gtk_combo_box_text_get_active_text (combo);
 
   // if there's not already a selection,
   // pull the default for the newsgroup
@@ -1178,9 +1179,9 @@ PostUI :: update_profile_combobox ()
   }
 
   // tear out the old entries
-  GtkTreeModel * model (gtk_combo_box_get_model (combo));
+  GtkTreeModel * model (gtk_combo_box_get_model (GTK_COMBO_BOX(combo)));
   for (int i(0), qty(gtk_tree_model_iter_n_children(model,0)); i<qty; ++i)
-    gtk_combo_box_remove_text (combo, 0);
+    gtk_combo_box_text_remove (combo, 0);
 
   // add the new entries
   typedef std::set<std::string> names_t;
@@ -1188,14 +1189,14 @@ PostUI :: update_profile_combobox ()
   int index (0);
   int sel_index (0);
   foreach_const (names_t, profile_names, it) {
-    gtk_combo_box_append_text (combo, it->c_str());
+    gtk_combo_box_text_append_text (combo, it->c_str());
     if (active_text && (*it == active_text))
       sel_index = index;
     ++index;
   }
  
   // ensure _something_ is selected...
-  gtk_combo_box_set_active (combo, sel_index);
+  gtk_combo_box_set_active (GTK_COMBO_BOX(combo), sel_index);
 
   // cleanup
   g_free (active_text);
@@ -1335,7 +1336,7 @@ Profile
 PostUI :: get_current_profile ()
 {
   Profile profile;
-  char * pch = gtk_combo_box_get_active_text (GTK_COMBO_BOX(_from_combo));
+  char * pch = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT(_from_combo));
   if (pch) {
     _profiles.get_profile (pch, profile);
     g_free (pch);
@@ -1734,7 +1735,7 @@ PostUI :: create_main_tab ()
   gtk_misc_set_alignment (GTK_MISC(l), 0.0f, 0.5f);
   gtk_table_attach (GTK_TABLE(t), l, 0, 1, row, row+1, GTK_FILL, GTK_FILL, 0, 0);
 
-  w = _from_combo = gtk_combo_box_new_text ();
+  w = _from_combo = gtk_combo_box_text_new ();
   gtk_cell_layout_clear (GTK_CELL_LAYOUT(w));
   GtkCellRenderer * r =  gtk_cell_renderer_text_new();
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(w), r, true);
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index 7dac161..aa8a9ba 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -31,6 +31,7 @@ extern "C" {
 #include "prefs-ui.h"
 #include "tango-colors.h"
 #include "url.h"
+#include "gtk_compat.h"
 
 using namespace pan;
 
@@ -147,10 +148,10 @@ namespace
     }
   }
 
-  void set_prefs_string_from_combo_box_entry (GtkComboBox * c, gpointer user_data)
+  void set_prefs_string_from_combo_box_entry (GtkComboBoxText * c, gpointer user_data)
   {
     const char * key = (const char*) g_object_get_data (G_OBJECT(c), PREFS_KEY);
-    char * val = gtk_combo_box_get_active_text (c);
+    char * val = gtk_combo_box_text_get_active_text (c);
     static_cast<Prefs*>(user_data)->set_string (key, val);
     g_free (val);
   }
@@ -162,10 +163,10 @@ namespace
     const char * key = "editor";
     const std::string editor = prefs.get_string (key, *editors.begin());
     editors.insert (editor);
-    GtkWidget * c = gtk_combo_box_entry_new_text ();
+    GtkWidget * c = gtk_combo_box_text_new_with_entry ();
     g_object_set_data_full (G_OBJECT(c), PREFS_KEY, g_strdup(key), g_free);
     foreach_const (std::set<std::string>, editors, it)
-      gtk_combo_box_append_text (GTK_COMBO_BOX(c), it->c_str());
+      gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT(c), it->c_str());
     gtk_combo_box_set_active (GTK_COMBO_BOX(c),
                               (int)std::distance (editors.begin(), editors.find(editor)));
     g_signal_connect (c, "changed", G_CALLBACK(set_prefs_string_from_combo_box_entry), &prefs);



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