[Galago-commits] r2512 - in trunk/notification-daemon: . src
themes/standard
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sun Jan 29 13:07:49 PST 2006
Author: chipx86
Date: 2006-01-29 13:07:46 -0800 (Sun, 29 Jan 2006)
New Revision: 2512
Modified:
trunk/notification-daemon/ChangeLog
trunk/notification-daemon/src/daemon.c
trunk/notification-daemon/src/engines.c
trunk/notification-daemon/themes/standard/theme.c
Log:
- Patch by Michael Vogt and modified a bit by me to add a close button to notifications. This is similar to the one used in Ubuntu Dapper, with a small placement change and functionality change: the notification no longer emits the ActionInvoked for the default action when closed. This closes ticket #8.
- Moved data freeing for the standard theme and for theme engine unreffing out of the close functions and into a callback specified through g_object_set_data_full().
- The daemon now listens for when notification windows are destroyed, and reacts appropriately, instead of crashing.
Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog 2006-01-29 20:16:33 UTC (rev 2511)
+++ trunk/notification-daemon/ChangeLog 2006-01-29 21:07:46 UTC (rev 2512)
@@ -1,3 +1,19 @@
+Sun Jan 29 13:03:09 PST 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * src/daemon.c:
+ * src/engines.c:
+ * themes/standard/theme.c:
+ - Patch by Michael Vogt and modified a bit by me to add a close
+ button to notifications. This is similar to the one used in Ubuntu
+ Dapper, with a small placement change and functionality change: the
+ notification no longer emits the ActionInvoked for the default action
+ when closed. This closes ticket #8.
+ - Moved data freeing for the standard theme and for theme engine
+ unreffing out of the close functions and into a callback specified
+ through g_object_set_data_full().
+ - The daemon now listens for when notification windows are destroyed,
+ and reacts appropriately, instead of crashing.
+
Sun Jan 29 12:12:43 PST 2006 Christian Hammond <chipx86 at chipx86.com>
* configure.ac:
Modified: trunk/notification-daemon/src/daemon.c
===================================================================
--- trunk/notification-daemon/src/daemon.c 2006-01-29 20:16:33 UTC (rev 2511)
+++ trunk/notification-daemon/src/daemon.c 2006-01-29 21:07:46 UTC (rev 2512)
@@ -230,7 +230,7 @@
}
static void
-_close_notification(NotifyDaemon *daemon, guint id)
+_close_notification(NotifyDaemon *daemon, guint id, gboolean hide_notification)
{
NotifyDaemonPrivate *priv = daemon->priv;
NotifyTimeout *nt;
@@ -241,11 +241,22 @@
{
_emit_closed_signal(G_OBJECT(nt->nw));
- theme_hide_notification(nt->nw);
+ if (hide_notification)
+ theme_hide_notification(nt->nw);
+
g_hash_table_remove(priv->notification_hash, &id);
}
}
+static void
+_notification_destroyed_cb(GtkWindow *nw, NotifyDaemon *daemon)
+{
+ _close_notification(
+ daemon,
+ GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id")),
+ FALSE);
+}
+
static gboolean
_is_expired(gpointer key, gpointer value, gpointer data)
{
@@ -525,8 +536,10 @@
_action_invoked_cb(nw, "default");
- _close_notification(daemon,
- GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id")));
+ _close_notification(
+ daemon,
+ GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id")),
+ TRUE);
}
static gboolean
@@ -818,6 +831,11 @@
nw = theme_create_notification(url_clicked_cb);
g_object_set_data(G_OBJECT(nw), "_notify_daemon", daemon);
new_notification = TRUE;
+
+ g_signal_connect(G_OBJECT(nw), "button-release-event",
+ G_CALLBACK(window_clicked_cb), daemon);
+ g_signal_connect(G_OBJECT(nw), "destroy",
+ G_CALLBACK(_notification_destroyed_cb), daemon);
}
theme_set_notification_text(nw, summary, body);
@@ -929,10 +947,6 @@
}
}
- g_signal_connect(G_OBJECT(nw), "button-release-event",
- G_CALLBACK(window_clicked_cb), daemon);
-
-
if (!screensaver_active(GTK_WIDGET(nw)) &&
!fullscreen_window_exists(GTK_WIDGET(nw)))
{
@@ -965,7 +979,7 @@
notify_daemon_close_notification_handler(NotifyDaemon *daemon,
guint id, GError ** error)
{
- _close_notification(daemon, id);
+ _close_notification(daemon, id, TRUE);
return TRUE;
}
Modified: trunk/notification-daemon/src/engines.c
===================================================================
--- trunk/notification-daemon/src/engines.c 2006-01-29 20:16:33 UTC (rev 2511)
+++ trunk/notification-daemon/src/engines.c 2006-01-29 21:07:46 UTC (rev 2512)
@@ -39,7 +39,6 @@
path = g_build_filename(ENGINES_DIR, filename, NULL);
g_free(filename);
- printf("Loading path '%s'\n", path);
engine = g_new0(ThemeEngine, 1);
engine->ref_count = 1;
engine->module = g_module_open(path, G_MODULE_BIND_LAZY);
@@ -145,12 +144,22 @@
return active_engine;
}
+static void
+theme_engine_unref(ThemeEngine *engine)
+{
+ engine->ref_count--;
+
+ if (engine->ref_count == 0)
+ destroy_engine(engine);
+}
+
GtkWindow *
theme_create_notification(UrlClickedCb url_clicked_cb)
{
ThemeEngine *engine = get_theme_engine();
GtkWindow *nw = engine->create_notification(url_clicked_cb);
- g_object_set_data(G_OBJECT(nw), "_theme_engine", engine);
+ g_object_set_data_full(G_OBJECT(nw), "_theme_engine", engine,
+ (GDestroyNotify)theme_engine_unref);
engine->ref_count++;
return nw;
}
@@ -160,11 +169,6 @@
{
ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
engine->destroy_notification(nw);
-
- engine->ref_count--;
-
- if (engine->ref_count == 0)
- destroy_engine(engine);
}
void
Modified: trunk/notification-daemon/themes/standard/theme.c
===================================================================
--- trunk/notification-daemon/themes/standard/theme.c 2006-01-29 20:16:33 UTC (rev 2511)
+++ trunk/notification-daemon/themes/standard/theme.c 2006-01-29 21:07:46 UTC (rev 2512)
@@ -82,13 +82,29 @@
return FALSE;
}
+static void
+destroy_windata(WindowData *windata)
+{
+ if (windata->gc != NULL)
+ g_object_unref(G_OBJECT(windata->gc));
+
+ if (windata->border_points != NULL)
+ g_free(windata->border_points);
+
+ if (windata->window_region != NULL)
+ gdk_region_destroy(windata->window_region);
+}
+
GtkWindow *
create_notification(UrlClickedCb url_clicked)
{
GtkWidget *win;
GtkWidget *main_vbox;
GtkWidget *hbox;
+ GtkWidget *hbox2;
GtkWidget *vbox;
+ GtkWidget *close_button;
+ GtkWidget *image;
GtkRequisition req;
WindowData *windata;
@@ -97,7 +113,8 @@
win = gtk_window_new(GTK_WINDOW_POPUP);
gtk_widget_add_events(win, GDK_BUTTON_RELEASE_MASK);
- g_object_set_data(G_OBJECT(win), "windata", windata);
+ g_object_set_data_full(G_OBJECT(win), "windata", windata,
+ (GDestroyNotify)destroy_windata);
gtk_widget_set_app_paintable(win, TRUE);
g_signal_connect(G_OBJECT(win), "expose-event",
@@ -143,12 +160,30 @@
gtk_container_add(GTK_CONTAINER(windata->contentbox), vbox);
gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
+ hbox2 = gtk_hbox_new(FALSE, 6);
+ gtk_widget_show(hbox2);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);
+
windata->summary_label = gtk_label_new(NULL);
gtk_widget_show(windata->summary_label);
- gtk_box_pack_start(GTK_BOX(vbox), windata->summary_label, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox2), windata->summary_label, TRUE, TRUE, 0);
gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0);
gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE);
+ /* Add the close button */
+ close_button = gtk_button_new();
+ gtk_widget_show(close_button);
+ gtk_box_pack_start(GTK_BOX(hbox2), close_button, FALSE, FALSE, 0);
+ gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE);
+ gtk_container_set_border_width(GTK_CONTAINER(close_button), 0);
+ gtk_widget_set_size_request(close_button, 20, 20);
+ g_signal_connect_swapped(G_OBJECT(close_button), "clicked",
+ G_CALLBACK(gtk_widget_destroy), win);
+
+ image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ gtk_widget_show(image);
+ gtk_container_add(GTK_CONTAINER(close_button), image);
+
windata->body_label = sexy_url_label_new();
gtk_widget_show(windata->body_label);
gtk_box_pack_start(GTK_BOX(vbox), windata->body_label, TRUE, TRUE, 0);
@@ -170,18 +205,6 @@
void
destroy_notification(GtkWindow *nw)
{
- WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");
- g_assert(windata != NULL);
-
- if (windata->gc != NULL)
- g_object_unref(G_OBJECT(windata->gc));
-
- if (windata->border_points != NULL)
- g_free(windata->border_points);
-
- if (windata->window_region != NULL)
- gdk_region_destroy(windata->window_region);
-
gtk_widget_destroy(GTK_WIDGET(nw));
}
More information about the galago-commits
mailing list