Reduce GConf roundtrips

metacity tries to do the right thing, by preloading all the relevant
directories before getting the keys one-by-one, but GConfClient isn't actually
smart enough to avoid server roundtrips in this case. That should certainly be
fixed in GConf.

In the meantime, here is a patch that reworks the metacity prefs initialization
to avoid roundtrips for individual keys anyway, by using
gconf_client_all_keys().

https://bugzilla.gnome.org/show_bug.cgi?id=574121
https://bugzilla.gnome.org/show_bug.cgi?id=607746
This commit is contained in:
Matthias Clasen 2010-01-21 16:54:22 -05:00 committed by Owen W. Taylor
parent 90f21fa5db
commit 2d57b1b470

View File

@ -52,6 +52,7 @@
#define KEY_COMPOSITOR "/apps/metacity/general/compositing_manager" #define KEY_COMPOSITOR "/apps/metacity/general/compositing_manager"
#define KEY_GNOME_ACCESSIBILITY "/desktop/gnome/interface/accessibility" #define KEY_GNOME_ACCESSIBILITY "/desktop/gnome/interface/accessibility"
#define KEY_COMMAND_DIRECTORY "/apps/metacity/keybinding_commands"
#define KEY_COMMAND_PREFIX "/apps/metacity/keybinding_commands/command_" #define KEY_COMMAND_PREFIX "/apps/metacity/keybinding_commands/command_"
#define KEY_TERMINAL_DIR "/desktop/gnome/applications/terminal" #define KEY_TERMINAL_DIR "/desktop/gnome/applications/terminal"
@ -62,6 +63,7 @@
#define KEY_WINDOW_BINDINGS_PREFIX "/apps/metacity/window_keybindings" #define KEY_WINDOW_BINDINGS_PREFIX "/apps/metacity/window_keybindings"
#define KEY_LIST_BINDINGS_SUFFIX "_list" #define KEY_LIST_BINDINGS_SUFFIX "_list"
#define KEY_WORKSPACE_NAME_DIRECTORY "/apps/metacity/workspace_names"
#define KEY_WORKSPACE_NAME_PREFIX "/apps/metacity/workspace_names/name_" #define KEY_WORKSPACE_NAME_PREFIX "/apps/metacity/workspace_names/name_"
#define KEY_CLUTTER_PLUGINS "/apps/mutter/general/clutter_plugins" #define KEY_CLUTTER_PLUGINS "/apps/mutter/general/clutter_plugins"
@ -1893,54 +1895,42 @@ static void
init_bindings (void) init_bindings (void)
{ {
#ifdef HAVE_GCONF #ifdef HAVE_GCONF
int i = 0; const char *prefix[] = {
GError *err; KEY_WINDOW_BINDINGS_PREFIX,
while (key_bindings[i].name)
{
GSList *list_val, *tmp;
char *str_val;
char *key;
key = g_strconcat (key_bindings[i].per_window?
KEY_WINDOW_BINDINGS_PREFIX:
KEY_SCREEN_BINDINGS_PREFIX, KEY_SCREEN_BINDINGS_PREFIX,
"/", NULL
key_bindings[i].name, NULL); };
int i;
GSList *list, *l, *list_val;
const char *str_val;
const char *key;
GConfEntry *entry;
GConfValue *value;
err = NULL; for (i = 0; prefix[i]; i++)
str_val = gconf_client_get_string (default_client, key, &err);
cleanup_error (&err);
update_binding (&key_bindings[i], str_val);
g_free (str_val);
g_free (key);
key = g_strconcat (key_bindings[i].per_window?
KEY_WINDOW_BINDINGS_PREFIX:
KEY_SCREEN_BINDINGS_PREFIX,
"/",
key_bindings[i].name,
KEY_LIST_BINDINGS_SUFFIX, NULL);
err = NULL;
list_val = gconf_client_get_list (default_client, key, GCONF_VALUE_STRING, &err);
cleanup_error (&err);
update_list_binding (&key_bindings[i], list_val, META_LIST_OF_STRINGS);
tmp = list_val;
while (tmp)
{ {
g_free (tmp->data); list = gconf_client_all_entries (default_client, prefix[i], NULL);
tmp = tmp->next; for (l = list; l; l = l->next)
} {
entry = l->data;
key = gconf_entry_get_key (entry);
value = gconf_entry_get_value (entry);
if (g_str_has_suffix (key, KEY_LIST_BINDINGS_SUFFIX))
{
list_val = gconf_client_get_list (default_client, key, GCONF_VALUE_STRING, NULL);
update_key_list_binding (key, list_val);
g_slist_foreach (list_val, (GFunc)g_free, NULL);
g_slist_free (list_val); g_slist_free (list_val);
g_free (key); }
else
++i; {
str_val = gconf_value_get_string (value);
update_key_binding (key, str_val);
}
gconf_entry_free (entry);
}
g_slist_free (list);
} }
#else /* HAVE_GCONF */ #else /* HAVE_GCONF */
@ -1964,28 +1954,23 @@ static void
init_commands (void) init_commands (void)
{ {
#ifdef HAVE_GCONF #ifdef HAVE_GCONF
int i; GSList *list, *l;
GError *err; const char *str_val;
const char *key;
GConfEntry *entry;
GConfValue *value;
i = 0; list = gconf_client_all_entries (default_client, KEY_COMMAND_DIRECTORY, NULL);
while (i < MAX_COMMANDS) for (l = list; l; l = l->next)
{ {
char *str_val; entry = l->data;
char *key; key = gconf_entry_get_key (entry);
value = gconf_entry_get_value (entry);
key = meta_prefs_get_gconf_key_for_command (i); str_val = gconf_value_get_string (value);
err = NULL;
str_val = gconf_client_get_string (default_client, key, &err);
cleanup_error (&err);
update_command (key, str_val); update_command (key, str_val);
gconf_entry_free (entry);
g_free (str_val);
g_free (key);
++i;
} }
g_slist_free (list);
#else #else
int i; int i;
for (i = 0; i < MAX_COMMANDS; i++) for (i = 0; i < MAX_COMMANDS; i++)
@ -1997,30 +1982,23 @@ static void
init_workspace_names (void) init_workspace_names (void)
{ {
#ifdef HAVE_GCONF #ifdef HAVE_GCONF
int i; GSList *list, *l;
GError *err; const char *str_val;
const char *key;
GConfEntry *entry;
GConfValue *value;
i = 0; list = gconf_client_all_entries (default_client, KEY_WORKSPACE_NAME_DIRECTORY, NULL);
while (i < MAX_REASONABLE_WORKSPACES) for (l = list; l; l = l->next)
{ {
char *str_val; entry = l->data;
char *key; key = gconf_entry_get_key (entry);
value = gconf_entry_get_value (entry);
key = gconf_key_for_workspace_name (i); str_val = gconf_value_get_string (value);
err = NULL;
str_val = gconf_client_get_string (default_client, key, &err);
cleanup_error (&err);
update_workspace_name (key, str_val); update_workspace_name (key, str_val);
gconf_entry_free (entry);
g_assert (workspace_names[i] != NULL);
g_free (str_val);
g_free (key);
++i;
} }
g_slist_free (list);
#else #else
int i; int i;
for (i = 0; i < MAX_REASONABLE_WORKSPACES; i++) for (i = 0; i < MAX_REASONABLE_WORKSPACES; i++)