changeset 14169:4687f862a56b

[gaim-migrate @ 16819] Patch to eggtrayicon by Dan Winship makes icon transparent committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 17 Aug 2006 22:42:28 +0000
parents fa4fc7e5d93d
children b1ce2e9e494a
files COPYRIGHT ChangeLog plugins/docklet/eggtrayicon.c
diffstat 3 files changed, 48 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/COPYRIGHT	Thu Aug 17 21:16:50 2006 +0000
+++ b/COPYRIGHT	Thu Aug 17 22:42:28 2006 +0000
@@ -317,6 +317,7 @@
 Dan Willemsen
 Jason Willis
 Matt Wilson
+Dan Winship
 Scott Wolchok
 Pui Lam Wong
 Justin Wood
--- a/ChangeLog	Thu Aug 17 21:16:50 2006 +0000
+++ b/ChangeLog	Thu Aug 17 22:42:28 2006 +0000
@@ -99,6 +99,7 @@
 	  removed.
 	* 'Highlight when nick said' option added to Message Notification
 	  plugin.
+	* The system tray icon is now transparent (Dan Winship)
 
 	MSN Features:
 	* Custom smiley receiving support (Irving Cordova & Francesco Fracassi)
--- a/plugins/docklet/eggtrayicon.c	Thu Aug 17 21:16:50 2006 +0000
+++ b/plugins/docklet/eggtrayicon.c	Thu Aug 17 22:42:28 2006 +0000
@@ -54,6 +54,9 @@
 static void egg_tray_icon_realize   (GtkWidget *widget);
 static void egg_tray_icon_unrealize (GtkWidget *widget);
 
+static void egg_tray_icon_add (GtkContainer *container,
+                               GtkWidget *widget);
+
 static void egg_tray_icon_update_manager_window    (EggTrayIcon *icon,
 						    gboolean     dock_if_realized);
 static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon);
@@ -109,6 +112,7 @@
 {
   GObjectClass *gobject_class = (GObjectClass *)klass;
   GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
+  GtkContainerClass *container_class = (GtkContainerClass *)klass;
 
   parent_class = g_type_class_peek_parent (klass);
 
@@ -117,6 +121,8 @@
   widget_class->realize   = egg_tray_icon_realize;
   widget_class->unrealize = egg_tray_icon_unrealize;
 
+  container_class->add = egg_tray_icon_add;
+
   g_object_class_install_property (gobject_class,
 				   PROP_ORIENTATION,
 				   g_param_spec_enum ("orientation",
@@ -374,6 +380,36 @@
   egg_tray_icon_update_manager_window (icon, TRUE);
 }
 
+static gboolean
+transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
+{
+	gdk_window_clear_area (widget->window, event->area.x, event->area.y,
+	                      event->area.width, event->area.height);
+	return FALSE;
+}
+
+static void
+make_transparent_again (GtkWidget *widget, GtkStyle *previous_style,
+                       gpointer user_data)
+{
+	gdk_window_set_back_pixmap(widget->window, NULL, TRUE);
+}
+
+static void
+make_transparent (GtkWidget *widget, gpointer user_data)
+{
+	if (GTK_WIDGET_NO_WINDOW (widget) || GTK_WIDGET_APP_PAINTABLE (widget))
+		return;
+
+	gtk_widget_set_app_paintable (widget, TRUE);
+	gtk_widget_set_double_buffered (widget, FALSE);
+	gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+	g_signal_connect (widget, "expose_event",
+	                 G_CALLBACK (transparent_expose_event), NULL);
+	g_signal_connect_after (widget, "style_set",
+	                       G_CALLBACK (make_transparent_again), NULL);
+}
+
 static void
 egg_tray_icon_realize (GtkWidget *widget)
 {
@@ -386,6 +422,8 @@
   if (GTK_WIDGET_CLASS (parent_class)->realize)
     GTK_WIDGET_CLASS (parent_class)->realize (widget);
 
+  make_transparent (widget, NULL);
+
 #if GTK_CHECK_VERSION(2,1,0)
   screen = gdk_screen_get_number (gtk_widget_get_screen (widget));
   xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget));
@@ -425,6 +463,14 @@
 			 egg_tray_icon_manager_filter, icon);
 }
 
+static void
+egg_tray_icon_add (GtkContainer *container, GtkWidget *widget)
+{
+	g_signal_connect (widget, "realize",
+	                 G_CALLBACK (make_transparent), NULL);
+	GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
+}
+
 #if GTK_CHECK_VERSION(2,1,0)
 EggTrayIcon *
 egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)