changeset 6894:c2fb9192377b

[gaim-migrate @ 7441] robot101: instead of blinking between the one with the envelope, and the one without, it's going to blink between blank and the one with the envelope committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Fri, 19 Sep 2003 23:18:40 +0000
parents 126e123bf065
children 847d899a5724
files pixmaps/gaim_blank_4bit_16.ico plugins/docklet/docklet-win32.c plugins/docklet/docklet-x11.c plugins/docklet/docklet.c plugins/docklet/docklet.h src/win32/gaimrc.rc src/win32/resource.h
diffstat 7 files changed, 62 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
Binary file pixmaps/gaim_blank_4bit_16.ico has changed
--- a/plugins/docklet/docklet-win32.c	Fri Sep 19 15:54:45 2003 +0000
+++ b/plugins/docklet/docklet-win32.c	Fri Sep 19 23:18:40 2003 +0000
@@ -55,6 +55,7 @@
 static HICON sysicon_away=0;
 static HICON sysicon_pend=0;
 static HICON sysicon_awypend=0;
+static HICON sysicon_blank=0;
 static NOTIFYICONDATA wgaim_nid;
 
 
@@ -151,9 +152,11 @@
 static void systray_change_icon(HICON icon, char* text) {
 	char *locenc=NULL;
 	wgaim_nid.hIcon = icon;
-	locenc = g_locale_from_utf8(text, -1, NULL, NULL, NULL);
-	lstrcpy(wgaim_nid.szTip, locenc);
-	g_free(locenc);
+        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);
 }
 
@@ -184,6 +187,10 @@
 	}
 }
 
+static void wgaim_tray_blank_icon() {
+        systray_change_icon(sysicon_blank, NULL);
+}
+
 static void wgaim_tray_create() {
 	/* dummy window to process systray messages */
 	systray_hwnd = systray_create_hiddenwin();
@@ -194,6 +201,7 @@
 	sysicon_away = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAY_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
 	sysicon_pend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_PEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
 	sysicon_awypend = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_AWAYPEND_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
+	sysicon_blank = (HICON)LoadImage(wgaim_hinstance(), MAKEINTRESOURCE(GAIM_BLANK_TRAY_ICON), IMAGE_ICON, 16, 16, 0);
 
 	/* Create icon in systray */
 	systray_init_icon(systray_hwnd, sysicon_disconn);
@@ -210,7 +218,8 @@
 {
 	wgaim_tray_create,
 	wgaim_tray_destroy,
-	wgaim_tray_update_icon
+	wgaim_tray_update_icon,
+        wgaim_tray_blank_icon
 };
 
 /* Used by docklet's plugin load func */
--- a/plugins/docklet/docklet-x11.c	Fri Sep 19 15:54:45 2003 +0000
+++ b/plugins/docklet/docklet-x11.c	Fri Sep 19 23:18:40 2003 +0000
@@ -36,6 +36,7 @@
 /* globals */
 static EggTrayIcon *docklet = NULL;
 static GtkWidget *image = NULL;
+static GdkPixbuf *blank_icon = NULL;
 
 /* protos */
 static void docklet_x11_create();
@@ -109,6 +110,20 @@
 }
 
 static void
+docklet_x11_blank_icon()
+{
+	if (!blank_icon) {
+		gint width, height;
+
+		gtk_icon_size_lookup(GTK_ICON_SIZE_LARGE_TOOLBAR, &width, &height);
+		blank_icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+		gdk_pixbuf_fill(blank_icon, 0);
+	}
+
+	gtk_image_set_from_pixbuf(GTK_IMAGE(image), blank_icon);
+}
+
+static void
 docklet_x11_destroy()
 {
 	docklet_remove(GTK_WIDGET_VISIBLE(docklet));
@@ -119,6 +134,10 @@
 	g_object_unref(G_OBJECT(docklet));
 	docklet = NULL;
 
+	if (blank_icon)
+		g_object_unref(G_OBJECT(blank_icon));
+	blank_icon = NULL;
+
 	gaim_debug(GAIM_DEBUG_INFO, "tray icon", "destroyed\n");
 }
 
@@ -157,7 +176,8 @@
 {
 	docklet_x11_create,
 	docklet_x11_destroy,
-	docklet_x11_update_icon
+	docklet_x11_update_icon,
+	docklet_x11_blank_icon
 };
 
 void
--- a/plugins/docklet/docklet.c	Fri Sep 19 15:54:45 2003 +0000
+++ b/plugins/docklet/docklet.c	Fri Sep 19 23:18:40 2003 +0000
@@ -84,7 +84,7 @@
 }
 
 #ifdef _WIN32
-/* This is a workaround for a bug in windows GTK+.. Clicking outside of the
+/* This is a workaround for a bug in windows GTK+. Clicking outside of the
    menu does not get rid of it, so instead we get rid of it as soon as the
    pointer leaves the menu. */
 static gboolean
@@ -197,36 +197,30 @@
 docklet_blink_icon()
 {
 	static gboolean blinked = FALSE;
-	enum docklet_status icon = status;
 
 	blinked = !blinked;
 
-	if (status == online_pending) {
-		if (blinked) {
-			/* last icon was the right one... let's change it */
-			icon = online;
-		} else {
-			/* last icon was the wrong one, change it back */
-			icon = online_pending;
-		}
-	} else if (status == away_pending) {
-		if (blinked) {
-			/* last icon was the right one... let's change it */
-			icon = away;
-		} else {
-			/* last icon was the wrong one, change it back */
-			icon = away_pending;
-		}
-	} else {
-		/* no messages, stop blinking */
-		blinked = FALSE;
-		return FALSE;
+	switch (status) {
+		case online_pending:
+		case away_pending:
+			if (blinked) {
+				if (ui_ops && ui_ops->blank_icon)
+					ui_ops->blank_icon();
+			} else {
+				if (ui_ops && ui_ops->update_icon)
+					ui_ops->update_icon(status);
+			}
+			return TRUE; /* keep blinking */
+			break;
+		case offline:
+		case offline_connecting:
+		case online:
+		case online_connecting:
+		case away:
+			blinked = FALSE;
+			return FALSE; /* no more blinking */
+			break;
 	}
-
-	if (ui_ops->update_icon)
-		ui_ops->update_icon(icon);
-
-	return TRUE; /* keep blinking */
 }
 
 static gboolean
@@ -260,7 +254,7 @@
 
 	/* update the icon if we changed status */
 	if (status != oldstatus) {
-		if (ui_ops->update_icon)
+		if (ui_ops && ui_ops->update_icon)
 			ui_ops->update_icon(status);
 
 		/* and schedule the blinker function if messages are pending */
@@ -327,7 +321,7 @@
 	gaim_gtk_blist_docklet_add();
 
 	docklet_update_status();
-	if (ui_ops->update_icon)
+	if (ui_ops && ui_ops->update_icon)
 		ui_ops->update_icon(status);
 }
 
@@ -428,7 +422,7 @@
 	handle = plugin;
 
 	docklet_ui_init();
-	if (ui_ops->create)
+	if (ui_ops && ui_ops->create)
 		ui_ops->create();
 
 	gaim_signal_connect(conn_handle, "signed-on",
@@ -455,7 +449,7 @@
 static gboolean
 plugin_unload(GaimPlugin *plugin)
 {
-	if (ui_ops->destroy)
+	if (ui_ops && ui_ops->destroy)
 		ui_ops->destroy();
 
 	/* XXX: do this while gaim has no other way to toggle the global mute */
--- a/plugins/docklet/docklet.h	Fri Sep 19 15:54:45 2003 +0000
+++ b/plugins/docklet/docklet.h	Fri Sep 19 23:18:40 2003 +0000
@@ -41,6 +41,7 @@
 	void (*create)();
 	void (*destroy)();
 	void (*update_icon)(enum docklet_status);
+	void (*blank_icon)();
 };
 
 /* useful for setting idle callbacks that will be cleaned up */
--- a/src/win32/gaimrc.rc	Fri Sep 19 15:54:45 2003 +0000
+++ b/src/win32/gaimrc.rc	Fri Sep 19 23:18:40 2003 +0000
@@ -6,3 +6,4 @@
 GAIM_AWAY_TRAY_ICON	ICON "../pixmaps/gaim_away_4bit_16.ico"
 GAIM_PEND_TRAY_ICON	ICON "../pixmaps/gaim_msgunread_4bit_16.ico"
 GAIM_AWAYPEND_TRAY_ICON ICON "../pixmaps/gaim_msgpend_4bit_16.ico"
+GAIM_BLANK_TRAY_ICON	ICON "../pixmaps/gaim_blank_4bit_16.ico"
--- a/src/win32/resource.h	Fri Sep 19 15:54:45 2003 +0000
+++ b/src/win32/resource.h	Fri Sep 19 23:18:40 2003 +0000
@@ -6,3 +6,4 @@
 #define GAIM_AWAY_TRAY_ICON             109
 #define GAIM_PEND_TRAY_ICON             110
 #define GAIM_AWAYPEND_TRAY_ICON         111
+#define GAIM_BLANK_TRAY_ICON            112