Commit b5abe063 authored by Vincent Untz's avatar Vincent Untz Committed by Vincent Untz
Browse files

Migrate to GtkTooltip.

2007-07-01  Vincent Untz  <vuntz@gnome.org>

	Migrate to GtkTooltip.

	* panel-util.[ch]: (panel_util_query_tooltip_cb): new, check if
	tooltips are enabled but displaying one
	(panel_util_set_tooltip_text): wrapper for tooltip for the panel,
	since we need to check if the tooltips are enabled in the panel config.
	* panel-config-global.c: simplify, since we don't need to do the
	GtkTooltips stuff
	* main.c: (main):
	* panel-globals.h: remove useless global GtkTooltips variable
	* drawer.c:
	* launcher.c:
	* menu.c:
	* panel-action-button.c:
	* panel-menu-button.c:
	* panel-menu-items.c:
	* panel-recent.c: use panel_util_set_tooltip_text()
	* panel-menu-bar.c: (panel_menu_bar_enter_applications): kill
	(panel_menu_bar_enter_places): kill
	(panel_menu_bar_enter_desktop): kill
	(panel_menu_bar_reinit_tooltip): updated
	(panel_menu_bar_hide_tooltip): updated
	(panel_menu_bar_setup_tooltip): simplify thanks to GtkTooltip
	* gnome-desktop-item-edit.c:
	(panel_global_config_get_tooltips_enabled): needed symbol for
	compilation. This is just a hacky workaround.

svn path=/trunk/; revision=10508
parent f105b8e4
2007-07-01 Vincent Untz <vuntz@gnome.org>
Migrate to GtkTooltip.
* panel-util.[ch]: (panel_util_query_tooltip_cb): new, check if
tooltips are enabled but displaying one
(panel_util_set_tooltip_text): wrapper for tooltip for the panel,
since we need to check if the tooltips are enabled in the panel config.
* panel-config-global.c: simplify, since we don't need to do the
GtkTooltips stuff
* main.c: (main):
* panel-globals.h: remove useless global GtkTooltips variable
* drawer.c:
* launcher.c:
* menu.c:
* panel-action-button.c:
* panel-menu-button.c:
* panel-menu-items.c:
* panel-recent.c: use panel_util_set_tooltip_text()
* panel-menu-bar.c: (panel_menu_bar_enter_applications): kill
(panel_menu_bar_enter_places): kill
(panel_menu_bar_enter_desktop): kill
(panel_menu_bar_reinit_tooltip): updated
(panel_menu_bar_hide_tooltip): updated
(panel_menu_bar_setup_tooltip): simplify thanks to GtkTooltip
* gnome-desktop-item-edit.c:
(panel_global_config_get_tooltips_enabled): needed symbol for
compilation. This is just a hacky workaround.
2007-07-01 Vincent Untz <vuntz@gnome.org>
 
* panel-icon-names.h: add icon for home folder
......
......@@ -316,7 +316,7 @@ set_tooltip_and_name (Drawer *drawer,
tooltip = NULL;
panel_toplevel_set_name (drawer->toplevel, tooltip);
gtk_tooltips_set_tip (panel_tooltips, drawer->button, tooltip, NULL);
panel_util_set_tooltip_text (drawer->button, tooltip);
}
static Drawer *
......
......@@ -16,6 +16,8 @@
/* FIXME Symbol needed by panel-util.c - sucky */
#include "applet.h"
GSList *panel_applet_list_applets (void) { return NULL; }
#include "panel-config-global.h"
gboolean panel_global_config_get_tooltips_enabled (void) { return FALSE; }
static int dialogs = 0;
static gboolean create_new = FALSE;
......
......@@ -605,7 +605,8 @@ setup_button (Launcher *launcher)
str = unescaped_str;
}
gtk_tooltips_set_tip (panel_tooltips, launcher->button, str, NULL);
panel_util_set_tooltip_text (launcher->button, str);
/* Setup accessible name */
panel_a11y_set_atk_name_desc (launcher->button, str, NULL);
......
......@@ -34,8 +34,6 @@
GSList *panels = NULL;
GSList *panel_list = NULL;
GtkTooltips *panel_tooltips = NULL;
static char *deprecated_profile;
static const GOptionEntry options[] = {
......@@ -72,8 +70,6 @@ main (int argc, char **argv)
gnome_authentication_manager_init ();
panel_tooltips = gtk_tooltips_new ();
panel_action_protocol_init ();
panel_multiscreen_init ();
panel_init_stock_icons_and_items ();
......
......@@ -1049,8 +1049,9 @@ drag_begin_menu_cb (GtkWidget *widget, GdkDragContext *context)
{
/* FIXME: workaround for a possible gtk+ bug
* See bugs #92085(gtk+) and #91184(panel) for details.
* Maybe it's not needed with GtkTooltip?
*/
gtk_tooltips_disable (panel_tooltips);
g_object_set (widget, "has-tooltip", FALSE, NULL);
}
/* This is a _horrible_ hack to have this here. This needs to be added to the
......@@ -1070,8 +1071,7 @@ drag_end_menu_cb (GtkWidget *widget, GdkDragContext *context)
/* FIXME: workaround for a possible gtk+ bug
* See bugs #92085(gtk+) and #91184(panel) for details.
*/
if (panel_global_config_get_tooltips_enabled ())
gtk_tooltips_enable (panel_tooltips);
g_object_set (widget, "has-tooltip", TRUE, NULL);
while (parent)
{
......@@ -1441,10 +1441,8 @@ create_submenu_entry (GtkWidget *menu,
TRUE);
if (gmenu_tree_directory_get_comment (directory))
gtk_tooltips_set_tip (panel_tooltips,
menuitem,
gmenu_tree_directory_get_comment (directory),
NULL);
panel_util_set_tooltip_text (menuitem,
gmenu_tree_directory_get_comment (directory));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
......@@ -1529,11 +1527,10 @@ create_menuitem (GtkWidget *menu,
gmenu_tree_directory_get_comment (alias_directory)) ||
(!alias_directory &&
gmenu_tree_entry_get_comment (entry)))
gtk_tooltips_set_tip (panel_tooltips,
menuitem,
alias_directory ? gmenu_tree_directory_get_comment (alias_directory) :
gmenu_tree_entry_get_comment (entry),
NULL);
panel_util_set_tooltip_text (menuitem,
alias_directory ?
gmenu_tree_directory_get_comment (alias_directory) :
gmenu_tree_entry_get_comment (entry));
g_signal_connect_after (menuitem, "button_press_event",
G_CALLBACK (menuitem_button_press_event), NULL);
......
......@@ -616,8 +616,8 @@ panel_action_button_set_type (PanelActionButton *button,
if (actions [type].icon_name != NULL)
button_widget_set_icon_name (BUTTON_WIDGET (button), actions [type].icon_name);
gtk_tooltips_set_tip (panel_tooltips, GTK_WIDGET (button),
_(actions [type].tooltip), NULL);
panel_util_set_tooltip_text (GTK_WIDGET (button),
_(actions [type].tooltip));
panel_a11y_set_atk_name_desc (GTK_WIDGET (button), _(actions [type].tooltip), NULL);
panel_action_button_update_sensitivity (button);
......
......@@ -98,15 +98,11 @@ panel_global_config_set_entry (GConfEntry *entry)
if (!value || !key)
return;
if (strcmp (key, "tooltips_enabled") == 0) {
if (strcmp (key, "tooltips_enabled") == 0)
global_config.tooltips_enabled =
gconf_value_get_bool (value);
if (global_config.tooltips_enabled)
gtk_tooltips_enable (panel_tooltips);
else
gtk_tooltips_disable (panel_tooltips);
} else if (strcmp (key, "enable_animations") == 0)
else if (strcmp (key, "enable_animations") == 0)
global_config.enable_animations =
gconf_value_get_bool (value);
......
......@@ -32,8 +32,6 @@ G_BEGIN_DECLS
extern GSList *panels;
extern GSList *panel_list;
extern GtkTooltips *panel_tooltips;
G_END_DECLS
#endif /* __PANEL_GLOBALS_H__ */
......@@ -67,49 +67,16 @@ enum {
static void panel_menu_bar_update_text_gravity (PanelMenuBar *menubar);
static gboolean
panel_menu_bar_enter_applications (GtkWidget *widget,
GdkEventCrossing *event,
PanelMenuBar *menubar)
{
gtk_tooltips_set_tip (panel_tooltips,
GTK_WIDGET (menubar),
_("Browse and run installed applications"),
NULL);
return FALSE;
}
static gboolean
panel_menu_bar_enter_places (GtkWidget *widget,
GdkEventCrossing *event,
PanelMenuBar *menubar)
{
gtk_tooltips_set_tip (panel_tooltips,
GTK_WIDGET (menubar),
_("Access documents, folders and network places"),
NULL);
return FALSE;
}
static gboolean
panel_menu_bar_enter_desktop (GtkWidget *widget,
GdkEventCrossing *event,
PanelMenuBar *menubar)
{
gtk_tooltips_set_tip (panel_tooltips,
GTK_WIDGET (menubar),
_("Change desktop appearance and behavior, get help, or log out"),
NULL);
return FALSE;
}
static gboolean
panel_menu_bar_reinit_tooltip (GtkWidget *widget,
PanelMenuBar *menubar)
{
gtk_tooltips_set_tip (panel_tooltips,
GTK_WIDGET (menubar),
"", NULL);
g_object_set (menubar->priv->applications_item,
"has-tooltip", TRUE, NULL);
g_object_set (menubar->priv->places_item,
"has-tooltip", TRUE, NULL);
g_object_set (menubar->priv->desktop_item,
"has-tooltip", TRUE, NULL);
return FALSE;
}
......@@ -118,9 +85,7 @@ static gboolean
panel_menu_bar_hide_tooltip (GtkWidget *widget,
PanelMenuBar *menubar)
{
gtk_tooltips_set_tip (panel_tooltips,
GTK_WIDGET (menubar),
NULL, NULL);
g_object_set (widget, "has-tooltip", FALSE, NULL);
return FALSE;
}
......@@ -128,19 +93,12 @@ panel_menu_bar_hide_tooltip (GtkWidget *widget,
static void
panel_menu_bar_setup_tooltip (PanelMenuBar *menubar)
{
/* Update tooltip when we enter the menu items */
g_signal_connect (menubar->priv->applications_item,
"enter-notify-event",
G_CALLBACK (panel_menu_bar_enter_applications),
menubar);
g_signal_connect (menubar->priv->places_item,
"enter-notify-event",
G_CALLBACK (panel_menu_bar_enter_places),
menubar);
g_signal_connect (menubar->priv->desktop_item,
"enter-notify-event",
G_CALLBACK (panel_menu_bar_enter_desktop),
menubar);
panel_util_set_tooltip_text (menubar->priv->applications_item,
_("Browse and run installed applications"));
panel_util_set_tooltip_text (menubar->priv->places_item,
_("Access documents, folders and network places"));
panel_util_set_tooltip_text (menubar->priv->desktop_item,
_("Change desktop appearance and behavior, get help, or log out"));
//FIXME: this doesn't handle the right-click case. Sigh.
/* Hide tooltip if a menu is activated */
......@@ -162,13 +120,6 @@ panel_menu_bar_setup_tooltip (PanelMenuBar *menubar)
"deactivate",
G_CALLBACK (panel_menu_bar_reinit_tooltip),
menubar);
/* Preset a tooltip that will change when the cursor enters an item
* If we don't do this, the tooltip will not work on the first enter
* event. */
gtk_tooltips_set_tip (panel_tooltips,
GTK_WIDGET (menubar),
"", NULL);
}
static void
......
......@@ -814,8 +814,7 @@ panel_menu_button_set_tooltip (PanelMenuButton *button,
if (tooltip && tooltip [0]) {
button->priv->tooltip = g_strdup (tooltip);
gtk_tooltips_set_tip (panel_tooltips, GTK_WIDGET (button),
tooltip, NULL);
panel_util_set_tooltip_text (GTK_WIDGET (button), tooltip);
}
}
......
......@@ -208,8 +208,7 @@ panel_menu_items_append_from_desktop (GtkWidget *menu,
setup_menu_item_with_icon (item, panel_menu_icon_get_size (),
icon, NULL, name, TRUE);
if (comment != NULL)
gtk_tooltips_set_tip (panel_tooltips, item, comment, NULL);
panel_util_set_tooltip_text (item, comment);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
g_signal_connect_data (item, "activate",
......@@ -257,10 +256,7 @@ panel_menu_items_append_place_item (const char *icon_name,
title,
TRUE);
gtk_tooltips_set_tip (panel_tooltips,
item,
tooltip,
NULL);
panel_util_set_tooltip_text (item, tooltip);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
......@@ -292,10 +288,10 @@ panel_menu_items_create_action_item_full (PanelActionButtonType action_type,
label ? label : panel_action_get_text (action_type),
TRUE);
gtk_tooltips_set_tip (panel_tooltips,
item,
tooltip ? tooltip : panel_action_get_tooltip (action_type),
NULL);
panel_util_set_tooltip_text (item,
tooltip ?
tooltip :
panel_action_get_tooltip (action_type));
g_signal_connect (item, "activate",
panel_action_get_invoke (action_type), NULL);
......
......@@ -255,10 +255,8 @@ panel_recent_append_documents_menu (GtkWidget *top_menu,
GTK_STOCK_CLEAR,
_("Clear Recent Documents"),
TRUE);
gtk_tooltips_set_tip (panel_tooltips,
menu_item,
_("Clear all items from the recent documents list"),
NULL);
panel_util_set_tooltip_text (menu_item,
_("Clear all items from the recent documents list"));
gtk_menu_shell_append (GTK_MENU_SHELL (recent_menu), menu_item);
g_signal_connect (menu_item, "activate",
......
......@@ -34,6 +34,7 @@
#include "applet.h"
#include "nothing.h"
#include "xstuff.h"
#include "panel-config-global.h"
#include "panel-globals.h"
#include "launcher.h"
#include "panel-icon-names.h"
......@@ -1542,3 +1543,33 @@ panel_util_get_icon_for_uri (const char *text_uri)
GNOME_ICON_LOOKUP_FLAGS_NONE,
GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE);
}
static gboolean
panel_util_query_tooltip_cb (GtkWidget *widget,
gint x,
gint y,
gboolean keyboard_tip,
GtkTooltip *tooltip,
const char *text)
{
if (!panel_global_config_get_tooltips_enabled ())
return FALSE;
gtk_tooltip_set_text (tooltip, text);
return TRUE;
}
void
panel_util_set_tooltip_text (GtkWidget *widget,
const char *text)
{
if (string_empty (text)) {
g_object_set (widget, "has-tooltip", FALSE, NULL);
return;
}
g_object_set (widget, "has-tooltip", TRUE, NULL);
g_signal_connect_data (widget, "query-tooltip",
G_CALLBACK (panel_util_query_tooltip_cb),
g_strdup (text), (GClosureNotify) g_free, 0);
}
......@@ -131,6 +131,9 @@ const char *panel_util_get_vfs_method_display_name (const char *method);
char *panel_util_get_label_for_uri (const char *text_uri);
char *panel_util_get_icon_for_uri (const char *text_uri);
void panel_util_set_tooltip_text (GtkWidget *widget,
const char *text);
G_END_DECLS
#endif /* PANEL_UTIL_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment