[Galago-commits] r2443 - in trunk/notification-daemon: . src themes/standard

galago-commits at freedesktop.org galago-commits at freedesktop.org
Thu Jan 19 23:24:15 PST 2006


Author: chipx86
Date: 2006-01-19 23:24:13 -0800 (Thu, 19 Jan 2006)
New Revision: 2443

Modified:
   trunk/notification-daemon/ChangeLog
   trunk/notification-daemon/src/daemon.c
   trunk/notification-daemon/themes/standard/theme.c
Log:
Add the beginnings of action support.


Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog	2006-01-20 06:34:29 UTC (rev 2442)
+++ trunk/notification-daemon/ChangeLog	2006-01-20 07:24:13 UTC (rev 2443)
@@ -1,3 +1,9 @@
+Thu Jan 19 23:23:55 PST 2006  Christian Hammond <chipx86 at chipx86.com>
+
+	* src/daemon.c:
+	* themes/standard/theme.c:
+	  - Add the beginnings of action support.
+
 Thu Jan 19 22:34:16 PST 2006  Christian Hammond <chipx86 at chipx86.com>
 
 	* data/Makefile.am:

Modified: trunk/notification-daemon/src/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon.c	2006-01-20 06:34:29 UTC (rev 2442)
+++ trunk/notification-daemon/src/daemon.c	2006-01-20 07:24:13 UTC (rev 2443)
@@ -36,6 +36,8 @@
 #include "engines.h"
 #include "notificationdaemon-dbus-glue.h"
 
+#define IMAGE_SIZE 48
+
 struct _NotifyTimeout
 {
 	GTimeVal expiration;
@@ -362,7 +364,8 @@
 	int n_channels;
 	gsize expected_len;
 	GdkPixbuf *pixbuf;
-	GValueArray *image_struct;GValue *value;
+	GValueArray *image_struct;
+	GValue *value;
 	GArray *tmp_array;
 
 	if (!G_VALUE_HOLDS(icon_data, G_TYPE_VALUE_ARRAY))
@@ -658,7 +661,6 @@
 	/*
 	 *XXX This needs to handle file URIs and all that.
 	 */
-	/* set_icon_from_data(nw, icon); */
 
 	/* deal with x, and y hints */
 	if ((data = (GValue *)g_hash_table_lookup(hints, "x")) != NULL)
@@ -724,7 +726,41 @@
 		if (data)
 			_notify_daemon_process_icon_data(daemon, nw, data);
 	}
+	else
+	{
+		GdkPixbuf *pixbuf;
 
+		if (!strncmp(icon, "file://", 7) || *icon == '/')
+		{
+			if (!strncmp(icon, "file://", 7))
+				icon += 7;
+
+			/* Load file */
+			pixbuf = gdk_pixbuf_new_from_file(icon, NULL);
+		}
+		else
+		{
+			/* Load icon theme icon */
+			GtkIconTheme *theme = gtk_icon_theme_new();
+			pixbuf = gtk_icon_theme_load_icon(theme, icon, IMAGE_SIZE,
+											  GTK_ICON_LOOKUP_USE_BUILTIN,
+											  NULL);
+			g_object_unref(G_OBJECT(theme));
+
+			if (pixbuf == NULL)
+			{
+				/* Well... maybe this is a file afterall. */
+				pixbuf = gdk_pixbuf_new_from_file(icon, NULL);
+			}
+		}
+
+		if (pixbuf != NULL)
+		{
+			theme_set_notification_icon(nw, pixbuf);
+			g_object_unref(G_OBJECT(pixbuf));
+		}
+	}
+
 	g_signal_connect(
 		G_OBJECT(nw), "button-release-event",
 		G_CALLBACK(_notification_daemon_handle_bubble_widget_default), daemon);

Modified: trunk/notification-daemon/themes/standard/theme.c
===================================================================
--- trunk/notification-daemon/themes/standard/theme.c	2006-01-20 06:34:29 UTC (rev 2442)
+++ trunk/notification-daemon/themes/standard/theme.c	2006-01-20 07:24:13 UTC (rev 2443)
@@ -10,13 +10,16 @@
 	GtkWidget *summary_label;
 	GtkWidget *body_label;
 	GtkWidget *actions_box;
+	GtkWidget *last_sep;
+
+	guint num_actions_added;
+
 	gboolean has_arrow;
 	int point_x;
 	int point_y;
 	GdkGC *gc;
 	GdkPoint arrow_points[7];
 	GdkRegion *window_region;
-
 	GHashTable *hints;
 } WindowData;
 
@@ -186,7 +189,7 @@
 	g_signal_connect(G_OBJECT(windata->body_label), "url_activated",
 					 G_CALLBACK(url_activated_cb), NULL);
 
-	windata->actions_box = gtk_hbox_new(FALSE, 6);
+	windata->actions_box = gtk_hbox_new(FALSE, 4);
 	gtk_widget_show(windata->actions_box);
 	gtk_box_pack_start(GTK_BOX(vbox), windata->actions_box, FALSE, TRUE, 0);
 
@@ -278,9 +281,51 @@
 }
 
 void
-add_notification_action(GtkWindow *nw, const char *label, const char *key,
+add_notification_action(GtkWindow *nw, const char *text, const char *key,
 						GCallback cb)
 {
+	/*
+	 * TODO: Use SexyUrlLabel. This requires a way of disabling the
+	 *       right-click menu.
+	 */
+	WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
+	GtkWidget *evbox;
+	GtkWidget *label;
+	GdkColor color;
+	GdkCursor *cursor;
+	char *buf;
+
+	g_assert(windata != NULL);
+
+	if (windata->num_actions_added > 0)
+	{
+		label = gtk_label_new("|");
+		gtk_widget_show(label);
+		gtk_box_pack_start(GTK_BOX(windata->actions_box), label,
+						    FALSE, FALSE, 0);
+	}
+
+	evbox = gtk_event_box_new();
+	gtk_widget_show(evbox);
+	gtk_box_pack_start(GTK_BOX(windata->actions_box), evbox, FALSE, FALSE, 0);
+	gtk_widget_realize(evbox);
+	gdk_color_parse("white", &color);
+	gtk_widget_modify_bg(evbox, GTK_STATE_NORMAL, &color);
+
+	cursor = gdk_cursor_new_for_display(gtk_widget_get_display(evbox),
+										GDK_HAND2);
+	gdk_window_set_cursor(evbox->window, cursor);
+	gdk_cursor_unref(cursor);
+
+	label = gtk_label_new(NULL);
+	gtk_widget_show(label);
+	gtk_container_add(GTK_CONTAINER(evbox), label);
+	buf = g_strdup_printf("<span color=\"blue\""
+						  " underline=\"single\">%s</span>", text);
+	gtk_label_set_markup(GTK_LABEL(label), buf);
+	g_free(buf);
+
+	windata->num_actions_added++;
 }
 
 static void



More information about the galago-commits mailing list