diff options
author | Stefano Karapetsas <[email protected]> | 2012-10-01 22:58:54 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-10-01 22:58:54 +0200 |
commit | d2c7965aa092cecb857bd0301b7c9ff2dc10f9f8 (patch) | |
tree | 016ada3eb78c3c6f438abab5635ba17474d47a2b /plugins/keyboard | |
parent | 03478b4d1d9fdc5f2f2fdbf9c41d963dabc0d00b (diff) | |
download | mate-settings-daemon-d2c7965aa092cecb857bd0301b7c9ff2dc10f9f8.tar.bz2 mate-settings-daemon-d2c7965aa092cecb857bd0301b7c9ff2dc10f9f8.tar.xz |
migrate to gsettingsmate-settings-daemon-1.5.0
Diffstat (limited to 'plugins/keyboard')
-rw-r--r-- | plugins/keyboard/modmap-dialog.ui | 16 | ||||
-rw-r--r-- | plugins/keyboard/msd-keyboard-manager.c | 154 | ||||
-rw-r--r-- | plugins/keyboard/msd-keyboard-xkb.c | 314 | ||||
-rw-r--r-- | plugins/keyboard/msd-keyboard-xkb.h | 5 | ||||
-rw-r--r-- | plugins/keyboard/msd-xmodmap.c | 142 |
5 files changed, 208 insertions, 423 deletions
diff --git a/plugins/keyboard/modmap-dialog.ui b/plugins/keyboard/modmap-dialog.ui index 12c34a6..73d5a57 100644 --- a/plugins/keyboard/modmap-dialog.ui +++ b/plugins/keyboard/modmap-dialog.ui @@ -202,22 +202,6 @@ <property name="position">1</property> </packing> </child> - <child> - <object class="GtkCheckButton" id="checkbutton1"> - <property name="label" translatable="yes">_Do not show this message again</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">False</property> - <property name="use_underline">True</property> - <property name="active">True</property> - <property name="draw_indicator">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">2</property> - </packing> - </child> </object> <packing> <property name="position">2</property> diff --git a/plugins/keyboard/msd-keyboard-manager.c b/plugins/keyboard/msd-keyboard-manager.c index 0969459..d4a25b3 100644 --- a/plugins/keyboard/msd-keyboard-manager.c +++ b/plugins/keyboard/msd-keyboard-manager.c @@ -59,23 +59,26 @@ #define HOST_NAME_MAX 255 #endif -#define MSD_KEYBOARD_KEY "/desktop/mate/peripherals/keyboard" +#define MSD_KEYBOARD_SCHEMA "org.mate.peripherals-keyboard" -#define KEY_REPEAT MSD_KEYBOARD_KEY "/repeat" -#define KEY_CLICK MSD_KEYBOARD_KEY "/click" -#define KEY_RATE MSD_KEYBOARD_KEY "/rate" -#define KEY_DELAY MSD_KEYBOARD_KEY "/delay" -#define KEY_CLICK_VOLUME MSD_KEYBOARD_KEY "/click_volume" +#define KEY_REPEAT "repeat" +#define KEY_CLICK "click" +#define KEY_RATE "rate" +#define KEY_DELAY "delay" +#define KEY_CLICK_VOLUME "click-volume" -#define KEY_BELL_VOLUME MSD_KEYBOARD_KEY "/bell_volume" -#define KEY_BELL_PITCH MSD_KEYBOARD_KEY "/bell_pitch" -#define KEY_BELL_DURATION MSD_KEYBOARD_KEY "/bell_duration" -#define KEY_BELL_MODE MSD_KEYBOARD_KEY "/bell_mode" +#define KEY_BELL_VOLUME "bell-volume" +#define KEY_BELL_PITCH "bell-pitch" +#define KEY_BELL_DURATION "bell-duration" +#define KEY_BELL_MODE "bell-mode" + +#define KEY_NUMLOCK_STATE "numlock-state" +#define KEY_NUMLOCK_REMEMBER "remember-numlock-state" struct MsdKeyboardManagerPrivate { - gboolean have_xkb; - gint xkb_event_base; - guint notify; + gboolean have_xkb; + gint xkb_event_base; + GSettings *settings; }; static void msd_keyboard_manager_class_init (MsdKeyboardManagerClass* klass); @@ -126,29 +129,6 @@ static gboolean xkb_set_keyboard_autorepeat_rate(int delay, int rate) } #endif -static char* msd_keyboard_get_hostname_key (const char *subkey) -{ - char hostname[HOST_NAME_MAX + 1]; - - if (gethostname (hostname, sizeof (hostname)) == 0 && - strcmp (hostname, "localhost") != 0 && - strcmp (hostname, "localhost.localdomain") != 0) { - char *escaped; - char *key; - - escaped = mateconf_escape_key (hostname, -1); - key = g_strconcat (MSD_KEYBOARD_KEY - "/host-", - escaped, - "/0/", - subkey, - NULL); - g_free (escaped); - return key; - } else - return NULL; -} - #ifdef HAVE_X11_EXTENSIONS_XKB_H typedef enum { @@ -203,52 +183,20 @@ numlock_set_xkb_state (NumLockState new_state) XkbLockModifiers (dpy, XkbUseCoreKbd, num_mask, new_state ? num_mask : 0); } -static char * -numlock_mateconf_state_key (void) -{ - char *key = msd_keyboard_get_hostname_key ("numlock_on"); - if (!key) { - g_message ("NumLock remembering disabled because hostname is set to \"localhost\""); - } - return key; -} - static NumLockState -numlock_get_mateconf_state (MateConfClient *client) +numlock_get_settings_state (GSettings *settings) { int curr_state; - GError *err = NULL; - char *key = numlock_mateconf_state_key (); - - if (!key) { - return NUMLOCK_STATE_UNKNOWN; - } - - curr_state = mateconf_client_get_bool (client, key, &err); - if (err) { - curr_state = NUMLOCK_STATE_UNKNOWN; - g_error_free (err); - } - - g_free (key); + curr_state = g_settings_get_enum (settings, KEY_NUMLOCK_STATE); return curr_state; } -static void numlock_set_mateconf_state(MateConfClient *client, NumLockState new_state) +static void numlock_set_settings_state(GSettings *settings, NumLockState new_state) { - //printf("numlock_set_mateconf_state\n"); - char* key; - if (new_state != NUMLOCK_STATE_ON && new_state != NUMLOCK_STATE_OFF) { return; } - - key = numlock_mateconf_state_key (); - - if (key) { - mateconf_client_set_bool (client, key, new_state, NULL); - g_free (key); - } + g_settings_set_enum (settings, KEY_NUMLOCK_STATE, new_state); } static GdkFilterReturn @@ -265,9 +213,9 @@ numlock_xkb_callback (GdkXEvent *xev_, unsigned num_mask = numlock_NumLock_modifier_mask (); unsigned locked_mods = xkbev->state.locked_mods; int numlock_state = !! (num_mask & locked_mods); - MateConfClient *client = mateconf_client_get_default (); - numlock_set_mateconf_state (client, numlock_state); - g_object_unref (client); + GSettings *settings = g_settings_new (MSD_KEYBOARD_SCHEMA); + numlock_set_settings_state (settings, numlock_state); + g_object_unref (settings); } } return GDK_FILTER_CONTINUE; @@ -287,9 +235,8 @@ numlock_install_xkb_callback (MsdKeyboardManager *manager) #endif /* HAVE_X11_EXTENSIONS_XKB_H */ static void -apply_settings (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +apply_settings (GSettings *settings, + gchar *key, MsdKeyboardManager *manager) { XKeyboardControl kbdcontrol; @@ -306,23 +253,23 @@ apply_settings (MateConfClient *client, gboolean rnumlock; #endif /* HAVE_X11_EXTENSIONS_XKB_H */ - repeat = mateconf_client_get_bool (client, KEY_REPEAT, NULL); - click = mateconf_client_get_bool (client, KEY_CLICK, NULL); - rate = mateconf_client_get_int (client, KEY_RATE, NULL); - delay = mateconf_client_get_int (client, KEY_DELAY, NULL); - click_volume = mateconf_client_get_int (client, KEY_CLICK_VOLUME, NULL); + repeat = g_settings_get_boolean (settings, KEY_REPEAT); + click = g_settings_get_boolean (settings, KEY_CLICK); + rate = g_settings_get_int (settings, KEY_RATE); + delay = g_settings_get_int (settings, KEY_DELAY); + click_volume = g_settings_get_int (settings, KEY_CLICK_VOLUME); #if 0 - bell_volume = mateconf_client_get_int (client, KEY_BELL_VOLUME, NULL); + bell_volume = g_settings_get_int (settings, KEY_BELL_VOLUME); #endif - bell_pitch = mateconf_client_get_int (client, KEY_BELL_PITCH, NULL); - bell_duration = mateconf_client_get_int (client, KEY_BELL_DURATION, NULL); + bell_pitch = g_settings_get_int (settings, KEY_BELL_PITCH); + bell_duration = g_settings_get_int (settings, KEY_BELL_DURATION); - volume_string = mateconf_client_get_string (client, KEY_BELL_MODE, NULL); + volume_string = g_settings_get_string (settings, KEY_BELL_MODE); bell_volume = (volume_string && !strcmp (volume_string, "on")) ? 50 : 0; g_free (volume_string); #ifdef HAVE_X11_EXTENSIONS_XKB_H - rnumlock = mateconf_client_get_bool (client, MSD_KEYBOARD_KEY "/remember_numlock_state", NULL); + rnumlock = g_settings_get_boolean (settings, KEY_NUMLOCK_REMEMBER); #endif /* HAVE_X11_EXTENSIONS_XKB_H */ gdk_error_trap_push (); @@ -361,7 +308,7 @@ apply_settings (MateConfClient *client, #ifdef HAVE_X11_EXTENSIONS_XKB_H if (manager->priv->have_xkb && rnumlock) { - numlock_set_xkb_state (numlock_get_mateconf_state (client)); + numlock_set_xkb_state (numlock_get_settings_state (settings)); } #endif /* HAVE_X11_EXTENSIONS_XKB_H */ @@ -372,30 +319,22 @@ apply_settings (MateConfClient *client, void msd_keyboard_manager_apply_settings (MsdKeyboardManager *manager) { - MateConfClient *client; - - client = mateconf_client_get_default (); - apply_settings (client, 0, NULL, manager); - g_object_unref (client); + apply_settings (manager->priv->settings, NULL, manager); } static gboolean start_keyboard_idle_cb (MsdKeyboardManager *manager) { - MateConfClient *client; - mate_settings_profile_start (NULL); g_debug ("Starting keyboard manager"); manager->priv->have_xkb = 0; - client = mateconf_client_get_default (); - - mateconf_client_add_dir (client, MSD_KEYBOARD_KEY, MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); + manager->priv->settings = g_settings_new (MSD_KEYBOARD_SCHEMA); /* Essential - xkb initialization should happen before */ msd_keyboard_xkb_set_post_activation_callback ((PostActivationCallback) msd_load_modmap_files, NULL); - msd_keyboard_xkb_init (client, manager); + msd_keyboard_xkb_init (manager); #ifdef HAVE_X11_EXTENSIONS_XKB_H numlock_xkb_init (manager); @@ -404,11 +343,7 @@ start_keyboard_idle_cb (MsdKeyboardManager *manager) /* apply current settings before we install the callback */ msd_keyboard_manager_apply_settings (manager); - manager->priv->notify = mateconf_client_notify_add (client, MSD_KEYBOARD_KEY, - (MateConfClientNotifyFunc) apply_settings, manager, - NULL, NULL); - - g_object_unref (client); + g_signal_connect (manager->priv->settings, "changed", G_CALLBACK (apply_settings), manager); #ifdef HAVE_X11_EXTENSIONS_XKB_H numlock_install_xkb_callback (manager); @@ -439,12 +374,9 @@ msd_keyboard_manager_stop (MsdKeyboardManager *manager) g_debug ("Stopping keyboard manager"); - if (p->notify != 0) { - MateConfClient *client = mateconf_client_get_default (); - mateconf_client_remove_dir (client, MSD_KEYBOARD_KEY, NULL); - mateconf_client_notify_remove (client, p->notify); - g_object_unref (client); - p->notify = 0; + if (p->settings != NULL) { + g_object_unref (p->settings); + p->settings = NULL; } #if HAVE_X11_EXTENSIONS_XKB_H diff --git a/plugins/keyboard/msd-keyboard-xkb.c b/plugins/keyboard/msd-keyboard-xkb.c index 9042f03..546c3d8 100644 --- a/plugins/keyboard/msd-keyboard-xkb.c +++ b/plugins/keyboard/msd-keyboard-xkb.c @@ -29,7 +29,7 @@ #include <gdk/gdk.h> #include <gdk/gdkx.h> #include <gtk/gtk.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include <libmatekbd/matekbd-status.h> #include <libmatekbd/matekbd-keyboard-drawing.h> @@ -44,8 +44,16 @@ #define GTK_RESPONSE_PRINT 2 +#define MATEKBD_DESKTOP_SCHEMA "org.mate.peripherals-keyboard-xkb.general" +#define MATEKBD_KBD_SCHEMA "org.mate.peripherals-keyboard-xkb.kbd" + +#define KNOWN_FILES_KEY "known-file-list" + static MsdKeyboardManager* manager = NULL; +static GSettings* settings_desktop; +static GSettings* settings_kbd; + static XklEngine* xkl_engine; static XklConfigRegistry* xkl_registry = NULL; @@ -57,20 +65,9 @@ static MatekbdKeyboardConfig initial_sys_kbd_config; static gboolean inited_ok = FALSE; -static guint notify_desktop = 0; -static guint notify_keyboard = 0; - static PostActivationCallback pa_callback = NULL; static void *pa_callback_user_data = NULL; -static const char KNOWN_FILES_KEY[] = "/desktop/mate/peripherals/keyboard/general/known_file_list"; - -static const char DISABLE_INDICATOR_KEY[] = "/desktop/mate/peripherals/keyboard/general/disable_indicator"; - -static const char DUPLICATE_LEDS_KEY[] = "/desktop/mate/peripherals/keyboard/general/duplicate_leds"; - -static const char* mdm_keyboard_layout = NULL; - static GtkStatusIcon* icon = NULL; static GHashTable* preview_dialogs = NULL; @@ -107,6 +104,24 @@ static void msd_keyboard_log_appender(const char file[], const char function[], } #endif +static void g_strv_delete_str (gchar **a, gchar *str) +{ + int i; + int j; + gchar **b; + b = g_new0 (gchar *, g_strv_length (a) - 1); + + j = 0; + for (i = 0; a[i] != NULL; i++) { + if (g_strcmp0 (a[i], str) != 0) { + b[j] = g_strdup (a[i]); + j++; + } + } + g_strfreev (a); + a = b; +} + static void activation_error (void) { @@ -147,7 +162,7 @@ activation_error (void) "Try using a simpler configuration or using a later version of the XFree software.") : "", "xprop -root | grep XKB", - "mateconftool-2 -R /desktop/mate/peripherals/keyboard/kbd"); + "gsettings list-keys org.mate.peripherals-keyboard-xkb.kbd"); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); msd_delayed_show_dialog (dialog); @@ -156,22 +171,19 @@ activation_error (void) static void apply_desktop_settings (void) { - MateConfClient *conf_client; gboolean show_leds; int i; if (!inited_ok) return; msd_keyboard_manager_apply_settings (manager); - matekbd_desktop_config_load_from_mateconf (¤t_config); + matekbd_desktop_config_load_from_gsettings (¤t_config); /* again, probably it would be nice to compare things before activating them */ matekbd_desktop_config_activate (¤t_config); - conf_client = mateconf_client_get_default (); - show_leds = - mateconf_client_get_bool (conf_client, DUPLICATE_LEDS_KEY, NULL); - g_object_unref (conf_client); + /* FIXME add an option to GSettings to duplicate leds? */ + show_leds = FALSE; for (i = sizeof (indicator_icons) / sizeof (indicator_icons[0]); --i >= 0;) { gtk_status_icon_set_visible (indicator_icons[i], @@ -180,6 +192,12 @@ apply_desktop_settings (void) } static void +apply_desktop_settings_cb (GSettings *settings, gchar *key, gpointer user_data) +{ + apply_desktop_settings (); +} + +static void popup_menu_launch_capplet () { GError *error = NULL; @@ -326,15 +344,10 @@ status_icon_popup_menu_cb (GtkStatusIcon * icon, guint button, guint time) static void show_hide_icon () { - if (g_slist_length (current_kbd_config.layouts_variants) > 1) { + if (g_strv_length (current_kbd_config.layouts_variants) > 1) { if (icon == NULL) { - MateConfClient *conf_client = - mateconf_client_get_default (); - gboolean disable = - mateconf_client_get_bool (conf_client, - DISABLE_INDICATOR_KEY, - NULL); - g_object_unref (conf_client); + /* FIXME add an option to GSettings to disable this? */ + gboolean disable = FALSE; if (disable) return; @@ -380,8 +393,8 @@ filter_xkb_config (void) XklConfigItem *item; gchar *lname; gchar *vname; - GSList *lv; - GSList *filtered; + gchar **lv; + int i; gboolean any_change = FALSE; xkl_debug (100, "Filtering configuration against the registry\n"); @@ -395,25 +408,20 @@ filter_xkb_config (void) return FALSE; } } - lv = current_kbd_config.layouts_variants; + lv = g_strdupv(current_kbd_config.layouts_variants); item = xkl_config_item_new (); - while (lv) { - xkl_debug (100, "Checking [%s]\n", lv->data); + for (lv = 0; lv[i] != NULL; i++) { + xkl_debug (100, "Checking [%s]\n", lv[i]); if (matekbd_keyboard_config_split_items - (lv->data, &lname, &vname)) { + (lv[i], &lname, &vname)) { g_snprintf (item->name, sizeof (item->name), "%s", lname); if (!xkl_config_registry_find_layout (xkl_registry, item)) { xkl_debug (100, "Bad layout [%s]\n", lname); - filtered = lv; - lv = lv->next; - g_free (filtered->data); - current_kbd_config.layouts_variants = - g_slist_delete_link - (current_kbd_config.layouts_variants, - filtered); + g_strv_delete_str (current_kbd_config.layouts_variants, + lv[i]); any_change = TRUE; continue; } @@ -426,20 +434,14 @@ filter_xkb_config (void) xkl_debug (100, "Bad variant [%s(%s)]\n", lname, vname); - filtered = lv; - lv = lv->next; - g_free (filtered->data); - current_kbd_config.layouts_variants - = - g_slist_delete_link + g_strv_delete_str (current_kbd_config.layouts_variants, - filtered); + lv[i]); any_change = TRUE; continue; } } } - lv = lv->next; } g_object_unref (item); return any_change; @@ -448,108 +450,14 @@ filter_xkb_config (void) static void apply_xkb_settings (void) { - MateConfClient *conf_client; MatekbdKeyboardConfig current_sys_kbd_config; - int group_to_activate = -1; - char *mdm_layout; - char *s; if (!inited_ok) return; - conf_client = mateconf_client_get_default (); - - /* With MDM the user can already set a layout from the login - * screen. Try to keep that setting. - * We clear mdm_keyboard_layout early, so we don't risk - * recursion from mateconf notification. - */ - mdm_layout = g_strdup (mdm_keyboard_layout); - mdm_keyboard_layout = NULL; - - /* mdm's configuration and $MDM_KEYBOARD_LAYOUT separates layout and - * variant with a space, but mateconf uses tabs; so convert to be robust - * with both */ - for (s = mdm_layout; s && *s; ++s) { - if (*s == ' ') { - *s = '\t'; - } - } + matekbd_keyboard_config_init (¤t_sys_kbd_config, xkl_engine); - if (mdm_layout != NULL) { - GSList *layouts; - GSList *found_node; - int max_groups; - - max_groups = - MAX (xkl_engine_get_max_num_groups (xkl_engine), 1); - layouts = - mateconf_client_get_list (conf_client, - MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, - MATECONF_VALUE_STRING, NULL); - - /* Use system layouts as a default if we do not have - * user configuration */ - if (layouts == NULL) { - GSList *i; - int len; - - for (i = initial_sys_kbd_config.layouts_variants; - i; i = g_slist_next (i)) { - s = g_strdup (i->data); - - /* chop off empty variants to avoid duplicates */ - len = strlen (s); - if (s[len - 1] == '\t') - s[len - 1] = '\0'; - layouts = g_slist_append (layouts, s); - } - } - - /* Add the layout if it doesn't already exist. XKB limits the - * total number of layouts. If we already have the maximum - * number of layouts configured, we replace the last one. This - * prevents the list from becoming full if the user has a habit - * of selecting many different keyboard layouts in MDM. */ - - found_node = - g_slist_find_custom (layouts, mdm_layout, - (GCompareFunc) g_strcmp0); - - if (!found_node) { - /* Insert at the last valid place, or at the end of - * list, whichever comes first */ - layouts = - g_slist_insert (layouts, g_strdup (mdm_layout), - max_groups - 1); - if (g_slist_length (layouts) > max_groups) { - GSList *last; - GSList *free_layouts; - - last = - g_slist_nth (layouts, max_groups - 1); - free_layouts = last->next; - last->next = NULL; - - g_slist_foreach (free_layouts, - (GFunc) g_free, NULL); - g_slist_free (free_layouts); - } - - mateconf_client_set_list (conf_client, - MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS, - MATECONF_VALUE_STRING, layouts, - NULL); - } - - g_slist_foreach (layouts, (GFunc) g_free, NULL); - g_slist_free (layouts); - } - - matekbd_keyboard_config_init (¤t_sys_kbd_config, - conf_client, xkl_engine); - - matekbd_keyboard_config_load_from_mateconf (¤t_kbd_config, + matekbd_keyboard_config_load_from_gsettings (¤t_kbd_config, &initial_sys_kbd_config); matekbd_keyboard_config_load_from_x_current (¤t_sys_kbd_config, @@ -572,47 +480,25 @@ apply_xkb_settings (void) xkl_debug (100, "Actual KBD configuration was not changed: redundant notification\n"); - if (mdm_layout != NULL) { - /* If there are multiple layouts, - * try to find the one closest to the mdm layout - */ - GSList *l; - int i; - size_t len = strlen (mdm_layout); - for (i = 0, l = current_kbd_config.layouts_variants; l; - i++, l = l->next) { - char *lv = l->data; - if (strncmp (lv, mdm_layout, len) == 0 - && (lv[len] == '\0' || lv[len] == '\t')) { - group_to_activate = i; - break; - } - } - } - - g_free (mdm_layout); - - if (group_to_activate != -1) - xkl_engine_lock_group (current_config.engine, - group_to_activate); matekbd_keyboard_config_term (¤t_sys_kbd_config); show_hide_icon (); } static void -msd_keyboard_xkb_analyze_sysconfig (void) +apply_xkb_settings_cb (GSettings *settings, gchar *key, gpointer user_data) { - MateConfClient *conf_client; + apply_xkb_settings (); +} +static void +msd_keyboard_xkb_analyze_sysconfig (void) +{ if (!inited_ok) return; - conf_client = mateconf_client_get_default (); - matekbd_keyboard_config_init (&initial_sys_kbd_config, - conf_client, xkl_engine); + matekbd_keyboard_config_init (&initial_sys_kbd_config, xkl_engine); matekbd_keyboard_config_load_from_x_initial (&initial_sys_kbd_config, NULL); - g_object_unref (conf_client); } static gboolean @@ -625,7 +511,6 @@ msd_chk_file_list (void) GSList *tmp = NULL; GSList *tmp_l = NULL; gboolean new_file_exist = FALSE; - MateConfClient *conf_client; home_dir = g_dir_open (g_get_home_dir (), 0, NULL); while ((fname = g_dir_read_name (home_dir)) != NULL) { @@ -636,12 +521,17 @@ msd_chk_file_list (void) } g_dir_close (home_dir); - conf_client = mateconf_client_get_default (); - - last_login_file_list = mateconf_client_get_list (conf_client, - KNOWN_FILES_KEY, - MATECONF_VALUE_STRING, - NULL); + gchar **settings_list; + settings_list = g_settings_get_strv (settings_desktop, KNOWN_FILES_KEY); + if (settings_list != NULL) { + gint i; + for (i = 0; i < G_N_ELEMENTS (settings_list); i++) { + if (settings_list[i] != NULL) + last_login_file_list = + g_slist_append (last_login_file_list, g_strdup (settings_list[i])); + } + g_strfreev (settings_list); + } /* Compare between the two file list, currently available modmap files and the files available in the last log in */ @@ -665,14 +555,15 @@ msd_chk_file_list (void) } if (new_file_exist) { - mateconf_client_set_list (conf_client, - KNOWN_FILES_KEY, - MATECONF_VALUE_STRING, - file_list, NULL); + GSList *l; + GPtrArray *array = g_ptr_array_new (); + for (l = file_list; l != NULL; l = l->next) + g_ptr_array_add (array, l->data); + g_ptr_array_add (array, NULL); + g_settings_set_strv (settings_desktop, KNOWN_FILES_KEY, (const gchar **) array->pdata); + g_ptr_array_free (array, FALSE); } - g_object_unref (conf_client); - g_slist_foreach (file_list, (GFunc) g_free, NULL); g_slist_free (file_list); @@ -708,16 +599,6 @@ msd_keyboard_xkb_evt_filter (GdkXEvent * xev, GdkEvent * event) return GDK_FILTER_CONTINUE; } -static guint -register_config_callback (MateConfClient * client, - const char *path, MateConfClientNotifyFunc func) -{ - mateconf_client_add_dir (client, path, MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - return mateconf_client_notify_add (client, path, func, NULL, NULL, - NULL); -} - /* When new Keyboard is plugged in - reload the settings */ static void msd_keyboard_new_device (XklEngine * engine) @@ -770,8 +651,7 @@ msd_keyboard_state_changed (XklEngine * engine, XklEngineStateChange type, } void -msd_keyboard_xkb_init (MateConfClient * client, - MsdKeyboardManager * kbd_manager) +msd_keyboard_xkb_init (MsdKeyboardManager * kbd_manager) { int i; Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); @@ -806,12 +686,13 @@ msd_keyboard_xkb_init (MateConfClient * client, if (xkl_engine) { inited_ok = TRUE; - mdm_keyboard_layout = g_getenv ("MDM_KEYBOARD_LAYOUT"); + settings_desktop = g_settings_new (MATEKBD_DESKTOP_SCHEMA); + settings_kbd = g_settings_new (MATEKBD_KBD_SCHEMA); matekbd_desktop_config_init (¤t_config, - client, xkl_engine); + xkl_engine); matekbd_keyboard_config_init (¤t_kbd_config, - client, xkl_engine); + xkl_engine); xkl_engine_backup_names_prop (xkl_engine); msd_keyboard_xkb_analyze_sysconfig (); mate_settings_profile_start @@ -820,17 +701,8 @@ msd_keyboard_xkb_init (MateConfClient * client, mate_settings_profile_end ("msd_keyboard_xkb_chk_lcl_xmm"); - notify_desktop = - register_config_callback (client, - MATEKBD_DESKTOP_CONFIG_DIR, - (MateConfClientNotifyFunc) - apply_desktop_settings); - - notify_keyboard = - register_config_callback (client, - MATEKBD_KEYBOARD_CONFIG_DIR, - (MateConfClientNotifyFunc) - apply_xkb_settings); + g_signal_connect (settings_desktop, "changed", G_CALLBACK(apply_desktop_settings_cb), NULL); + g_signal_connect (settings_kbd, "changed", G_CALLBACK(apply_xkb_settings_cb), NULL); gdk_window_add_filter (NULL, (GdkFilterFunc) msd_keyboard_xkb_evt_filter, NULL); @@ -865,7 +737,6 @@ msd_keyboard_xkb_init (MateConfClient * client, void msd_keyboard_xkb_shutdown (void) { - MateConfClient *client; int i; pa_callback = NULL; @@ -890,27 +761,18 @@ msd_keyboard_xkb_shutdown (void) gdk_window_remove_filter (NULL, (GdkFilterFunc) msd_keyboard_xkb_evt_filter, NULL); - client = mateconf_client_get_default (); - - if (notify_desktop != 0) { - mateconf_client_remove_dir (client, MATEKBD_DESKTOP_CONFIG_DIR, - NULL); - mateconf_client_notify_remove (client, notify_desktop); - notify_desktop = 0; + if (settings_desktop != NULL) { + g_object_unref (settings_desktop); } - if (notify_keyboard != 0) { - mateconf_client_remove_dir (client, MATEKBD_KEYBOARD_CONFIG_DIR, - NULL); - mateconf_client_notify_remove (client, notify_keyboard); - notify_keyboard = 0; + if (settings_kbd != NULL) { + g_object_unref (settings_kbd); } if (xkl_registry) { g_object_unref (xkl_registry); } - g_object_unref (client); g_object_unref (xkl_engine); xkl_engine = NULL; diff --git a/plugins/keyboard/msd-keyboard-xkb.h b/plugins/keyboard/msd-keyboard-xkb.h index 7d2d558..816e341 100644 --- a/plugins/keyboard/msd-keyboard-xkb.h +++ b/plugins/keyboard/msd-keyboard-xkb.h @@ -24,13 +24,10 @@ #ifndef __MSD_KEYBOARD_XKB_H #define __MSD_KEYBOARD_XKB_H -#include <mateconf/mateconf.h> -#include <mateconf/mateconf-client.h> - #include <libxklavier/xklavier.h> #include "msd-keyboard-manager.h" -void msd_keyboard_xkb_init(MateConfClient* client, MsdKeyboardManager* manager); +void msd_keyboard_xkb_init(MsdKeyboardManager* manager); void msd_keyboard_xkb_shutdown(void); typedef void (*PostActivationCallback) (void* userData); diff --git a/plugins/keyboard/msd-xmodmap.c b/plugins/keyboard/msd-xmodmap.c index 5baf37c..7539382 100644 --- a/plugins/keyboard/msd-xmodmap.c +++ b/plugins/keyboard/msd-xmodmap.c @@ -26,43 +26,33 @@ #include <glib.h> #include <gtk/gtk.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include "msd-xmodmap.h" -static const char DISABLE_XMM_WARNING_KEY[] = - "/desktop/mate/peripherals/keyboard/disable_xmm_and_xkb_warning"; - -static const char LOADED_FILES_KEY[] = - "/desktop/mate/peripherals/keyboard/general/update_handlers"; - - -static void -check_button_callback (GtkWidget *chk_button, - gpointer data) -{ - MateConfClient *client; - - client = mateconf_client_get_default (); - - mateconf_client_set_bool (client, - DISABLE_XMM_WARNING_KEY, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (chk_button)), - NULL); - - g_object_unref (client); -} +#define KEYBOARD_SCHEMA "org.mate.peripherals-keyboard-xkb.general" +#define LOADED_FILES_KEY "update-handlers" void msd_load_modmap_files (void) { - MateConfClient *client; + GSettings *settings; GSList *tmp; GSList *loaded_file_list; - client = mateconf_client_get_default (); + settings = g_settings_new (KEYBOARD_SCHEMA); - loaded_file_list = mateconf_client_get_list (client, LOADED_FILES_KEY, MATECONF_VALUE_STRING, NULL); + gchar **settings_list; + settings_list = g_settings_get_strv (settings, LOADED_FILES_KEY); + if (settings_list != NULL) { + gint i; + for (i = 0; i < G_N_ELEMENTS (settings_list); i++) { + if (settings_list[i] != NULL) + loaded_file_list = + g_slist_append (loaded_file_list, g_strdup (settings_list[i])); + } + g_strfreev (settings_list); + } for (tmp = loaded_file_list; tmp != NULL; tmp = tmp->next) { gchar *file; @@ -79,7 +69,7 @@ msd_load_modmap_files (void) } g_slist_free (loaded_file_list); - g_object_unref (client); + g_object_unref (settings); } static void @@ -88,8 +78,6 @@ response_callback (GtkWidget *dialog, void *data) { if (id == GTK_RESPONSE_OK) { - GtkWidget *chk_button = g_object_get_data (G_OBJECT (dialog), "check_button"); - check_button_callback (chk_button, NULL); msd_load_modmap_files (); } gtk_widget_destroy (dialog); @@ -140,7 +128,7 @@ remove_button_clicked_callback (GtkWidget *button, GtkListStore *tree = NULL; GtkTreeSelection *selection; GtkWidget *treeview; - MateConfClient *client; + GSettings *settings; GSList *filenames = NULL; GSList *tmp = NULL; GSList *loaded_files = NULL; @@ -159,20 +147,31 @@ remove_button_clicked_callback (GtkWidget *button, /* Remove the selected file */ - client = mateconf_client_get_default (); + settings = g_settings_new (KEYBOARD_SCHEMA); + + gchar **settings_list; + settings_list = g_settings_get_strv (settings, LOADED_FILES_KEY); + if (settings_list != NULL) { + gint i; + for (i = 0; i < G_N_ELEMENTS (settings_list); i++) { + if (settings_list[i] != NULL) + loaded_files = + g_slist_append (loaded_files, g_strdup (settings_list[i])); + } + g_strfreev (settings_list); + } - loaded_files = mateconf_client_get_list (client, - LOADED_FILES_KEY, - MATECONF_VALUE_STRING, - NULL); loaded_files = remove_string_from_list (loaded_files, (char *)filenames->data); - mateconf_client_set_list (client, - LOADED_FILES_KEY, - MATECONF_VALUE_STRING, - loaded_files, - NULL); - g_object_unref (client); + GSList *l; + GPtrArray *array = g_ptr_array_new (); + for (l = loaded_files; l != NULL; l = l->next) + g_ptr_array_add (array, l->data); + g_ptr_array_add (array, NULL); + g_settings_set_strv (settings, LOADED_FILES_KEY, (const gchar **) array->pdata); + g_ptr_array_free (array, FALSE); + + g_object_unref (settings); tree = g_object_get_data (G_OBJECT (dialog), "tree"); @@ -201,7 +200,7 @@ load_button_clicked_callback (GtkWidget *button, GSList *filenames = NULL; GSList *tmp = NULL; GSList *loaded_files = NULL; - MateConfClient *client; + GSettings *settings; dialog = data; @@ -216,12 +215,19 @@ load_button_clicked_callback (GtkWidget *button, return; /* Add the files to left-tree-view */ - client = mateconf_client_get_default (); - - loaded_files = mateconf_client_get_list (client, - LOADED_FILES_KEY, - MATECONF_VALUE_STRING, - NULL); + settings = g_settings_new (KEYBOARD_SCHEMA); + + gchar **settings_list; + settings_list = g_settings_get_strv (settings, LOADED_FILES_KEY); + if (settings_list != NULL) { + gint i; + for (i = 0; i < G_N_ELEMENTS (settings_list); i++) { + if (settings_list[i] != NULL) + loaded_files = + g_slist_append (loaded_files, g_strdup (settings_list[i])); + } + g_strfreev (settings_list); + } if (g_slist_find_custom (loaded_files, filenames->data, (GCompareFunc) strcmp)) { g_free (filenames->data); @@ -230,12 +236,14 @@ load_button_clicked_callback (GtkWidget *button, } loaded_files = g_slist_append (loaded_files, filenames->data); - mateconf_client_set_list (client, - LOADED_FILES_KEY, - MATECONF_VALUE_STRING, - loaded_files, - NULL); + GSList *l; + GPtrArray *array = g_ptr_array_new (); + for (l = loaded_files; l != NULL; l = l->next) + g_ptr_array_add (array, l->data); + g_ptr_array_add (array, NULL); + g_settings_set_strv (settings, LOADED_FILES_KEY, (const gchar **) array->pdata); + g_ptr_array_free (array, FALSE); tree = g_object_get_data (G_OBJECT (dialog), "tree"); @@ -250,7 +258,7 @@ load_button_clicked_callback (GtkWidget *button, } out: - g_object_unref (client); + g_object_unref (settings); g_slist_foreach (loaded_files, (GFunc) g_free, NULL); g_slist_free (loaded_files); } @@ -273,12 +281,11 @@ msd_modmap_dialog_call (void) GtkTreeViewColumn *column; GtkWidget *add_button; GtkWidget *remove_button; - GtkWidget *chk_button; GSList *tmp; GDir *homeDir; GSList *loaded_files; const char *fname; - MateConfClient *client; + GSettings *settings; homeDir = g_dir_open (g_get_home_dir (), 0, NULL); if (homeDir == NULL) @@ -315,13 +322,6 @@ msd_modmap_dialog_call (void) "clicked", G_CALLBACK (remove_button_clicked_callback), load_dialog); - chk_button = GTK_WIDGET (gtk_builder_get_object (builder, - "checkbutton1")); - g_signal_connect (chk_button, - "toggled", - G_CALLBACK (check_button_callback), - NULL); - g_object_set_data (G_OBJECT (load_dialog), "check_button", chk_button); treeview = GTK_WIDGET (gtk_builder_get_object (builder, "treeview1")); g_object_set_data (G_OBJECT (load_dialog), "treeview1", treeview); treeview = GTK_WIDGET (gtk_builder_get_object (builder, "treeview2")); @@ -369,9 +369,19 @@ msd_modmap_dialog_call (void) gtk_tree_view_append_column (GTK_TREE_VIEW (treeview1), column); gtk_tree_view_column_set_sort_column_id (column, 0); - client = mateconf_client_get_default (); - loaded_files = mateconf_client_get_list (client, LOADED_FILES_KEY, MATECONF_VALUE_STRING, NULL); - g_object_unref (client); + settings = g_settings_new (KEYBOARD_SCHEMA); + + gchar **settings_list; + settings_list = g_settings_get_strv (settings, LOADED_FILES_KEY); + if (settings_list != NULL) { + gint i; + for (i = 0; i < G_N_ELEMENTS (settings_list); i++) { + if (settings_list[i] != NULL) + loaded_files = + g_slist_append (loaded_files, g_strdup (settings_list[i])); + } + g_strfreev (settings_list); + } /* Add the data */ for (tmp = loaded_files; tmp != NULL; tmp = tmp->next) { |