Move tooltip API from sokoke to compat

This commit is contained in:
Christian Dywan 2008-06-08 19:45:33 +02:00
parent 13f8171e24
commit 0cf86e0ee0
7 changed files with 43 additions and 42 deletions

View file

@ -11,6 +11,33 @@
#include "compat.h" #include "compat.h"
#if !GTK_CHECK_VERSION(2, 12, 0)
void
sokoke_widget_set_tooltip_text (GtkWidget* widget, const gchar* text)
{
static GtkTooltips* tooltips;
if (!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
#ifndef WEBKIT_CHECK_VERSION #ifndef WEBKIT_CHECK_VERSION
/** /**

View file

@ -16,6 +16,18 @@
G_BEGIN_DECLS G_BEGIN_DECLS
#if !GTK_CHECK_VERSION(2, 12, 0)
void
gtk_widget_set_tooltip_text (GtkWidget* widget,
const gchar* text);
void
gtk_tool_item_set_tooltip_text (GtkToolItem* toolitem,
const gchar* text);
#endif
#ifndef WEBKIT_CHECK_VERSION #ifndef WEBKIT_CHECK_VERSION
gfloat gfloat

View file

@ -2759,7 +2759,7 @@ midori_browser_init (MidoriBrowser* browser)
g_signal_connect (toolitem, "clicked", g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_browser_bookmarkbar_folder_activate_cb), G_CALLBACK (midori_browser_bookmarkbar_folder_activate_cb),
browser); browser);
sokoke_tool_item_set_tooltip_text(toolitem, desc); gtk_tool_item_set_tooltip_text (toolitem, desc);
g_object_set_data (G_OBJECT (toolitem), "KatzeXbelItem", item); g_object_set_data (G_OBJECT (toolitem), "KatzeXbelItem", item);
break; break;
case KATZE_XBEL_ITEM_KIND_BOOKMARK: case KATZE_XBEL_ITEM_KIND_BOOKMARK:
@ -2769,7 +2769,7 @@ midori_browser_init (MidoriBrowser* browser)
g_signal_connect (toolitem, "clicked", g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_browser_menu_bookmarks_item_activate_cb), G_CALLBACK (midori_browser_menu_bookmarks_item_activate_cb),
browser); browser);
sokoke_tool_item_set_tooltip_text(toolitem, desc); gtk_tool_item_set_tooltip_text (toolitem, desc);
g_object_set_data (G_OBJECT (toolitem), "KatzeXbelItem", item); g_object_set_data (G_OBJECT (toolitem), "KatzeXbelItem", item);
break; break;
case KATZE_XBEL_ITEM_KIND_SEPARATOR: case KATZE_XBEL_ITEM_KIND_SEPARATOR:

View file

@ -210,7 +210,7 @@ midori_panel_init (MidoriPanel* panel)
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1); gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE); toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Close panel")); gtk_tool_button_set_label (GTK_TOOL_BUTTON (toolitem), _("Close panel"));
sokoke_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem), _("Close panel")); gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (toolitem), _("Close panel"));
g_signal_connect (toolitem, "clicked", g_signal_connect (toolitem, "clicked",
G_CALLBACK (midori_panel_button_close_clicked_cb), panel); G_CALLBACK (midori_panel_button_close_clicked_cb), panel);
gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1); gtk_toolbar_insert (GTK_TOOLBAR (labelbar), toolitem, -1);

View file

@ -666,7 +666,7 @@ midori_web_view_set_property (GObject* object,
if (priv->tab_label) if (priv->tab_label)
{ {
gtk_label_set_text (GTK_LABEL (priv->tab_label), title); gtk_label_set_text (GTK_LABEL (priv->tab_label), title);
sokoke_widget_set_tooltip_text (priv->tab_label, title); gtk_widget_set_tooltip_text (priv->tab_label, title);
} }
if (priv->proxy_menu_item) if (priv->proxy_menu_item)
gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN ( gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (

View file

@ -130,36 +130,6 @@ sokoke_container_show_children (GtkContainer* container)
gtk_container_foreach (container, (GtkCallback)(gtk_widget_show_all), NULL); gtk_container_foreach (container, (GtkCallback)(gtk_widget_show_all), NULL);
} }
void
sokoke_widget_set_tooltip_text (GtkWidget* widget, const gchar* text)
{
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_widget_set_tooltip_text (widget, text);
#else
static GtkTooltips* tooltips;
if (!tooltips)
tooltips = gtk_tooltips_new ();
gtk_tooltips_set_tip (tooltips, widget, text, NULL);
#endif
}
void
sokoke_tool_item_set_tooltip_text (GtkToolItem* toolitem, const gchar* text)
{
if (text && *text)
{
#if GTK_CHECK_VERSION(2, 12, 0)
gtk_tool_item_set_tooltip_text (toolitem, text);
#else
static GtkTooltips* tooltips = NULL;
if (G_UNLIKELY (!tooltips))
tooltips = gtk_tooltips_new();
gtk_tool_item_set_tooltip (toolitem, tooltips, text, NULL);
#endif
}
}
typedef struct typedef struct
{ {
GtkWidget* widget; GtkWidget* widget;

View file

@ -45,14 +45,6 @@ sokoke_widget_set_visible (GtkWidget* widget,
void void
sokoke_container_show_children (GtkContainer* container); sokoke_container_show_children (GtkContainer* container);
void
sokoke_widget_set_tooltip_text (GtkWidget* widget,
const gchar* text);
void
sokoke_tool_item_set_tooltip_text (GtkToolItem* toolitem,
const gchar* text);
void void
sokoke_widget_popup (GtkWidget* widget, sokoke_widget_popup (GtkWidget* widget,
GtkMenu* menu, GtkMenu* menu,