From 578f74a30820dcbc5c8eb2f2d6793b46ec0deaea Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Fri, 1 Jan 2010 23:24:03 +0100 Subject: [PATCH] Merge compat.h into sokoke and remove gtk_show_uri implementation --- midori/compat.c | 67 ------------------------------------- midori/compat.h | 56 ------------------------------- midori/main.c | 1 - midori/midori-browser.c | 1 - midori/midori-panel.c | 1 - midori/midori-preferences.c | 1 - midori/midori-view.c | 1 - midori/sokoke.c | 44 +++++++++++++++++++++++- midori/sokoke.h | 21 ++++++++++++ panels/midori-transfers.c | 1 - tests/magic-uri.c | 1 - 11 files changed, 64 insertions(+), 131 deletions(-) delete mode 100644 midori/compat.c delete mode 100644 midori/compat.h diff --git a/midori/compat.c b/midori/compat.c deleted file mode 100644 index 273935e4..00000000 --- a/midori/compat.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2008-2009 Christian Dywan - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - See the file COPYING for the full license text. -*/ - -#include "compat.h" - -#include - -#if !GTK_CHECK_VERSION (2, 14, 0) - -gboolean -gtk_show_uri (GdkScreen* screen, - const gchar* uri, - guint32 timestamp, - GError** error) -{ - g_return_val_if_fail (uri != NULL, FALSE); - - return g_app_info_launch_default_for_uri (uri, NULL, NULL); -} - -#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 diff --git a/midori/compat.h b/midori/compat.h deleted file mode 100644 index b7df7047..00000000 --- a/midori/compat.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2008-2009 Christian Dywan - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - See the file COPYING for the full license text. -*/ - -#ifndef __COMPAT_H__ -#define __COMPAT_H__ - -#if HAVE_CONFIG_H - #include -#endif - -#include - -G_BEGIN_DECLS - -#if !GLIB_CHECK_VERSION (2, 14, 0) - #define G_PARAM_STATIC_STRINGS \ - (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) -#endif - -#if !GTK_CHECK_VERSION (2, 14, 0) - -gboolean -gtk_show_uri (GdkScreen* screen, - const gchar* uri, - guint32 timestamp, - GError** error); - -#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 - -G_END_DECLS - -#endif /* __COMPAT_H__ */ diff --git a/midori/main.c b/midori/main.c index 077bc6af..6efde200 100644 --- a/midori/main.c +++ b/midori/main.c @@ -25,7 +25,6 @@ #include "midori-transfers.h" #include "sokoke.h" -#include "compat.h" #if HAVE_UNISTD_H #include diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 62667dbb..e65187bf 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -26,7 +26,6 @@ #include "midori-stock.h" #include "gtkiconentry.h" -#include "compat.h" #include "marshal.h" #include "sokoke.h" diff --git a/midori/midori-panel.c b/midori/midori-panel.c index bb1af4e8..5f2c9720 100644 --- a/midori/midori-panel.c +++ b/midori/midori-panel.c @@ -13,7 +13,6 @@ #include "midori-view.h" -#include "compat.h" #include "marshal.h" #include "sokoke.h" diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c index f80b31c0..f8227558 100644 --- a/midori/midori-preferences.c +++ b/midori/midori-preferences.c @@ -16,7 +16,6 @@ #endif #include "sokoke.h" -#include "compat.h" #include #include diff --git a/midori/midori-view.c b/midori/midori-view.c index 5a2e43d7..d86a5398 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -18,7 +18,6 @@ #include "midori-stock.h" #include "midori-browser.h" -#include "compat.h" #include "marshal.h" #include "sokoke.h" diff --git a/midori/sokoke.c b/midori/sokoke.c index 15e5504b..bd74132f 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -17,7 +17,6 @@ #include #endif -#include "compat.h" #include "midori-stock.h" #if HAVE_UNISTD_H @@ -52,6 +51,44 @@ #include #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) { @@ -248,8 +285,13 @@ sokoke_show_uri (GdkScreen* screen, g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (!error || !*error, FALSE); + #if GTK_CHECK_VERSION (2, 14, 0) if (gtk_show_uri (screen, uri, timestamp, error)) return TRUE; + #else + if (g_app_info_launch_default_for_uri (uri, NULL, NULL)) + return TRUE; + #endif for (i = 0; i < G_N_ELEMENTS (fallbacks); i++) { diff --git a/midori/sokoke.h b/midori/sokoke.h index 85c11ff8..621ca999 100644 --- a/midori/sokoke.h +++ b/midori/sokoke.h @@ -18,6 +18,27 @@ #include #include +#if !GLIB_CHECK_VERSION (2, 14, 0) + #define G_PARAM_STATIC_STRINGS \ + (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB) +#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 + gchar* sokoke_js_script_eval (JSContextRef js_context, const gchar* script, diff --git a/panels/midori-transfers.c b/panels/midori-transfers.c index 46783370..55d74c49 100644 --- a/panels/midori-transfers.c +++ b/panels/midori-transfers.c @@ -17,7 +17,6 @@ #include "midori-view.h" #include "sokoke.h" -#include "compat.h" #include struct _MidoriTransfers diff --git a/tests/magic-uri.c b/tests/magic-uri.c index 35c6fdb5..7c47d4c4 100644 --- a/tests/magic-uri.c +++ b/tests/magic-uri.c @@ -14,7 +14,6 @@ #include #endif -#include "compat.h" #include "sokoke.h" #define SM "http://www.searchmash.com/search/"