]> spindle.queued.net Git - midori/commitdiff
Merge GLib and GTK+ compatibility in gtk3-compat.h
authorChristian Dywan <christian@twotoasts.de>
Thu, 20 Oct 2011 20:46:43 +0000 (22:46 +0200)
committerChristian Dywan <christian@twotoasts.de>
Thu, 20 Oct 2011 20:46:43 +0000 (22:46 +0200)
katze/gtk3-compat.h
katze/katze-preferences.c
katze/katze-scrolled.c
katze/katze-throbber.c
katze/katze-utils.c
midori/sokoke.c
midori/sokoke.h

index ac774eb9f127adff18689ab093b886fc24a3f803..c40aca270be3299455b9bb6a238a6be49aba9096 100644 (file)
@@ -4,6 +4,76 @@
 #ifndef H_GTK3_COMPAT_20110110
 #define H_GTK3_COMPAT_20110110
 
+G_BEGIN_DECLS
+
+#if !GLIB_CHECK_VERSION (2, 32, 0)
+    #define G_SOURCE_REMOVE   FALSE
+    #define G_SOURCE_CONTINUE TRUE
+#endif
+
+#if !GLIB_CHECK_VERSION (2, 30, 0)
+    #define g_format_size(sz) g_format_size_for_display ((goffset)sz)
+#endif
+
+#if !GTK_CHECK_VERSION (2, 14, 0)
+    #define gtk_dialog_get_content_area(dlg) dlg->vbox
+    #define gtk_dialog_get_action_area(dlg) dlg->action_area
+    #define gtk_widget_get_window(wdgt) wdgt->window
+    #define gtk_adjustment_get_page_size(adj) adj->page_size
+    #define gtk_adjustment_get_upper(adj) adj->upper
+    #define gtk_adjustment_get_lower(adj) adj->lower
+    #define gtk_adjustment_get_value(adj) adj->value
+#endif
+
+#if !GTK_CHECK_VERSION (2, 16, 0)
+    #define GTK_ACTIVATABLE GTK_WIDGET
+    #define gtk_activatable_get_related_action gtk_widget_get_action
+    #define gtk_menu_item_set_label(menuitem, label) \
+        gtk_label_set_label (GTK_LABEL (GTK_BIN (menuitem)->child), \
+                             label ? label : "");
+#endif
+
+#if !GTK_CHECK_VERSION (2, 18, 0)
+    #define gtk_widget_is_toplevel(widget) GTK_WIDGET_TOPLEVEL (widget)
+    #define gtk_widget_has_focus(widget) GTK_WIDGET_HAS_FOCUS (widget)
+    #define gtk_widget_get_visible(widget) GTK_WIDGET_VISIBLE (widget)
+    #define gtk_widget_get_sensitive(widget) GTK_WIDGET_IS_SENSITIVE (widget)
+    #define gtk_widget_set_can_focus(widget,flag) \
+        GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS)
+    #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
+    #define gtk_widget_get_has_window(wdgt) !GTK_WIDGET_NO_WINDOW (wdgt)
+    #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
+    #define gtk_widget_set_window(wdgt, wndw) wdgt->window = wndw
+    #define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE
+    #define gtk_widget_get_drawable GTK_WIDGET_VISIBLE
+    #define gtk_widget_set_has_window(wdgt, wnd) \
+        if (wnd) GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_NO_WINDOW); \
+        else GTK_WIDGET_SET_FLAGS (wdgt, GTK_NO_WINDOW)
+#endif
+
+#if !GTK_CHECK_VERSION (2, 20, 0)
+    #define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED (widget)
+    #define gtk_widget_set_realized(wdgt, real) \
+        if (real) GTK_WIDGET_SET_FLAGS (wdgt, GTK_REALIZED); \
+        else GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_REALIZED)
+#endif
+
+#if !GTK_CHECK_VERSION(2, 12, 0)
+
+void
+gtk_widget_set_has_tooltip             (GtkWidget*         widget,
+                                        gboolean           has_tooltip);
+
+void
+gtk_widget_set_tooltip_text            (GtkWidget*         widget,
+                                        const gchar*       text);
+
+void
+gtk_tool_item_set_tooltip_text         (GtkToolItem*       toolitem,
+                                        const gchar*       text);
+
+#endif
+
 #if !GTK_CHECK_VERSION (2, 24 ,0)
     #define gtk_combo_box_text_append_text gtk_combo_box_append_text
     #define gtk_combo_box_text_new gtk_combo_box_new_text
     #define GDK_KEY_Return GDK_Return
 #endif
 
+G_END_DECLS
+
 #endif
index c700c279b4baaa159a33c226bc583843b856714c..6c05f63821730db50586d39910d9c869698d4fdd 100644 (file)
 #include <string.h>
 #include <glib/gi18n.h>
 
-#if !GTK_CHECK_VERSION (2, 14, 0)
-    #define gtk_dialog_get_content_area(dialog) dialog->vbox
-#endif
-
 struct _KatzePreferencesPrivate
 {
     #if HAVE_HILDON
index d9ed5ad975f31882da55ab175eb348b6b911f21a..4fe090b843a59e5f8dd0b1103808e44785808a79 100644 (file)
 #include "katze-scrolled.h"
 #include "katze-utils.h"
 
-#if !GTK_CHECK_VERSION (2, 14, 0)
-    #define gtk_adjustment_get_page_size(adj) adj->page_size
-    #define gtk_adjustment_get_upper(adj) adj->upper
-    #define gtk_adjustment_get_lower(adj) adj->lower
-    #define gtk_adjustment_get_value(adj) adj->value
-    #define gtk_widget_get_window(wdgt) wdgt->window
-#endif
-#if !GTK_CHECK_VERSION (2, 18, 0)
-    #define gtk_widget_set_window(wdgt, wndw) wdgt->window = wndw
-    #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
-    #define gtk_widget_is_drawable GTK_WIDGET_DRAWABLE
-    #define gtk_widget_get_drawable GTK_WIDGET_VISIBLE
-    #define gtk_widget_get_visible(wdgt) GTK_WIDGET_VISIBLE (wdgt)
-#endif
-#if !GTK_CHECK_VERSION (2, 19, 6)
-    #define gtk_widget_set_realized(wdgt, real) \
-        if (real) GTK_WIDGET_SET_FLAGS (wdgt, GTK_REALIZED); \
-        else GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_REALIZED)
-#endif
-
 #define DEFAULT_INTERVAL 50
 #define DEFAULT_DECELERATION 0.7
 #define DEFAULT_DRAGGING_STOPPED_DELAY 100
index ff403237cb844ad39d6123e60152eedfabc579ed..0ffc74aa82a1d408798d90f482332e8465f3c77d 100644 (file)
 
 #define HAVE_SPINNER GTK_CHECK_VERSION (2, 20, 0)
 
-#if !GTK_CHECK_VERSION (2, 18, 0)
-    #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
-    #define gtk_widget_set_has_window(wdgt, wnd) \
-        if (wnd) GTK_WIDGET_UNSET_FLAGS (wdgt, GTK_NO_WINDOW); \
-        else GTK_WIDGET_SET_FLAGS (wdgt, GTK_NO_WINDOW)
-#endif
-
 struct _KatzeThrobber
 {
     #if HAVE_SPINNER
index 9869908ba1cb5076adf09ca56083be8db8ca8221..27366f2858f29d52d7b80654205aefc78a15890d 100644 (file)
     #include <hildon/hildon.h>
 #endif
 
-#if !GTK_CHECK_VERSION (2, 14, 0)
-    #define gtk_widget_get_window(wdgt) wdgt->window
-#endif
-#if !GTK_CHECK_VERSION (2, 18, 0)
-    #define gtk_widget_get_has_window(wdgt) !GTK_WIDGET_NO_WINDOW (wdgt)
-    #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
-#endif
-
 #define I_ g_intern_static_string
 
 static void
index 14027c13ea37aac8e852442f61bb8ef32aedd907..5aae9cabcab86ae3f1b73f0ae2444632a939acfe 100644 (file)
@@ -12,7 +12,6 @@
 */
 
 #include "sokoke.h"
-#include "gtk3-compat.h"
 
 #if HAVE_CONFIG_H
     #include <config.h>
     #include <hildon-uri.h>
 #endif
 
-#if !GTK_CHECK_VERSION(2, 12, 0)
-
-void
-gtk_widget_set_has_tooltip (GtkWidget* widget,
-                            gboolean   has_tooltip)
-{
-    /* Do nothing */
-}
-
-void
-gtk_widget_set_tooltip_text (GtkWidget*   widget,
-                             const gchar* text)
-{
-    if (text && *text)
-    {
-        static GtkTooltips* tooltips = NULL;
-        if (G_UNLIKELY (!tooltips))
-            tooltips = gtk_tooltips_new ();
-        gtk_tooltips_set_tip (tooltips, widget, text, NULL);
-    }
-}
-
-void
-gtk_tool_item_set_tooltip_text (GtkToolItem* toolitem,
-                                const gchar* text)
-{
-    if (text && *text)
-    {
-        static GtkTooltips* tooltips = NULL;
-        if (G_UNLIKELY (!tooltips))
-            tooltips = gtk_tooltips_new ();
-
-        gtk_tool_item_set_tooltip (toolitem, tooltips, text, NULL);
-    }
-}
-
-#endif
-
 static gchar*
 sokoke_js_string_utf8 (JSStringRef js_string)
 {
index 3e132df24513adafba82c66b583cc54d6498c124..a7ddf8aac66ac38ed9e8dd49a567c86eaa05bb57 100644 (file)
 
 #include <JavaScriptCore/JavaScript.h>
 #include <midori/midori-websettings.h>
-
-#if !GLIB_CHECK_VERSION (2, 30, 0)
-    #define g_format_size(sz) g_format_size_for_display ((goffset)sz)
-#endif
-
-#if !GTK_CHECK_VERSION (2, 14, 0)
-    #define gtk_dialog_get_content_area(dlg) dlg->vbox
-    #define gtk_dialog_get_action_area(dlg) dlg->action_area
-    #define gtk_widget_get_window(wdgt) wdgt->window
-#endif
-
-#if !GTK_CHECK_VERSION (2, 16, 0)
-    #define GTK_ACTIVATABLE GTK_WIDGET
-    #define gtk_activatable_get_related_action gtk_widget_get_action
-    #define gtk_menu_item_set_label(menuitem, label) \
-        gtk_label_set_label (GTK_LABEL (GTK_BIN (menuitem)->child), \
-                             label ? label : "");
-#endif
-
-#if !GTK_CHECK_VERSION (2, 18, 0)
-    #define gtk_widget_is_toplevel(widget) GTK_WIDGET_TOPLEVEL (widget)
-    #define gtk_widget_has_focus(widget) GTK_WIDGET_HAS_FOCUS (widget)
-    #define gtk_widget_get_visible(widget) GTK_WIDGET_VISIBLE (widget)
-    #define gtk_widget_get_sensitive(widget) GTK_WIDGET_IS_SENSITIVE (widget)
-    #define gtk_widget_set_can_focus(widget,flag) \
-        GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS)
-    #define gtk_widget_get_allocation(wdgt, alloc) *alloc = wdgt->allocation
-#endif
-
-#if !GTK_CHECK_VERSION (2, 20, 0)
-    #define gtk_widget_get_realized(widget) GTK_WIDGET_REALIZED (widget)
-#endif
-
-#if !GTK_CHECK_VERSION(2, 12, 0)
-
-void
-gtk_widget_set_has_tooltip             (GtkWidget*         widget,
-                                        gboolean           has_tooltip);
-
-void
-gtk_widget_set_tooltip_text            (GtkWidget*         widget,
-                                        const gchar*       text);
-
-void
-gtk_tool_item_set_tooltip_text         (GtkToolItem*       toolitem,
-                                        const gchar*       text);
-
-#endif
+#include <katze/gtk3-compat.h>
 
 gchar*
 sokoke_js_script_eval                   (JSContextRef    js_context,