[PATCH] shared GConfClient
- From: Rodrigo Moya <rodrigo novell com>
- To: Control Center List <gnomecc-list gnome org>
- Subject: [PATCH] shared GConfClient
- Date: Sun, 16 Oct 2005 00:38:40 +0200
Hi
Another possible improvement is via the use of a shared GConfClient,
that is around during the entire lifetime of the settings daemon,
instead of get_default/_unref all the time.
As with all performance patches, this will be only committed, for the
time being, to HEAD.
Any comments?
--
Rodrigo Moya <rodrigo novell com>
? org.gnome.SettingsDaemon.desktop-service
? org.gnome.SettingsDaemon.service
? org.gnome.SettingsDaemon.service.in
? performance-patch.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/ChangeLog,v
retrieving revision 1.194
diff -u -p -r1.194 ChangeLog
--- ChangeLog 15 Oct 2005 21:56:43 -0000 1.194
+++ ChangeLog 15 Oct 2005 22:35:31 -0000
@@ -1,3 +1,34 @@
+2005-10-16 Rodrigo Moya <rodrigo novell com>
+
+ * factory.c: declare a global GConfClient.
+ (main): unref the global GConfClient.
+
+ * gnome-settings-daemon.[ch] (gnome_settings_daemon_get_conf_client):
+ new function to use the same GConfClient everywhere.
+ (gnome_settings_daemon_new): use the global GConfClient.
+
+ * gnome-settings-accessibility-keyboard.c (set_server_from_gconf,
+ ax_response_callback, set_gconf_from_server):
+ * gnome-settings-gtk1theme.c (apply_settings):
+ * gnome-settings-keybindings.c (bindings_get_entry):
+ * gnome-settings-keyboard.c (numlock_get_gconf_state,
+ numlock_set_gconf_state, apply_settings):
+ * gnome-settings-keyboard-xkb.c (apply_xkb_settings,
+ gnome_settings_keyboard_xkb_sysconfig_changed_response,
+ gnome_settings_keyboard_xkb_analyze_sysconfig,
+ gnome_settings_chk_file_list):
+ * gnome-settings-screensaver.c (key_toggled_cb,
+ really_start_screensaver):
+ * gnome-settings-sound.c (apply_settings):
+ * gnome-settings-xmodmap.c (check_button_callback,
+ gnome_settings_load_modmap_files, remove_button_clicked_callback,
+ load_button_clicked_callback, gnome_settings_modmap_dialog_call):
+ * gnome-settings-xsettings.c (xft_callback):
+ use the global GConfClient.
+
+ * gnome-settings-keyboard-xkb.c (gnome_settings_keyboard_xkb_load):
+ don't get another GConfClient when we're getting one passed!
+
2005-10-14 Rodrigo Moya <rodrigo novell com>
* gnome-settings-daemon.c (child_watch_cb): added this function to
Index: factory.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/factory.c,v
retrieving revision 1.11
diff -u -p -r1.11 factory.c
--- factory.c 15 Oct 2005 21:56:43 -0000 1.11
+++ factory.c 15 Oct 2005 22:35:31 -0000
@@ -13,6 +13,7 @@
#include <libgnomeui/gnome-client.h>
static BonoboObject *services_server = NULL;
+GConfClient *conf_client = NULL;
int main (int argc, char *argv [])
{
@@ -56,6 +57,10 @@ int main (int argc, char *argv [])
G_CALLBACK (gtk_main_quit), NULL);
gtk_main();
+
+ /* cleanup */
+ if (conf_client)
+ g_object_unref (conf_client);
return -1;
}
Index: gnome-settings-accessibility-keyboard.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-accessibility-keyboard.c,v
retrieving revision 1.33
diff -u -p -r1.33 gnome-settings-accessibility-keyboard.c
--- gnome-settings-accessibility-keyboard.c 25 Jul 2005 13:25:34 -0000 1.33
+++ gnome-settings-accessibility-keyboard.c 15 Oct 2005 22:35:31 -0000
@@ -158,9 +158,9 @@ set_ctrl_from_gconf (XkbDescRec *desc, G
static void
set_server_from_gconf (GConfEntry *ignored)
{
- GConfClient *client = gconf_client_get_default ();
XkbDescRec *desc;
gboolean enable_accessX;
+ GConfClient *client = gnome_settings_daemon_get_conf_client ();
desc = get_xkb_desc_rec ();
if (!desc) {
@@ -283,8 +283,6 @@ set_server_from_gconf (GConfEntry *ignor
XSync (GDK_DISPLAY (), FALSE);
gdk_error_trap_pop ();
-
- g_object_unref (client);
}
static gboolean
@@ -299,7 +297,7 @@ ax_response_callback (gint response_id,
case GTK_RESPONSE_REJECT:
case GTK_RESPONSE_CANCEL:
{
- GConfClient *client = gconf_client_get_default ();
+ GConfClient *client = gnome_settings_daemon_get_conf_client ();
/* we're reverting, so we invert sense of 'enabled' flag */
d ("cancelling AccessX request");
@@ -420,7 +418,7 @@ static void
set_gconf_from_server (GConfEntry *ignored)
{
gboolean in_gconf;
- GConfClient *client = gconf_client_get_default ();
+ GConfClient *client = gnome_settings_daemon_get_conf_client ();
GConfChangeSet *cs = gconf_change_set_new ();
XkbDescRec *desc = get_xkb_desc_rec ();
gboolean changed = FALSE, slowkeys_changed, stickykeys_changed;
@@ -520,7 +518,6 @@ set_gconf_from_server (GConfEntry *ignor
gconf_client_suggest_sync (client, NULL);
}
gconf_change_set_unref (cs);
- g_object_unref (client);
}
static GdkFilterReturn
Index: gnome-settings-daemon.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-daemon.c,v
retrieving revision 1.38
diff -u -p -r1.38 gnome-settings-daemon.c
--- gnome-settings-daemon.c 15 Oct 2005 21:56:43 -0000 1.38
+++ gnome-settings-daemon.c 15 Oct 2005 22:35:31 -0000
@@ -334,7 +334,7 @@ gnome_settings_daemon_new (void)
/* We use GConfClient not GConfClient because a cache isn't useful
* for us
*/
- client = gconf_client_get_default ();
+ client = gnome_settings_daemon_get_conf_client ();
/* gnome_settings_disk_init (client);*/
gnome_settings_font_init (client);
@@ -410,8 +410,6 @@ gnome_settings_daemon_new (void)
gnome_settings_xrdb_load (client);
gnome_settings_typing_break_load (client);
- g_object_unref (client);
-
return G_OBJECT (daemon);
}
@@ -535,4 +533,15 @@ gnome_settings_daemon_spawn_with_input (
}
g_child_watch_add (child_pid, (GChildWatchFunc) child_watch_cb, command);
+}
+
+extern GConfClient *conf_client;
+
+GConfClient *
+gnome_settings_daemon_get_conf_client (void)
+{
+ if (!conf_client)
+ conf_client = gconf_client_get_default ();
+
+ return conf_client;
}
Index: gnome-settings-daemon.h
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-daemon.h,v
retrieving revision 1.7
diff -u -p -r1.7 gnome-settings-daemon.h
--- gnome-settings-daemon.h 22 May 2005 15:46:43 -0000 1.7
+++ gnome-settings-daemon.h 15 Oct 2005 22:35:31 -0000
@@ -69,6 +69,8 @@ GObject *gnome_settings_daemon_new
void gnome_settings_daemon_spawn_with_input (char **argv,
const char *input);
+GConfClient *gnome_settings_daemon_get_conf_client (void);
+
G_END_DECLS
#endif /* __GNOME_SETTINGS_DAEMON_H */
Index: gnome-settings-gtk1theme.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-gtk1theme.c,v
retrieving revision 1.3
diff -u -p -r1.3 gnome-settings-gtk1theme.c
--- gnome-settings-gtk1theme.c 21 Oct 2004 19:41:26 -0000 1.3
+++ gnome-settings-gtk1theme.c 15 Oct 2005 22:35:31 -0000
@@ -146,7 +146,7 @@ check_filename (char *base_dir,
static void
apply_settings (void)
{
- GConfClient *client = gconf_client_get_default ();
+ GConfClient *client = gnome_settings_daemon_get_conf_client ();
gchar *current_theme;
gchar *theme_filename;
gchar *rc_filename;
@@ -202,8 +202,7 @@ apply_settings (void)
if (write_contents (rc_filename, new_contents))
send_change_message ();
}
-
- g_object_unref (client);
+
g_free (new_contents);
g_free (current_contents);
g_free (rc_filename);
Index: gnome-settings-keybindings.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-keybindings.c,v
retrieving revision 1.10
diff -u -p -r1.10 gnome-settings-keybindings.c
--- gnome-settings-keybindings.c 22 May 2005 15:46:43 -0000 1.10
+++ gnome-settings-keybindings.c 15 Oct 2005 22:35:31 -0000
@@ -178,7 +178,7 @@ bindings_get_entry (char *subdir)
char *gconf_key;
char *action = NULL;
char *key = NULL;
- GConfClient *client = gconf_client_get_default();
+ GConfClient *client = gnome_settings_daemon_get_conf_client ();
g_return_val_if_fail (subdir != NULL, FALSE);
@@ -190,7 +190,6 @@ bindings_get_entry (char *subdir)
/* Get entries for this binding */
list = gconf_client_all_entries (client, subdir, NULL);
- g_object_unref (client);
for (li = list; li != NULL; li = li->next)
{
Index: gnome-settings-keyboard-xkb.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-keyboard-xkb.c,v
retrieving revision 1.34
diff -u -p -r1.34 gnome-settings-keyboard-xkb.c
--- gnome-settings-keyboard-xkb.c 26 Jul 2005 20:38:24 -0000 1.34
+++ gnome-settings-keyboard-xkb.c 15 Oct 2005 22:35:31 -0000
@@ -146,9 +146,8 @@ apply_xkb_settings (void)
if (!initedOk)
return;
- confClient = gconf_client_get_default ();
+ confClient = gnome_settings_daemon_get_conf_client ();
GSwitchItKbdConfigInit (¤tSysKbdConfig, confClient);
- g_object_unref (confClient);
GSwitchItKbdConfigLoadFromGConf (¤tKbdConfig, &initialSysKbdConfig);
@@ -180,7 +179,7 @@ gnome_settings_keyboard_xkb_sysconfig_ch
gboolean dontShowAgain = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (g_object_get_data (G_OBJECT (dialog), "chkDontShowAgain")));
- confClient = gconf_client_get_default ();
+ confClient = gnome_settings_daemon_get_conf_client ();
switch (what2do) {
case RESPONSE_USE_X:
@@ -196,8 +195,6 @@ gnome_settings_keyboard_xkb_sysconfig_ch
gconf_client_set_bool (confClient, DISABLE_SYSCONF_CHANGED_WARNING_KEY, TRUE, NULL);
gtk_widget_destroy (GTK_WIDGET (dialog));
-
- g_object_unref (confClient);
}
static void
@@ -209,11 +206,10 @@ gnome_settings_keyboard_xkb_analyze_sysc
if (!initedOk)
return;
- confClient = gconf_client_get_default ();
+ confClient = gnome_settings_daemon_get_conf_client ();
GSwitchItKbdConfigInit (&backupGConfKbdConfig, confClient);
GSwitchItKbdConfigInit (&initialSysKbdConfig, confClient);
dontShow = gconf_client_get_bool (confClient, DISABLE_SYSCONF_CHANGED_WARNING_KEY, NULL);
- g_object_unref (confClient);
GSwitchItKbdConfigLoadFromGConfBackup (&backupGConfKbdConfig);
GSwitchItKbdConfigLoadFromXInitial (&initialSysKbdConfig);
@@ -275,7 +271,7 @@ gnome_settings_chk_file_list (void)
GSList *tmp = NULL;
GSList *tmp_l = NULL;
gboolean new_file_exist = FALSE;
- GConfClient *confClient = gconf_client_get_default ();
+ GConfClient *confClient = gnome_settings_daemon_get_conf_client ();
homeDir = g_dir_open (g_get_home_dir (), 0, NULL);
while ((fname = g_dir_read_name (homeDir)) != NULL) {
@@ -316,8 +312,6 @@ gnome_settings_chk_file_list (void)
g_slist_foreach (last_login_file_list, (GFunc) g_free, NULL);
g_slist_free (last_login_file_list);
- g_object_unref (G_OBJECT (confClient));
-
return new_file_exist;
}
@@ -385,14 +379,9 @@ gnome_settings_keyboard_xkb_init (GConfC
void
gnome_settings_keyboard_xkb_load (GConfClient * client)
{
- GConfClient *confClient;
- confClient = gconf_client_get_default ();
-
- GSwitchItConfigInit (¤tConfig, confClient);
+ GSwitchItConfigInit (¤tConfig, client);
apply_settings ();
- GSwitchItKbdConfigInit (¤tKbdConfig, confClient);
+ GSwitchItKbdConfigInit (¤tKbdConfig, client);
apply_xkb_settings ();
-
- g_object_unref (confClient);
}
Index: gnome-settings-keyboard.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-keyboard.c,v
retrieving revision 1.16
diff -u -p -r1.16 gnome-settings-keyboard.c
--- gnome-settings-keyboard.c 10 Oct 2005 19:32:45 -0000 1.16
+++ gnome-settings-keyboard.c 15 Oct 2005 22:35:31 -0000
@@ -166,12 +166,11 @@ numlock_get_gconf_state ()
GError *err = NULL;
char *key = numlock_gconf_state_key ();
if (!key) return NUMLOCK_STATE_UNKNOWN;
- gcc = gconf_client_get_default ();
+ gcc = gnome_settings_daemon_get_conf_client ();
int curr_state = gconf_client_get_bool (gcc, key, &err);
if (err) curr_state = NUMLOCK_STATE_UNKNOWN;
g_clear_error (&err);
g_free (key);
- g_object_unref (gcc);
return curr_state;
}
@@ -184,10 +183,9 @@ numlock_set_gconf_state (gboolean new_st
return;
key = numlock_gconf_state_key ();
if (!key) return;
- gcc = gconf_client_get_default ();
+ gcc = gnome_settings_daemon_get_conf_client ();
gconf_client_set_bool (gcc, key, new_state, NULL);
g_free (key);
- g_object_unref (gcc);
}
static GdkFilterReturn
@@ -253,7 +251,7 @@ apply_settings (void)
XKeyboardControl kbdcontrol;
- client = gconf_client_get_default ();
+ client = gnome_settings_daemon_get_conf_client ();
repeat = gconf_client_get_bool (client, "/desktop/gnome/peripherals/keyboard/repeat", NULL);
click = gconf_client_get_bool (client, "/desktop/gnome/peripherals/keyboard/click", NULL);
@@ -272,8 +270,6 @@ apply_settings (void)
#ifdef HAVE_X11_EXTENSIONS_XKB_H
rnumlock = gconf_client_get_bool (client, GSD_KEYBOARD_KEY "/remember_numlock_state", NULL);
#endif /* HAVE_X11_EXTENSIONS_XKB_H */
-
- g_object_unref (client);
gdk_error_trap_push ();
if (repeat) {
Index: gnome-settings-screensaver.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-screensaver.c,v
retrieving revision 1.5
diff -u -p -r1.5 gnome-settings-screensaver.c
--- gnome-settings-screensaver.c 15 Oct 2005 21:56:43 -0000 1.5
+++ gnome-settings-screensaver.c 15 Oct 2005 22:35:32 -0000
@@ -24,6 +24,7 @@
#include <config.h>
+#include "gnome-settings-daemon.h"
#include "gnome-settings-screensaver.h"
#include <glib/gi18n.h>
@@ -61,13 +62,12 @@ key_toggled_cb (GtkWidget *toggle, gpoin
{
GConfClient *client;
- client = gconf_client_get_default ();
+ client = gnome_settings_daemon_get_conf_client ();
gconf_client_set_bool (client,
SHOW_STARTUP_ERRORS_KEY,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle))
? 0 : 1,
NULL);
- g_object_unref (client);
}
static gboolean
@@ -96,9 +96,8 @@ really_start_screensaver (gpointer user_
if (g_spawn_command_line_async (ss_command, &gerr))
return FALSE;
- client = gconf_client_get_default ();
+ client = gnome_settings_daemon_get_conf_client ();
show_error = gconf_client_get_bool (client, SHOW_STARTUP_ERRORS_KEY, NULL);
- g_object_unref (client);
if (!show_error) {
g_error_free (gerr);
return FALSE;
Index: gnome-settings-sound.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-sound.c,v
retrieving revision 1.11
diff -u -p -r1.11 gnome-settings-sound.c
--- gnome-settings-sound.c 22 May 2005 15:46:43 -0000 1.11
+++ gnome-settings-sound.c 15 Oct 2005 22:35:32 -0000
@@ -144,7 +144,7 @@ apply_settings (void)
gboolean enable_esd;
gboolean event_sounds;
- client = gconf_client_get_default ();
+ client = gnome_settings_daemon_get_conf_client ();
enable_esd = gconf_client_get_bool (client, "/desktop/gnome/sound/enable_esd", NULL);
event_sounds = gconf_client_get_bool (client, "/desktop/gnome/sound/event_sounds", NULL);
@@ -175,8 +175,6 @@ apply_settings (void)
sound_properties_foreach (props, reload_foreach_cb, NULL);
gtk_object_destroy (GTK_OBJECT (props));
}
-
- g_object_unref (client);
}
void
Index: gnome-settings-xmodmap.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-xmodmap.c,v
retrieving revision 1.2
diff -u -p -r1.2 gnome-settings-xmodmap.c
--- gnome-settings-xmodmap.c 22 May 2005 15:46:43 -0000 1.2
+++ gnome-settings-xmodmap.c 15 Oct 2005 22:35:32 -0000
@@ -1,6 +1,6 @@
/* gnome-settings-xmodmap.c
*
- * Copyright © 2005 Novell Inc.
+ * Copyright �© 2005 Novell Inc.
*
* Written by Shakti Sen <shprasad novell com>
*
@@ -22,6 +22,7 @@
#include <config.h>
+#include "gnome-settings-daemon.h"
#include "gnome-settings-xmodmap.h"
#include <string.h>
@@ -43,7 +44,8 @@ static void
check_button_callback (GtkWidget *chk_button,
gpointer data)
{
- GConfClient *confClient = gconf_client_get_default ();
+ GConfClient *confClient = gnome_settings_daemon_get_conf_client ();
+
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_button))) {
gconf_client_set_bool (confClient, DISABLE_XMM_WARNING_KEY, TRUE,
NULL);
@@ -52,13 +54,12 @@ check_button_callback (GtkWidget *chk_bu
gconf_client_set_bool (confClient, DISABLE_XMM_WARNING_KEY, FALSE,
NULL);
}
- g_object_unref (confClient);
}
void
gnome_settings_load_modmap_files ()
{
- GConfClient *confClient = gconf_client_get_default ();
+ GConfClient *confClient = gnome_settings_daemon_get_conf_client ();
GSList *tmp = NULL;
GSList *loaded_file_list = gconf_client_get_list (confClient, LOADED_FILES_KEY, GCONF_VALUE_STRING, NULL);
tmp = loaded_file_list;
@@ -69,7 +70,6 @@ gnome_settings_load_modmap_files ()
tmp = tmp->next;
g_free (command);
}
- g_object_unref (confClient);
}
static void
@@ -129,7 +129,7 @@ remove_string_from_list (GSList *lis
static void
remove_button_clicked_callback (GtkWidget *button,
- void *data)
+ void *data)
{
GladeXML *xml;
GtkWidget *dialog;
@@ -155,7 +155,7 @@ remove_button_clicked_callback (GtkWidge
return;
/* Remove the selected file */
- confClient = gconf_client_get_default ();
+ confClient = gnome_settings_daemon_get_conf_client ();
loaded_files = gconf_client_get_list (confClient, LOADED_FILES_KEY, GCONF_VALUE_STRING, NULL);
loaded_files = remove_string_from_list (loaded_files, (char *)filenames->data);
@@ -177,8 +177,6 @@ remove_button_clicked_callback (GtkWidge
g_slist_foreach (loaded_files, (GFunc) g_free, NULL);
g_slist_free (loaded_files);
-
- g_object_unref (G_OBJECT (confClient));
}
static void
@@ -208,7 +206,7 @@ load_button_clicked_callback (GtkWidget
/* Add the files to left-tree-view */
- confClient = gconf_client_get_default ();
+ confClient = gnome_settings_daemon_get_conf_client ();
loaded_files = gconf_client_get_list (confClient, LOADED_FILES_KEY, GCONF_VALUE_STRING, NULL);
tmp = loaded_files;
while (tmp != NULL) {
@@ -238,8 +236,6 @@ load_button_clicked_callback (GtkWidget
}
g_slist_foreach (loaded_files, (GFunc) g_free, NULL);
g_slist_free (loaded_files);
-
- g_object_unref (G_OBJECT (confClient));
}
void
@@ -263,7 +259,7 @@ gnome_settings_modmap_dialog_call (void)
GDir *homeDir;
GSList *loaded_files = NULL;
G_CONST_RETURN gchar *fname;
- GConfClient *confClient = gconf_client_get_default ();
+ GConfClient *confClient = gnome_settings_daemon_get_conf_client ();
homeDir = g_dir_open (g_get_home_dir (), 0, NULL);
if (homeDir == NULL)
return;
@@ -341,7 +337,6 @@ gnome_settings_modmap_dialog_call (void)
gtk_tree_view_column_set_sort_column_id (column, 0);
loaded_files = gconf_client_get_list (confClient, LOADED_FILES_KEY, GCONF_VALUE_STRING, NULL);
- g_object_unref (confClient);
/* Add the data */
tmp = loaded_files;
Index: gnome-settings-xsettings.c
===================================================================
RCS file: /cvs/gnome/gnome-control-center/gnome-settings-daemon/gnome-settings-xsettings.c,v
retrieving revision 1.30
diff -u -p -r1.30 gnome-settings-xsettings.c
--- gnome-settings-xsettings.c 7 Jul 2005 19:35:59 -0000 1.30
+++ gnome-settings-xsettings.c 15 Oct 2005 22:35:32 -0000
@@ -255,10 +255,9 @@ xft_callback (GConfEntry *entry)
GConfClient *client;
int i;
- client = gconf_client_get_default ();
+ client = gnome_settings_daemon_get_conf_client ();
gnome_settings_update_xft (client);
- g_object_unref (client);
for (i = 0; managers [i]; i++)
xsettings_manager_notify (managers [i]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]