summaryrefslogtreecommitdiff
path: root/charpick
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-11-24 18:17:36 +0100
committerStefano Karapetsas <[email protected]>2012-11-24 18:17:36 +0100
commitd2d15da67e19e821d051d1b2382885854acd140c (patch)
tree21989327fc0e6a8d36e37318de970c7f6e72b6fe /charpick
parent8ea3054c1e05445f990c98db033754cf190d2a7a (diff)
downloadmate-applets-d2d15da67e19e821d051d1b2382885854acd140c.tar.bz2
mate-applets-d2d15da67e19e821d051d1b2382885854acd140c.tar.xz
charpick: migrate to gsettings
Diffstat (limited to 'charpick')
-rw-r--r--charpick/Makefile.am23
-rw-r--r--charpick/charpick.c66
-rw-r--r--charpick/charpick.h5
-rw-r--r--charpick/charpick.schemas.in36
-rw-r--r--charpick/org.mate.panel.applet.charpick.gschema.xml.in.in14
-rw-r--r--charpick/properties.c18
6 files changed, 47 insertions, 115 deletions
diff --git a/charpick/Makefile.am b/charpick/Makefile.am
index 40c62338..2597bded 100644
--- a/charpick/Makefile.am
+++ b/charpick/Makefile.am
@@ -4,7 +4,7 @@ INCLUDES = \
-I. \
-I$(srcdir) \
-DCHARPICK_MENU_UI_DIR=\""$(uidir)"\" \
- $(MATE_APPLETS3_CFLAGS) \
+ $(MATE_APPLETS4_CFLAGS) \
$(GUCHARMAP_CFLAGS)
libexec_PROGRAMS = charpick_applet2
@@ -14,7 +14,7 @@ charpick_applet2_SOURCES = charpick.c \
properties.c
charpick_applet2_LDADD = \
- $(MATE_APPLETS3_LIBS) \
+ $(MATE_APPLETS4_LIBS) \
$(GUCHARMAP_LIBS)
appletdir = $(datadir)/mate-panel/applets
@@ -38,25 +38,22 @@ org.mate.panel.applet.CharpickerAppletFactory.service: $(service_in_files)
-e "s|\@LIBEXECDIR\@|$(libexecdir)|" \
$< > $@
-CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(schemas_DATA)
+@INTLTOOL_XML_NOMERGE_RULE@
+gsettings_SCHEMAS = org.mate.panel.applet.charpick.gschema.xml
+@GSETTINGS_RULES@
-schemasdir = @MATECONF_SCHEMA_FILE_DIR@
-schemas_in_files = charpick.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
+%.gschema.xml.in: %.gschema.xml.in.in Makefile
+ $(AM_V_GEN) $(SED) -e 's^\@GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@
-@INTLTOOL_SCHEMAS_RULE@
uidir = $(datadir)/mate-2.0/ui
ui_DATA = charpick-applet-menu.xml
+CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(gsettings_SCHEMAS_in) $(gsettings_SCHEMAS) *.gschema.valid
+
EXTRA_DIST = \
org.mate.applets.CharpickerApplet.mate-panel-applet.in.in \
$(service_in_files) \
$(ui_DATA) \
- $(schemas_in_files)
-
-if MATECONF_SCHEMAS_INSTALL
-install-data-local:
- MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(schemas_DATA) ;
-endif
+ $(gsettings_SCHEMAS_in_in)
-include $(top_srcdir)/git.mk
diff --git a/charpick/charpick.c b/charpick/charpick.c
index 1c544338..3e3ab77b 100644
--- a/charpick/charpick.c
+++ b/charpick/charpick.c
@@ -5,6 +5,7 @@
#include <config.h>
#include <string.h>
#include <mate-panel-applet.h>
+#include <mate-panel-applet-gsettings.h>
#ifdef HAVE_GUCHARMAP
# include <gucharmap/gucharmap.h>
#endif
@@ -112,25 +113,6 @@ static const gunichar * const chartable[] = {
af_ZA_code
};
-gboolean
-key_writable (MatePanelApplet *applet, const char *key)
-{
- gboolean writable;
- char *fullkey;
- static MateConfClient *client = NULL;
- if (client == NULL)
- client = mateconf_client_get_default ();
-
- fullkey = mate_panel_applet_mateconf_get_full_key (applet, key);
-
- writable = mateconf_client_key_is_writable (client, fullkey, NULL);
-
- g_free (fullkey);
-
- return writable;
-}
-
-
/* sets the picked character as the selection when it gets a request */
static void
charpick_selection_handler(GtkWidget *widget,
@@ -299,8 +281,8 @@ menuitem_activated (GtkMenuItem *menuitem, charpick_data *curr_data)
curr_data->charlist = string;
build_table (curr_data);
- if (key_writable (applet, "current_list"))
- mate_panel_applet_mateconf_set_string (applet, "current_list", curr_data->charlist, NULL);
+ if (g_settings_is_writable (curr_data->settings, "current-list"))
+ g_settings_set_string (curr_data->settings, "current-list", curr_data->charlist);
}
void
@@ -653,46 +635,20 @@ applet_destroy (GtkWidget *widget, gpointer data)
void
save_chartable (charpick_data *curr_data)
{
- MatePanelApplet *applet = MATE_PANEL_APPLET (curr_data->applet);
- MateConfValue *value;
- GList *list = curr_data->chartable;
- GSList *slist = NULL;
-
- while (list) {
- gchar *charlist = list->data;
- MateConfValue *v1;
- v1 = mateconf_value_new_from_string (MATECONF_VALUE_STRING, charlist, NULL);
- slist = g_slist_append (slist, v1);
- list = g_list_next (list);
- }
-
- value = mateconf_value_new (MATECONF_VALUE_LIST);
- mateconf_value_set_list_type (value, MATECONF_VALUE_STRING);
- mateconf_value_set_list_nocopy (value, slist);
- mate_panel_applet_mateconf_set_value (applet, "chartable", value, NULL);
- mateconf_value_free (value);
+ mate_panel_applet_settings_set_glist (curr_data->settings,
+ "chartable", curr_data->chartable);
}
static void
get_chartable (charpick_data *curr_data)
{
MatePanelApplet *applet = MATE_PANEL_APPLET (curr_data->applet);
- MateConfValue *value;
gint i, n;
+ GSList *value = NULL;
- value = mate_panel_applet_mateconf_get_value (applet, "chartable", NULL);
+ value = mate_panel_applet_settings_get_gslist (curr_data->settings, "chartable");
if (value) {
- GSList *slist = mateconf_value_get_list (value);
- while (slist) {
- MateConfValue *v1 = slist->data;
- gchar *charlist;
-
- charlist = g_strdup (mateconf_value_get_string (v1));
- curr_data->chartable = g_list_append (curr_data->chartable, charlist);
-
- slist = g_slist_next (slist);
- }
- mateconf_value_free (value);
+ curr_data->chartable = value;
}
else {
n = G_N_ELEMENTS (chartable);
@@ -703,7 +659,7 @@ get_chartable (charpick_data *curr_data)
curr_data->chartable = g_list_append (curr_data->chartable, string);
}
- if ( ! key_writable (MATE_PANEL_APPLET (curr_data->applet), "chartable"))
+ if ( ! g_settings_is_writable (curr_data->settings, "chartable"))
save_chartable (curr_data);
}
@@ -760,7 +716,6 @@ charpicker_applet_fill (MatePanelApplet *applet)
mate_panel_applet_set_background_widget (applet, GTK_WIDGET (applet));
- mate_panel_applet_add_preferences (applet, "/schemas/apps/charpick/prefs", NULL);
mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
curr_data = g_new0 (charpick_data, 1);
@@ -768,10 +723,11 @@ charpicker_applet_fill (MatePanelApplet *applet)
curr_data->applet = GTK_WIDGET (applet);
curr_data->about_dialog = NULL;
curr_data->add_edit_dialog = NULL;
+ curr_data->settings = mate_panel_applet_settings_new (applet, "org.mate.panel.applet.charpick");
get_chartable (curr_data);
- string = mate_panel_applet_mateconf_get_string (applet, "current_list", NULL);
+ string = g_settings_get_string (curr_data->settings, "current-list");
if (string) {
list = curr_data->chartable;
while (list) {
diff --git a/charpick/charpick.h b/charpick/charpick.h
index 4a945334..939556ba 100644
--- a/charpick/charpick.h
+++ b/charpick/charpick.h
@@ -3,9 +3,9 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include <mate-panel-applet.h>
-#include <mate-panel-applet-mateconf.h>
+#include <mate-panel-applet-gsettings.h>
#define NO_LAST_INDEX -1
@@ -28,6 +28,7 @@ struct _charpick_data {
GtkWidget *menu;
GtkWidget *add_edit_dialog;
GtkWidget *add_edit_entry;
+ GSettings *settings;
};
diff --git a/charpick/charpick.schemas.in b/charpick/charpick.schemas.in
deleted file mode 100644
index bb3c9d7c..00000000
--- a/charpick/charpick.schemas.in
+++ /dev/null
@@ -1,36 +0,0 @@
-<mateconfschemafile>
- <schemalist>
-
- <schema>
- <key>/schemas/apps/charpick/prefs/default_list</key>
- <owner>charpick_applet2</owner>
- <type>string</type>
- <locale name="C">
- <short>DEPRECATED - Characters shown on applet startup</short>
- <long></long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/charpick/prefs/current_list</key>
- <owner>charpick_applet2</owner>
- <type>string</type>
- <locale name="C">
- <short>Characters shown on applet startup</short>
- <long>The string that the user had selected when the applet was last used. This string will be displayed when the user starts the applet.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/charpick/prefs/chartable</key>
- <owner>charpick_applet2</owner>
- <type>list</type>
- <list_type>string</list_type>
- <locale name="C">
- <short>List of available palettes</short>
- <long>List of strings containing the available palettes.</long>
- </locale>
- </schema>
-
- </schemalist>
-</mateconfschemafile>
diff --git a/charpick/org.mate.panel.applet.charpick.gschema.xml.in.in b/charpick/org.mate.panel.applet.charpick.gschema.xml.in.in
new file mode 100644
index 00000000..555cc4b6
--- /dev/null
+++ b/charpick/org.mate.panel.applet.charpick.gschema.xml.in.in
@@ -0,0 +1,14 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+ <schema id="org.mate.panel.applet.charpick">
+ <key name="current-list" type="s">
+ <default>''</default>
+ <_summary>Characters shown on applet startup</_summary>
+ <_description>The string that the user had selected when the applet was last used. This string will be displayed when the user starts the applet.</_description>
+ </key>
+ <key name="chartable" type="as">
+ <default>[]</default>
+ <_summary>List of available palettes</_summary>
+ <_description>List of strings containing the available palettes.</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/charpick/properties.c b/charpick/properties.c
index c3347352..ba979385 100644
--- a/charpick/properties.c
+++ b/charpick/properties.c
@@ -162,10 +162,10 @@ add_palette_cb (GtkDialog *dialog, int response_id, charpick_data *curr_data)
curr_data->charlist = curr_data->chartable->data;
build_table (curr_data);
- if (key_writable (MATE_PANEL_APPLET (curr_data->applet), "current_list"))
- mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (curr_data->applet),
- "current_list",
- curr_data->charlist, NULL);
+ if (g_settings_is_writable (curr_data->settings, "current-list"))
+ g_settings_set_string (curr_data->settings,
+ "current-list",
+ curr_data->charlist);
}
save_chartable (curr_data);
@@ -226,8 +226,8 @@ edit_palette_cb (GtkDialog *dialog, int response_id, charpick_data *curr_data)
curr_data->charlist = new;
build_table (curr_data);
- if (key_writable (MATE_PANEL_APPLET (curr_data->applet), "current_list"))
- mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (curr_data->applet), "current_list", curr_data->charlist, NULL);
+ if (g_settings_is_writable (curr_data->settings, "current-list"))
+ g_settings_set_string (curr_data->settings, "current-list", curr_data->charlist);
}
g_free (charlist);
@@ -315,8 +315,8 @@ delete_palette (GtkButton *button, charpick_data *curr_data)
if (g_ascii_strcasecmp (curr_data->charlist, charlist) == 0) {
curr_data->charlist = curr_data->chartable != NULL ?
curr_data->chartable->data : "";
- if (key_writable (MATE_PANEL_APPLET (curr_data->applet), "current_list"))
- mate_panel_applet_mateconf_set_string (MATE_PANEL_APPLET (curr_data->applet), "current_list", curr_data->charlist, NULL);
+ if (g_settings_is_writable (curr_data->settings, "current-list"))
+ g_settings_set_string (curr_data->settings, "current-list", curr_data->charlist);
}
g_free (charlist);
@@ -489,7 +489,7 @@ static void default_chars_frame_create(charpick_data *curr_data)
set_access_namedesc (button, _("Delete button"),
_("Click to delete the selected palette"));
- if ( ! key_writable (MATE_PANEL_APPLET (curr_data->applet), "chartable"))
+ if ( ! g_settings_is_writable (curr_data->settings, "chartable"))
gtk_widget_set_sensitive (vbox3, FALSE);
return;