[anjuta/gsettings-migration: 46/65] cvs-plugin: Ported to GSettings
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/gsettings-migration: 46/65] cvs-plugin: Ported to GSettings
- Date: Sun, 17 Oct 2010 09:36:37 +0000 (UTC)
commit 40ecd663b929e01ce8646e5adc2c03d091c80850
Author: Johannes Schmid <jhs gnome org>
Date: Sun Oct 10 12:56:56 2010 +0200
cvs-plugin: Ported to GSettings
plugins/cvs-plugin/cvs-interface.c | 52 ++++++++++++++----------------------
plugins/cvs-plugin/plugin.c | 11 ++++++-
plugins/cvs-plugin/plugin.h | 3 ++
3 files changed, 32 insertions(+), 34 deletions(-)
---
diff --git a/plugins/cvs-plugin/cvs-interface.c b/plugins/cvs-plugin/cvs-interface.c
index ad1e84b..6489bd6 100644
--- a/plugins/cvs-plugin/cvs-interface.c
+++ b/plugins/cvs-plugin/cvs-interface.c
@@ -24,7 +24,7 @@
#include "plugin.h"
#include "libgen.h"
-static gchar* create_cvs_command_with_cvsroot(AnjutaPreferences* prefs,
+static gchar* create_cvs_command_with_cvsroot(GSettings* settings,
const gchar* action,
const gchar* command_options,
const gchar* command_arguments,
@@ -38,14 +38,14 @@ static gchar* create_cvs_command_with_cvsroot(AnjutaPreferences* prefs,
/* command global_options cvsroot action command_options command_arguments */
gchar* CVS_FORMAT = "%s %s %s %s %s %s";
- g_return_val_if_fail (prefs != NULL, NULL);
+ g_return_val_if_fail (settings != NULL, NULL);
g_return_val_if_fail (action != NULL, NULL);
g_return_val_if_fail (command_options != NULL, NULL);
g_return_val_if_fail (command_arguments != NULL, NULL);
- cvs = anjuta_preferences_get(prefs, "cvs.path");
- compression = anjuta_preferences_get_int(prefs, "cvs.compression");
- ignorerc = anjuta_preferences_get_bool(prefs, "cvs.ignorerc");
+ cvs = g_settings_get_string(settings, "cvs.path");
+ compression = g_settings_get_int(settings, "cvs.compression");
+ ignorerc = g_settings_get_boolean(settings, "cvs.ignorerc");
if (compression && ignorerc)
global_options = g_strdup_printf("-f -z%d", compression);
else if (compression)
@@ -66,12 +66,12 @@ static gchar* create_cvs_command_with_cvsroot(AnjutaPreferences* prefs,
return command;
}
-inline static gchar* create_cvs_command(AnjutaPreferences* prefs,
+inline static gchar* create_cvs_command(GSettings* settings,
const gchar* action,
const gchar* command_options,
const gchar* command_arguments)
{
- return create_cvs_command_with_cvsroot(prefs, action, command_options,
+ return create_cvs_command_with_cvsroot(settings, action, command_options,
command_arguments, NULL);
}
@@ -122,8 +122,7 @@ void anjuta_cvs_add (AnjutaPlugin *obj, const gchar* filename,
command = create_cvs_command(
- anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "add", options->str, basename(file));
+ plugin->settings, "add", options->str, basename(file));
cvs_execute(plugin, command, dirname(file));
g_free(command);
@@ -152,16 +151,14 @@ void anjuta_cvs_commit (AnjutaPlugin *obj, const gchar* filename, const gchar* l
if (!is_directory(filename))
{
gchar* file = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "commit", options->str, basename(file));
+ command = create_cvs_command(plugin->settings, "commit", options->str, basename(file));
cvs_execute(plugin, command, dirname(file));
g_free(file);
}
else
{
gchar* dir = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "commit", options->str, "");
+ command = create_cvs_command(plugin->settings, "commit", options->str, "");
cvs_execute(plugin, command, dir);
g_free(dir);
}
@@ -186,15 +183,13 @@ void anjuta_cvs_diff (AnjutaPlugin *obj, const gchar* filename, const gchar* rev
if (!is_directory(filename))
{
gchar* file = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "diff", options->str, basename(file));
+ command = create_cvs_command(plugin->settings, "diff", options->str, basename(file));
cvs_execute_diff(plugin, command, dirname(file));
}
else
{
gchar* dir = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "diff", options->str, "");
+ command = create_cvs_command(plugin->settings, "diff", options->str, "");
cvs_execute_diff(plugin, command, dir);
g_free(dir);
}
@@ -214,16 +209,14 @@ void anjuta_cvs_log (AnjutaPlugin *obj, const gchar* filename, gboolean recurse,
if (!is_directory(filename))
{
gchar* file = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "log", options->str, basename(file));
+ command = create_cvs_command(plugin->settings, "log", options->str, basename(file));
cvs_execute_log(plugin, command, dirname(file));
g_free(file);
}
else
{
gchar* dir = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "log", options->str, "");
+ command = create_cvs_command(plugin->settings, "log", options->str, "");
cvs_execute_log(plugin, command, dir);
g_free(dir);
}
@@ -239,8 +232,7 @@ void anjuta_cvs_remove (AnjutaPlugin *obj, const gchar* filename, GError **err)
gchar* file = g_strdup(filename);
command = create_cvs_command(
- anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "remove", options->str, basename(file));
+ plugin->settings, "remove", options->str, basename(file));
cvs_execute(plugin, command, dirname(file));
g_free(file);
@@ -260,16 +252,14 @@ void anjuta_cvs_status (AnjutaPlugin *obj, const gchar* filename, gboolean recur
if (!is_directory(filename))
{
gchar* file = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "status", options->str, basename(file));
+ command = create_cvs_command(plugin->settings, "status", options->str, basename(file));
cvs_execute_status(plugin, command, dirname(file));
g_free(file);
}
else
{
gchar* dir = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "status", options->str, "");
+ command = create_cvs_command(plugin->settings, "status", options->str, "");
cvs_execute_status(plugin, command, dir);
g_free(dir);
}
@@ -299,16 +289,14 @@ void anjuta_cvs_update (AnjutaPlugin *obj, const gchar* filename, gboolean recur
if (!is_directory(filename))
{
gchar* file = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "update", options->str, basename(file));
+ command = create_cvs_command(plugin->settings, "update", options->str, basename(file));
cvs_execute(plugin, command, dirname(file));
g_free(file);
}
else
{
gchar* dir = g_strdup(filename);
- command = create_cvs_command(anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell,
- NULL), "update", options->str, "");
+ command = create_cvs_command(plugin->settings, "update", options->str, "");
cvs_execute(plugin, command, dir);
}
g_free(command);
@@ -354,7 +342,7 @@ void anjuta_cvs_import (AnjutaPlugin *obj, const gchar* dir, const gchar* cvsroo
g_string_append_printf(options, " %s %s %s", module, vendor, release);
cvs_command = create_cvs_command_with_cvsroot(
- anjuta_shell_get_preferences (ANJUTA_PLUGIN(plugin)->shell, NULL),
+ plugin->settings,
"import", options->str, "", root);
cvs_execute(plugin, cvs_command, dir);
diff --git a/plugins/cvs-plugin/plugin.c b/plugins/cvs-plugin/plugin.c
index 6b0ff94..af86f84 100644
--- a/plugins/cvs-plugin/plugin.c
+++ b/plugins/cvs-plugin/plugin.c
@@ -35,6 +35,8 @@
#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-cvs.ui"
#define ICON_FILE "anjuta-cvs-plugin-48.png"
+#define PREF_SCHEMA "org.gnome.anjuta.cvs"
+
static gpointer parent_class;
static GtkActionEntry actions_cvs[] = {
@@ -422,7 +424,10 @@ finalize (GObject *obj)
static void
dispose (GObject *obj)
{
- // CVSPlugin *plugin = ANJUTA_PLUGIN_CVS (obj);
+ CVSPlugin *plugin = ANJUTA_PLUGIN_CVS (obj);
+
+ g_object_unref (plugin->settings);
+
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
@@ -438,6 +443,7 @@ cvs_plugin_instance_init (GObject *obj)
plugin->fm_current_filename = NULL;
plugin->project_root_dir = NULL;
plugin->current_editor_filename = NULL;
+ plugin->settings = g_settings_new (PREF_SCHEMA);
}
static void
@@ -459,12 +465,13 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
/* Create the messages preferences page */
GError* error = NULL;
GtkBuilder *bxml = gtk_builder_new();
+ CVSPlugin *plugin = ANJUTA_PLUGIN_CVS (ipref);
if (!gtk_builder_add_from_file(bxml, GLADE_FILE, &error))
{
g_warning("Couldn't load builder file: %s", error->message);
g_error_free(error);
}
- anjuta_preferences_add_from_builder (prefs, bxml, "cvs", _("CVS"), ICON_FILE);
+ anjuta_preferences_add_from_builder (prefs, bxml, plugin->settings, "cvs", _("CVS"), ICON_FILE);
g_object_unref (bxml);
}
diff --git a/plugins/cvs-plugin/plugin.h b/plugins/cvs-plugin/plugin.h
index 5d8b034..d2e7ac5 100644
--- a/plugins/cvs-plugin/plugin.h
+++ b/plugins/cvs-plugin/plugin.h
@@ -64,6 +64,9 @@ struct _CVSPlugin{
gchar *fm_current_filename;
gchar *project_root_dir;
gchar *current_editor_filename;
+
+ /* Settings */
+ GSettings* settings;
};
struct _CVSPluginClass{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]