diff options
author | Nick Schermer <nick@xfce.org> | 2010-02-26 14:08:18 +0100 |
---|---|---|
committer | Nick Schermer <nick@xfce.org> | 2010-02-26 14:11:40 +0100 |
commit | a10713891382c44625348647bc1ee49287964dc2 (patch) | |
tree | 788139c1c378a0511557acd8addc0c2e9f010c22 /common | |
parent | e8bf6d1e2e02b4d30f431f6d1f5007e9d7ebd00f (diff) | |
download | xfce4-panel-a10713891382c44625348647bc1ee49287964dc2.tar.gz |
Add a shared hash table for the panel properties.
The shared table is set during panel startup, the panel will load
all the properties and all (internal) plugin will use this table
during startup, which gives a nice performance boost.
Diffstat (limited to 'common')
-rw-r--r-- | common/panel-xfconf.c | 25 | ||||
-rw-r--r-- | common/panel-xfconf.h | 14 |
2 files changed, 32 insertions, 7 deletions
diff --git a/common/panel-xfconf.c b/common/panel-xfconf.c index bcf86a36..b2d89579 100644 --- a/common/panel-xfconf.c +++ b/common/panel-xfconf.c @@ -50,6 +50,11 @@ static void panel_properties_channel_destroyed (gpointer user_data, +/* shared table which is used to speed up the panel startup */ +static GHashTable *shared_hash_table = NULL; + + + static void panel_properties_object_notify (GObject *object, GParamSpec *pspec, @@ -166,6 +171,8 @@ panel_properties_bind (XfconfChannel *channel, /* get or ref the hash table */ if (G_LIKELY (hash_table != NULL)) g_hash_table_ref (hash_table); + else if (shared_hash_table != NULL) + hash_table = g_hash_table_ref (shared_hash_table); else hash_table = xfconf_channel_get_properties (channel, property_base); @@ -209,6 +216,22 @@ panel_properties_bind (XfconfChannel *channel, } /* cleanup */ - if (hash_table != NULL) + if (G_LIKELY (hash_table != NULL)) g_hash_table_unref (hash_table); } + + + +void +panel_properties_shared_hash_table (GHashTable *hash_table) +{ + /* release previous table */ + if (shared_hash_table != NULL) + g_hash_table_unref (shared_hash_table); + + /* set new table */ + if (hash_table != NULL) + shared_hash_table = g_hash_table_ref (hash_table); + else + shared_hash_table = NULL; +} diff --git a/common/panel-xfconf.h b/common/panel-xfconf.h index ed28c774..b192e86d 100644 --- a/common/panel-xfconf.h +++ b/common/panel-xfconf.h @@ -29,12 +29,14 @@ struct _PanelProperty GType type; }; -void panel_properties_bind (XfconfChannel *channel, - GObject *object, - const gchar *property_base, - const PanelProperty *properties, - GHashTable *hash_table); +void panel_properties_bind (XfconfChannel *channel, + GObject *object, + const gchar *property_base, + const PanelProperty *properties, + GHashTable *hash_table); -void panel_properties_unbind (GObject *object); +void panel_properties_unbind (GObject *object); + +void panel_properties_shared_hash_table (GHashTable *hash_table); #endif /* !__PANEL_XFCONF_H__ */ |