[Galago-commits] r2429 - in trunk/notification-daemon: . src

galago-commits at freedesktop.org galago-commits at freedesktop.org
Sun Jan 15 14:53:47 PST 2006


Author: chipx86
Date: 2006-01-15 14:53:45 -0800 (Sun, 15 Jan 2006)
New Revision: 2429

Modified:
   trunk/notification-daemon/ChangeLog
   trunk/notification-daemon/src/engines.c
   trunk/notification-daemon/src/engines.h
Log:
- Save the engine used in the resulting notification window's object data. Use that engine for all future operations on that notification.
- Handle ref counting on notification engines so that they'll be properly when the time comes. As of right now, this won't happen.


Modified: trunk/notification-daemon/ChangeLog
===================================================================
--- trunk/notification-daemon/ChangeLog	2006-01-15 22:41:42 UTC (rev 2428)
+++ trunk/notification-daemon/ChangeLog	2006-01-15 22:53:45 UTC (rev 2429)
@@ -1,3 +1,13 @@
+Sun Jan 15 14:49:49 PST 2006  Christian Hammond <chipx86 at chipx86.com>
+
+	* src/engines.c:
+	* src/engines.h:
+	  - Save the engine used in the resulting notification window's
+	    object data. Use that engine for all future operations on that
+	    notification.
+	  - Handle ref counting on notification engines so that they'll be
+	    properly when the time comes. As of right now, this won't happen.
+
 Fri Jan 13 11:44:00 PST 2006  Christian Hammond <chipx86 at chipx86.com>
 
 	* src/engines.c:

Modified: trunk/notification-daemon/src/engines.c
===================================================================
--- trunk/notification-daemon/src/engines.c	2006-01-15 22:41:42 UTC (rev 2428)
+++ trunk/notification-daemon/src/engines.c	2006-01-15 22:53:45 UTC (rev 2429)
@@ -5,7 +5,7 @@
 	GModule *module;
 	guint ref_count;
 
-	gpointer (*create_notification)(void);
+	GtkWindow *(*create_notification)(void);
 	void (*destroy_notification)(GtkWindow *nw);
 	void (*show_notification)(GtkWindow *nw);
 	void (*hide_notification)(GtkWindow *nw);
@@ -65,6 +65,18 @@
 	return engine;
 }
 
+static void
+destroy_engine(ThemeEngine *engine)
+{
+	g_assert(engine->ref_count == 0);
+
+	if (active_engine == engine)
+		active_engine = NULL;
+
+	g_module_close(engine->module);
+	g_free(engine);
+}
+
 static ThemeEngine *
 get_theme_engine(void)
 {
@@ -78,64 +90,82 @@
 	return active_engine;
 }
 
-gpointer
+GtkWindow *
 theme_create_notification(void)
 {
-	return get_theme_engine()->create_notification();
+	ThemeEngine *engine = get_theme_engine();
+	GtkWindow *nw = engine->create_notification();
+	g_object_set_data(G_OBJECT(nw), "_theme_engine", engine);
+	engine->ref_count++;
+	return nw;
 }
 
 void
 theme_destroy_notification(GtkWindow *nw)
 {
-	get_theme_engine()->destroy_notification(nw);
+	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
 theme_show_notification(GtkWindow *nw)
 {
-	get_theme_engine()->show_notification(nw);
+	ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+	engine->show_notification(nw);
 }
 
 void
 theme_hide_notification(GtkWindow *nw)
 {
-	get_theme_engine()->hide_notification(nw);
+	ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+	engine->hide_notification(nw);
 }
 
 void
 theme_set_notification_hints(GtkWindow *nw, GHashTable *hints)
 {
-	get_theme_engine()->set_notification_hints(nw, hints);
+	ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+	engine->set_notification_hints(nw, hints);
 }
 
 void
 theme_set_notification_text(GtkWindow *nw, const char *summary,
 							const char *body)
 {
-	get_theme_engine()->set_notification_text(nw, summary, body);
+	ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+	engine->set_notification_text(nw, summary, body);
 }
 
 void
 theme_set_notification_icon(GtkWindow *nw, GdkPixbuf *pixbuf)
 {
-	get_theme_engine()->set_notification_icon(nw, pixbuf);
+	ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+	engine->set_notification_icon(nw, pixbuf);
 }
 
 void
 theme_set_notification_arrow(GtkWindow *nw, gboolean visible, int x, int y)
 {
-	get_theme_engine()->set_notification_arrow(nw, visible, x, y);
+	ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+	engine->set_notification_arrow(nw, visible, x, y);
 }
 
 void
 theme_add_notification_action(GtkWindow *nw, const char *label,
 							  const char *key, GCallback cb)
 {
-	get_theme_engine()->add_notification_action(nw, label, key, cb);
+	ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+	engine->add_notification_action(nw, label, key, cb);
 }
 
 void
 theme_move_notification(GtkWindow *nw, int x, int y)
 {
-	get_theme_engine()->move_notification(nw, x, y);
+	ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine");
+	engine->move_notification(nw, x, y);
 }

Modified: trunk/notification-daemon/src/engines.h
===================================================================
--- trunk/notification-daemon/src/engines.h	2006-01-15 22:41:42 UTC (rev 2428)
+++ trunk/notification-daemon/src/engines.h	2006-01-15 22:53:45 UTC (rev 2429)
@@ -3,7 +3,7 @@
 
 #include <gtk/gtk.h>
 
-gpointer theme_create_notification(void);
+GtkWindow *theme_create_notification(void);
 void theme_destroy_notification(GtkWindow *nw);
 void theme_show_notification(GtkWindow *nw);
 void theme_hide_notification(GtkWindow *nw);



More information about the galago-commits mailing list