summaryrefslogtreecommitdiff
path: root/src/gsettings.c
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-07-15 05:24:16 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-07-15 05:24:16 +0800
commitdc7a61ff42237af3eb57e97e1680903a318e2cd8 (patch)
treefdc23c2471d6ac693c140b7ec68a1a3d29fcc7da /src/gsettings.c
parentefc33903b0a017c6b20cc578b4762c43a0697bd3 (diff)
downloadcompizconfig-backend-gsettings-dc7a61ff42237af3eb57e97e1680903a318e2cd8.tar.gz
compizconfig-backend-gsettings-dc7a61ff42237af3eb57e97e1680903a318e2cd8.tar.bz2
Moved all the GConf integration support into a separate file
keep the USE_GCONF markers
Diffstat (limited to 'src/gsettings.c')
-rw-r--r--src/gsettings.c1039
1 files changed, 8 insertions, 1031 deletions
diff --git a/src/gsettings.c b/src/gsettings.c
index 8139676..2d75793 100644
--- a/src/gsettings.c
+++ b/src/gsettings.c
@@ -31,47 +31,7 @@
*
**/
-#define _GNU_SOURCE
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <malloc.h>
-#include <string.h>
-#include <dirent.h>
-
-#include <ccs.h>
-#include <ccs-backend.h>
-
-#include <gio/gio.h>
-
-#include <X11/X.h>
-#include <X11/Xlib.h>
-
-#ifdef USE_GCONF
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.h>
-#include <gconf/gconf-value.h>
-#endif
-
-#define CompAltMask (1 << 16)
-#define CompMetaMask (1 << 17)
-#define CompSuperMask (1 << 18)
-#define CompHyperMask (1 << 19)
-#define CompModeSwitchMask (1 << 20)
-#define CompNumLockMask (1 << 21)
-#define CompScrollLockMask (1 << 22)
-
-#define SCHEMA_ID "org.freedesktop.compiz"
-#define METACITY "/apps/metacity"
-#define COMPIZ "/apps/compiz-1"
-#define COMPIZCONFIG "/apps/compizconfig-1"
-#define PROFILEPATH COMPIZCONFIG "/profiles"
-#define DEFAULTPROF "Default"
-#define CORE_NAME "core"
-
-#define BUFSIZE 512
-
-#define NUM_WATCHED_DIRS 3
+#include "gsettings.h"
static void
valueChanged (GSettings *settings,
@@ -83,17 +43,12 @@ gnomeValueChanged (GSettings *settings,
gchar *keyname,
gpointer user_data);
-#ifdef USE_GCONF
-static GConfClient *client = NULL;
-static guint gnomeGConfNotifyIds[NUM_WATCHED_DIRS];
-#endif
-
static GList *settings_list = NULL;
static GSettings *compizconfig_settings = NULL;
static GSettings *current_profile_settings = NULL;
static GList *watched_gnome_settings = NULL;
-static char *currentProfile = NULL;
+char *currentProfile = NULL;
static gchar *
gsettings_get_schema_name (const char *plugin)
@@ -151,24 +106,6 @@ gsettings_backend_unclean (char *gsettingName)
return clean;
}
-#define CLEAN_SETTING_NAME char *cleanSettingName = gsettings_backend_clean (setting->name)
-
-#define KEYNAME(sn) char keyName[BUFSIZE]; \
- snprintf (keyName, BUFSIZE, "screen%i", sn);
-
-#define PATHNAME char pathName[BUFSIZE]; \
- if (!setting->parent->name || \
- strcmp (setting->parent->name, "core") == 0) \
- snprintf (pathName, BUFSIZE, \
- "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \
- setting->parent->name, keyName); \
- else \
- snprintf(pathName, BUFSIZE, \
- "%s/%s/plugins/%s/%s/options/", COMPIZ, currentProfile, \
- setting->parent->name, keyName);
-
-#define CLEANUP_CLEAN_SETTING_NAME free (cleanSettingName);
-
static GSettings *
gsettings_object_for_plugin_path (const char *plugin,
const char *path,
@@ -254,33 +191,10 @@ gsettings_object_for_setting (CCSSetting *setting)
return gsettings_object_for_plugin_path (setting->parent->name, pathName, setting->parent->context);
}
-#ifdef USE_GCONF
-
-static const char* watchedGConfGnomeDirectories[] = {
- METACITY,
- "/desktop/gnome/applications/terminal",
- "/apps/panel/applets/window_list/prefs"
-};
-
-#endif
-
/* some forward declarations */
-static Bool readInit (CCSContext * context);
-static void readSetting (CCSContext * context, CCSSetting * setting);
-static Bool readOption (CCSSetting * setting);
-static Bool writeInit (CCSContext * context);
-static void writeOption (CCSSetting *setting);
static void writeIntegratedOption (CCSContext *context, CCSSetting *setting,
int index);
-typedef enum {
- OptionInt,
- OptionBool,
- OptionKey,
- OptionString,
- OptionSpecial,
-} SpecialOptionType;
-
typedef struct _SpecialOptionGSettings {
const char* settingName;
const char* pluginName;
@@ -289,341 +203,6 @@ typedef struct _SpecialOptionGSettings {
const char* type;
} SpecialOption;
-#ifdef USE_GCONF
-typedef struct _SpecialOptionGConf {
- const char* settingName;
- const char* pluginName;
- Bool screen;
- const char* gnomeName;
- SpecialOptionType type;
-} SpecialOptionGConf;
-
-
-const SpecialOptionGConf specialOptions[] = {
- {"run_key", "gnomecompat", FALSE,
- METACITY "/global_keybindings/panel_run_dialog", OptionKey},
- {"main_menu_key", "gnomecompat", FALSE,
- METACITY "/global_keybindings/panel_main_menu", OptionKey},
- {"run_command_screenshot_key", "gnomecompat", FALSE,
- METACITY "/global_keybindings/run_command_screenshot", OptionKey},
- {"run_command_window_screenshot_key", "gnomecompat", FALSE,
- METACITY "/global_keybindings/run_command_window_screenshot", OptionKey},
- {"run_command_terminal_key", "gnomecompat", FALSE,
- METACITY "/global_keybindings/run_command_terminal", OptionKey},
-
- {"toggle_window_maximized_key", "core", FALSE,
- METACITY "/window_keybindings/toggle_maximized", OptionKey},
- {"minimize_window_key", "core", FALSE,
- METACITY "/window_keybindings/minimize", OptionKey},
- {"maximize_window_key", "core", FALSE,
- METACITY "/window_keybindings/maximize", OptionKey},
- {"unmaximize_window_key", "core", FALSE,
- METACITY "/window_keybindings/unmaximize", OptionKey},
- {"maximize_window_horizontally_key", "core", FALSE,
- METACITY "/window_keybindings/maximize_horizontally", OptionKey},
- {"maximize_window_vertically_key", "core", FALSE,
- METACITY "/window_keybindings/maximize_vertically", OptionKey},
- {"raise_window_key", "core", FALSE,
- METACITY "/window_keybindings/raise", OptionKey},
- {"lower_window_key", "core", FALSE,
- METACITY "/window_keybindings/lower", OptionKey},
- {"close_window_key", "core", FALSE,
- METACITY "/window_keybindings/close", OptionKey},
- {"toggle_window_shaded_key", "core", FALSE,
- METACITY "/window_keybindings/toggle_shaded", OptionKey},
-
- {"show_desktop_key", "core", FALSE,
- METACITY "/global_keybindings/show_desktop", OptionKey},
-
- {"initiate_key", "move", FALSE,
- METACITY "/window_keybindings/begin_move", OptionKey},
- {"initiate_key", "resize", FALSE,
- METACITY "/window_keybindings/begin_resize", OptionKey},
- {"window_menu_key", "core", FALSE,
- METACITY "/window_keybindings/activate_window_menu", OptionKey},
-
- /* integration of Metacity's mouse_button_modifier option */
- {"initiate_button", "move", FALSE,
- METACITY "/window_keybindings/begin_move", OptionSpecial},
- {"initiate_button", "resize", FALSE,
- METACITY "/window_keybindings/begin_resize", OptionSpecial},
- {"window_menu_button", "core", FALSE,
- METACITY "/window_keybindings/activate_window_menu", OptionSpecial},
- {"mouse_button_modifier", NULL, FALSE,
- METACITY "/general/mouse_button_modifier", OptionSpecial},
- /* integration of the Metacity's option to swap mouse buttons */
- {"resize_with_right_button", NULL, FALSE,
- METACITY "/general/resize_with_right_button", OptionSpecial},
-
- {"visual_bell", "fade", TRUE,
- METACITY "/general/visual_bell", OptionBool},
- {"fullscreen_visual_bell", "fade", TRUE,
- METACITY "/general/visual_bell_type", OptionSpecial},
-
- {"next_key", "staticswitcher", FALSE,
- METACITY "/global_keybindings/switch_windows", OptionKey},
- {"prev_key", "staticswitcher", FALSE,
- METACITY "/global_keybindings/switch_windows_backward", OptionKey},
-
- {"toggle_sticky_key", "extrawm", FALSE,
- METACITY "/window_keybindings/toggle_on_all_workspaces", OptionKey},
- {"toggle_fullscreen_key", "extrawm", FALSE,
- METACITY "/window_keybindings/toggle_fullscreen", OptionKey},
-
- {"command0", "commands", FALSE,
- METACITY "/keybinding_commands/command_1", OptionString},
- {"command1", "commands", FALSE,
- METACITY "/keybinding_commands/command_2", OptionString},
- {"command2", "commands", FALSE,
- METACITY "/keybinding_commands/command_3", OptionString},
- {"command3", "commands", FALSE,
- METACITY "/keybinding_commands/command_4", OptionString},
- {"command4", "commands", FALSE,
- METACITY "/keybinding_commands/command_5", OptionString},
- {"command5", "commands", FALSE,
- METACITY "/keybinding_commands/command_6", OptionString},
- {"command6", "commands", FALSE,
- METACITY "/keybinding_commands/command_7", OptionString},
- {"command7", "commands", FALSE,
- METACITY "/keybinding_commands/command_8", OptionString},
- {"command8", "commands", FALSE,
- METACITY "/keybinding_commands/command_9", OptionString},
- {"command9", "commands", FALSE,
- METACITY "/keybinding_commands/command_10", OptionString},
- {"command10", "commands", FALSE,
- METACITY "/keybinding_commands/command_11", OptionString},
- {"command11", "commands", FALSE,
- METACITY "/keybinding_commands/command_12", OptionString},
-
- {"run_command0_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_1", OptionKey},
- {"run_command1_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_2", OptionKey},
- {"run_command2_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_3", OptionKey},
- {"run_command3_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_4", OptionKey},
- {"run_command4_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_5", OptionKey},
- {"run_command5_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_6", OptionKey},
- {"run_command6_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_7", OptionKey},
- {"run_command7_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_8", OptionKey},
- {"run_command8_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_9", OptionKey},
- {"run_command9_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_10", OptionKey},
- {"run_command10_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_11", OptionKey},
- {"run_command11_key", "commands", FALSE,
- METACITY "/global_keybindings/run_command_12", OptionKey},
-
- {"rotate_to_1_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_1", OptionKey},
- {"rotate_to_2_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_2", OptionKey},
- {"rotate_to_3_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_3", OptionKey},
- {"rotate_to_4_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_4", OptionKey},
- {"rotate_to_5_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_5", OptionKey},
- {"rotate_to_6_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_6", OptionKey},
- {"rotate_to_7_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_7", OptionKey},
- {"rotate_to_8_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_8", OptionKey},
- {"rotate_to_9_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_9", OptionKey},
- {"rotate_to_10_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_10", OptionKey},
- {"rotate_to_11_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_11", OptionKey},
- {"rotate_to_12_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_12", OptionKey},
-
- {"rotate_left_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_left", OptionKey},
- {"rotate_right_key", "rotate", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_right", OptionKey},
-
- {"switch_to_1_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_1", OptionKey},
- {"switch_to_2_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_2", OptionKey},
- {"switch_to_3_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_3", OptionKey},
- {"switch_to_4_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_4", OptionKey},
- {"switch_to_5_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_5", OptionKey},
- {"switch_to_6_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_6", OptionKey},
- {"switch_to_7_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_7", OptionKey},
- {"switch_to_8_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_8", OptionKey},
- {"switch_to_9_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_9", OptionKey},
- {"switch_to_10_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_10", OptionKey},
- {"switch_to_11_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_11", OptionKey},
- {"switch_to_12_key", "vpswitch", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_12", OptionKey},
-
- {"up_key", "wall", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_up", OptionKey},
- {"down_key", "wall", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_down", OptionKey},
- {"left_key", "wall", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_left", OptionKey},
- {"right_key", "wall", FALSE,
- METACITY "/global_keybindings/switch_to_workspace_right", OptionKey},
- {"left_window_key", "wall", FALSE,
- METACITY "/window_keybindings/move_to_workspace_left", OptionKey},
- {"right_window_key", "wall", FALSE,
- METACITY "/window_keybindings/move_to_workspace_right", OptionKey},
- {"up_window_key", "wall", FALSE,
- METACITY "/window_keybindings/move_to_workspace_up", OptionKey},
- {"down_window_key", "wall", FALSE,
- METACITY "/window_keybindings/move_to_workspace_down", OptionKey},
-
- {"put_topleft_key", "put", FALSE,
- METACITY "/window_keybindings/move_to_corner_nw", OptionKey},
- {"put_topright_key", "put", FALSE,
- METACITY "/window_keybindings/move_to_corner_ne", OptionKey},
- {"put_bottomleft_key", "put", FALSE,
- METACITY "/window_keybindings/move_to_corner_sw", OptionKey},
- {"put_bottomright_key", "put", FALSE,
- METACITY "/window_keybindings/move_to_corner_se", OptionKey},
- {"put_left_key", "put", FALSE,
- METACITY "/window_keybindings/move_to_side_w", OptionKey},
- {"put_right_key", "put", FALSE,
- METACITY "/window_keybindings/move_to_side_e", OptionKey},
- {"put_top_key", "put", FALSE,
- METACITY "/window_keybindings/move_to_side_n", OptionKey},
- {"put_bottom_key", "put", FALSE,
- METACITY "/window_keybindings/move_to_side_s", OptionKey},
-
- {"rotate_to_1_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_1", OptionKey},
- {"rotate_to_2_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_2", OptionKey},
- {"rotate_to_3_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_3", OptionKey},
- {"rotate_to_4_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_4", OptionKey},
- {"rotate_to_5_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_5", OptionKey},
- {"rotate_to_6_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_6", OptionKey},
- {"rotate_to_7_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_7", OptionKey},
- {"rotate_to_8_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_8", OptionKey},
- {"rotate_to_9_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_9", OptionKey},
- {"rotate_to_10_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_10", OptionKey},
- {"rotate_to_11_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_11", OptionKey},
- {"rotate_to_12_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_12", OptionKey},
-
- {"rotate_left_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_left", OptionKey},
- {"rotate_right_window_key", "rotate", FALSE,
- METACITY "/window_keybindings/move_to_workspace_right", OptionKey},
-
- {"command_screenshot", "gnomecompat", FALSE,
- METACITY "/keybinding_commands/command_screenshot", OptionString},
- {"command_window_screenshot", "gnomecompat", FALSE,
- METACITY "/keybinding_commands/command_window_screenshot", OptionString},
- {"command_terminal", "gnomecompat", FALSE,
- "/desktop/gnome/applications/terminal/exec", OptionString},
-
- {"current_viewport", "thumbnail", TRUE,
- "/apps/panel/applets/window_list/prefs/display_all_workspaces",
- OptionSpecial},
-
- {"autoraise", "core", FALSE,
- METACITY "/general/auto_raise", OptionBool},
- {"autoraise_delay", "core", FALSE,
- METACITY "/general/auto_raise_delay", OptionInt},
- {"raise_on_click", "core", FALSE,
- METACITY "/general/raise_on_click", OptionBool},
- {"click_to_focus", "core", FALSE,
- METACITY "/general/focus_mode", OptionSpecial},
-
- {"audible_bell", "core", FALSE,
- METACITY "/general/audible_bell", OptionBool},
- /*{"hsize", "core", TRUE,
- METACITY "/general/num_workspaces", OptionInt},*/
-};
-
-#define N_SOPTIONS (sizeof (specialOptions) / sizeof (struct _SpecialOptionGConf))
-#endif
-
-static CCSSetting *
-findDisplaySettingForPlugin (CCSContext *context,
- const char *plugin,
- const char *setting)
-{
- CCSPlugin *p;
- CCSSetting *s;
-
- p = ccsFindPlugin (context, plugin);
- if (!p)
- return NULL;
-
- s = ccsFindSetting (p, setting);
- if (!s)
- return NULL;
-
- return s;
-}
-
-#ifdef USE_GCONF
-static Bool
-isGConfIntegratedOption (CCSSetting *setting,
- int *index)
-{
- unsigned int i;
-
- for (i = 0; i < N_SOPTIONS; i++)
- {
- const SpecialOptionGConf *opt = &specialOptions[i];
-
- if (strcmp (cleanSettingName, opt->settingName) != 0)
- continue;
-
- if (setting->parent->name)
- {
- if (!opt->pluginName)
- continue;
- if (strcmp (setting->parent->name, opt->pluginName) != 0)
- continue;
- }
- else
- {
- if (opt->pluginName)
- continue;
- }
-
- if (index)
- *index = i;
-
- return TRUE;
- }
-
- return FALSE;
-}
-#endif
-
static Bool
isIntegratedOption (CCSSetting *setting,
int *index)
@@ -708,137 +287,6 @@ valueChanged (GSettings *settings,
free (uncleanKeyName);
}
-#ifdef USE_GCONF
-static void
-gnomeGConfValueChanged (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- gpointer user_data)
-{
- CCSContext *context = (CCSContext *)user_data;
- char *keyName = (char*) gconf_entry_get_key (entry);
- int i, last = 0, num = 0;
- Bool needInit = TRUE;
-
- if (!ccsGetIntegrationEnabled (context))
- return;
-
- /* we have to loop multiple times here, because one Gnome
- option may be integrated with multiple Compiz options */
-
- while (1)
- {
- for (i = last, num = -1; i < N_SOPTIONS; i++)
- {
- if (strcmp (specialOptions[i].gnomeName, keyName) == 0)
- {
- num = i;
- last = i + 1;
- break;
- }
- }
-
- if (num < 0)
- break;
-
- if ((strcmp (specialOptions[num].settingName,
- "mouse_button_modifier") == 0) ||
- (strcmp (specialOptions[num].settingName,
- "resize_with_right_button") == 0))
- {
- CCSSetting *s;
-
- if (needInit)
- {
- readInit (context);
- needInit = FALSE;
- }
-
- s = findDisplaySettingForPlugin (context, "core",
- "window_menu_button");
- if (s)
- readSetting (context, s);
-
- s = findDisplaySettingForPlugin (context, "move",
- "initiate_button");
- if (s)
- readSetting (context, s);
-
- s = findDisplaySettingForPlugin (context, "resize",
- "initiate_button");
- if (s)
- readSetting (context, s);
- }
- else
- {
- CCSPlugin *plugin = NULL;
- CCSSetting *setting;
- SpecialOptionGConf *opt = (SpecialOptionGConf *) &specialOptions[num];
-
- plugin = ccsFindPlugin (context, (char*) opt->pluginName);
- if (plugin)
- {
- for (i = 0; i < 1; i++)
- {
- setting = ccsFindSetting (plugin, (char*) opt->settingName);
-
- if (setting)
- {
- if (needInit)
- {
- readInit (context);
- needInit = FALSE;
- }
- readSetting (context, setting);
- }
-
- /* do not read display settings multiple
- times for multiscreen environments */
- }
- }
- }
- }
-}
-
-static void
-initGConfClient (CCSContext *context)
-{
- int i;
-
- client = gconf_client_get_default ();
-
- for (i = 0; i < NUM_WATCHED_DIRS; i++)
- {
- gnomeGConfNotifyIds[i] = gconf_client_notify_add (client,
- watchedGConfGnomeDirectories[i],
- gnomeGConfValueChanged, context,
- NULL, NULL);
- gconf_client_add_dir (client, watchedGConfGnomeDirectories[i],
- GCONF_CLIENT_PRELOAD_NONE, NULL);
- }
-}
-
-static void
-finiGConfClient (void)
-{
- int i;
-
- for (i = 0; i < NUM_WATCHED_DIRS; i++)
- {
- if (gnomeGConfNotifyIds[i])
- {
- gconf_client_notify_remove (client, gnomeGConfNotifyIds[0]);
- gnomeGConfNotifyIds[i] = 0;
- }
- gconf_client_remove_dir (client, watchedGConfGnomeDirectories[i], NULL);
- }
- gconf_client_suggest_sync (client, NULL);
-
- g_object_unref (client);
- client = NULL;
-}
-#endif
-
static Bool
readListValue (CCSSetting *setting)
{
@@ -997,224 +445,6 @@ readListValue (CCSSetting *setting)
return FALSE;
}
-#ifdef USE_GCONF
-
-static unsigned int
-getGnomeMouseButtonModifier(void)
-{
- unsigned int modMask = 0;
- GError *err = NULL;
- char *value;
-
- value = gconf_client_get_string (client,
- METACITY "/general/mouse_button_modifier",
- &err);
-
- if (err)
- {
- g_error_free (err);
- return 0;
- }
-
- if (!value)
- return 0;
-
- modMask = ccsStringToModifiers (value);
- g_free (value);
-
- return modMask;
-}
-
-#endif
-
-static unsigned int
-getButtonBindingForSetting (CCSContext *context,
- const char *plugin,
- const char *setting)
-{
- CCSSetting *s;
-
- s = findDisplaySettingForPlugin (context, plugin, setting);
- if (!s)
- return 0;
-
- if (s->type != TypeButton)
- return 0;
-
- return s->value->value.asButton.button;
-}
-
-#ifdef USE_GCONF
-
-static Bool
-readGConfIntegratedOption (CCSContext *context,
- CCSSetting *setting,
- int index)
-{
- GConfValue *gconfValue;
- GError *err = NULL;
- Bool ret = FALSE;
-
- ret = readOption (setting);
-
- gconfValue = gconf_client_get (client,
- specialOptions[index].gnomeName,
- &err);
-
- if (err)
- {
- g_error_free (err);
- return FALSE;
- }
-
- if (!gconfValue)
- return FALSE;
-
- switch (specialOptions[index].type) {
- case OptionInt:
- if (gconfValue->type == GCONF_VALUE_INT)
- {
- guint value;
-
- value = gconf_value_get_int (gconfValue);
- ccsSetInt (setting, value);
- ret = TRUE;
- }
- break;
- case OptionBool:
- if (gconfValue->type == GCONF_VALUE_BOOL)
- {
- gboolean value;
-
- value = gconf_value_get_bool (gconfValue);
- ccsSetBool (setting, value ? TRUE : FALSE);
- ret = TRUE;
- }
- break;
- case OptionString:
- if (gconfValue->type == GCONF_VALUE_STRING)
- {
- const char *value;
-
- value = gconf_value_get_string (gconfValue);
- if (value)
- {
- ccsSetString (setting, value);
- ret = TRUE;
- }
- }
- break;
- case OptionKey:
- if (gconfValue->type == GCONF_VALUE_STRING)
- {
- const char *value;
-
- value = gconf_value_get_string (gconfValue);
- if (value)
- {
- CCSSettingKeyValue key;
-
- memset (&key, 0, sizeof (CCSSettingKeyValue));
- ccsGetKey (setting, &key);
- if (ccsStringToKeyBinding (value, &key))
- {
- ccsSetKey (setting, key);
- ret = TRUE;
- }
- }
- }
- break;
- case OptionSpecial:
- {
- const char *settingName = specialOptions[index].settingName;
- const char *pluginName = specialOptions[index].pluginName;
-
- if (strcmp (settingName, "current_viewport") == 0)
- {
- if (gconfValue->type == GCONF_VALUE_BOOL)
- {
- gboolean showAll;
-
- showAll = gconf_value_get_bool (gconfValue);
- ccsSetBool (setting, !showAll);
- ret = TRUE;
- }
- }
- else if (strcmp (settingName, "fullscreen_visual_bell") == 0)
- {
- if (gconfValue->type == GCONF_VALUE_STRING)
- {
- const char *value;
-
- value = gconf_value_get_string (gconfValue);
- if (value)
- {
- Bool fullscreen;
-
- fullscreen = strcmp (value, "fullscreen") == 0;
- ccsSetBool (setting, fullscreen);
- ret = TRUE;
- }
- }
- }
- else if (strcmp (settingName, "click_to_focus") == 0)
- {
- if (gconfValue->type == GCONF_VALUE_STRING)
- {
- const char *focusMode;
-
- focusMode = gconf_value_get_string (gconfValue);
-
- if (focusMode)
- {
- Bool clickToFocus = (strcmp (focusMode, "click") == 0);
- ccsSetBool (setting, clickToFocus);
- ret = TRUE;
- }
- }
- }
- else if (((strcmp (settingName, "initiate_button") == 0) &&
- ((strcmp (pluginName, "move") == 0) ||
- (strcmp (pluginName, "resize") == 0))) ||
- ((strcmp (settingName, "window_menu_button") == 0) &&
- (strcmp (pluginName, "core") == 0)))
- {
- gboolean resizeWithRightButton;
- CCSSettingButtonValue button;
-
- memset (&button, 0, sizeof (CCSSettingButtonValue));
- ccsGetButton (setting, &button);
-
- button.buttonModMask = getGnomeMouseButtonModifier ();
-
- resizeWithRightButton =
- gconf_client_get_bool (client, METACITY
- "/general/resize_with_right_button",
- &err);
-
- if (strcmp (settingName, "window_menu_button") == 0)
- button.button = resizeWithRightButton ? 2 : 3;
- else if (strcmp (pluginName, "resize") == 0)
- button.button = resizeWithRightButton ? 3 : 2;
- else
- button.button = 1;
-
- ccsSetButton (setting, button);
- ret = TRUE;
- }
- }
- break;
- default:
- break;
- }
-
- gconf_value_free (gconfValue);
-
- return ret;
-}
-
-#endif
-
static Bool
readIntegratedOption (CCSContext *context,
CCSSetting *setting,
@@ -1227,7 +457,7 @@ readIntegratedOption (CCSContext *context,
#endif
}
-static Bool
+Bool
readOption (CCSSetting * setting)
{
GSettings *settings = gsettings_object_for_setting (setting);
@@ -1536,259 +766,6 @@ writeListValue (CCSSetting *setting,
g_object_unref (settings);
}
-#ifdef USE_GCONF
-static Bool
-setGnomeMouseButtonModifier (unsigned int modMask)
-{
- char *modifiers, *currentValue;
- GError *err = NULL;
-
- modifiers = ccsModifiersToString (modMask);
- if (!modifiers)
- return FALSE;
-
- currentValue = gconf_client_get_string (client,
- METACITY
- "/general/mouse_button_modifier",
- &err);
- if (err)
- {
- free (modifiers);
- g_error_free (err);
- return FALSE;
- }
-
- if (!currentValue || (strcmp (currentValue, modifiers) != 0))
- gconf_client_set_string (client,
- METACITY "/general/mouse_button_modifier",
- modifiers, NULL);
- if (currentValue)
- g_free (currentValue);
-
- free (modifiers);
-
- return TRUE;
-}
-#endif
-
-static void
-setButtonBindingForSetting (CCSContext *context,
- const char *plugin,
- const char *setting,
- unsigned int button,
- unsigned int buttonModMask)
-{
- CCSSetting *s;
- CCSSettingButtonValue value;
-
- s = findDisplaySettingForPlugin (context, plugin, setting);
- if (!s)
- return;
-
- if (s->type != TypeButton)
- return;
-
- value = s->value->value.asButton;
-
- if ((value.button != button) || (value.buttonModMask != buttonModMask))
- {
- value.button = button;
- value.buttonModMask = buttonModMask;
-
- ccsSetButton (s, value);
- }
-}
-
-#ifdef USE_GCONF
-static void
-writeGConfIntegratedOption (CCSContext *context,
- CCSSetting *setting,
- int index)
-{
- GError *err = NULL;
- const char *optionName = specialOptions[index].gnomeName;
-
- switch (specialOptions[index].type)
- {
- case OptionInt:
- {
- int newValue, currentValue;
- if (!ccsGetInt (setting, &newValue))
- break;
- currentValue = gconf_client_get_int (client, optionName, &err);
-
- if (!err && (currentValue != newValue))
- gconf_client_set_int(client, specialOptions[index].gnomeName,
- newValue, NULL);
- }
- break;
- case OptionBool:
- {
- Bool newValue;
- gboolean currentValue;
- if (!ccsGetBool (setting, &newValue))
- break;
- currentValue = gconf_client_get_bool (client, optionName, &err);
-
- if (!err && ((currentValue && !newValue) ||
- (!currentValue && newValue)))
- gconf_client_set_bool (client, specialOptions[index].gnomeName,
- newValue, NULL);
- }
- break;
- case OptionString:
- {
- char *newValue;
- gchar *currentValue;
- if (!ccsGetString (setting, &newValue))
- break;
- currentValue = gconf_client_get_string (client, optionName, &err);
-
- if (!err && currentValue)
- {
- if (strcmp (currentValue, newValue) != 0)
- gconf_client_set_string (client, optionName,
- newValue, NULL);
- g_free (currentValue);
- }
- }
- break;
- case OptionKey:
- {
- char *newValue;
- gchar *currentValue;
-
- newValue = ccsKeyBindingToString (&setting->value->value.asKey);
- if (newValue)
- {
- if (strcmp (newValue, "Disabled") == 0)
- {
- /* Metacity doesn't like "Disabled", it wants "disabled" */
- newValue[0] = 'd';
- }
-
- currentValue = gconf_client_get_string (client,
- optionName, &err);
-
- if (!err && currentValue)
- {
- if (strcmp (currentValue, newValue) != 0)
- gconf_client_set_string (client, optionName,
- newValue, NULL);
- g_free (currentValue);
- }
- free (newValue);
- }
- }
- break;
- case OptionSpecial:
- {
- const char *settingName = specialOptions[index].settingName;
- const char *pluginName = specialOptions[index].pluginName;
-
- if (strcmp (settingName, "current_viewport") == 0)
- {
- Bool currentViewport;
-
- if (!ccsGetBool (setting, &currentViewport))
- break;
-
- gconf_client_set_bool (client, optionName,
- !currentViewport, NULL);
- }
- else if (strcmp (settingName, "fullscreen_visual_bell") == 0)
- {
- Bool fullscreen;
- gchar *currentValue, *newValue;
- if (!ccsGetBool (setting, &fullscreen))
- break;
-
- newValue = fullscreen ? "fullscreen" : "frame_flash";
- currentValue = gconf_client_get_string (client,
- optionName, &err);
- if (!err && currentValue)
- {
- if (strcmp (currentValue, newValue) != 0)
- gconf_client_set_string (client, optionName,
- newValue, NULL);
- g_free (currentValue);
- }
- }
- else if (strcmp (settingName, "click_to_focus") == 0)
- {
- Bool clickToFocus;
- gchar *newValue, *currentValue;
- if (!ccsGetBool (setting, &clickToFocus))
- break;
-
- newValue = clickToFocus ? "click" : "sloppy";
- currentValue = gconf_client_get_string (client,
- optionName, &err);
-
- if (!err && currentValue)
- {
- if (strcmp (currentValue, newValue) != 0)
- gconf_client_set_string (client, optionName,
- newValue, NULL);
- g_free (currentValue);
- }
- }
- else if (((strcmp (settingName, "initiate_button") == 0) &&
- ((strcmp (pluginName, "move") == 0) ||
- (strcmp (pluginName, "resize") == 0))) ||
- ((strcmp (settingName, "window_menu_button") == 0) &&
- (strcmp (pluginName, "core") == 0)))
- {
- unsigned int modMask;
- Bool resizeWithRightButton = FALSE;
- gboolean currentValue;
-
- if ((getButtonBindingForSetting (context, "resize",
- "initiate_button") == 3) ||
- (getButtonBindingForSetting (context, "core",
- "window_menu_button") == 2))
- {
- resizeWithRightButton = TRUE;
- }
-
- currentValue =
- gconf_client_get_bool (client, METACITY
- "/general/resize_with_right_button",
- &err);
-
- if (!err && ((currentValue && !resizeWithRightButton) ||
- (!currentValue && resizeWithRightButton)))
- {
- gconf_client_set_bool (client,
- METACITY
- "/general/resize_with_right_button",
- resizeWithRightButton, NULL);
- }
-
- modMask = setting->value->value.asButton.buttonModMask;
- if (setGnomeMouseButtonModifier (modMask))
- {
- setButtonBindingForSetting (context, "move",
- "initiate_button", 1, modMask);
- setButtonBindingForSetting (context, "resize",
- "initiate_button",
- resizeWithRightButton ? 3 : 2,
- modMask);
- setButtonBindingForSetting (context, "core",
- "window_menu_button",
- resizeWithRightButton ? 2 : 3,
- modMask);
- }
- }
- }
- break;
- }
-
- if (err)
- g_error_free (err);
-}
-#endif
-
static void
writeIntegratedOption (CCSContext *context,
CCSSetting *setting,
@@ -1816,7 +793,7 @@ resetOptionToDefault (CCSSetting * setting)
CLEANUP_CLEAN_SETTING_NAME;
}
-static void
+void
writeOption (CCSSetting * setting)
{
GSettings *settings = gsettings_object_for_setting (setting);
@@ -2099,13 +1076,13 @@ finiBackend (CCSContext * context)
return TRUE;
}
-static Bool
+Bool
readInit (CCSContext * context)
{
return updateProfile (context);
}
-static void
+void
readSetting (CCSContext *context,
CCSSetting *setting)
{
@@ -2124,13 +1101,13 @@ readSetting (CCSContext *context,
ccsResetToDefault (setting);
}
-static Bool
+Bool
writeInit (CCSContext * context)
{
return updateProfile (context);
}
-static void
+void
writeSetting (CCSContext *context,
CCSSetting *setting)
{