From 0f3f63d973b8084e936dccad13ccf4f683ec0ce8 Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Tue, 13 Nov 2012 12:12:33 +0100 Subject: mate-window-picker-applet: migrate to gsettings --- mate-window-picker-applet/Makefile.am | 14 ++++--- mate-window-picker-applet/applet.c | 46 +++++++--------------- .../mate-window-picker-applet.schemas.in | 13 ------ ...let.mate-window-picker-applet.gschema.xml.in.in | 9 +++++ mate-window-picker-applet/task-title.c | 15 ++----- 5 files changed, 36 insertions(+), 61 deletions(-) delete mode 100644 mate-window-picker-applet/mate-window-picker-applet.schemas.in create mode 100644 mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in.in diff --git a/mate-window-picker-applet/Makefile.am b/mate-window-picker-applet/Makefile.am index 20b39bd..74d642b 100644 --- a/mate-window-picker-applet/Makefile.am +++ b/mate-window-picker-applet/Makefile.am @@ -45,10 +45,12 @@ org.mate.panel.applet.MateWindowPickerFactory.service: $(service_in_files) -e "s|\@LOCATION\@|$(APPLET_LOCATION)|" \ $< > $@ -schemasdir = @MATECONF_SCHEMA_FILE_DIR@ -schemas_in_files = mate-window-picker-applet.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) -@INTLTOOL_SCHEMAS_RULE@ +@INTLTOOL_XML_NOMERGE_RULE@ +gsettings_SCHEMAS = org.mate.panel.applet.mate-window-picker-applet.gschema.xml +@GSETTINGS_RULES@ + +%.gschema.xml.in: %.gschema.xml.in.in Makefile + $(AM_V_GEN) $(SED) -e 's^\@GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@ xmluidir = $(datadir)/mate-panel/ui xmlui_DATA = mate-window-picker-applet-menu.xml @@ -57,9 +59,9 @@ EXTRA_DIST = \ org.mate.panel.MateWindowPicker.panel-applet.in.in \ $(service_in_files) \ $(ui_DATA) \ - $(schemas_in_files) + $(gsettings_SCHEMAS_in_in) -CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(schemas_DATA) +CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(gsettings_SCHEMAS_in) $(gsettings_SCHEMAS) clean: rm -f $(desktop_DATA) $(desktop_DATA).in $(server_DATA) $(server_DATA).in diff --git a/mate-window-picker-applet/applet.c b/mate-window-picker-applet/applet.c index c2b33a6..509bfbb 100644 --- a/mate-window-picker-applet/applet.c +++ b/mate-window-picker-applet/applet.c @@ -30,20 +30,22 @@ #include +#include #include -#include -#include +#include #include "task-list.h" #include "task-title.h" -#define SHOW_WIN_KEY "show_all_windows" +#define APPLET_SCHEMA "org.mate.panel.applet.mate-window-picker-applet" +#define SHOW_WIN_KEY "show-all-windows" typedef struct { GtkWidget *tasks; GtkWidget *applet; GtkWidget *title; + GSettings *settings; } WinPickerApp; @@ -76,9 +78,8 @@ static const gchar *close_window_authors [] = { }; static void -on_show_all_windows_changed (MateConfClient *client, - guint conn_id, - MateConfEntry *entry, +on_show_all_windows_changed (GSettings *settings, + gchar *key, gpointer data) { WinPickerApp *app; @@ -86,8 +87,7 @@ on_show_all_windows_changed (MateConfClient *client, app = (WinPickerApp*)data; - show_windows = mate_panel_applet_mateconf_get_bool (MATE_PANEL_APPLET (app->applet), - SHOW_WIN_KEY, NULL); + show_windows = g_settings_get_boolean (settings, SHOW_WIN_KEY); g_object_set (app->tasks, "show_all_windows", show_windows, NULL); } @@ -122,8 +122,6 @@ cw_applet_fill (MatePanelApplet *applet, MatewnckScreen *screen; WinPickerApp *app; GtkWidget *eb, *tasks, *title; - GError *error = NULL; - gchar *key; gchar *ui_path; GtkActionGroup *action_group; @@ -140,21 +138,10 @@ cw_applet_fill (MatePanelApplet *applet, mainapp = app; screen = matewnck_screen_get_default (); - /* mateconf prefs */ - mate_panel_applet_add_preferences (applet, - "/schemas/apps/mate-window-picker-applet/prefs", - &error); - if (error) - { - g_warning ("%s", error->message); - g_error_free (error); - } - - key = mate_panel_applet_mateconf_get_full_key (applet, SHOW_WIN_KEY); - mateconf_client_notify_add (mateconf_client_get_default (), key, - on_show_all_windows_changed, app, - NULL, NULL); - g_free (key); + /* gsettings prefs */ + app->settings = mate_panel_applet_settings_new (applet, APPLET_SCHEMA); + g_signal_connect (app->settings, "changed::" SHOW_WIN_KEY, + G_CALLBACK (on_show_all_windows_changed), app); app->applet = GTK_WIDGET (applet); force_no_focus_padding (GTK_WIDGET (applet)); @@ -172,7 +159,7 @@ cw_applet_fill (MatePanelApplet *applet, gtk_widget_show_all (GTK_WIDGET (applet)); - on_show_all_windows_changed (NULL, 0, NULL, app); + on_show_all_windows_changed (app->settings, SHOW_WIN_KEY, app); /* Signals */ g_signal_connect (applet, "change-background", @@ -287,8 +274,7 @@ on_checkbox_toggled (GtkToggleButton *check, gpointer null) is_active = gtk_toggle_button_get_active (check); - mate_panel_applet_mateconf_set_bool (MATE_PANEL_APPLET (mainapp->applet), - SHOW_WIN_KEY, is_active, NULL); + g_settings_set_boolean (mainapp->settings, SHOW_WIN_KEY, is_active); } static void @@ -317,9 +303,7 @@ display_prefs_dialog (GtkAction *action, check = gtk_check_button_new_with_label (_("Show windows from all workspaces")); gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, TRUE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), - mate_panel_applet_mateconf_get_bool ( - MATE_PANEL_APPLET (mainapp->applet), - SHOW_WIN_KEY, NULL)); + g_settings_get_boolean (mainapp->settings, SHOW_WIN_KEY)); g_signal_connect (check, "toggled", G_CALLBACK (on_checkbox_toggled), NULL); diff --git a/mate-window-picker-applet/mate-window-picker-applet.schemas.in b/mate-window-picker-applet/mate-window-picker-applet.schemas.in deleted file mode 100644 index ccceb1c..0000000 --- a/mate-window-picker-applet/mate-window-picker-applet.schemas.in +++ /dev/null @@ -1,13 +0,0 @@ - - - - /schemas/apps/mate-window-picker-applet/prefs/show_all_windows - mate-window-picker-applet - bool - true - - Show windows from all workspaces. - - - - diff --git a/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in.in b/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in.in new file mode 100644 index 0000000..88964f1 --- /dev/null +++ b/mate-window-picker-applet/org.mate.panel.applet.mate-window-picker-applet.gschema.xml.in.in @@ -0,0 +1,9 @@ + + + + true + <_summary>Show windows from all workspaces. + <_description>Show windows from all workspaces. + + + diff --git a/mate-window-picker-applet/task-title.c b/mate-window-picker-applet/task-title.c index 4795559..35d8854 100644 --- a/mate-window-picker-applet/task-title.c +++ b/mate-window-picker-applet/task-title.c @@ -21,10 +21,6 @@ #include #include -#include - -#include -#include #include "task-list.h" @@ -35,7 +31,7 @@ G_DEFINE_TYPE (TaskTitle, task_title, GTK_TYPE_EVENT_BOX); TaskTitlePrivate)) #define LOGOUT "mate-session-save --kill --gui" -#define SHOW_HOME_TITLE_KEY "/apps/window-picker-applet/show_home_title" +#define SHOW_HOME_TITLE_KEY "show-home-title" struct _TaskTitlePrivate { @@ -406,7 +402,6 @@ static void task_title_init (TaskTitle *title) { TaskTitlePrivate *priv; - MateConfClient *client; GdkScreen *gdkscreen; GtkIconTheme *theme; GtkSettings *settings; @@ -419,11 +414,9 @@ task_title_init (TaskTitle *title) priv->screen = matewnck_screen_get_default (); priv->window = NULL; - client = mateconf_client_get_default (); - priv->show_home_title = mateconf_client_get_bool (client, - SHOW_HOME_TITLE_KEY, - NULL); - g_object_unref (client); + /* FIXME we can add an option for this in future */ + /* now it's disabled with gsettings migration */ + priv->show_home_title = FALSE; gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK); -- cgit v1.2.1