changeset 29232:1446436616d4

Use GtkStatusIcon on GTK+ 2.10+. That's actually the required version for next minor, but I'm leaving in the rest of the code until all the kinks are worked out. I still need to figure out how to properly move the icons so that they scale nicely. The code is done, just the files need proper placement. References #2629.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 08 Nov 2009 08:23:21 +0000
parents 4f325adb8ced
children 6652fdb8baf5 e77894113a14
files ChangeLog pidgin/Makefile.am pidgin/gtkdocklet-x11.c pidgin/gtkdocklet.h pidgin/pidginstock.c pidgin/pidginstock.h
diffstat 6 files changed, 51 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Nov 08 04:40:35 2009 +0000
+++ b/ChangeLog	Sun Nov 08 08:23:21 2009 +0000
@@ -12,6 +12,8 @@
 	  box to a "Developer Information" dialog accessible on the Help menu.
 	* Moved the Translator information from the About box to a "Translator
 	  Information" dialog accessible on the Help menu.
+	* Use GtkStatusIcon for the docklet, providing better integration in
+	  notification area.
 
 version 2.6.4 (??/??/20??):
 	libpurple:
--- a/pidgin/Makefile.am	Sun Nov 08 04:40:35 2009 +0000
+++ b/pidgin/Makefile.am	Sun Nov 08 08:23:21 2009 +0000
@@ -87,6 +87,7 @@
 	gtkdialogs.c \
 	gtkdnd-hints.c \
 	gtkdocklet.c \
+	gtkdocklet-gtk.c \
 	gtkdocklet-x11.c \
 	gtkeventloop.c \
 	gtkft.c \
--- a/pidgin/gtkdocklet-x11.c	Sun Nov 08 04:40:35 2009 +0000
+++ b/pidgin/gtkdocklet-x11.c	Sun Nov 08 08:23:21 2009 +0000
@@ -34,6 +34,8 @@
 #include "gtkdocklet.h"
 #include <gdk/gdkkeysyms.h>
 
+#if !GTK_CHECK_VERSION(2,10,0)
+
 #define SHORT_EMBED_TIMEOUT 5000
 #define LONG_EMBED_TIMEOUT 15000
 
@@ -352,3 +354,6 @@
 	purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet/x11");
 	purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE);
 }
+
+#endif  /* !GTK_CHECK_VERSION(2,10,0) */
+
--- a/pidgin/gtkdocklet.h	Sun Nov 08 04:40:35 2009 +0000
+++ b/pidgin/gtkdocklet.h	Sun Nov 08 08:23:21 2009 +0000
@@ -49,7 +49,7 @@
 void pidgin_docklet_uninit(void);
 void*pidgin_docklet_get_handle(void);
 
-/* function in gtkdocklet-{x11,win32}.c */
+/* function in gtkdocklet-{gtk,x11,win32}.c */
 void docklet_ui_init(void);
 
 #endif /* _GTKDOCKLET_H_ */
--- a/pidgin/pidginstock.c	Sun Nov 08 04:40:35 2009 +0000
+++ b/pidgin/pidginstock.c	Sun Nov 08 08:23:21 2009 +0000
@@ -198,7 +198,10 @@
 	{ PIDGIN_STOCK_STATUS_LOGOUT,    "status",  "log-out.png",       TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, TRUE,  NULL },
 	{ PIDGIN_STOCK_STATUS_OFFLINE,   "status",  "offline.png",       TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, PIDGIN_STOCK_STATUS_OFFLINE_I  },
 	{ PIDGIN_STOCK_STATUS_PERSON,    "status",  "person.png",        TRUE, TRUE, TRUE,  TRUE,  TRUE,  FALSE, FALSE, NULL },
-	{ PIDGIN_STOCK_STATUS_MESSAGE,   "toolbar", "message-new.png",   TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL },
+	{ PIDGIN_STOCK_STATUS_MESSAGE,   "toolbar", "message-new.png",   TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, NULL }
+};
+
+const SizedStockIcon sized_tray_icons [] = {
 
 	{ PIDGIN_STOCK_TRAY_AVAILABLE, "tray", "tray-online.png",        FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
 	{ PIDGIN_STOCK_TRAY_INVISIBLE, "tray", "tray-invisible.png",     FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, NULL },
@@ -332,7 +335,8 @@
 
 static void
 add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, PidginIconTheme *theme,
-		const char *size, SizedStockIcon sized_icon, gboolean translucent)
+		const char *size, SizedStockIcon sized_icon, gboolean translucent,
+		gboolean size_wildcarded)
 {
 	char *filename;
 	GtkIconSource *source;
@@ -349,7 +353,7 @@
 	gtk_icon_source_set_direction(source, GTK_TEXT_DIR_LTR);
 	gtk_icon_source_set_direction_wildcarded(source, !sized_icon.rtl);
 	gtk_icon_source_set_size(source, sizeid);
-	gtk_icon_source_set_size_wildcarded(source, FALSE);
+	gtk_icon_source_set_size_wildcarded(source, size_wildcarded);
 	gtk_icon_source_set_state_wildcarded(source, TRUE);
 	gtk_icon_set_add_source(iconset, source);
 	gtk_icon_source_free(source);
@@ -359,7 +363,7 @@
 		gtk_icon_source_set_pixbuf(source, pixbuf);
 		gtk_icon_source_set_direction_wildcarded(source, TRUE);
 		gtk_icon_source_set_size(source, GTK_ICON_SIZE_MENU);
-		gtk_icon_source_set_size_wildcarded(source, FALSE);
+		gtk_icon_source_set_size_wildcarded(source, size_wildcarded);
 		gtk_icon_source_set_state_wildcarded(source, TRUE);
 		gtk_icon_set_add_source(iconset, source);
 		gtk_icon_source_free(source);
@@ -379,7 +383,7 @@
 		gtk_icon_source_set_filename(source, filename);
 		gtk_icon_source_set_direction(source, GTK_TEXT_DIR_RTL);
 		gtk_icon_source_set_size(source, sizeid);
-		gtk_icon_source_set_size_wildcarded(source, FALSE);
+		gtk_icon_source_set_size_wildcarded(source, size_wildcarded);
 		gtk_icon_source_set_state_wildcarded(source, TRUE);
 		gtk_icon_set_add_source(iconset, source);
 		g_free(filename);
@@ -435,9 +439,9 @@
 
 #define ADD_SIZED_ICON(name, size) \
 		if (sized_status_icons[i].name) { \
-			add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], FALSE); \
+			add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], FALSE, FALSE); \
 			if (sized_status_icons[i].translucent_name) \
-				add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], TRUE); \
+				add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], TRUE, FALSE); \
 		}
 		ADD_SIZED_ICON(microscopic, "11");
 		ADD_SIZED_ICON(extra_small, "16");
@@ -456,6 +460,35 @@
 		}
 	}
 
+	for (i = 0; i < G_N_ELEMENTS(sized_tray_icons); i++)
+	{
+		normal = gtk_icon_set_new();
+		if (sized_tray_icons[i].translucent_name)
+			translucent = gtk_icon_set_new();
+
+#define ADD_SIZED_ICON(name, size) \
+		if (sized_tray_icons[i].name) { \
+			add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_tray_icons[i], FALSE, TRUE); \
+			if (sized_tray_icons[i].translucent_name) \
+				add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_tray_icons[i], TRUE, TRUE); \
+		}
+		ADD_SIZED_ICON(microscopic, "11");
+		ADD_SIZED_ICON(extra_small, "16");
+		ADD_SIZED_ICON(small, "22");
+		ADD_SIZED_ICON(medium, "32");
+		ADD_SIZED_ICON(large, "48");
+		ADD_SIZED_ICON(huge, "64");
+#undef ADD_SIZED_ICON
+
+		gtk_icon_factory_add(icon_factory, sized_tray_icons[i].name, normal);
+		gtk_icon_set_unref(normal);
+
+		if (sized_tray_icons[i].translucent_name) {
+			gtk_icon_factory_add(icon_factory, sized_tray_icons[i].translucent_name, translucent);
+			gtk_icon_set_unref(translucent);
+		}
+	}
+
 	gtk_widget_destroy(win);
 	g_object_unref(G_OBJECT(icon_factory));
 	reload_settings();
@@ -527,7 +560,7 @@
 
 #define ADD_SIZED_ICON(name, size) \
 		if (sized_stock_icons[i].name) \
-			add_sized_icon(iconset, name, PIDGIN_ICON_THEME(theme), size, sized_stock_icons[i], FALSE);
+			add_sized_icon(iconset, name, PIDGIN_ICON_THEME(theme), size, sized_stock_icons[i], FALSE, FALSE);
 		ADD_SIZED_ICON(microscopic, "11");
 		ADD_SIZED_ICON(extra_small, "16");
 		ADD_SIZED_ICON(small, "22");
--- a/pidgin/pidginstock.h	Sun Nov 08 04:40:35 2009 +0000
+++ b/pidgin/pidginstock.h	Sun Nov 08 08:23:21 2009 +0000
@@ -161,7 +161,7 @@
 #endif
 
 /* Tray icons */
-#define PIDGIN_STOCK_TRAY_AVAILABLE       "pidgin-tray-available"
+#define PIDGIN_STOCK_TRAY_AVAILABLE       "pidgin-tray-online"
 #define PIDGIN_STOCK_TRAY_INVISIBLE	  "pidgin-tray-invisible"
 #define PIDGIN_STOCK_TRAY_AWAY	  	  "pidgin-tray-away"
 #define PIDGIN_STOCK_TRAY_BUSY            "pidgin-tray-busy"