[Galago-commits] r2446 - in trunk/notification-daemon: . src
themes/standard
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Fri Jan 20 00:00:25 PST 2006
Author: chipx86
Date: 2006-01-20 00:00:14 -0800 (Fri, 20 Jan 2006)
New Revision: 2446
Modified:
trunk/notification-daemon/ChangeLog
trunk/notification-daemon/src/daemon.c
trunk/notification-daemon/src/engines.c
trunk/notification-daemon/src/engines.h
trunk/notification-daemon/themes/standard/theme.c
Log:
- Add proper support for actions.
- Remove the action_invoked parameter to create_notification(), since we're already passing it to add_notification_action.
Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog 2006-01-20 07:45:19 UTC (rev 2445)
+++ trunk/notification-daemon/ChangeLog 2006-01-20 08:00:14 UTC (rev 2446)
@@ -1,3 +1,13 @@
+Thu Jan 19 23:59:42 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/daemon.c:
+ * src/engines.c:
+ * src/engines.h:
+ * themes/standard/theme.c:
+ - Add proper support for actions.
+ - Remove the action_invoked parameter to create_notification(), since
+ we're already passing it to add_notification_action.
+
Thu Jan 19 23:44:31 PST 2006 Christian Hammond <chipx86 at chipx86.com>
* src/daemon.c:
Modified: trunk/notification-daemon/src/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon.c 2006-01-20 07:45:19 UTC (rev 2445)
+++ trunk/notification-daemon/src/daemon.c 2006-01-20 08:00:14 UTC (rev 2446)
@@ -132,12 +132,8 @@
return g_object_new(NOTIFY_TYPE_DAEMON, NULL);
}
-/*
- *XXX The notify_widget thing needs to be replaced with some struct.
- */
-#if 0
static void
-_emit_action_invoked_signal(GObject *notify_widget, gchar *action)
+_action_invoked_cb(GtkWindow *nw, const char *key)
{
DBusConnection *con;
DBusError error;
@@ -161,15 +157,15 @@
"org.freedesktop.Notifications",
"ActionInvoked");
- dest = g_object_get_data(notify_widget, "_notify_sender");
- id = GPOINTER_TO_UINT(g_object_get_data(notify_widget, "_notify_id"));
+ dest = g_object_get_data(G_OBJECT(nw), "_notify_sender");
+ id = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id"));
g_assert(dest != NULL);
dbus_message_set_destination(message, dest);
dbus_message_append_args(message,
DBUS_TYPE_UINT32, &id,
- DBUS_TYPE_STRING, &action,
+ DBUS_TYPE_STRING, &key,
DBUS_TYPE_INVALID);
dbus_connection_send(con, message, NULL);
@@ -178,15 +174,8 @@
dbus_connection_unref(con);
}
}
-#endif
static void
-_action_invoked_cb(const char *key)
-{
- g_message("'%s' invoked", key);
-}
-
-static void
_emit_closed_signal(GObject *notify_widget)
{
DBusConnection *con;
@@ -519,18 +508,7 @@
return TRUE;
}
-#if 0
static void
-_notification_daemon_handle_bubble_widget_action(GtkWidget *b,
- GtkWindow *nw)
-{
- gchar *action = (gchar *)g_object_get_data(G_OBJECT(b), "_notify_action");
-
- _emit_action_invoked_signal(G_OBJECT(nw), action);
-}
-#endif
-
-static void
_notification_daemon_handle_bubble_widget_default(GtkWindow *nw,
GdkEventButton *button,
NotifyDaemon *daemon)
@@ -624,12 +602,6 @@
}
static void
-action_invoked_cb(GtkWindow *nw, const char *key)
-{
- printf("Action invoked: '%s'\n", key);
-}
-
-static void
url_clicked_cb(GtkWindow *nw, const char *url)
{
char *escaped_url;
@@ -702,7 +674,7 @@
}
else
{
- nw = theme_create_notification(action_invoked_cb, url_clicked_cb);
+ nw = theme_create_notification(url_clicked_cb);
}
theme_set_notification_text(nw, summary, body);
@@ -739,21 +711,6 @@
theme_add_notification_action(nw, l, actions[i],
G_CALLBACK(_action_invoked_cb));
-
-#if 0
- b = egg_notification_bubble_widget_create_button(nw, l);
-
- g_object_set_data_full(G_OBJECT(b),
- "_notify_action",
- g_strdup(actions[i]),
- (GDestroyNotify) g_free);
-
- g_signal_connect(b,
- "clicked",
- (GCallback)
- _notification_daemon_handle_bubble_widget_action,
- nw);
-#endif
}
if (use_pos_data)
Modified: trunk/notification-daemon/src/engines.c
===================================================================
--- trunk/notification-daemon/src/engines.c 2006-01-20 07:45:19 UTC (rev 2445)
+++ trunk/notification-daemon/src/engines.c 2006-01-20 08:00:14 UTC (rev 2446)
@@ -9,8 +9,7 @@
GModule *module;
guint ref_count;
- GtkWindow *(*create_notification)(ActionInvokedCb action_invoked_cb,
- UrlClickedCb url_clicked_cb);
+ GtkWindow *(*create_notification)(UrlClickedCb url_clicked_cb);
void (*destroy_notification)(GtkWindow *nw);
void (*show_notification)(GtkWindow *nw);
void (*hide_notification)(GtkWindow *nw);
@@ -147,12 +146,10 @@
}
GtkWindow *
-theme_create_notification(ActionInvokedCb action_invoked_cb,
- UrlClickedCb url_clicked_cb)
+theme_create_notification(UrlClickedCb url_clicked_cb)
{
ThemeEngine *engine = get_theme_engine();
- GtkWindow *nw = engine->create_notification(action_invoked_cb,
- url_clicked_cb);
+ GtkWindow *nw = engine->create_notification(url_clicked_cb);
g_object_set_data(G_OBJECT(nw), "_theme_engine", engine);
engine->ref_count++;
return nw;
Modified: trunk/notification-daemon/src/engines.h
===================================================================
--- trunk/notification-daemon/src/engines.h 2006-01-20 07:45:19 UTC (rev 2445)
+++ trunk/notification-daemon/src/engines.h 2006-01-20 08:00:14 UTC (rev 2446)
@@ -3,11 +3,9 @@
#include <gtk/gtk.h>
-typedef void (*ActionInvokedCb)(GtkWindow *nw, const char *key);
typedef void (*UrlClickedCb)(GtkWindow *nw, const char *url);
-GtkWindow *theme_create_notification(ActionInvokedCb action_invoked_cb,
- UrlClickedCb url_clicked_cb);
+GtkWindow *theme_create_notification(UrlClickedCb url_clicked_cb);
void theme_destroy_notification(GtkWindow *nw);
void theme_show_notification(GtkWindow *nw);
void theme_hide_notification(GtkWindow *nw);
Modified: trunk/notification-daemon/themes/standard/theme.c
===================================================================
--- trunk/notification-daemon/themes/standard/theme.c 2006-01-20 07:45:19 UTC (rev 2445)
+++ trunk/notification-daemon/themes/standard/theme.c 2006-01-20 08:00:14 UTC (rev 2446)
@@ -25,7 +25,6 @@
GdkRegion *window_region;
GHashTable *hints;
- ActionInvokedCb action_invoked;
UrlClickedCb url_clicked;
} WindowData;
@@ -81,8 +80,7 @@
}
GtkWindow *
-create_notification(ActionInvokedCb action_invoked,
- UrlClickedCb url_clicked)
+create_notification(UrlClickedCb url_clicked)
{
GtkWidget *win;
GtkWidget *main_vbox;
@@ -93,7 +91,6 @@
WindowData *windata;
windata = g_new0(WindowData, 1);
- windata->action_invoked = action_invoked;
windata->url_clicked = url_clicked;
win = gtk_window_new(GTK_WINDOW_POPUP);
@@ -247,9 +244,19 @@
gtk_widget_hide(windata->spacer);
}
+static void
+action_clicked_cb(GtkWidget *evbox, GdkEventButton *event,
+ ActionInvokedCb action_cb)
+{
+ GtkWindow *nw = g_object_get_data(G_OBJECT(evbox), "_nw");
+ const char *key = g_object_get_data(G_OBJECT(evbox), "_action_key");
+
+ action_cb(nw, key);
+}
+
void
add_notification_action(GtkWindow *nw, const char *text, const char *key,
- GCallback cb)
+ ActionInvokedCb cb)
{
/*
* TODO: Use SexyUrlLabel. This requires a way of disabling the
@@ -279,6 +286,12 @@
gdk_color_parse("white", &color);
gtk_widget_modify_bg(evbox, GTK_STATE_NORMAL, &color);
+ g_object_set_data(G_OBJECT(evbox), "_nw", nw);
+ g_object_set_data_full(G_OBJECT(evbox),
+ "_action_key", g_strdup(key), g_free);
+ g_signal_connect(G_OBJECT(evbox), "button-release-event",
+ G_CALLBACK(action_clicked_cb), cb);
+
cursor = gdk_cursor_new_for_display(gtk_widget_get_display(evbox),
GDK_HAND2);
gdk_window_set_cursor(evbox->window, cursor);
More information about the galago-commits
mailing list