[gnome-panel] libpanel-applet: store factories in hash table



commit dca3101714da67adc08fc986a6355afada4bde15
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Nov 6 19:24:40 2014 +0200

    libpanel-applet: store factories in hash table

 libpanel-applet/panel-applet-factory.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/libpanel-applet/panel-applet-factory.c b/libpanel-applet/panel-applet-factory.c
index 63ffee2..4b32c78 100644
--- a/libpanel-applet/panel-applet-factory.c
+++ b/libpanel-applet/panel-applet-factory.c
@@ -44,11 +44,20 @@ struct _PanelAppletFactoryClass {
 
 G_DEFINE_TYPE (PanelAppletFactory, panel_applet_factory, G_TYPE_OBJECT)
 
+static GHashTable *factories = NULL;
+
 static void
 panel_applet_factory_finalize (GObject *object)
 {
        PanelAppletFactory *factory = PANEL_APPLET_FACTORY (object);
 
+       g_hash_table_remove (factories, factory->factory_id);
+
+       if (g_hash_table_size (factories) == 0) {
+               g_hash_table_unref (factories);
+               factories = NULL;
+       }
+
        if (factory->registration_id) {
                g_dbus_connection_unregister_object (factory->connection, factory->registration_id);
                factory->registration_id = 0;
@@ -108,6 +117,12 @@ panel_applet_factory_new (const gchar *factory_id,
        factory->applet_type = applet_type;
        factory->closure = g_closure_ref (closure);
 
+       if (factories == NULL) {
+               factories = g_hash_table_new (g_str_hash, g_str_equal);
+       }
+
+       g_hash_table_insert (factories, factory->factory_id, factory);
+
        return factory;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]