Mercurial > pidgin
changeset 11908:34ea75bdd0c9
[gaim-migrate @ 14199]
SF Patch #1342714 from Sadrul
"This patch enables widgets added to the menutray to
show tooltips. The widgets with no X-window cannot have
a tooltip, and there's a warning debug message for such
cases."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 30 Oct 2005 23:14:39 +0000 |
parents | d2db6426c88a |
children | 1b029c5898af |
files | src/gtkconv.c src/gtkmenutray.c src/gtkmenutray.h |
diffstat | 3 files changed, 43 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkconv.c Sun Oct 30 23:00:47 2005 +0000 +++ b/src/gtkconv.c Sun Oct 30 23:14:39 2005 +0000 @@ -2607,7 +2607,8 @@ if(gtkwin->menu.typing_icon) { gtk_widget_show(gtkwin->menu.typing_icon); gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), - gtkwin->menu.typing_icon); + gtkwin->menu.typing_icon, + _("The buddy is typing a message")); } }
--- a/src/gtkmenutray.c Sun Oct 30 23:00:47 2005 +0000 +++ b/src/gtkmenutray.c Sun Oct 30 23:14:39 2005 +0000 @@ -17,6 +17,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "debug.h" + #include "gtkmenutray.h" #include <gtk/gtkiconfactory.h> @@ -131,6 +133,8 @@ if(!GTK_IS_WIDGET(menu_tray->tray)) menu_tray->tray = gtk_hbox_new(FALSE, 0); + menu_tray->tooltips = gtk_tooltips_new(); + #if GTK_CHECK_VERSION(2,2,0) settings = gtk_settings_get_for_screen(gtk_widget_get_screen(widget)); @@ -190,17 +194,36 @@ } void -gaim_gtk_menu_tray_append(GaimGtkMenuTray *menu_tray, GtkWidget *widget) { +gaim_gtk_menu_tray_append(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip) +{ g_return_if_fail(GAIM_GTK_IS_MENU_TRAY(menu_tray)); g_return_if_fail(GTK_IS_WIDGET(widget)); + gaim_gtk_menu_tray_set_tooltip(menu_tray, widget, tooltip); gtk_box_pack_end(GTK_BOX(menu_tray->tray), widget, FALSE, FALSE, 0); } void -gaim_gtk_menu_tray_prepend(GaimGtkMenuTray *menu_tray, GtkWidget *widget) { +gaim_gtk_menu_tray_prepend(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip) +{ g_return_if_fail(GAIM_GTK_IS_MENU_TRAY(menu_tray)); g_return_if_fail(GTK_IS_WIDGET(widget)); + gaim_gtk_menu_tray_set_tooltip(menu_tray, widget, tooltip); gtk_box_pack_start(GTK_BOX(menu_tray->tray), widget, FALSE, FALSE, 0); } + +void +gaim_gtk_menu_tray_set_tooltip(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip) +{ + if (!menu_tray->tooltips) + return; + + /* Should we check whether widget is a child of menu_tray? */ + if (GTK_WIDGET_NO_WINDOW(widget)) + gaim_debug_warning("GtkMenuTray", + "The widget does not have it's own window. Tooltip cannot be set for this widget.\n"); + else + gtk_tooltips_set_tip(menu_tray->tooltips, widget, tooltip, NULL); +} +
--- a/src/gtkmenutray.h Sun Oct 30 23:00:47 2005 +0000 +++ b/src/gtkmenutray.h Sun Oct 30 23:14:39 2005 +0000 @@ -25,6 +25,7 @@ #include <gtk/gtkhbox.h> #include <gtk/gtkmenuitem.h> +#include <gtk/gtktooltips.h> #define GAIM_GTK_TYPE_MENU_TRAY (gaim_gtk_menu_tray_get_gtype()) #define GAIM_GTK_MENU_TRAY(obj) (GTK_CHECK_CAST((obj), GAIM_GTK_TYPE_MENU_TRAY, GaimGtkMenuTray)) @@ -40,6 +41,7 @@ struct _GaimGtkMenuTray { GtkMenuItem gparent; /**< The parent instance */ GtkWidget *tray; /**< The tray */ + GtkTooltips *tooltips; /**< Tooltips */ }; /** A GaimGtkMenuTrayClass */ @@ -78,16 +80,27 @@ * * @param menu_tray The tray * @param widget The widget + * @param tooltip The tooltip for this widget (widget requires its own X-window) */ -void gaim_gtk_menu_tray_append(GaimGtkMenuTray *menu_tray, GtkWidget *widget); +void gaim_gtk_menu_tray_append(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip); /** * Prepends a widget into the tray * - * @param menu_tray The try + * @param menu_tray The tray * @param widget The widget + * @param tooltip The tooltip for this widget (widget requires its own X-window) */ -void gaim_gtk_menu_tray_prepend(GaimGtkMenuTray *menu_tray, GtkWidget *widget); +void gaim_gtk_menu_tray_prepend(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip); + +/** + * Set the tooltip for a widget + * + * @param menu_tray The tray + * @param widget The widget + * @param tooltip The tooltip to set for the widget (widget requires its own X-window) + */ +void gaim_gtk_menu_tray_set_tooltip(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip); G_END_DECLS