[anjuta/gsettings-migration: 41/65] file-manager: Ported to GSettings
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/gsettings-migration: 41/65] file-manager: Ported to GSettings
- Date: Sun, 17 Oct 2010 09:36:12 +0000 (UTC)
commit 50bb76f791e7a4395e0f7ceaf29204b2195a2b34
Author: Johannes Schmid <jhs gnome org>
Date: Sun Oct 10 12:23:18 2010 +0200
file-manager: Ported to GSettings
plugins/file-manager/plugin.c | 59 ++++++++++++++++++++---------------------
plugins/file-manager/plugin.h | 2 +-
2 files changed, 30 insertions(+), 31 deletions(-)
---
diff --git a/plugins/file-manager/plugin.c b/plugins/file-manager/plugin.c
index eed8257..5424054 100644
--- a/plugins/file-manager/plugin.c
+++ b/plugins/file-manager/plugin.c
@@ -39,6 +39,7 @@
#define FILE_MANAGER_BUILDER PACKAGE_DATA_DIR"/glade/file-manager.ui"
#define FILE_MANAGER_BUILDER_ROOT "filemanager_prefs"
+#define PREF_SCHEMA "org.gnome.anjuta.file-manager"
#define PREF_ROOT "filemanager-root"
#define PREF_FILTER_BINARY "filemanager-filter-binary"
#define PREF_FILTER_HIDDEN "filemanager-filter-hidden"
@@ -80,7 +81,7 @@ static void
file_manager_set_default_uri (AnjutaFileManager* file_manager)
{
GFile *file;
- gchar* path = anjuta_preferences_get (anjuta_preferences_default(), PREF_ROOT);
+ gchar* path = g_settings_get_string (file_manager->settings, PREF_ROOT);
if (path)
{
@@ -246,9 +247,9 @@ on_file_view_show_popup_menu (AnjutaFileView* view, GFile* file,
}
static void
-on_notify_root(AnjutaPreferences* prefs,
- const gchar* key,
- gpointer user_data)
+on_notify_root(GSettings* settings,
+ const gchar* key,
+ gpointer user_data)
{
AnjutaFileManager* file_manager = (AnjutaFileManager*) user_data;
if (!file_manager->have_project)
@@ -259,7 +260,7 @@ on_notify_root(AnjutaPreferences* prefs,
}
static void
-on_notify(AnjutaPreferences* prefs,
+on_notify(GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -268,10 +269,10 @@ on_notify(AnjutaPreferences* prefs,
GtkTreeModel* file_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT(sort_model));
g_object_set (G_OBJECT (file_model),
- "filter_binary", anjuta_preferences_get_bool (prefs, PREF_FILTER_BINARY),
- "filter_hidden", anjuta_preferences_get_bool (prefs, PREF_FILTER_HIDDEN),
- "filter_backup", anjuta_preferences_get_bool (prefs, PREF_FILTER_BACKUP),
- "filter_unversioned", anjuta_preferences_get_bool (prefs, PREF_FILTER_UNVERSIONED), NULL);
+ "filter_binary", g_settings_get_boolean (settings, PREF_FILTER_BINARY),
+ "filter_hidden", g_settings_get_boolean (settings, PREF_FILTER_HIDDEN),
+ "filter_backup", g_settings_get_boolean (settings, PREF_FILTER_BACKUP),
+ "filter_unversioned", g_settings_get_boolean (settings, PREF_FILTER_UNVERSIONED), NULL);
file_view_refresh (file_manager->fv);
}
@@ -280,8 +281,6 @@ file_manager_activate (AnjutaPlugin *plugin)
{
AnjutaUI *ui;
AnjutaFileManager *file_manager;
- gint notify_id;
- AnjutaPreferences* prefs = anjuta_preferences_default ();
DEBUG_PRINT ("%s", "AnjutaFileManager: Activating AnjutaFileManager plugin ...");
file_manager = (AnjutaFileManager*) plugin;
@@ -333,13 +332,18 @@ file_manager_activate (AnjutaPlugin *plugin)
project_root_added,
project_root_removed, NULL);
-
- REGISTER_NOTIFY (PREF_ROOT, on_notify_root);
- REGISTER_NOTIFY (PREF_FILTER_BINARY, on_notify);
- REGISTER_NOTIFY (PREF_FILTER_BACKUP, on_notify);
- REGISTER_NOTIFY (PREF_FILTER_HIDDEN, on_notify);
- REGISTER_NOTIFY (PREF_FILTER_UNVERSIONED, on_notify);
- on_notify (prefs, NULL, file_manager);
+
+ g_signal_connect (file_manager->settings, "changed::" PREF_ROOT,
+ G_CALLBACK (on_notify_root), file_manager);
+ g_signal_connect (file_manager->settings, "changed::" PREF_FILTER_BINARY,
+ G_CALLBACK (on_notify), file_manager);
+ g_signal_connect (file_manager->settings, "changed::" PREF_FILTER_HIDDEN,
+ G_CALLBACK (on_notify), file_manager);
+ g_signal_connect (file_manager->settings, "changed::" PREF_FILTER_BACKUP,
+ G_CALLBACK (on_notify), file_manager);
+ g_signal_connect (file_manager->settings, "changed::" PREF_FILTER_UNVERSIONED,
+ G_CALLBACK (on_notify), file_manager);
+ on_notify (file_manager->settings, NULL, file_manager);
return TRUE;
}
@@ -365,16 +369,7 @@ file_manager_deactivate (AnjutaPlugin *plugin)
static void
file_manager_finalize (GObject *obj)
-{
- AnjutaFileManager *plugin = (AnjutaFileManager*)obj;
- GList* id;
- for (id = plugin->notify_ids; id != NULL; id = id->next)
- {
- anjuta_preferences_notify_remove(anjuta_preferences_default (),
- GPOINTER_TO_UINT(id->data));
- }
- g_list_free(plugin->notify_ids);
-
+{
/* Finalization codes here */
G_OBJECT_CLASS (parent_class)->finalize (obj);
}
@@ -382,6 +377,9 @@ file_manager_finalize (GObject *obj)
static void
file_manager_dispose (GObject *obj)
{
+ AnjutaFileManager *plugin = (AnjutaFileManager*)obj;
+ g_object_unref (plugin->settings);
+
/* Disposition codes */
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
@@ -391,7 +389,7 @@ file_manager_instance_init (GObject *obj)
{
AnjutaFileManager *plugin = (AnjutaFileManager*)obj;
- plugin->notify_ids = NULL;
+ plugin->settings = g_settings_new (PREF_SCHEMA);
plugin->have_project = FALSE;
plugin->uiid = 0;
@@ -448,6 +446,7 @@ ipreferences_merge (IAnjutaPreferences* ipref,
{
GError* error = NULL;
GtkBuilder* bxml = gtk_builder_new ();
+ AnjutaFileManager* fm = (AnjutaFileManager*) ipref;
if (!gtk_builder_add_from_file (bxml, FILE_MANAGER_BUILDER, &error))
{
@@ -455,7 +454,7 @@ ipreferences_merge (IAnjutaPreferences* ipref,
g_error_free (error);
}
- anjuta_preferences_add_from_builder (prefs, bxml, FILE_MANAGER_BUILDER_ROOT, _("File Manager"),
+ anjuta_preferences_add_from_builder (prefs, bxml, fm->settings, FILE_MANAGER_BUILDER_ROOT, _("File Manager"),
ICON_FILE);
}
diff --git a/plugins/file-manager/plugin.h b/plugins/file-manager/plugin.h
index 38a0538..5337012 100644
--- a/plugins/file-manager/plugin.h
+++ b/plugins/file-manager/plugin.h
@@ -45,7 +45,7 @@ struct _AnjutaFileManager {
gint uiid;
GtkActionGroup *action_group;
- GList* notify_ids;
+ GSettings* settings;
};
struct _AnjutaFileManagerClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]