[anjuta/gsettings-migration: 52/65] sourceview: Ported to GSettings
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/gsettings-migration: 52/65] sourceview: Ported to GSettings
- Date: Sun, 17 Oct 2010 09:37:07 +0000 (UTC)
commit a29771a2b222aa330cc7e40b68b0330e060aa4d9
Author: Johannes Schmid <jhs gnome org>
Date: Tue Oct 12 18:09:08 2010 +0200
sourceview: Ported to GSettings
Printing is still to be fixed (e.g. moved to print dialog)
plugins/sourceview/plugin.c | 28 ++++---
plugins/sourceview/plugin.h | 1 +
plugins/sourceview/sourceview-io.c | 4 +-
plugins/sourceview/sourceview-prefs.c | 123 +++++++++++++++----------------
plugins/sourceview/sourceview-print.c | 68 +++++++++--------
plugins/sourceview/sourceview-private.h | 2 +-
plugins/sourceview/sourceview.c | 17 +++-
7 files changed, 130 insertions(+), 113 deletions(-)
---
diff --git a/plugins/sourceview/plugin.c b/plugins/sourceview/plugin.c
index b48fc6a..3095003 100644
--- a/plugins/sourceview/plugin.c
+++ b/plugins/sourceview/plugin.c
@@ -38,6 +38,7 @@
#include "sourceview.h"
#include "sourceview-private.h"
+#define PREF_SCHEMA "org.gnome.anjuta.sourceview"
#define PREFS_GLADE PACKAGE_DATA_DIR"/glade/anjuta-editor-sourceview.ui"
#define ICON_FILE "anjuta-editor-sourceview-plugin-48.png"
@@ -85,14 +86,18 @@ sourceview_plugin_finalize (GObject *obj)
static void
sourceview_plugin_dispose (GObject *obj)
{
- /* Disposition codes */
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (obj);
+
+ g_object_unref (plugin->settings);
+
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
static void
sourceview_plugin_instance_init (GObject *obj)
{
-
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (obj);
+ plugin->settings = g_settings_new (PREF_SCHEMA);
}
static void
@@ -115,8 +120,8 @@ ieditor_factory_new_editor(IAnjutaEditorFactory* factory,
GError** error)
{
AnjutaPlugin* plugin = ANJUTA_PLUGIN(factory);
- AnjutaPreferences* prefs = anjuta_shell_get_preferences (plugin->shell, NULL);
- gchar* current_style = anjuta_preferences_get (prefs, SOURCEVIEW_STYLE);
+ SourceviewPlugin* splugin = ANJUTA_PLUGIN_SOURCEVIEW (plugin);
+ gchar* current_style = g_settings_get_string (splugin->settings, SOURCEVIEW_STYLE);
GtkSourceStyleSchemeManager* manager = gtk_source_style_scheme_manager_get_default();
Sourceview* sv;
sv = sourceview_new(file, filename, plugin);
@@ -142,14 +147,14 @@ enum
};
static GtkTreeModel*
-create_style_model (AnjutaPreferences* prefs, GtkTreeIter** current)
+create_style_model (GSettings* settings, GtkTreeIter** current)
{
GtkListStore* model = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING);
GtkSourceStyleSchemeManager* manager = gtk_source_style_scheme_manager_get_default();
const gchar* const *styles = gtk_source_style_scheme_manager_get_scheme_ids (manager);
const gchar* const *style;
- gchar* current_style = anjuta_preferences_get (prefs, SOURCEVIEW_STYLE);
+ gchar* current_style = g_settings_get_string (settings, SOURCEVIEW_STYLE);
*current = NULL;
for (style = styles; *style != NULL; style++)
{
@@ -185,9 +190,9 @@ on_style_changed (GtkComboBox* combo, SourceviewPlugin* plugin)
COLUMN_ID, &id, -1);
scheme = gtk_source_style_scheme_manager_get_scheme (manager, id);
- anjuta_preferences_set (anjuta_shell_get_preferences (shell, NULL),
- SOURCEVIEW_STYLE,
- id);
+ g_settings_set_string (plugin->settings,
+ SOURCEVIEW_STYLE,
+ id);
g_free (id);
@@ -227,7 +232,8 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
return;
}
anjuta_preferences_add_from_builder (prefs,
- builder,
+ builder,
+ plugin->settings,
"Editor",
_("GtkSourceView Editor"),
ICON_FILE);
@@ -241,7 +247,7 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
/* Init styles combo */
plugin->combo_styles = GTK_WIDGET (gtk_builder_get_object (builder, COMBO_STYLES));
gtk_combo_box_set_model (GTK_COMBO_BOX (plugin->combo_styles),
- create_style_model(prefs, &iter));
+ create_style_model(plugin->settings, &iter));
g_signal_connect (plugin->combo_styles, "changed", G_CALLBACK (on_style_changed), plugin);
gtk_cell_layout_clear (GTK_CELL_LAYOUT(plugin->combo_styles));
diff --git a/plugins/sourceview/plugin.h b/plugins/sourceview/plugin.h
index 7487f46..dde1089 100644
--- a/plugins/sourceview/plugin.h
+++ b/plugins/sourceview/plugin.h
@@ -43,6 +43,7 @@ struct _SourceviewPlugin{
GtkWidget* combo_styles;
GtkWidget* check_font;
+ GSettings* settings;
};
struct _SourceviewPluginClass{
diff --git a/plugins/sourceview/sourceview-io.c b/plugins/sourceview/sourceview-io.c
index 72805d8..3d557a9 100644
--- a/plugins/sourceview/sourceview-io.c
+++ b/plugins/sourceview/sourceview-io.c
@@ -289,8 +289,8 @@ sourceview_io_save_as (SourceviewIO* sio, GFile* file)
cancel_monitor (sio);
- backup = anjuta_preferences_get_bool (sio->sv->priv->prefs,
- "sourceview-backup");
+ backup = g_settings_get_boolean (sio->sv->priv->settings,
+ "sourceview-backup");
if (sio->last_encoding == NULL)
{
diff --git a/plugins/sourceview/sourceview-prefs.c b/plugins/sourceview/sourceview-prefs.c
index a9f3e8d..fbb1a02 100644
--- a/plugins/sourceview/sourceview-prefs.c
+++ b/plugins/sourceview/sourceview-prefs.c
@@ -25,10 +25,10 @@
#include <gconf/gconf-client.h>
#define REGISTER_NOTIFY(key, func) \
- notify_id = anjuta_preferences_notify_add (sv->priv->prefs, \
- key, func, sv); \
- sv->priv->notify_ids = g_list_prepend (sv->priv->notify_ids, \
- GUINT_TO_POINTER(notify_id));
+ g_signal_connect (sv->priv->settings, "changed::" key, G_CALLBACK(func), sv);
+
+#define PREF_SCHEMA "org.gnome.anjuta.sourceview"
+
/* Editor preferences */
#define HIGHLIGHT_SYNTAX "sourceview-syntax-highlight"
#define HIGHLIGHT_CURRENT_LINE "sourceview-currentline-highlight"
@@ -56,7 +56,7 @@
static void
-on_notify_view_spaces (AnjutaPreferences* prefs,
+on_notify_view_spaces (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -65,7 +65,7 @@ on_notify_view_spaces (AnjutaPreferences* prefs,
GtkSourceDrawSpacesFlags flags =
gtk_source_view_get_draw_spaces (GTK_SOURCE_VIEW (sv->priv->view));
- if (anjuta_preferences_get_bool (prefs, key))
+ if (g_settings_get_boolean (settings, key))
flags |= (GTK_SOURCE_DRAW_SPACES_SPACE | GTK_SOURCE_DRAW_SPACES_TAB);
else
flags &= ~(GTK_SOURCE_DRAW_SPACES_SPACE | GTK_SOURCE_DRAW_SPACES_TAB);
@@ -75,7 +75,7 @@ on_notify_view_spaces (AnjutaPreferences* prefs,
}
static void
-on_notify_view_eol (AnjutaPreferences* prefs,
+on_notify_view_eol (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -84,7 +84,7 @@ on_notify_view_eol (AnjutaPreferences* prefs,
GtkSourceDrawSpacesFlags flags =
gtk_source_view_get_draw_spaces (GTK_SOURCE_VIEW (sv->priv->view));
- if (anjuta_preferences_get_bool (prefs, key))
+ if (g_settings_get_boolean (settings, key))
flags |= GTK_SOURCE_DRAW_SPACES_NEWLINE;
else
flags &= ~GTK_SOURCE_DRAW_SPACES_NEWLINE;
@@ -94,7 +94,7 @@ on_notify_view_eol (AnjutaPreferences* prefs,
}
static void
-on_notify_line_wrap (AnjutaPreferences* prefs,
+on_notify_line_wrap (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -102,11 +102,11 @@ on_notify_line_wrap (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (sv->priv->view),
- anjuta_preferences_get_bool (prefs, key) ? GTK_WRAP_WORD : GTK_WRAP_NONE);
+ g_settings_get_boolean (settings, key) ? GTK_WRAP_WORD : GTK_WRAP_NONE);
}
static void
-on_notify_disable_hilite (AnjutaPreferences* prefs,
+on_notify_disable_hilite (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -114,12 +114,12 @@ on_notify_disable_hilite (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_source_buffer_set_highlight_syntax(GTK_SOURCE_BUFFER(sv->priv->document),
- anjuta_preferences_get_bool (prefs, key));
+ g_settings_get_boolean (settings, key));
}
static void
-on_notify_highlight_current_line(AnjutaPreferences* prefs,
+on_notify_highlight_current_line(GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -127,11 +127,11 @@ on_notify_highlight_current_line(AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_source_view_set_highlight_current_line(GTK_SOURCE_VIEW(sv->priv->view),
- anjuta_preferences_get_bool (prefs, key));
+ g_settings_get_boolean (settings, key));
}
static void
-on_notify_tab_size (AnjutaPreferences* prefs,
+on_notify_tab_size (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -142,11 +142,11 @@ on_notify_tab_size (AnjutaPreferences* prefs,
g_return_if_fail(GTK_IS_SOURCE_VIEW(sv->priv->view));
gtk_source_view_set_tab_width(GTK_SOURCE_VIEW(sv->priv->view),
- anjuta_preferences_get_int (prefs, key));
+ g_settings_get_int (sv->priv->settings, key));
}
static void
-on_notify_use_tab_for_indentation (AnjutaPreferences* prefs,
+on_notify_use_tab_for_indentation (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -154,11 +154,11 @@ on_notify_use_tab_for_indentation (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_source_view_set_insert_spaces_instead_of_tabs(GTK_SOURCE_VIEW(sv->priv->view),
- !anjuta_preferences_get_bool (prefs, key));
+ !g_settings_get_boolean (settings, key));
}
static void
-on_notify_braces_check (AnjutaPreferences* prefs,
+on_notify_braces_check (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -166,11 +166,11 @@ on_notify_braces_check (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_source_buffer_set_highlight_matching_brackets(GTK_SOURCE_BUFFER(sv->priv->document),
- anjuta_preferences_get_bool (prefs, key));
+ g_settings_get_boolean (settings, key));
}
static void
-on_notify_autocompletion (AnjutaPreferences* prefs,
+on_notify_autocompletion (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -178,7 +178,7 @@ on_notify_autocompletion (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
GtkSourceCompletion* completion = gtk_source_view_get_completion(GTK_SOURCE_VIEW(sv->priv->view));
- if (anjuta_preferences_get_bool (prefs, key))
+ if (g_settings_get_boolean (settings, key))
{
DEBUG_PRINT ("Register word completion provider");
GtkSourceCompletionWords *prov_words;
@@ -209,7 +209,7 @@ on_notify_autocompletion (AnjutaPreferences* prefs,
}
static void
-on_notify_view_marks (AnjutaPreferences* prefs,
+on_notify_view_marks (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -217,12 +217,12 @@ on_notify_view_marks (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_source_view_set_show_line_marks(GTK_SOURCE_VIEW(sv->priv->view),
- anjuta_preferences_get_bool (prefs, key));
+ g_settings_get_boolean (settings, key));
}
static void
-on_notify_view_linenums (AnjutaPreferences* prefs,
+on_notify_view_linenums (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -230,12 +230,12 @@ on_notify_view_linenums (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(sv->priv->view),
- anjuta_preferences_get_bool (prefs, key));
+ g_settings_get_boolean (settings, key));
}
static void
-on_notify_view_right_margin (AnjutaPreferences* prefs,
+on_notify_view_right_margin (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -243,11 +243,11 @@ on_notify_view_right_margin (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_source_view_set_show_right_margin(GTK_SOURCE_VIEW(sv->priv->view),
- anjuta_preferences_get_bool (prefs, key));
+ g_settings_get_boolean (settings, key));
}
static void
-on_notify_right_margin_position (AnjutaPreferences* prefs,
+on_notify_right_margin_position (GSettings* settings,
const gchar* key,
gpointer user_data)
{
@@ -255,34 +255,33 @@ on_notify_right_margin_position (AnjutaPreferences* prefs,
sv = ANJUTA_SOURCEVIEW(user_data);
gtk_source_view_set_right_margin_position(GTK_SOURCE_VIEW(sv->priv->view),
- anjuta_preferences_get_bool (prefs, key));
+ g_settings_get_boolean (settings, key));
}
static void
-on_notify_font (AnjutaPreferences* prefs,
+on_notify_font (GSettings* settings,
const gchar* key,
gpointer user_data)
{
Sourceview *sv;
sv = ANJUTA_SOURCEVIEW(user_data);
- gchar* font = anjuta_preferences_get (prefs, key);
-
- if (font != NULL)
- anjuta_view_set_font(sv->priv->view, FALSE,
- font);
+ gchar* font = g_settings_get_string (settings, key);
+
+ anjuta_view_set_font(sv->priv->view, FALSE,
+ font);
g_free (font);
}
static void
-on_notify_font_theme (AnjutaPreferences* prefs,
+on_notify_font_theme (GSettings* settings,
const gchar* key,
gpointer user_data)
{
Sourceview *sv;
sv = ANJUTA_SOURCEVIEW(user_data);
- if (anjuta_preferences_get_bool (prefs, key))
+ if (g_settings_get_boolean (settings, key))
{
GConfClient *gclient = gconf_client_get_default ();
gchar *desktop_fixed_font;
@@ -296,24 +295,23 @@ on_notify_font_theme (AnjutaPreferences* prefs,
}
else
{
- gchar* font = anjuta_preferences_get (prefs, FONT);
- if (font != NULL)
- anjuta_view_set_font(sv->priv->view, FALSE, font);
+ gchar* font = g_settings_get_string (settings, FONT);
+ anjuta_view_set_font(sv->priv->view, FALSE, font);
g_free (font);
}
}
/* Preferences notifications */
static void
-on_notify_indic_colors (AnjutaPreferences* prefs,
+on_notify_indic_colors (GSettings* settings,
const gchar *key,
gpointer user_data)
{
char* error_color =
- anjuta_preferences_get (anjuta_preferences_default(),
+ g_settings_get_string (settings,
COLOR_ERROR);
char* warning_color =
- anjuta_preferences_get (anjuta_preferences_default(),
+ g_settings_get_string (settings,
COLOR_WARNING);
Sourceview* sv = ANJUTA_SOURCEVIEW (user_data);
@@ -329,13 +327,12 @@ init_fonts(Sourceview* sv)
{
gboolean font_theme;
- font_theme = anjuta_preferences_get_bool (sv->priv->prefs, FONT_THEME);
+ font_theme = g_settings_get_boolean (sv->priv->settings, FONT_THEME);
if (!font_theme)
{
- gchar* font = anjuta_preferences_get (sv->priv->prefs, FONT);
- if (font != NULL)
- anjuta_view_set_font(sv->priv->view, FALSE, font);
+ gchar* font = g_settings_get_string (sv->priv->settings, FONT);
+ anjuta_view_set_font(sv->priv->view, FALSE, font);
g_free (font);
}
else
@@ -359,20 +356,26 @@ init_fonts(Sourceview* sv)
static int
get_key_int(Sourceview* sv, const gchar* key)
{
- return anjuta_preferences_get_int (sv->priv->prefs, key);
+ return g_settings_get_int (sv->priv->settings, key);
}
static int
get_key_bool(Sourceview* sv, const gchar* key)
{
- return anjuta_preferences_get_bool (sv->priv->prefs, key);
+ return g_settings_get_int (sv->priv->settings, key);
}
+#define PREF_SCHEMA_MSGMAN "org.gnome.anjuta.message-manager"
+
void
sourceview_prefs_init(Sourceview* sv)
{
- guint notify_id;
GtkSourceDrawSpacesFlags flags = 0;
+ GSettings* msg_settings = g_settings_new (PREF_SCHEMA_MSGMAN);
+ /* We create a new GSettings object here because if we used the one from
+ * the editor might be destroyed while the plugin is still alive
+ */
+ sv->priv->settings = g_settings_new (PREF_SCHEMA);
/* Init */
gtk_source_buffer_set_highlight_syntax(GTK_SOURCE_BUFFER(sv->priv->document),
@@ -408,7 +411,7 @@ sourceview_prefs_init(Sourceview* sv)
init_fonts(sv);
- on_notify_autocompletion(sv->priv->prefs, AUTOCOMPLETION, sv);
+ on_notify_autocompletion(sv->priv->settings, AUTOCOMPLETION, sv);
/* Register gconf notifications */
REGISTER_NOTIFY (TAB_SIZE, on_notify_tab_size);
@@ -426,18 +429,14 @@ sourceview_prefs_init(Sourceview* sv)
REGISTER_NOTIFY (RIGHTMARGIN_POSITION, on_notify_right_margin_position);
REGISTER_NOTIFY (FONT_THEME, on_notify_font_theme);
REGISTER_NOTIFY (FONT, on_notify_font);
- REGISTER_NOTIFY (COLOR_ERROR, on_notify_indic_colors);
- REGISTER_NOTIFY (COLOR_WARNING, on_notify_indic_colors);
+
+ g_signal_connect (msg_settings, "changed::" COLOR_ERROR,
+ G_CALLBACK (on_notify_indic_colors), sv);
+ g_signal_connect (msg_settings, "changed::" COLOR_WARNING,
+ G_CALLBACK (on_notify_indic_colors), sv);
}
void sourceview_prefs_destroy(Sourceview* sv)
{
- AnjutaPreferences* prefs = sv->priv->prefs;
- GList* id;
- DEBUG_PRINT("%s", "Destroying preferences");
- for (id = sv->priv->notify_ids; id != NULL; id = id->next)
- {
- anjuta_preferences_notify_remove(prefs,GPOINTER_TO_UINT(id->data));
- }
- g_list_free(sv->priv->notify_ids);
+ g_object_unref (sv->priv->settings);
}
diff --git a/plugins/sourceview/sourceview-print.c b/plugins/sourceview/sourceview-print.c
index e120342..f429584 100644
--- a/plugins/sourceview/sourceview-print.c
+++ b/plugins/sourceview/sourceview-print.c
@@ -66,8 +66,8 @@ draw_page (GtkPrintOperation *operation,
static void
end_print (GtkPrintOperation *operation,
- GtkPrintContext *context,
- SourceviewPrinting* printing)
+ GtkPrintContext *context,
+ SourceviewPrinting* printing)
{
g_object_unref (printing->compositor);
g_slice_free (SourceviewPrinting, printing);
@@ -76,6 +76,8 @@ end_print (GtkPrintOperation *operation,
static GtkPrintOperation*
print_setup (Sourceview* sv)
{
+ /* FIXME */
+#if 0
GtkSourceView *view = GTK_SOURCE_VIEW (sv->priv->view);
GtkSourcePrintCompositor *compositor;
GtkPrintOperation *operation;
@@ -85,50 +87,50 @@ print_setup (Sourceview* sv)
filename = ianjuta_document_get_filename (IANJUTA_DOCUMENT (sv), NULL);
basename = g_filename_display_basename (filename);
-
+
compositor = gtk_source_print_compositor_new_from_view (view);
-
- if (anjuta_preferences_get_int (sv->priv->prefs, PRINT_LINEWRAP))
+
+ if (g_settings_get_int (sv->priv->settings, PRINT_LINEWRAP))
{
gtk_source_print_compositor_set_wrap_mode (compositor,
- GTK_WRAP_WORD_CHAR);
+ GTK_WRAP_WORD_CHAR);
}
else
gtk_source_print_compositor_set_wrap_mode (compositor,
- GTK_WRAP_NONE);
-
+ GTK_WRAP_NONE);
+
gtk_source_print_compositor_set_print_line_numbers (compositor,
- anjuta_preferences_get_bool (sv->priv->prefs,
- PRINT_LINENUMBERS));
-
+ anjuta_preferences_get_bool (sv->priv->prefs,
+ PRINT_LINENUMBERS));
+
gtk_source_print_compositor_set_header_format (compositor,
- TRUE,
- "%x",
- basename,
- "Page %N/%Q");
-
+ TRUE,
+ "%x",
+ basename,
+ "Page %N/%Q");
+
gtk_source_print_compositor_set_footer_format (compositor,
- TRUE,
- "%T",
- basename,
- "Page %N/%Q");
-
+ TRUE,
+ "%T",
+ basename,
+ "Page %N/%Q");
+
gtk_source_print_compositor_set_print_header (compositor,
- anjuta_preferences_get_bool (sv->priv->prefs,
- PRINT_HEADER));
+ anjuta_preferences_get_bool (sv->priv->prefs,
+ PRINT_HEADER));
gtk_source_print_compositor_set_print_footer (compositor,
- anjuta_preferences_get_bool (sv->priv->prefs,
- PRINT_FOOTER));
-
-
+ anjuta_preferences_get_bool (sv->priv->prefs,
+ PRINT_FOOTER));
+
+
gtk_source_print_compositor_set_highlight_syntax (compositor,
- anjuta_preferences_get_bool (sv->priv->prefs,
- PRINT_HIGHLIGHT)),
-
+ anjuta_preferences_get_bool (sv->priv->prefs,
+ PRINT_HIGHLIGHT)),
+
operation = gtk_print_operation_new ();
-
+
gtk_print_operation_set_job_name (operation, basename);
-
+
gtk_print_operation_set_show_progress (operation, TRUE);
printing->compositor = compositor;
@@ -147,6 +149,8 @@ print_setup (Sourceview* sv)
g_free (basename);
return operation;
+#endif
+ return NULL;
}
void
diff --git a/plugins/sourceview/sourceview-private.h b/plugins/sourceview/sourceview-private.h
index 88a3071..76d01f7 100644
--- a/plugins/sourceview/sourceview-private.h
+++ b/plugins/sourceview/sourceview-private.h
@@ -43,7 +43,7 @@ struct SourceviewPrivate {
gboolean read_only;
/* Preferences */
- AnjutaPreferences* prefs;
+ GSettings* settings;
GList* notify_ids;
/* Popup menu */
diff --git a/plugins/sourceview/sourceview.c b/plugins/sourceview/sourceview.c
index ff7a28b..b42a6da 100644
--- a/plugins/sourceview/sourceview.c
+++ b/plugins/sourceview/sourceview.c
@@ -183,15 +183,22 @@ static void sourceview_create_markers(Sourceview* sv)
}
}
+#define PREF_SCHEMA_MSGMAN "org.gnome.anjuta.message-manager"
+#define PREF_COLOR_ERROR "msgman-color-error"
+#define PREF_COLOR_WARNING "msgman-color-warning"
+
+
/* Create tags for highlighting */
static void sourceview_create_highligth_indic(Sourceview* sv)
{
+ GSettings* msg_settings = g_settings_new (PREF_SCHEMA_MSGMAN);
+
char* error_color =
- anjuta_preferences_get (anjuta_preferences_default(),
- "msgman-color-error");
+ g_settings_get_string (msg_settings,
+ PREF_COLOR_ERROR);
char* warning_color =
- anjuta_preferences_get (anjuta_preferences_default (),
- "msgman-color-error");
+ g_settings_get_string (msg_settings,
+ PREF_COLOR_WARNING);
sv->priv->important_indic =
gtk_text_buffer_create_tag (GTK_TEXT_BUFFER(sv->priv->document),
IMPORTANT_INDIC,
@@ -209,6 +216,7 @@ static void sourceview_create_highligth_indic(Sourceview* sv)
PANGO_UNDERLINE_ERROR, NULL);
g_free (error_color);
g_free (warning_color);
+ g_object_unref (msg_settings);
}
static void
@@ -826,7 +834,6 @@ sourceview_new(GFile* file, const gchar* filename, AnjutaPlugin* plugin)
Sourceview *sv = ANJUTA_SOURCEVIEW(g_object_new(ANJUTA_TYPE_SOURCEVIEW, NULL));
/* Apply Preferences */
- sv->priv->prefs = anjuta_preferences_default();
sourceview_prefs_init(sv);
sv->priv->plugin = plugin;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]