Merge compat.h into sokoke and remove gtk_show_uri implementation

This commit is contained in:
Christian Dywan 2010-01-01 23:24:03 +01:00
parent 2f202f8020
commit 578f74a308
11 changed files with 64 additions and 131 deletions

View file

@ -1,67 +0,0 @@
/*
Copyright (C) 2008-2009 Christian Dywan <christian@twotoasts.de>
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 <string.h>
#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

View file

@ -1,56 +0,0 @@
/*
Copyright (C) 2008-2009 Christian Dywan <christian@twotoasts.de>
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 <config.h>
#endif
#include <webkit/webkit.h>
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__ */

View file

@ -25,7 +25,6 @@
#include "midori-transfers.h"
#include "sokoke.h"
#include "compat.h"
#if HAVE_UNISTD_H
#include <unistd.h>

View file

@ -26,7 +26,6 @@
#include "midori-stock.h"
#include "gtkiconentry.h"
#include "compat.h"
#include "marshal.h"
#include "sokoke.h"

View file

@ -13,7 +13,6 @@
#include "midori-view.h"
#include "compat.h"
#include "marshal.h"
#include "sokoke.h"

View file

@ -16,7 +16,6 @@
#endif
#include "sokoke.h"
#include "compat.h"
#include <string.h>
#include <glib/gi18n.h>

View file

@ -18,7 +18,6 @@
#include "midori-stock.h"
#include "midori-browser.h"
#include "compat.h"
#include "marshal.h"
#include "sokoke.h"

View file

@ -17,7 +17,6 @@
#include <config.h>
#endif
#include "compat.h"
#include "midori-stock.h"
#if HAVE_UNISTD_H
@ -52,6 +51,44 @@
#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)
{
@ -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++)
{

View file

@ -18,6 +18,27 @@
#include <webkit/webkit.h>
#include <JavaScriptCore/JavaScript.h>
#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,

View file

@ -17,7 +17,6 @@
#include "midori-view.h"
#include "sokoke.h"
#include "compat.h"
#include <glib/gi18n.h>
struct _MidoriTransfers

View file

@ -14,7 +14,6 @@
#include <config.h>
#endif
#include "compat.h"
#include "sokoke.h"
#define SM "http://www.searchmash.com/search/"