From 78bd678462f2f5cc78b8986e4d17d98e5286819d Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Mon, 22 Oct 2012 16:39:08 +0200 Subject: migrate control-center to gsettings --- shell/Makefile.am | 17 ++-------- shell/control-center.c | 36 ++++++++++++++------- shell/control-center.schemas.in | 71 ----------------------------------------- 3 files changed, 26 insertions(+), 98 deletions(-) delete mode 100644 shell/control-center.schemas.in diff --git a/shell/Makefile.am b/shell/Makefile.am index db58a1f4..9ce991ba 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -33,24 +33,11 @@ directory_in_files = matecc.directory.in directory_DATA = $(directory_in_files:.directory.in=.directory) @INTLTOOL_DIRECTORY_RULE@ -schemasdir = @MATECONF_SCHEMA_FILE_DIR@ -schemas_DATA = control-center.schemas -@INTLTOOL_SCHEMAS_RULE@ - -install-data-local: $(schema_DATA) -if MATECONF_SCHEMAS_INSTALL - if test -z "$(DESTDIR)" ; then \ - for p in $^ ; do \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $$p 2>&1 > /dev/null; \ - done \ - fi -endif - menudir = $(sysconfdir)/xdg/menus menu_DATA = matecc.menu -EXTRA_DIST = matecc.desktop.in.in matecc.directory.in matecc.menu $(schemas_DATA).in +EXTRA_DIST = matecc.desktop.in.in matecc.directory.in matecc.menu -DISTCLEANFILES = matecc.desktop matecc.desktop.in matecc.directory $(schemas_DATA) +DISTCLEANFILES = matecc.desktop matecc.desktop.in matecc.directory -include $(top_srcdir)/git.mk diff --git a/shell/control-center.c b/shell/control-center.c index b25f42d7..79dd4a5f 100644 --- a/shell/control-center.c +++ b/shell/control-center.c @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -30,23 +31,34 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data); static GSList* get_actions_list(); -#define CONTROL_CENTER_PREFIX "/apps/control-center/cc_" -#define CONTROL_CENTER_ACTIONS_LIST_KEY (CONTROL_CENTER_PREFIX "actions_list") +#define CONTROL_CENTER_SCHEMA "org.mate.control-center" +#define CONTROL_CENTER_ACTIONS_LIST_KEY "cc-actions-list" #define CONTROL_CENTER_ACTIONS_SEPARATOR ";" -#define EXIT_SHELL_ON_STATIC_ACTION "exit_shell_on_static_action" +#define EXIT_SHELL_ON_STATIC_ACTION "cc-exit-shell-on-static-action" static GSList* get_actions_list(void) { + GSettings *settings; GSList* l; - GSList* key_list; + GSList* key_list = NULL; GSList* actions_list = NULL; AppAction* action; - - key_list = get_slab_mateconf_slist(CONTROL_CENTER_ACTIONS_LIST_KEY); + gchar **array; + gint i; + + settings = g_settings_new (CONTROL_CENTER_SCHEMA); + array = g_settings_get_strv (settings, CONTROL_CENTER_ACTIONS_LIST_KEY); + if (array != NULL) { + for (i = 0; array[i]; i++) { + key_list = g_slist_append (key_list, g_strdup (array[i])); + } + } + g_strfreev (array); + g_object_unref (settings); if (!key_list) { - g_warning(_("key not found [%s]\n"), CONTROL_CENTER_ACTIONS_LIST_KEY); + g_warning(_("%s key is empty\n"), CONTROL_CENTER_ACTIONS_LIST_KEY); return NULL; } @@ -79,9 +91,9 @@ static GSList* get_actions_list(void) void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data) { - gchar* temp; AppShellData* app_data = (AppShellData*) data; MateDesktopItem* item = (MateDesktopItem*) g_object_get_data(G_OBJECT(tile), APP_ACTION_KEY); + GSettings *settings; if (event->type == TILE_EVENT_ACTIVATED_DOUBLE_CLICK) { @@ -90,9 +102,9 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data) open_desktop_item_exec(item); - temp = g_strdup_printf("%s%s", app_data->mateconf_prefix, EXIT_SHELL_ON_STATIC_ACTION); + settings = g_settings_new (CONTROL_CENTER_SCHEMA); - if (get_slab_mateconf_bool(temp)) + if (g_settings_get_boolean(settings, EXIT_SHELL_ON_STATIC_ACTION)) { if (app_data->exit_on_close) { @@ -104,7 +116,7 @@ void handle_static_action_clicked(Tile* tile, TileEvent* event, gpointer data) } } - g_free(temp); + g_object_unref(settings); } static UniqueResponse message_received_cb(UniqueApp* app, UniqueCommand command, UniqueMessageData* message, guint time, gpointer user_data) @@ -182,7 +194,7 @@ int main(int argc, char* argv[]) return retval; } - app_data = appshelldata_new("matecc.menu", NULL, CONTROL_CENTER_PREFIX, GTK_ICON_SIZE_DND, FALSE, TRUE); + app_data = appshelldata_new("matecc.menu", GTK_ICON_SIZE_DND, FALSE, TRUE); generate_categories(app_data); actions = get_actions_list(); diff --git a/shell/control-center.schemas.in b/shell/control-center.schemas.in deleted file mode 100644 index c7dce99b..00000000 --- a/shell/control-center.schemas.in +++ /dev/null @@ -1,71 +0,0 @@ - - - - /schemas/apps/control-center/cc_actions_list - /apps/control-center/cc_actions_list - control-center - list - string - - [Change Theme;gtk-theme-selector.desktop,Set Preferred Applications;default-applications.desktop,Add Printer;mate-cups-manager.desktop] - Task names and associated .desktop files - The task name to be displayed in the control-center followed by a ";" separator then the filename of an associated .desktop file to launch for that task. - - - - /schemas/apps/control-center/cc_exit_shell_on_static_action - /apps/control-center/cc_exit_shell_on_static_action - control-center - bool - false - - Close the control-center when a task is activated - if true, the control-center will close when a "Common Task" is activated. - - - - /schemas/apps/control-center/cc_exit_shell_on_action_start - /apps/control-center/cc_exit_shell_on_action_start - control-center - bool - false - - Exit shell on start action performed - Indicates whether to close the shell when a start action is performed. - - - - /schemas/apps/control-center/cc_exit_shell_on_action_help - /apps/control-center/cc_exit_shell_on_action_help - control-center - bool - false - - Exit shell on help action performed - Indicates whether to close the shell when a help action is performed. - - - - /schemas/apps/control-center/cc_exit_shell_on_action_add_remove - /apps/control-center/cc_exit_shell_on_action_add_remove - control-center - bool - false - - Exit shell on add or remove action performed - Indicates whether to close the shell when an add or remove action is performed. - - - - /schemas/apps/control-center/cc_exit_shell_on_action_upgrade_uninstall - /apps/control-center/cc_exit_shell_on_action_upgrade_uninstall - control-center - bool - false - - Exit shell on upgrade or uninstall action performed - Indicates whether to close the shell when an upgrade or uninstall action is performed. - - - - -- cgit v1.2.1