[anjuta/gsettings-migration: 50/65] document-manager: Ported to GSettings
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/gsettings-migration: 50/65] document-manager: Ported to GSettings
- Date: Sun, 17 Oct 2010 09:36:57 +0000 (UTC)
commit 27af7f34642ac01548887577906f50c7a79d19a5
Author: Johannes Schmid <jhs gnome org>
Date: Sun Oct 10 13:31:32 2010 +0200
document-manager: Ported to GSettings
plugins/document-manager/action-callbacks.c | 28 +++++-----
plugins/document-manager/anjuta-docman.c | 20 ++++----
plugins/document-manager/anjuta-docman.h | 3 +-
plugins/document-manager/plugin.c | 77 +++++++++++----------------
plugins/document-manager/plugin.h | 10 ++--
5 files changed, 62 insertions(+), 76 deletions(-)
---
diff --git a/plugins/document-manager/action-callbacks.c b/plugins/document-manager/action-callbacks.c
index 77c7e34..130b47a 100644
--- a/plugins/document-manager/action-callbacks.c
+++ b/plugins/document-manager/action-callbacks.c
@@ -748,8 +748,8 @@ on_editor_linenos1_activate (GtkAction *action, gpointer user_data)
DocmanPlugin *plugin;
plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- anjuta_preferences_set_bool (plugin->prefs,
- VIEW_LINENUMBERS_MARGIN, state);
+ g_settings_set_boolean (plugin->settings,
+ VIEW_LINENUMBERS_MARGIN, state);
}
void
@@ -759,8 +759,8 @@ on_editor_markers1_activate (GtkAction *action, gpointer user_data)
DocmanPlugin *plugin;
plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- anjuta_preferences_set_bool (plugin->prefs,
- VIEW_MARKER_MARGIN, state);
+ g_settings_set_boolean (plugin->settings,
+ VIEW_MARKER_MARGIN, state);
}
void
@@ -770,8 +770,8 @@ on_editor_codefold1_activate (GtkAction *action, gpointer user_data)
DocmanPlugin *plugin;
plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- anjuta_preferences_set_bool (plugin->prefs,
- VIEW_FOLD_MARGIN, state);
+ g_settings_set_boolean (plugin->settings,
+ VIEW_FOLD_MARGIN, state);
}
void
@@ -781,8 +781,8 @@ on_editor_indentguides1_activate (GtkAction *action, gpointer user_data)
DocmanPlugin *plugin;
plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- anjuta_preferences_set_bool (plugin->prefs,
- VIEW_INDENTATION_GUIDES, state);
+ g_settings_set_boolean (plugin->settings,
+ VIEW_INDENTATION_GUIDES, state);
}
void
@@ -792,8 +792,8 @@ on_editor_whitespaces1_activate (GtkAction *action, gpointer user_data)
DocmanPlugin *plugin;
plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- anjuta_preferences_set_bool (plugin->prefs,
- VIEW_WHITE_SPACES, state);
+ g_settings_set_boolean (plugin->settings,
+ VIEW_WHITE_SPACES, state);
}
void
@@ -803,8 +803,8 @@ on_editor_eolchars1_activate (GtkAction *action, gpointer user_data)
DocmanPlugin *plugin;
plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- anjuta_preferences_set_bool (plugin->prefs,
- VIEW_EOL, state);
+ g_settings_set_boolean (plugin->settings,
+ VIEW_EOL, state);
}
void
@@ -814,8 +814,8 @@ on_editor_linewrap1_activate (GtkAction *action, gpointer user_data)
DocmanPlugin *plugin;
plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- anjuta_preferences_set_bool (plugin->prefs,
- VIEW_LINE_WRAP, state);
+ g_settings_set_boolean (plugin->settings,
+ VIEW_LINE_WRAP, state);
}
void
diff --git a/plugins/document-manager/anjuta-docman.c b/plugins/document-manager/anjuta-docman.c
index 7a24564..9eab062 100644
--- a/plugins/document-manager/anjuta-docman.c
+++ b/plugins/document-manager/anjuta-docman.c
@@ -57,7 +57,7 @@ typedef struct _AnjutaDocmanPage AnjutaDocmanPage;
struct _AnjutaDocmanPriv {
DocmanPlugin *plugin;
- AnjutaPreferences *preferences;
+ GSettings* settings;
GList *pages; /* list of AnjutaDocmanPage's */
GtkWidget *fileselection;
@@ -336,7 +336,7 @@ on_notebook_tab_btnrelease (GtkWidget *widget, GdkEventButton *event, AnjutaDocm
}
/* normal button click close */
- if (anjuta_preferences_get_bool (docman->priv->preferences, EDITOR_TABS_RECENT_FIRST))
+ if (g_settings_get_boolean (docman->priv->settings, EDITOR_TABS_RECENT_FIRST))
{
GList *node;
@@ -743,8 +743,8 @@ anjuta_docman_save_document_as (AnjutaDocman *docman, IAnjutaDocument *doc,
ianjuta_file_savable_save_as (IANJUTA_FILE_SAVABLE (doc), file, NULL);
}
- if (anjuta_preferences_get_bool (ANJUTA_PREFERENCES (docman->priv->preferences),
- EDITOR_TABS_ORDERING))
+ if (g_settings_get_boolean (docman->priv->settings,
+ EDITOR_TABS_ORDERING))
anjuta_docman_order_tabs (docman);
gtk_widget_destroy (dialog);
@@ -914,7 +914,7 @@ anjuta_docman_class_init (AnjutaDocmanClass *klass)
}
GtkWidget*
-anjuta_docman_new (DocmanPlugin* plugin, AnjutaPreferences *pref)
+anjuta_docman_new (DocmanPlugin* plugin)
{
GtkWidget *docman;
@@ -924,7 +924,7 @@ anjuta_docman_new (DocmanPlugin* plugin, AnjutaPreferences *pref)
AnjutaUI* ui;
AnjutaDocman* real_docman = ANJUTA_DOCMAN (docman);
real_docman->priv->plugin = plugin;
- real_docman->priv->preferences = pref;
+ real_docman->priv->settings = plugin->settings;
real_docman->priv->documents_action_group = gtk_action_group_new ("ActionGroupDocument");
real_docman->maximized = FALSE;
ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
@@ -960,8 +960,8 @@ on_notebook_switch_page (GtkNotebook *notebook,
*/
if (!docman->priv->tab_pressed /* after a tab-click, sorting is done upon release */
&& !g_tabbing
- && !anjuta_preferences_get_bool (docman->priv->preferences, EDITOR_TABS_ORDERING)
- && anjuta_preferences_get_bool (docman->priv->preferences, EDITOR_TABS_RECENT_FIRST))
+ && !g_settings_get_boolean (docman->priv->settings, EDITOR_TABS_ORDERING)
+ && g_settings_get_boolean (docman->priv->settings, EDITOR_TABS_RECENT_FIRST))
{
gtk_notebook_reorder_child (notebook, page->widget, 0);
}
@@ -1224,8 +1224,8 @@ anjuta_docman_set_current_document (AnjutaDocman *docman, IAnjutaDocument *doc)
page->widget);
gtk_notebook_set_current_page (GTK_NOTEBOOK (docman), page_num);
- if (anjuta_preferences_get_bool (ANJUTA_PREFERENCES (docman->priv->preferences),
- EDITOR_TABS_ORDERING))
+ if (g_settings_get_boolean (docman->priv->settings,
+ EDITOR_TABS_ORDERING))
anjuta_docman_order_tabs (docman);
gtk_widget_grab_focus (GTK_WIDGET (doc));
diff --git a/plugins/document-manager/anjuta-docman.h b/plugins/document-manager/anjuta-docman.h
index 3835ff3..cdc05f6 100644
--- a/plugins/document-manager/anjuta-docman.h
+++ b/plugins/document-manager/anjuta-docman.h
@@ -22,7 +22,6 @@
#define _ANJUTA_DOCMAN_H_
#include <gtk/gtk.h>
-#include <libanjuta/anjuta-preferences.h>
#include <libanjuta/anjuta-shell.h>
#include <libanjuta/interfaces/ianjuta-editor.h>
#include <libanjuta/interfaces/ianjuta-document.h>
@@ -56,7 +55,7 @@ struct _AnjutaDocmanClass {
};
GType anjuta_docman_get_type (void);
-GtkWidget* anjuta_docman_new (DocmanPlugin *plugin, AnjutaPreferences *pref);
+GtkWidget* anjuta_docman_new (DocmanPlugin *plugin);
void anjuta_docman_set_popup_menu (AnjutaDocman *docman, GtkWidget *menu);
diff --git a/plugins/document-manager/plugin.c b/plugins/document-manager/plugin.c
index cdc5b42..30dff5f 100644
--- a/plugins/document-manager/plugin.c
+++ b/plugins/document-manager/plugin.c
@@ -54,6 +54,8 @@
#define PREFS_BUILDER PACKAGE_DATA_DIR"/glade/anjuta-document-manager.ui"
#define ICON_FILE "anjuta-document-manager-plugin-48.png"
+#define PREF_SCHEMA "org.gnome.anjuta.document-manager"
+
#define ANJUTA_PIXMAP_BOOKMARK_TOGGLE "anjuta-bookmark-toggle"
#define ANJUTA_PIXMAP_BOOKMARK_PREV "anjuta-bookmark-prev"
#define ANJUTA_PIXMAP_BOOKMARK_NEXT "anjuta-bookmark-next"
@@ -586,7 +588,7 @@ ui_states_init (AnjutaPlugin *plugin)
GtkAction *action;
gboolean state;
- state = anjuta_preferences_get_bool (eplugin->prefs, prefs[i]);
+ state = g_settings_get_boolean (eplugin->settings, prefs[i]);
action = anjuta_ui_get_action (eplugin->ui, "ActionGroupEditorView",
actions_view[i].name);
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), state);
@@ -936,7 +938,7 @@ update_status (DocmanPlugin *plugin, IAnjutaEditor *te)
if (IANJUTA_IS_EDITOR_ZOOM(te))
{
- zoom = anjuta_preferences_get_int (plugin->prefs, TEXT_ZOOM_FACTOR);
+ zoom = g_settings_get_int (plugin->settings, TEXT_ZOOM_FACTOR);
anjuta_status_set_default (status, _("Zoom"), "%d", zoom);
}
else
@@ -1349,8 +1351,8 @@ on_window_key_release_event (AnjutaShell *shell,
gint cur_page;
plugin->g_tabbing = FALSE;
- if (anjuta_preferences_get_bool (plugin->prefs,
- EDITOR_TABS_RECENT_FIRST))
+ if (g_settings_get_boolean (plugin->settings,
+ EDITOR_TABS_RECENT_FIRST))
{
/*
TTimo: move the current notebook page to first position
@@ -1473,7 +1475,7 @@ on_save_prompt (AnjutaShell *shell, AnjutaSavePrompt *save_prompt,
static void
docman_plugin_set_tab_pos (DocmanPlugin *ep)
{
- if (anjuta_preferences_get_bool (ep->prefs, EDITOR_TABS_HIDE))
+ if (g_settings_get_boolean (ep->settings, EDITOR_TABS_HIDE))
{
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (ep->docman), FALSE);
}
@@ -1483,7 +1485,7 @@ docman_plugin_set_tab_pos (DocmanPlugin *ep)
GtkPositionType pos;
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (ep->docman), TRUE);
- tab_pos = anjuta_preferences_get (ep->prefs, EDITOR_TABS_POS);
+ tab_pos = g_settings_get_string (ep->settings, EDITOR_TABS_POS);
pos = GTK_POS_TOP;
if (tab_pos)
@@ -1514,7 +1516,6 @@ static gboolean
on_docman_auto_save (gpointer data)
{
gboolean retval;
- AnjutaPreferences* prefs;
DocmanPlugin *plugin;
AnjutaDocman *docman;
AnjutaStatus* status;
@@ -1526,8 +1527,7 @@ on_docman_auto_save (gpointer data)
if (!docman)
return FALSE;
- prefs = anjuta_shell_get_preferences (docman->shell, NULL);
- if (anjuta_preferences_get_bool (prefs, SAVE_AUTOMATIC) == FALSE)
+ if (g_settings_get_boolean (plugin->settings, SAVE_AUTOMATIC) == FALSE)
{
plugin->autosave_on = FALSE;
return FALSE;
@@ -1576,7 +1576,7 @@ on_docman_auto_save (gpointer data)
}
static void
-on_notify_timer (AnjutaPreferences* prefs,
+on_notify_timer (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -1588,8 +1588,8 @@ on_notify_timer (AnjutaPreferences* prefs,
plugin = ANJUTA_PLUGIN_DOCMAN (user_data);
docman = ANJUTA_DOCMAN (plugin->docman);
- auto_save_timer = anjuta_preferences_get_int(prefs, AUTOSAVE_TIMER);
- auto_save = anjuta_preferences_get_bool(prefs, SAVE_AUTOMATIC);
+ auto_save_timer = g_settings_get_int(settings, AUTOSAVE_TIMER);
+ auto_save = g_settings_get_boolean(settings, SAVE_AUTOMATIC);
if (auto_save)
{
@@ -1619,37 +1619,21 @@ on_notify_timer (AnjutaPreferences* prefs,
}
}
-#define REGISTER_NOTIFY(key, func) \
- notify_id = anjuta_preferences_notify_add (ep->prefs, \
- key, func, ep); \
- ep->notify_ids = g_list_prepend (ep->notify_ids, \
- GUINT_TO_POINTER (notify_id));
static void
prefs_init (DocmanPlugin *ep)
{
- guint notify_id;
docman_plugin_set_tab_pos (ep);
- REGISTER_NOTIFY (EDITOR_TABS_HIDE, on_notify_prefs);
- REGISTER_NOTIFY (EDITOR_TABS_POS, on_notify_prefs);
- REGISTER_NOTIFY (AUTOSAVE_TIMER, on_notify_timer);
- REGISTER_NOTIFY (SAVE_AUTOMATIC, on_notify_timer);
-
- on_notify_timer(anjuta_preferences_default(), NULL, ep);
-}
-static void
-prefs_finalize (DocmanPlugin *ep)
-{
- GList *node;
- node = ep->notify_ids;
- while (node)
- {
- anjuta_preferences_notify_remove (ep->prefs,
- GPOINTER_TO_UINT (node->data));
- node = g_list_next (node);
- }
- g_list_free (ep->notify_ids);
- ep->notify_ids = NULL;
+ g_signal_connect (ep->settings, "changed::" EDITOR_TABS_HIDE,
+ G_CALLBACK (on_notify_prefs), ep);
+ g_signal_connect (ep->settings, "changed::" EDITOR_TABS_POS,
+ G_CALLBACK (on_notify_prefs), ep);
+ g_signal_connect (ep->settings, "changed::" AUTOSAVE_TIMER,
+ G_CALLBACK (on_notify_timer), ep);
+ g_signal_connect (ep->settings, "changed::" SAVE_AUTOMATIC,
+ G_CALLBACK (on_notify_timer), ep);
+
+ on_notify_timer(ep->settings, NULL, ep);
}
static gboolean
@@ -1667,10 +1651,9 @@ activate_plugin (AnjutaPlugin *plugin)
dplugin = ANJUTA_PLUGIN_DOCMAN (plugin);
dplugin->ui = anjuta_shell_get_ui (plugin->shell, NULL);
- dplugin->prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
ui = dplugin->ui;
- docman = anjuta_docman_new (dplugin, dplugin->prefs);
+ docman = anjuta_docman_new (dplugin);
dplugin->docman = docman;
ANJUTA_DOCMAN(docman)->shell = plugin->shell;
@@ -1793,7 +1776,6 @@ deactivate_plugin (AnjutaPlugin *plugin)
eplugin = ANJUTA_PLUGIN_DOCMAN (plugin);
- prefs_finalize (eplugin);
g_signal_handlers_disconnect_by_func (G_OBJECT (plugin->shell),
G_CALLBACK (on_session_save), plugin);
g_signal_handlers_disconnect_by_func (G_OBJECT (plugin->shell),
@@ -1842,7 +1824,10 @@ deactivate_plugin (AnjutaPlugin *plugin)
static void
dispose (GObject *obj)
{
- // DocmanPlugin *eplugin = ANJUTA_PLUGIN_DOCMAN (obj);
+ DocmanPlugin *eplugin = ANJUTA_PLUGIN_DOCMAN (obj);
+
+ g_object_unref (eplugin->settings);
+
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
@@ -1861,6 +1846,7 @@ docman_plugin_instance_init (GObject *obj)
plugin->g_tabbing = FALSE;
plugin->notify_ids = NULL;
plugin->support_plugins = NULL;
+ plugin->settings = g_settings_new (PREF_SCHEMA);
}
static void
@@ -2139,6 +2125,7 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
{
GError* error = NULL;
GtkBuilder* bxml = gtk_builder_new ();
+ DocmanPlugin* doc_plugin = ANJUTA_PLUGIN_DOCMAN (ipref);
/* Add preferences */
if (!gtk_builder_add_from_file (bxml, PREFS_BUILDER, &error))
@@ -2147,8 +2134,9 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
g_error_free (error);
}
- anjuta_preferences_add_from_builder (prefs,
- bxml, "Documents", _("Documents"), ICON_FILE);
+ anjuta_preferences_add_from_builder (prefs, bxml,
+ doc_plugin->settings,
+ "Documents", _("Documents"), ICON_FILE);
g_object_unref (G_OBJECT (bxml));
}
@@ -2157,7 +2145,6 @@ static void
ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
{
DocmanPlugin* plugin = ANJUTA_PLUGIN_DOCMAN (ipref);
- prefs_finalize(plugin);
anjuta_preferences_remove_page(prefs, _("Documents"));
}
diff --git a/plugins/document-manager/plugin.h b/plugins/document-manager/plugin.h
index 6d2f787..4644750 100644
--- a/plugins/document-manager/plugin.h
+++ b/plugins/document-manager/plugin.h
@@ -19,7 +19,7 @@ typedef struct _DocmanPluginClass DocmanPluginClass;
struct _DocmanPlugin{
AnjutaPlugin parent;
GtkWidget *docman;
- AnjutaPreferences *prefs;
+ GSettings* settings;
AnjutaUI *ui;
gint uiid;
GList *action_groups;
@@ -27,7 +27,7 @@ struct _DocmanPlugin{
/* project_root_uri watch*/
gint project_watch_id;
gchar* project_name;
- gchar* project_path;
+ gchar* project_path;
/*! state flag for Ctrl-TAB */
gboolean g_tabbing;
@@ -43,9 +43,9 @@ struct _DocmanPlugin{
/* Support plugins */
GList *support_plugins;
-
- /* SearchBox */
- GtkWidget* search_box;
+
+ /* SearchBox */
+ GtkWidget* search_box;
/* Base box of the widget */
GtkWidget* vbox;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]