[gnome-commander/GSettings] File roller plugin now uses GSettings, too



commit 9efa2fecda0162f2240dceb1482808c4d8f9da52
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Mon May 16 16:36:38 2016 +0200

    File roller plugin now uses GSettings, too

 data/org.gnome.gnome-commander.gschema.xml |   10 +++--
 plugins/fileroller/file-roller-plugin.cc   |   58 +++++++++++++++++++++++++++-
 plugins/fileroller/file-roller-plugin.h    |    4 ++
 3 files changed, 66 insertions(+), 6 deletions(-)
---
diff --git a/data/org.gnome.gnome-commander.gschema.xml b/data/org.gnome.gnome-commander.gschema.xml
index 0553f47..8e2cb70 100644
--- a/data/org.gnome.gnome-commander.gschema.xml
+++ b/data/org.gnome.gnome-commander.gschema.xml
@@ -1000,11 +1000,13 @@
       <default>['']</default>
     </key>
   </schema>
-  <schema gettext-domain="gnome-commander" 
id="org.gnome.gnome-commander.preferences.plugins.file-runner-plugin" 
path="/org/gnome/gnome-commander/plugins/file-runner-plugin/">
+  <schema gettext-domain="gnome-commander" id="org.gnome.gnome-commander.plugins.file-roller-plugin" 
path="/org/gnome/gnome-commander/plugins/file-roller-plugin/">
     <key name="default-type" type="s">
-        <default l10n="messages">'.tar.bz2'</default>
-        <summary></summary>
-        <description></description>
+        <default l10n="messages">'.zip'</default>
+        <summary>File suffix</summary>
+        <description>
+            Default file suffix of archives created with the file roller plugin.
+        </description>
     </key>
   </schema>
 </schemalist>
diff --git a/plugins/fileroller/file-roller-plugin.cc b/plugins/fileroller/file-roller-plugin.cc
index 7ff630d..ac6805d 100644
--- a/plugins/fileroller/file-roller-plugin.cc
+++ b/plugins/fileroller/file-roller-plugin.cc
@@ -30,6 +30,8 @@
 #define AUTHOR "Marcus Bjurman <marbj499 student liu se>"
 #define WEBPAGE "http://gcmd.github.io";
 
+#define GCMD_PLUGINS_FILE_ROLLER                     "org.gnome.gnome-commander.plugins.file-roller-plugin"
+#define GCMD_PLUGINS_FILE_ROLLER_DEFAULT_TYPE        "default-type"
 
 static PluginInfo plugin_nfo = {
     GNOME_CMD_PLUGIN_SYSTEM_CURRENT_VERSION,
@@ -76,6 +78,56 @@ static const gchar *handled_extensions[] =
 };
 
 
+/***********************************
+ * Functions for using GSettings
+ ***********************************/
+
+struct _PluginSettings
+{
+    GObject parent;
+    GSettings *file_roller_plugin;
+};
+
+G_DEFINE_TYPE (PluginSettings, plugin_settings, G_TYPE_OBJECT)
+
+static void plugin_settings_finalize (GObject *object)
+{
+    G_OBJECT_CLASS (plugin_settings_parent_class)->finalize (object);
+}
+
+static void plugin_settings_dispose (GObject *object)
+{
+    PluginSettings *gs = GCMD_SETTINGS (object);
+
+    g_clear_object (&gs->file_roller_plugin);
+
+    G_OBJECT_CLASS (plugin_settings_parent_class)->dispose (object);
+}
+
+static void plugin_settings_class_init (PluginSettingsClass *klass)
+{
+    GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+    object_class->finalize = plugin_settings_finalize;
+    object_class->dispose = plugin_settings_dispose;
+}
+
+PluginSettings *plugin_settings_new ()
+{
+    return (PluginSettings *) g_object_new (PLUGIN_TYPE_SETTINGS, NULL);
+}
+
+static void plugin_settings_init (PluginSettings *gs)
+{
+    gs->file_roller_plugin = g_settings_new (GCMD_PLUGINS_FILE_ROLLER);
+}
+
+
+/***********************************
+ * The File-Roller-Plugin
+ ***********************************/
+
+
 struct _FileRollerPluginPrivate
 {
     GtkWidget *conf_dialog;
@@ -84,6 +136,7 @@ struct _FileRollerPluginPrivate
     GnomeCmdState *state;
 
     gchar *default_ext;
+    PluginSettings *settings;
 };
 
 static GnomeCmdPluginClass *parent_class = NULL;
@@ -349,7 +402,7 @@ static void on_configure_close (GtkButton *btn, FileRollerPlugin *plugin)
 {
     plugin->priv->default_ext = g_strdup (get_combo_text (plugin->priv->conf_combo));
 
-    gnome_cmd_data_set_string ("/file-runner-plugin/default_type", plugin->priv->default_ext);
+    g_settings_set_string (plugin->priv->settings->file_roller_plugin, 
GCMD_PLUGINS_FILE_ROLLER_DEFAULT_TYPE, plugin->priv->default_ext);
 
     gtk_widget_hide (plugin->priv->conf_dialog);
 }
@@ -432,7 +485,8 @@ static void init (FileRollerPlugin *plugin)
 {
     plugin->priv = g_new (FileRollerPluginPrivate, 1);
 
-    plugin->priv->default_ext = gnome_cmd_data_get_string ("/file-runner-plugin/default_type", ".zip");
+    plugin->priv->settings = plugin_settings_new();
+    plugin->priv->default_ext = g_settings_get_string (plugin->priv->settings->file_roller_plugin, 
GCMD_PLUGINS_FILE_ROLLER_DEFAULT_TYPE);
 }
 
 
diff --git a/plugins/fileroller/file-roller-plugin.h b/plugins/fileroller/file-roller-plugin.h
index f47d39f..e480b6f 100644
--- a/plugins/fileroller/file-roller-plugin.h
+++ b/plugins/fileroller/file-roller-plugin.h
@@ -22,6 +22,10 @@
 #ifndef __FILE_ROLLER_PLUGIN_H__
 #define __FILE_ROLLER_PLUGIN_H__
 
+#define PLUGIN_TYPE_SETTINGS (plugin_settings_get_type ())
+G_DECLARE_FINAL_TYPE (PluginSettings, plugin_settings, GCMD, SETTINGS, GObject)
+PluginSettings *plugin_settings_new (void);
+
 #define FILE_ROLLER_PLUGIN(obj) \
     GTK_CHECK_CAST (obj, file_roller_plugin_get_type (), FileRollerPlugin)
 #define FILE_ROLLER_PLUGIN_CLASS(klass) \


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]