Mercurial > pidgin
changeset 12471:011efeb86b8d
[gaim-migrate @ 14781]
SF Patch #1368906 from charkins
"This patch adds a tooltip to the docklet icon. It is
based off of faceprint's code for the blist menutray.
Wingaim had some status strings it was displaying in
the tooltip, this patch removes those."
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 12 Dec 2005 19:55:42 +0000 |
parents | 13f351a0096e |
children | 065005e5f536 |
files | plugins/docklet/docklet-win32.c plugins/docklet/docklet-x11.c plugins/docklet/docklet.c plugins/docklet/docklet.h |
diffstat | 4 files changed, 70 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/docklet/docklet-win32.c Mon Dec 12 19:30:11 2005 +0000 +++ b/plugins/docklet/docklet-win32.c Mon Dec 12 19:55:42 2005 +0000 @@ -41,9 +41,6 @@ /* * DEFINES, MACROS & DATA TYPES */ -#define GAIM_SYSTRAY_HINT _("Gaim") -#define GAIM_SYSTRAY_DISCONN_HINT _("Gaim - Signed off") -#define GAIM_SYSTRAY_AWAY_HINT _("Gaim - Away") #define WM_TRAYMESSAGE WM_USER /* User defined WM Message */ /* @@ -133,8 +130,6 @@ } static void systray_init_icon(HWND hWnd, HICON icon) { - char* locenc=NULL; - ZeroMemory(&wgaim_nid,sizeof(wgaim_nid)); wgaim_nid.cbSize=sizeof(NOTIFYICONDATA); wgaim_nid.hWnd=hWnd; @@ -142,21 +137,13 @@ wgaim_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP; wgaim_nid.uCallbackMessage=WM_TRAYMESSAGE; wgaim_nid.hIcon=icon; - locenc=g_locale_from_utf8(GAIM_SYSTRAY_DISCONN_HINT, -1, NULL, NULL, NULL); - strcpy(wgaim_nid.szTip, locenc); - g_free(locenc); + lstrcpy(wgaim_nid.szTip, ""); Shell_NotifyIcon(NIM_ADD,&wgaim_nid); docklet_embedded(); } -static void systray_change_icon(HICON icon, char* text) { - char *locenc=NULL; +static void systray_change_icon(HICON icon) { wgaim_nid.hIcon = icon; - if (text) { - locenc = g_locale_from_utf8(text, -1, NULL, NULL, NULL); - lstrcpy(wgaim_nid.szTip, locenc); - g_free(locenc); - } Shell_NotifyIcon(NIM_MODIFY,&wgaim_nid); } @@ -167,27 +154,39 @@ static void wgaim_tray_update_icon(DockletStatus icon) { switch (icon) { case DOCKLET_STATUS_OFFLINE: - systray_change_icon(sysicon_disconn, GAIM_SYSTRAY_DISCONN_HINT); + systray_change_icon(sysicon_disconn); break; case DOCKLET_STATUS_CONNECTING: break; case DOCKLET_STATUS_ONLINE: - systray_change_icon(sysicon_conn, GAIM_SYSTRAY_HINT); + systray_change_icon(sysicon_conn); break; case DOCKLET_STATUS_ONLINE_PENDING: - systray_change_icon(sysicon_pend, GAIM_SYSTRAY_HINT); + systray_change_icon(sysicon_pend); break; case DOCKLET_STATUS_AWAY: - systray_change_icon(sysicon_away, GAIM_SYSTRAY_AWAY_HINT); + systray_change_icon(sysicon_away); break; case DOCKLET_STATUS_AWAY_PENDING: - systray_change_icon(sysicon_awypend, GAIM_SYSTRAY_AWAY_HINT); + systray_change_icon(sysicon_awypend); break; } } static void wgaim_tray_blank_icon() { - systray_change_icon(sysicon_blank, NULL); + systray_change_icon(sysicon_blank); +} + +static void wgaim_tray_set_tooltip(gchar *tooltip) { + if (tooltip) { + char *locenc = NULL; + locenc = g_locale_from_utf8(tooltip, -1, NULL, NULL, NULL); + lstrcpyn(wgaim_nid.szTip, locenc, sizeof(wgaim_nid.szTip)/sizeof(TCHAR)); + g_free(locenc); + } else { + lstrcpy(wgaim_nid.szTip, ""); + } + Shell_NotifyIcon(NIM_MODIFY, &wgaim_nid); } void wgaim_tray_minimize(GaimGtkBuddyList *gtkblist) { @@ -251,6 +250,7 @@ wgaim_tray_destroy, wgaim_tray_update_icon, wgaim_tray_blank_icon, + wgaim_tray_set_tooltip, NULL };
--- a/plugins/docklet/docklet-x11.c Mon Dec 12 19:30:11 2005 +0000 +++ b/plugins/docklet/docklet-x11.c Mon Dec 12 19:55:42 2005 +0000 @@ -38,6 +38,7 @@ /* globals */ static EggTrayIcon *docklet = NULL; static GtkWidget *image = NULL; +static GtkTooltips *tooltips = NULL; static GdkPixbuf *blank_icon = NULL; static int embed_timeout = 0; @@ -157,6 +158,22 @@ gtk_image_set_from_pixbuf(GTK_IMAGE(image), blank_icon); } +static void +docklet_x11_set_tooltip(gchar *tooltip) +{ + if (!tooltips) + tooltips = gtk_tooltips_new(); + + /* image->parent is a GtkEventBox */ + if (tooltip) { + gtk_tooltips_enable(tooltips); + gtk_tooltips_set_tip(tooltips, image->parent, tooltip, NULL); + } else { + gtk_tooltips_set_tip(tooltips, image->parent, "", NULL); + gtk_tooltips_disable(tooltips); + } +} + #if GTK_CHECK_VERSION(2,2,0) static void docklet_x11_position_menu(GtkMenu *menu, int *x, int *y, gboolean *push_in, @@ -238,7 +255,7 @@ gtk_container_add(GTK_CONTAINER(box), image); gtk_container_add(GTK_CONTAINER(docklet), box); - if(!gtk_check_version(2,4,0)) + if (!gtk_check_version(2,4,0)) g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); gtk_widget_show_all(GTK_WIDGET(docklet)); @@ -257,6 +274,7 @@ docklet_x11_destroy, docklet_x11_update_icon, docklet_x11_blank_icon, + docklet_x11_set_tooltip, #if GTK_CHECK_VERSION(2,2,0) docklet_x11_position_menu #else
--- a/plugins/docklet/docklet.c Mon Dec 12 19:30:11 2005 +0000 +++ b/plugins/docklet/docklet.c Mon Dec 12 19:55:42 2005 +0000 @@ -91,15 +91,41 @@ docklet_update_status() { GList *l; + GList *convs; DockletStatus newstatus = DOCKLET_STATUS_OFFLINE; gboolean pending = FALSE; /* determine if any ims have unseen messages */ - l = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, + convs = gaim_gtk_conversations_find_unseen_list(GAIM_CONV_TYPE_IM, GAIM_UNSEEN_TEXT, FALSE, 1); - if (l != NULL) { + if (convs != NULL) { pending = TRUE; - g_list_free(l); + + /* set tooltip if messages are pending */ + if (ui_ops->set_tooltip) { + GString *tooltip_text = g_string_new(""); + for (l = convs ; l != NULL ; l = l->next) { + if (GAIM_IS_GTK_CONVERSATION(l->data)) { + GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION((GaimConversation *)l->data); + g_string_append_printf(tooltip_text, + ngettext("%d unread message from %s\n", "%d unread messages from %s\n", gtkconv->unseen_count), + gtkconv->unseen_count, + gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); + } + } + + /* get rid of the last newline */ + if (tooltip_text->len > 0) + tooltip_text = g_string_truncate(tooltip_text, tooltip_text->len - 1); + + ui_ops->set_tooltip(tooltip_text->str); + + g_string_free(tooltip_text, TRUE); + } else { + ui_ops->set_tooltip(NULL); + } + + g_list_free(convs); } /* iterate through all accounts and determine which