[pan2: 20/268] Refactor Gtk compatibility in seperate header file.



commit 5d2086e2cb6f772fef6f772952b6f27acfae699a
Author: K. Haley <haleykd users sf net>
Date:   Tue May 10 13:25:21 2011 -0600

    Refactor Gtk compatibility in seperate header file.

 pan/gui/body-pane.cc          |    7 ------
 pan/gui/e-charset-combo-box.c |    8 +-----
 pan/gui/group-pane.cc         |    7 ------
 pan/gui/group-prefs-dialog.cc |    7 ------
 pan/gui/gtk_compat.h          |   43 ++++++++++++++++++++++++++++++++++++++++-
 pan/gui/gui.cc                |    5 +---
 pan/gui/gui.h                 |    6 +----
 pan/gui/header-pane.cc        |   12 +----------
 8 files changed, 47 insertions(+), 48 deletions(-)
---
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 762226a..b83ae3f 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -51,13 +51,6 @@ using namespace pan;
 **/
 namespace
 {
-#if !GTK_CHECK_VERSION(2,18,0)
-  void gtk_widget_get_allocation( GtkWidget *w, GtkAllocation *a)
-  {
-    *a = w->allocation;
-  }
-#endif
-
   class PixbufCache
   {
     private:
diff --git a/pan/gui/e-charset-combo-box.c b/pan/gui/e-charset-combo-box.c
index 9dabe50..4110d39 100644
--- a/pan/gui/e-charset-combo-box.c
+++ b/pan/gui/e-charset-combo-box.c
@@ -24,6 +24,7 @@
 #include <glib/gi18n.h>
 
 #include "e-charset.h"
+#include "gtk_compat.h"
 
 #define E_CHARSET_COMBO_BOX_GET_PRIVATE(obj) \
 	(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -83,12 +84,7 @@ charset_combo_box_run_dialog (ECharsetComboBox *combo_box)
 	 *       finally resolved. */
 
 	parent = gtk_widget_get_toplevel (GTK_WIDGET (combo_box));
-#ifndef GTK_WIDGET_TOPLEVEL
-#define TOPLEVEL gtk_widget_is_toplevel
-#else
-#define TOPLEVEL GTK_WIDGET_TOPLEVEL
-#endif
-	parent = TOPLEVEL (parent) ? parent : NULL;
+	parent = gtk_widget_is_toplevel (parent) ? parent : NULL;
 
 	object = G_OBJECT (combo_box->priv->other_action);
 	charset = g_object_get_data (object, "charset");
diff --git a/pan/gui/group-pane.cc b/pan/gui/group-pane.cc
index e0a5df0..7e49f0b 100644
--- a/pan/gui/group-pane.cc
+++ b/pan/gui/group-pane.cc
@@ -571,13 +571,6 @@ namespace
     return false;
   }
 
-#if !GTK_CHECK_VERSION(2,18,0)
-  bool gtk_widget_has_focus( GtkWidget *w)
-  {
-    return GTK_WIDGET_HAS_FOCUS(w);
-  }
-#endif
-
   void refresh_search_entry (GtkWidget * w)
   {
     if (search_text.empty() && !gtk_widget_has_focus(w))
diff --git a/pan/gui/group-prefs-dialog.cc b/pan/gui/group-prefs-dialog.cc
index 589787b..be50369 100644
--- a/pan/gui/group-prefs-dialog.cc
+++ b/pan/gui/group-prefs-dialog.cc
@@ -40,13 +40,6 @@ namespace
   {
     delete static_cast<GroupPrefsDialog*>(castme);
   }
-
-#if !GTK_CHECK_VERSION(2,18,0)
-  bool gtk_widget_get_sensitive( GtkWidget *w)
-  {
-    return GTK_WIDGET_SENSITIVE(w);
-  }
-#endif
 }
   
 void
diff --git a/pan/gui/gtk_compat.h b/pan/gui/gtk_compat.h
index ed024b2..c10e1df 100644
--- a/pan/gui/gtk_compat.h
+++ b/pan/gui/gtk_compat.h
@@ -14,7 +14,46 @@
 #ifndef PAN_GTK_COMPAT_H
 #define PAN_GTK_COMPAT_H
 
-namespace {
+#ifdef __cplusplus
+namespace
+{
+#endif
+#if !GTK_CHECK_VERSION(2,18,0)
+  void gtk_widget_get_allocation( GtkWidget *w, GtkAllocation *a)
+  {
+    *a = w->allocation;
+  }
+  bool gtk_widget_has_focus( GtkWidget *w)
+  {
+    return GTK_WIDGET_HAS_FOCUS(w);
+  }
+  bool gtk_widget_get_sensitive( GtkWidget *w)
+  {
+    return GTK_WIDGET_SENSITIVE(w);
+  }
+  bool gtk_widget_get_visible(GtkWidget *w)
+  {
+    return GTK_WIDGET_VISIBLE(w);
+  }
+  bool gtk_widget_is_toplevel(GtkWidget *w)
+  {
+    return GTK_WIDGET_TOPLEVEL(w);
+  }
+#endif
+
+#if !GTK_CHECK_VERSION(2,20,0)
+  gboolean gtk_widget_get_realized(GtkWidget *w)
+  {
+    return GTK_WIDGET_REALIZED(w);
+  }
+#endif
+
+#ifdef GTK_DISABLE_DEPRECATED
+#if GTK_CHECK_VERSION(2,22,0)
+#define GtkNotebookPage void
+#endif
+#endif
+
 #if !GTK_CHECK_VERSION(2,24,0)
 #define GTK_COMBO_BOX_TEXT(cb) GTK_COMBO_BOX(cb)
   typedef GtkComboBox GtkComboBoxText;
@@ -39,6 +78,8 @@ namespace {
     gtk_combo_box_remove_text(cb, p);
   }
 #endif
+#ifdef __cplusplus
 }
+#endif
   
 #endif
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index 0c0a33d..fe11ecb 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -62,6 +62,7 @@ extern "C" {
 #include "server-ui.h"
 #include "task-pane.h"
 #include "url.h"
+#include "gtk_compat.h"
 
 namespace pan
 {
@@ -107,11 +108,7 @@ namespace
 
   void toggle_visible (GtkWidget * w)
   {
-#if GTK_CHECK_VERSION(2,18,0)
     set_visible (w, !gtk_widget_get_visible(w));
-#else
-    set_visible (w, !GTK_WIDGET_VISIBLE(w));
-#endif
   }
 }
 
diff --git a/pan/gui/gui.h b/pan/gui/gui.h
index 006ed63..bcdc6e2 100644
--- a/pan/gui/gui.h
+++ b/pan/gui/gui.h
@@ -30,11 +30,7 @@
 #include <pan/gui/group-prefs.h>
 #include <pan/gui/wait.h>
 
-#ifdef GTK_DISABLE_DEPRECATED
-#if GTK_CHECK_VERSION(2,22,0)
-#define GtkNotebookPage void
-#endif
-#endif
+#include "gtk_compat.h"
 
 namespace pan
 {
diff --git a/pan/gui/header-pane.cc b/pan/gui/header-pane.cc
index ab62206..d2525f8 100644
--- a/pan/gui/header-pane.cc
+++ b/pan/gui/header-pane.cc
@@ -37,6 +37,7 @@ extern "C" {
 #include "header-pane.h"
 #include "render-bytes.h"
 #include "tango-colors.h"
+#include "gtk_compat.h"
 
 using namespace pan;
 
@@ -545,11 +546,7 @@ HeaderPane :: set_group (const Quark& new_group)
       _atree->add_listener (this);
 
       rebuild ();
-#ifndef GTK_WIDGET_REALIZED
       if (gtk_widget_get_realized(_tree_view))
-#else
-      if (GTK_WIDGET_REALIZED(_tree_view))
-#endif
         gtk_tree_view_scroll_to_point (GTK_TREE_VIEW(_tree_view), 0, 0);
     }
   }
@@ -1204,13 +1201,6 @@ namespace
     return false;
   }
 
-#if !GTK_CHECK_VERSION(2,18,0)
-  bool gtk_widget_has_focus( GtkWidget *w)
-  {
-    return GTK_WIDGET_HAS_FOCUS(w);
-  }
-#endif
-
   void refresh_search_entry (GtkWidget * w)
   {
     if (search_text.empty() && !gtk_widget_has_focus(w))



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