diff options
author | Stefano Karapetsas <[email protected]> | 2013-01-24 21:06:15 +0100 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2013-01-24 21:06:15 +0100 |
commit | f2b686d6f67dacc30c0f497a99485e279def6cf4 (patch) | |
tree | e9dbc5c299f1175a815e6b4642b7f516e833fc99 /plugins | |
parent | 0a745cb559ffbcfad564437b214e649e0476d0f3 (diff) | |
download | pluma-f2b686d6f67dacc30c0f497a99485e279def6cf4.tar.bz2 pluma-f2b686d6f67dacc30c0f497a99485e279def6cf4.tar.xz |
time: Migrate to GSettings
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/time/Makefile.am | 13 | ||||
-rw-r--r-- | plugins/time/org.mate.pluma.plugins.time.gschema.xml.in.in | 23 | ||||
-rwxr-xr-x | plugins/time/pluma-time-plugin.c | 107 |
3 files changed, 62 insertions, 81 deletions
diff --git a/plugins/time/Makefile.am b/plugins/time/Makefile.am index bfb442b6..398e84b4 100755 --- a/plugins/time/Makefile.am +++ b/plugins/time/Makefile.am @@ -27,10 +27,17 @@ plugin_in_files = time.pluma-plugin.desktop.in plugin_DATA = $(plugin_in_files:.pluma-plugin.desktop.in=.pluma-plugin) -EXTRA_DIST = $(ui_DATA) $(plugin_in_files) +@INTLTOOL_XML_NOMERGE_RULE@ +gsettings_SCHEMAS = org.mate.pluma.plugins.time.gschema.xml +@GSETTINGS_RULES@ -CLEANFILES = $(plugin_DATA) -DISTCLEANFILES = $(plugin_DATA) +%.gschema.xml.in: %.gschema.xml.in.in Makefile + $(AM_V_GEN) $(SED) -e 's^\@GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@ + +EXTRA_DIST = $(ui_DATA) $(plugin_in_files) $(gsettings_SCHEMAS_in_in) + +CLEANFILES = $(plugin_DATA) $(gsettings_SCHEMAS_in) $(gsettings_SCHEMASn) +DISTCLEANFILES = $(plugin_DATA) $(gsettings_SCHEMAS_in) $(gsettings_SCHEMAS) -include $(top_srcdir)/git.mk diff --git a/plugins/time/org.mate.pluma.plugins.time.gschema.xml.in.in b/plugins/time/org.mate.pluma.plugins.time.gschema.xml.in.in new file mode 100644 index 00000000..d294cfec --- /dev/null +++ b/plugins/time/org.mate.pluma.plugins.time.gschema.xml.in.in @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<schemalist gettext-domain="@GETTEXT_PACKAGE@"> + <enum id="org.mate.pluma.plugins.time.PromptType"> + <value nick="prompt-selected-format" value="0"/> + <value nick="prompt-custom-format" value="1"/> + <value nick="use-selected-format" value="2"/> + <value nick="use-custom-format" value="3"/> + </enum> + <schema id="org.mate.pluma.plugins.time" path="/org/mate/pluma/plugins/time/"> + <key name="prompt-type" enum="org.mate.pluma.plugins.time.PromptType"> + <default>'prompt-selected-format'</default> + <_summary>Prompt type</_summary> + </key> + <key name="selected-format" type="s"> + <default>'%c'</default> + <_summary>Selected format</_summary> + </key> + <key name="custom-format" type="s"> + <default>'%d/%m/%Y %H:%M:%S'</default> + <_summary>Custom format</_summary> + </key> + </schema> +</schemalist> diff --git a/plugins/time/pluma-time-plugin.c b/plugins/time/pluma-time-plugin.c index 24433965..36a96352 100755 --- a/plugins/time/pluma-time-plugin.c +++ b/plugins/time/pluma-time-plugin.c @@ -33,14 +33,13 @@ #include <string.h> #include <time.h> -#include <mateconf/mateconf-client.h> - #include "pluma-time-plugin.h" #include <pluma/pluma-help.h> #include <glib/gi18n-lib.h> #include <glib.h> #include <gmodule.h> +#include <gio/gio.h> #include <pluma/pluma-debug.h> #include <pluma/pluma-utils.h> @@ -52,11 +51,11 @@ #define WINDOW_DATA_KEY "PlumaTimePluginWindowData" #define MENU_PATH "/MenuBar/EditMenu/EditOps_4" -/* mateconf keys */ -#define TIME_BASE_KEY "/apps/pluma/plugins/time" -#define PROMPT_TYPE_KEY TIME_BASE_KEY "/prompt_type" -#define SELECTED_FORMAT_KEY TIME_BASE_KEY "/selected_format" -#define CUSTOM_FORMAT_KEY TIME_BASE_KEY "/custom_format" +/* GSettings keys */ +#define TIME_SCHEMA "org.mate.pluma.plugins.time" +#define PROMPT_TYPE_KEY "prompt-type" +#define SELECTED_FORMAT_KEY "selected-format" +#define CUSTOM_FORMAT_KEY "custom-format" #define DEFAULT_CUSTOM_FORMAT "%d/%m/%Y %H:%M:%S" @@ -155,7 +154,7 @@ typedef enum struct _PlumaTimePluginPrivate { - MateConfClient *mateconf_client; + GSettings *settings; }; PLUMA_PLUGIN_REGISTER_TYPE(PlumaTimePlugin, pluma_time_plugin) @@ -193,12 +192,7 @@ pluma_time_plugin_init (PlumaTimePlugin *plugin) plugin->priv = PLUMA_TIME_PLUGIN_GET_PRIVATE (plugin); - plugin->priv->mateconf_client = mateconf_client_get_default (); - - mateconf_client_add_dir (plugin->priv->mateconf_client, - TIME_BASE_KEY, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); + plugin->priv->settings = g_settings_new (TIME_SCHEMA); } static void @@ -208,9 +202,7 @@ pluma_time_plugin_finalize (GObject *object) pluma_debug_message (DEBUG_PLUGINS, "PlumaTimePlugin finalizing"); - mateconf_client_suggest_sync (plugin->priv->mateconf_client, NULL); - - g_object_unref (G_OBJECT (plugin->priv->mateconf_client)); + g_object_unref (G_OBJECT (plugin->priv->settings)); G_OBJECT_CLASS (pluma_time_plugin_parent_class)->finalize (object); } @@ -329,62 +321,27 @@ impl_update_ui (PlumaPlugin *plugin, static PlumaTimePluginPromptType get_prompt_type (PlumaTimePlugin *plugin) { - gchar *prompt_type; - PlumaTimePluginPromptType res; - - prompt_type = mateconf_client_get_string (plugin->priv->mateconf_client, - PROMPT_TYPE_KEY, - NULL); - - if (prompt_type == NULL) - return PROMPT_SELECTED_FORMAT; - - if (strcmp (prompt_type, "USE_SELECTED_FORMAT") == 0) - res = USE_SELECTED_FORMAT; - else if (strcmp (prompt_type, "USE_CUSTOM_FORMAT") == 0) - res = USE_CUSTOM_FORMAT; - else if (strcmp (prompt_type, "PROMPT_CUSTOM_FORMAT") == 0) - res = PROMPT_CUSTOM_FORMAT; - else - res = PROMPT_SELECTED_FORMAT; + PlumaTimePluginPromptType prompt_type; - g_free (prompt_type); + prompt_type = g_settings_get_enum (plugin->priv->settings, + PROMPT_TYPE_KEY); - return res; + return prompt_type; } static void set_prompt_type (PlumaTimePlugin *plugin, PlumaTimePluginPromptType prompt_type) { - const gchar * str; - - if (!mateconf_client_key_is_writable (plugin->priv->mateconf_client, - PROMPT_TYPE_KEY, - NULL)) + if (!g_settings_is_writable (plugin->priv->settings, + PROMPT_TYPE_KEY)) { return; } - switch (prompt_type) - { - case USE_SELECTED_FORMAT: - str = "USE_SELECTED_FORMAT"; - break; - case USE_CUSTOM_FORMAT: - str = "USE_CUSTOM_FORMAT"; - break; - case PROMPT_CUSTOM_FORMAT: - str = "PROMPT_CUSTOM_FORMAT"; - break; - default: - str = "PROMPT_SELECTED_FORMAT"; - } - - mateconf_client_set_string (plugin->priv->mateconf_client, + g_settings_set_enum (plugin->priv->settings, PROMPT_TYPE_KEY, - str, - NULL); + prompt_type); } /* The selected format in the list */ @@ -393,9 +350,8 @@ get_selected_format (PlumaTimePlugin *plugin) { gchar *sel_format; - sel_format = mateconf_client_get_string (plugin->priv->mateconf_client, - SELECTED_FORMAT_KEY, - NULL); + sel_format = g_settings_get_string (plugin->priv->settings, + SELECTED_FORMAT_KEY); return sel_format ? sel_format : g_strdup (formats [0]); } @@ -406,17 +362,15 @@ set_selected_format (PlumaTimePlugin *plugin, { g_return_if_fail (format != NULL); - if (!mateconf_client_key_is_writable (plugin->priv->mateconf_client, - SELECTED_FORMAT_KEY, - NULL)) + if (!g_settings_is_writable (plugin->priv->settings, + SELECTED_FORMAT_KEY)) { return; } - mateconf_client_set_string (plugin->priv->mateconf_client, + g_settings_set_string (plugin->priv->settings, SELECTED_FORMAT_KEY, - format, - NULL); + format); } /* the custom format in the entry */ @@ -425,9 +379,8 @@ get_custom_format (PlumaTimePlugin *plugin) { gchar *format; - format = mateconf_client_get_string (plugin->priv->mateconf_client, - CUSTOM_FORMAT_KEY, - NULL); + format = g_settings_get_string (plugin->priv->settings, + CUSTOM_FORMAT_KEY); return format ? format : g_strdup (DEFAULT_CUSTOM_FORMAT); } @@ -438,15 +391,13 @@ set_custom_format (PlumaTimePlugin *plugin, { g_return_if_fail (format != NULL); - if (!mateconf_client_key_is_writable (plugin->priv->mateconf_client, - CUSTOM_FORMAT_KEY, - NULL)) + if (!g_settings_is_writable (plugin->priv->settings, + CUSTOM_FORMAT_KEY)) return; - mateconf_client_set_string (plugin->priv->mateconf_client, + g_settings_set_string (plugin->priv->settings, CUSTOM_FORMAT_KEY, - format, - NULL); + format); } static gchar * |