[anjuta] sourceview: Add editor view settings
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] sourceview: Add editor view settings
- Date: Sun, 18 Dec 2011 16:25:52 +0000 (UTC)
commit 42bb0463671495adaf640bc8405d8c335ae0e815
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Sun Dec 18 16:58:23 2011 +0100
sourceview: Add editor view settings
plugins/sourceview/Makefile.am | 5 +
....gnome.anjuta.plugins.sourceview.gschema.xml.in | 9 +
plugins/sourceview/plugin.c | 185 +++++++++++++++++---
plugins/sourceview/plugin.h | 12 +-
plugins/sourceview/sourceview-prefs.c | 85 ++++-----
plugins/sourceview/sourceview-prefs.h | 13 +-
plugins/sourceview/sourceview-private.h | 29 ++--
7 files changed, 237 insertions(+), 101 deletions(-)
---
diff --git a/plugins/sourceview/Makefile.am b/plugins/sourceview/Makefile.am
index 51fa089..e0e2bda 100644
--- a/plugins/sourceview/Makefile.am
+++ b/plugins/sourceview/Makefile.am
@@ -2,6 +2,10 @@
sourceview_xmldir = $(anjuta_glade_dir)
sourceview_xml_DATA = anjuta-editor-sourceview.ui
+# Plugin UI file
+sourceview_uidir = $(anjuta_ui_dir)
+sourceview_ui_DATA = anjuta-sourceview.xml
+
# Plugin Icon file
sourceview_pixmapsdir = $(anjuta_image_dir)
sourceview_pixmaps_DATA = \
@@ -86,6 +90,7 @@ EXTRA_DIST = \
anjuta-marshal.list \
$(plugin_in_files) \
$(sourceview_plugin_DATA) \
+ $(sourceview_ui_DATA) \
$(sourceview_pixmaps_DATA) \
$(sourceview_xml_DATA) \
$(gsettings_in_file)
diff --git a/plugins/sourceview/org.gnome.anjuta.plugins.sourceview.gschema.xml.in b/plugins/sourceview/org.gnome.anjuta.plugins.sourceview.gschema.xml.in
index d2b7cda..f8839d0 100644
--- a/plugins/sourceview/org.gnome.anjuta.plugins.sourceview.gschema.xml.in
+++ b/plugins/sourceview/org.gnome.anjuta.plugins.sourceview.gschema.xml.in
@@ -47,6 +47,15 @@
<key name="rightmargin-visible" type="b">
<default>true</default>
</key>
+ <key name="line-wrap" type="b">
+ <default>false</default>
+ </key>
+ <key name="whitespace" type="b">
+ <default>false</default>
+ </key>
+ <key name="eol" type="b">
+ <default>false</default>
+ </key>
<key name="rightmargin-position" type="i">
<default>80</default>
</key>
diff --git a/plugins/sourceview/plugin.c b/plugins/sourceview/plugin.c
index f704462..c2fa184 100644
--- a/plugins/sourceview/plugin.c
+++ b/plugins/sourceview/plugin.c
@@ -2,19 +2,19 @@
/*
* plugin.c
* Copyright (C) Johannes Schmid 2005 <jhs gnome org>
- *
+ *
* plugin.c is free software.
- *
+ *
* You may redistribute it and/or modify it under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
- *
+ *
* plugin.c is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with plugin.c. If not, write to:
* The Free Software Foundation, Inc.,
@@ -36,11 +36,13 @@
#include "plugin.h"
#include "sourceview.h"
+#include "sourceview-prefs.h"
#include "sourceview-private.h"
#define PREF_SCHEMA "org.gnome.anjuta.plugins.sourceview"
#define PREFS_GLADE PACKAGE_DATA_DIR"/glade/anjuta-editor-sourceview.ui"
#define ICON_FILE "anjuta-editor-sourceview-plugin-48.png"
+#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-sourceview.xml"
#define COMBO_STYLES "combo_styles"
#define SOURCEVIEW_STYLE "style"
@@ -53,6 +55,105 @@ static gpointer parent_class;
static GtkBuilder* builder = NULL;
static void
+on_editor_linenos_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_LINENUMBERS, state);
+}
+
+static void
+on_editor_markers_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_MARKS, state);
+}
+
+static void
+on_editor_whitespaces_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_WHITE_SPACES, state);
+}
+
+static void
+on_editor_eolchars_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_EOL, state);
+}
+
+static void
+on_editor_linewrap_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_LINE_WRAP, state);
+}
+
+static GtkToggleActionEntry actions_view[] = {
+ { "ActionViewEditorLinenumbers", NULL, N_("_Line Number Margin"), NULL,
+ N_("Show/Hide line numbers"),
+ G_CALLBACK (on_editor_linenos_activate), FALSE},
+ { "ActionViewEditorMarkers", NULL, N_("_Marker Margin"), NULL,
+ N_("Show/Hide marker margin"),
+ G_CALLBACK (on_editor_markers_activate), FALSE},
+ { "ActionViewEditorSpaces", NULL, N_("_White Space"), NULL,
+ N_("Show/Hide white spaces"),
+ G_CALLBACK (on_editor_whitespaces_activate), FALSE},
+ { "ActionViewEditorEOL", NULL, N_("_Line End Characters"), NULL,
+ N_("Show/Hide line end characters"),
+ G_CALLBACK (on_editor_eolchars_activate), FALSE},
+ { "ActionViewEditorWrapping", NULL, N_("Line _Wrapping"), NULL,
+ N_("Enable/disable line wrapping"),
+ G_CALLBACK (on_editor_linewrap_activate), FALSE}
+};
+
+static void
+ui_states_init (SourceviewPlugin* plugin, AnjutaUI *ui)
+{
+ static const gchar *prefs[] = {
+ VIEW_LINENUMBERS,
+ VIEW_MARKS,
+ VIEW_WHITE_SPACES,
+ VIEW_EOL,
+ VIEW_LINE_WRAP
+ };
+ gint i;
+
+ for (i = 0; i < sizeof (prefs)/sizeof(const gchar *); i++)
+ {
+ GtkAction *action;
+ gboolean state;
+
+ state = g_settings_get_boolean (plugin->settings, prefs[i]);
+ action = anjuta_ui_get_action (ui, "ActionGroupEditorView",
+ actions_view[i].name);
+ g_object_set (G_OBJECT (action), "sensitive", TRUE, "visible", TRUE, NULL);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), state);
+ }
+}
+
+
+static void
on_font_check_toggled(GtkToggleButton* button, GtkBuilder* builder)
{
GtkWidget* font_button;
@@ -61,18 +162,42 @@ on_font_check_toggled(GtkToggleButton* button, GtkBuilder* builder)
}
static gboolean
-sourceview_plugin_activate (AnjutaPlugin *plugin)
-{
+sourceview_plugin_activate (AnjutaPlugin *obj)
+{
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (obj);
+ AnjutaUI *ui;
+
DEBUG_PRINT ("%s", "SourceviewPlugin: Activating SourceviewPlugin plugin ...");
+ /* Add menu entries */
+ ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
+ plugin->group = anjuta_ui_add_toggle_action_group_entries (ui, "ActionGroupEditorView",
+ _("Editor view settings"),
+ actions_view,
+ G_N_ELEMENTS (actions_view),
+ GETTEXT_PACKAGE, TRUE, plugin);
+ ui_states_init (plugin, ui);
+ plugin->uiid = anjuta_ui_merge (ui, UI_FILE);
+
return TRUE;
}
static gboolean
-sourceview_plugin_deactivate (AnjutaPlugin *plugin)
+sourceview_plugin_deactivate (AnjutaPlugin *obj)
{
+ SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (obj);
+ AnjutaUI *ui;
+
DEBUG_PRINT ("%s", "SourceviewPlugin: Dectivating SourceviewPlugin plugin ...");
-
+
+ ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
+ anjuta_ui_unmerge (ui, plugin->uiid);
+ if (plugin->group != NULL)
+ {
+ anjuta_ui_remove_action_group (ui, plugin->group);
+ plugin->group = NULL;
+ }
+
return TRUE;
}
@@ -89,7 +214,7 @@ sourceview_plugin_dispose (GObject *obj)
SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (obj);
g_object_unref (plugin->settings);
-
+
G_OBJECT_CLASS (parent_class)->dispose (obj);
}
@@ -98,10 +223,12 @@ sourceview_plugin_instance_init (GObject *obj)
{
SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (obj);
plugin->settings = g_settings_new (PREF_SCHEMA);
+ plugin->group = NULL;
+ plugin->uiid = 0;
}
static void
-sourceview_plugin_class_init (GObjectClass *klass)
+sourceview_plugin_class_init (GObjectClass *klass)
{
AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
@@ -114,9 +241,9 @@ sourceview_plugin_class_init (GObjectClass *klass)
}
static IAnjutaEditor*
-ieditor_factory_new_editor(IAnjutaEditorFactory* factory,
+ieditor_factory_new_editor(IAnjutaEditorFactory* factory,
GFile* file,
- const gchar* filename,
+ const gchar* filename,
GError** error)
{
AnjutaPlugin* plugin = ANJUTA_PLUGIN(factory);
@@ -139,7 +266,7 @@ ieditor_factory_iface_init (IAnjutaEditorFactoryIface *iface)
iface->new_editor = ieditor_factory_new_editor;
}
-enum
+enum
{
COLUMN_NAME = 0,
COLUMN_DESC,
@@ -159,7 +286,7 @@ create_style_model (GSettings* settings, GtkTreeIter** current)
for (style = styles; *style != NULL; style++)
{
GtkTreeIter iter;
- GtkSourceStyleScheme* scheme =
+ GtkSourceStyleScheme* scheme =
gtk_source_style_scheme_manager_get_scheme (manager, *style);
const gchar* id = gtk_source_style_scheme_get_id (scheme);
gtk_list_store_append (model, &iter);
@@ -174,8 +301,8 @@ create_style_model (GSettings* settings, GtkTreeIter** current)
}
g_free (current_style);
return GTK_TREE_MODEL (model);
-}
-
+}
+
static void
on_style_changed (GtkComboBox* combo, SourceviewPlugin* plugin)
{
@@ -194,8 +321,8 @@ on_style_changed (GtkComboBox* combo, SourceviewPlugin* plugin)
SOURCEVIEW_STYLE,
id);
g_free (id);
-
-
+
+
docman = anjuta_shell_get_interface (shell,
IAnjutaDocumentManager, NULL);
if (docman)
@@ -234,22 +361,22 @@ ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError**
anjuta_preferences_add_from_builder (prefs,
builder,
plugin->settings,
- "Editor",
- _("GtkSourceView Editor"),
+ "Editor",
+ _("GtkSourceView Editor"),
ICON_FILE);
-
- plugin->check_font = GTK_WIDGET (gtk_builder_get_object (builder,
+
+ plugin->check_font = GTK_WIDGET (gtk_builder_get_object (builder,
FONT_USE_THEME_BUTTON));
- g_signal_connect(G_OBJECT(plugin->check_font), "toggled",
+ g_signal_connect(G_OBJECT(plugin->check_font), "toggled",
G_CALLBACK(on_font_check_toggled), builder);
on_font_check_toggled (GTK_TOGGLE_BUTTON (plugin->check_font), builder);
-
+
/* 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(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));
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(plugin->combo_styles), renderer_name, TRUE);
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(plugin->combo_styles), renderer_desc, FALSE);
@@ -271,11 +398,11 @@ static void
ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences* prefs, GError** e)
{
SourceviewPlugin* plugin = ANJUTA_PLUGIN_SOURCEVIEW (ipref);
- g_signal_handlers_disconnect_by_func(G_OBJECT(plugin->check_font),
+ g_signal_handlers_disconnect_by_func(G_OBJECT(plugin->check_font),
G_CALLBACK(on_font_check_toggled), builder);
- g_signal_handlers_disconnect_by_func(G_OBJECT(plugin->combo_styles),
+ g_signal_handlers_disconnect_by_func(G_OBJECT(plugin->combo_styles),
G_CALLBACK(on_style_changed), builder);
-
+
anjuta_preferences_remove_page(prefs, _("GtkSourceView Editor"));
g_object_unref(builder);
builder = NULL;
@@ -285,7 +412,7 @@ static void
ipreferences_iface_init(IAnjutaPreferencesIface* iface)
{
iface->merge = ipreferences_merge;
- iface->unmerge = ipreferences_unmerge;
+ iface->unmerge = ipreferences_unmerge;
}
ANJUTA_PLUGIN_BEGIN (SourceviewPlugin, sourceview_plugin);
diff --git a/plugins/sourceview/plugin.h b/plugins/sourceview/plugin.h
index dde1089..0fa3d36 100644
--- a/plugins/sourceview/plugin.h
+++ b/plugins/sourceview/plugin.h
@@ -2,19 +2,19 @@
/*
* plugin.h
* Copyright (C) Johannes Schmid 2005 <jhs gnome org>
- *
+ *
* plugin.h is free software.
- *
+ *
* You may redistribute it and/or modify it under the terms of the
* GNU General Public License, as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
- *
+ *
* plugin.h is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with plugin.h. If not, write to:
* The Free Software Foundation, Inc.,
@@ -40,10 +40,12 @@ typedef struct _SourceviewPluginClass SourceviewPluginClass;
struct _SourceviewPlugin{
AnjutaPlugin parent;
-
+
GtkWidget* combo_styles;
GtkWidget* check_font;
GSettings* settings;
+ GtkActionGroup *group;
+ gint uiid;
};
struct _SourceviewPluginClass{
diff --git a/plugins/sourceview/sourceview-prefs.c b/plugins/sourceview/sourceview-prefs.c
index 29d09f4..1ee440c 100644
--- a/plugins/sourceview/sourceview-prefs.c
+++ b/plugins/sourceview/sourceview-prefs.c
@@ -3,12 +3,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
-*
+*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
-*
+*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -26,7 +26,6 @@
g_signal_connect (settings, "changed::" key, G_CALLBACK(func), sv);
#define PREF_SCHEMA "org.gnome.anjuta.plugins.sourceview"
-#define DOCMAN_PREF_SCHEMA "org.gnome.anjuta.document-manager"
#define MSGMAN_PREF_SCHEMA "org.gnome.anjuta.message-manager"
@@ -39,16 +38,9 @@
#define INDENT_SIZE "indent-size"
#define AUTOCOMPLETION "autocomplete"
-#define VIEW_MARKS "margin-marker-visible"
-
-#define VIEW_LINENUMBERS "margin-linenumber-visible"
#define VIEW_RIGHTMARGIN "rightmargin-visible"
#define RIGHTMARGIN_POSITION "rightmargin-position"
-#define DOCMAN_VIEW_WHITE_SPACES "docman-whitespace"
-#define DOCMAN_VIEW_EOL "docman-eol"
-#define DOCMAN_VIEW_LINE_WRAP "docman-line-wrap"
-
#define MSGMAN_COLOR_ERROR "msgman-color-error"
#define MSGMAN_COLOR_WARNING "msgman-color.warning"
@@ -57,7 +49,6 @@
#define FONT "font"
#define DESKTOP_FIXED_FONT "/desktop/gnome/interface/monospace_font_name"
-
static void
on_notify_view_spaces (GSettings* settings,
const gchar* key,
@@ -65,15 +56,15 @@ on_notify_view_spaces (GSettings* settings,
{
Sourceview *sv;
sv = ANJUTA_SOURCEVIEW(user_data);
- GtkSourceDrawSpacesFlags flags =
+ GtkSourceDrawSpacesFlags flags =
gtk_source_view_get_draw_spaces (GTK_SOURCE_VIEW (sv->priv->view));
-
+
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);
-
- gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW(sv->priv->view),
+
+ gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW(sv->priv->view),
flags);
}
@@ -84,15 +75,15 @@ on_notify_view_eol (GSettings* settings,
{
Sourceview *sv;
sv = ANJUTA_SOURCEVIEW(user_data);
- GtkSourceDrawSpacesFlags flags =
+ GtkSourceDrawSpacesFlags flags =
gtk_source_view_get_draw_spaces (GTK_SOURCE_VIEW (sv->priv->view));
-
+
if (g_settings_get_boolean (settings, key))
flags |= GTK_SOURCE_DRAW_SPACES_NEWLINE;
else
flags &= ~GTK_SOURCE_DRAW_SPACES_NEWLINE;
-
- gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW(sv->priv->view),
+
+ gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW(sv->priv->view),
flags);
}
@@ -103,7 +94,7 @@ on_notify_line_wrap (GSettings* settings,
{
Sourceview *sv;
sv = ANJUTA_SOURCEVIEW(user_data);
-
+
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (sv->priv->view),
g_settings_get_boolean (settings, key) ? GTK_WRAP_WORD : GTK_WRAP_NONE);
}
@@ -138,8 +129,8 @@ on_notify_autocompletion (GSettings* settings,
gtk_source_completion_words_register (prov_words,
gtk_text_view_get_buffer (GTK_TEXT_VIEW (sv->priv->view)));
- gtk_source_completion_add_provider (completion,
- GTK_SOURCE_COMPLETION_PROVIDER (prov_words),
+ gtk_source_completion_add_provider (completion,
+ GTK_SOURCE_COMPLETION_PROVIDER (prov_words),
NULL);
}
else
@@ -180,11 +171,11 @@ on_notify_font_theme (GSettings* settings,
{
Sourceview *sv;
sv = ANJUTA_SOURCEVIEW(user_data);
-
+
if (g_settings_get_boolean (settings, key))
{
/* FIXME: GSettings */
-#if 0
+#if 0
GConfClient *gclient = gconf_client_get_default ();
gchar *desktop_fixed_font;
desktop_fixed_font =
@@ -194,7 +185,7 @@ on_notify_font_theme (GSettings* settings,
else
anjuta_view_set_font(sv->priv->view, TRUE, NULL);
g_free (desktop_fixed_font);
-#endif
+#endif
}
else
{
@@ -229,9 +220,9 @@ static void
init_fonts(Sourceview* sv)
{
gboolean font_theme;
-
+
font_theme = FALSE; //g_settings_get_boolean (sv->priv->settings, FONT_THEME);
-
+
if (!font_theme)
{
gchar* font = g_settings_get_string (sv->priv->settings, FONT);
@@ -241,10 +232,10 @@ init_fonts(Sourceview* sv)
#if 0
else
{
- /* FIXME: Get font from GSettings */
+ /* FIXME: Get font from GSettings */
GConfClient *gclient;
gchar *desktop_fixed_font;
-
+
gclient = gconf_client_get_default ();
desktop_fixed_font =
gconf_client_get_string (gclient, DESKTOP_FIXED_FONT, NULL);
@@ -258,7 +249,7 @@ init_fonts(Sourceview* sv)
#endif
}
-void
+void
sourceview_prefs_init(Sourceview* sv)
{
GtkSourceDrawSpacesFlags flags = 0;
@@ -266,10 +257,9 @@ sourceview_prefs_init(Sourceview* sv)
* the editor might be destroyed while the plugin is still alive
*/
sv->priv->settings = g_settings_new (PREF_SCHEMA);
- sv->priv->docman_settings = g_settings_new (DOCMAN_PREF_SCHEMA);
sv->priv->msgman_settings = g_settings_new (MSGMAN_PREF_SCHEMA);
- /* Bind simple options to GSettings */
+ /* Bind simple options to GSettings */
g_settings_bind (sv->priv->settings, HIGHLIGHT_SYNTAX,
sv->priv->document, "highlight-syntax",
G_SETTINGS_BIND_GET);
@@ -278,39 +268,39 @@ sourceview_prefs_init(Sourceview* sv)
G_SETTINGS_BIND_GET);
g_settings_bind (sv->priv->settings, TAB_SIZE,
sv->priv->view, "tab-width",
- G_SETTINGS_BIND_GET);
+ G_SETTINGS_BIND_GET);
g_settings_bind (sv->priv->settings, HIGHLIGHT_BRACKETS,
sv->priv->document, "highlight-matching-brackets",
G_SETTINGS_BIND_GET);
g_settings_bind (sv->priv->settings, VIEW_MARKS,
sv->priv->view, "show-line-marks",
- G_SETTINGS_BIND_GET);
+ G_SETTINGS_BIND_GET);
g_settings_bind (sv->priv->settings, RIGHTMARGIN_POSITION,
sv->priv->view, "right-margin-position",
- G_SETTINGS_BIND_GET);
+ G_SETTINGS_BIND_GET);
g_settings_bind (sv->priv->settings, VIEW_RIGHTMARGIN,
sv->priv->view, "show-right-margin",
- G_SETTINGS_BIND_GET);
+ G_SETTINGS_BIND_GET);
g_settings_bind (sv->priv->settings, VIEW_LINENUMBERS,
sv->priv->view, "show-line-numbers",
- G_SETTINGS_BIND_GET);
+ G_SETTINGS_BIND_GET);
/* Init non-simple options */
gtk_source_view_set_indent_width(GTK_SOURCE_VIEW(sv->priv->view), -1); /* Same as tab width */
gtk_source_view_set_insert_spaces_instead_of_tabs(GTK_SOURCE_VIEW(sv->priv->view),
!g_settings_get_boolean (sv->priv->settings, USE_TABS));
-
+
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (sv->priv->view),
- g_settings_get_boolean (sv->priv->docman_settings, DOCMAN_VIEW_EOL) ? GTK_WRAP_WORD : GTK_WRAP_NONE);
+ g_settings_get_boolean (sv->priv->settings, VIEW_EOL) ? GTK_WRAP_WORD : GTK_WRAP_NONE);
- if (g_settings_get_boolean (sv->priv->docman_settings, DOCMAN_VIEW_WHITE_SPACES))
+ if (g_settings_get_boolean (sv->priv->settings, VIEW_WHITE_SPACES))
flags |= (GTK_SOURCE_DRAW_SPACES_SPACE | GTK_SOURCE_DRAW_SPACES_TAB);
- if (g_settings_get_boolean (sv->priv->docman_settings, DOCMAN_VIEW_EOL))
+ if (g_settings_get_boolean (sv->priv->settings, VIEW_EOL))
flags |= GTK_SOURCE_DRAW_SPACES_NEWLINE;
gtk_source_view_set_draw_spaces (GTK_SOURCE_VIEW (sv->priv->view),
@@ -319,21 +309,21 @@ sourceview_prefs_init(Sourceview* sv)
init_fonts(sv);
on_notify_autocompletion(sv->priv->settings, AUTOCOMPLETION, sv);
-
+
/* Register notifications */
REGISTER_NOTIFY (sv->priv->settings, USE_TABS, on_notify_use_tab_for_indentation);
REGISTER_NOTIFY (sv->priv->settings, AUTOCOMPLETION, on_notify_autocompletion);
- REGISTER_NOTIFY (sv->priv->docman_settings, DOCMAN_VIEW_WHITE_SPACES, on_notify_view_spaces);
- REGISTER_NOTIFY (sv->priv->docman_settings, DOCMAN_VIEW_EOL, on_notify_view_eol);
- REGISTER_NOTIFY (sv->priv->docman_settings, DOCMAN_VIEW_LINE_WRAP, on_notify_line_wrap);
+ REGISTER_NOTIFY (sv->priv->settings, VIEW_WHITE_SPACES, on_notify_view_spaces);
+ REGISTER_NOTIFY (sv->priv->settings, VIEW_EOL, on_notify_view_eol);
+ REGISTER_NOTIFY (sv->priv->settings, VIEW_LINE_WRAP, on_notify_line_wrap);
REGISTER_NOTIFY (sv->priv->settings, FONT_THEME, on_notify_font_theme);
REGISTER_NOTIFY (sv->priv->settings, FONT, on_notify_font);
g_signal_connect (sv->priv->msgman_settings, "changed::" MSGMAN_COLOR_ERROR,
G_CALLBACK (on_notify_indic_colors), sv);
g_signal_connect (sv->priv->msgman_settings, "changed::" MSGMAN_COLOR_WARNING,
- G_CALLBACK (on_notify_indic_colors), sv);
+ G_CALLBACK (on_notify_indic_colors), sv);
}
void sourceview_prefs_destroy(Sourceview* sv)
@@ -342,10 +332,7 @@ void sourceview_prefs_destroy(Sourceview* sv)
g_object_unref (sv->priv->settings);
if (sv->priv->msgman_settings)
g_object_unref (sv->priv->msgman_settings);
- if (sv->priv->docman_settings)
- g_object_unref (sv->priv->docman_settings);
sv->priv->settings = NULL;
sv->priv->msgman_settings = NULL;
- sv->priv->docman_settings = NULL;
}
diff --git a/plugins/sourceview/sourceview-prefs.h b/plugins/sourceview/sourceview-prefs.h
index e0b7089..8da4f3f 100644
--- a/plugins/sourceview/sourceview-prefs.h
+++ b/plugins/sourceview/sourceview-prefs.h
@@ -3,23 +3,30 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
+
#ifndef SOURCEVIEW_PREFS_H
#define SOURCEVIEW_PREFS_H
#include <libanjuta/anjuta-preferences.h>
#include "sourceview.h"
+/* Editor preferences */
+#define VIEW_LINENUMBERS "margin-linenumber-visible"
+#define VIEW_MARKS "margin-marker-visible"
+#define VIEW_WHITE_SPACES "whitespace"
+#define VIEW_EOL "eol"
+#define VIEW_LINE_WRAP "line-wrap"
+
void
sourceview_prefs_init(Sourceview* sv);
diff --git a/plugins/sourceview/sourceview-private.h b/plugins/sourceview/sourceview-private.h
index 17e05d4..5326388 100644
--- a/plugins/sourceview/sourceview-private.h
+++ b/plugins/sourceview/sourceview-private.h
@@ -3,17 +3,17 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
+
#ifndef SOURCEVIEW_PRIVATE_H
#define SOURCEVIEW_PRIVATE_H
@@ -29,44 +29,43 @@
struct SourceviewPrivate {
/* GtkSouceView */
AnjutaView* view;
-
+
/* GtkSourceBuffer */
GtkSourceBuffer* document;
-
+
/* Highlight Tag */
GtkTextTag *important_indic;
GtkTextTag *warning_indic;
GtkTextTag *critical_indic;
-
+
/* IO */
SourceviewIO* io;
gboolean read_only;
-
+
/* Preferences */
GSettings* settings;
- GSettings* docman_settings;
GSettings* msgman_settings;
GList* notify_ids;
-
+
/* Popup menu */
GtkWidget* menu;
-
+
/* Message area */
GtkWidget* message_area;
/* Editor window */
GtkWidget* window;
-
+
/* Goto line hack */
gboolean loading;
gint goto_line;
-
+
/* Idle marking */
GSList* idle_sources;
-
+
/* Assist */
AssistTip* assist_tip;
-
+
/* Hover */
gchar* tooltip;
SourceviewCell* tooltip_cell;
@@ -77,7 +76,7 @@ struct SourceviewPrivate {
/* Reload */
GSList* reload_marks;
gint reload_line;
-
+
/* Plugin */
AnjutaPlugin* plugin;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]