[anjuta-extras] scintilla: Add editor view settings
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta-extras] scintilla: Add editor view settings
- Date: Sun, 18 Dec 2011 16:25:28 +0000 (UTC)
commit 02caef1f4d9956f9794275cc39d823f7f7c840c5
Author: SÃbastien Granjoux <seb sfo free fr>
Date: Sun Dec 18 12:45:45 2011 +0100
scintilla: Add editor view settings
plugins/scintilla/Makefile.am | 5 +
plugins/scintilla/anjuta-scintilla.xml | 29 ++++++
plugins/scintilla/plugin.c | 153 +++++++++++++++++++++++++++++++-
3 files changed, 186 insertions(+), 1 deletions(-)
---
diff --git a/plugins/scintilla/Makefile.am b/plugins/scintilla/Makefile.am
index f377ffe..7849a4e 100644
--- a/plugins/scintilla/Makefile.am
+++ b/plugins/scintilla/Makefile.am
@@ -6,6 +6,10 @@ SUBDIRS = scintilla properties
editor_gladedir = $(anjuta_glade_dir)
editor_glade_DATA = anjuta-editor-scintilla.ui
+# Plugin UI file
+editor_uidir = $(anjuta_ui_dir)
+editor_ui_DATA = anjuta-scintilla.xml
+
# Plugin Icon file
editor_pixmapsdir = $(anjuta_image_dir)
editor_pixmaps_DATA = \
@@ -80,6 +84,7 @@ EXTRA_DIST = \
$(plugin_in_files) \
$(editor_plugin_DATA) \
$(editor_ui_DATA) \
+ $(editor_ui_DATA) \
$(editor_glade_DATA) \
$(gsettings_in_file) \
License.txt
diff --git a/plugins/scintilla/anjuta-scintilla.xml b/plugins/scintilla/anjuta-scintilla.xml
new file mode 100644
index 0000000..564fd28
--- /dev/null
+++ b/plugins/scintilla/anjuta-scintilla.xml
@@ -0,0 +1,29 @@
+<!--*- xml -*-->
+<ui>
+ <menubar name="MenuMain">
+ <menu name="MenuView" action="ActionMenuView">
+ <menu name="MenuViewEditor" action="ActionMenuViewEditor">
+ <placeholder name="PlaceholderViewEditorMenus">
+ <menuitem name="LineNumbersMargin" action="ActionViewEditorLinenumbers" />
+ <menuitem name="MarkersMargin" action="ActionViewEditorMarkers" />
+ <menuitem name="CodeFoldMargin" action="ActionViewEditorFolds" />
+ <menuitem name="IndentationGuides" action="ActionViewEditorGuides" />
+ <menuitem name="WhiteSpaces" action="ActionViewEditorSpaces" />
+ <menuitem name="LineEndCharacters" action="ActionViewEditorEOL" />
+ <menuitem name="LineWrapping" action="ActionViewEditorWrapping" />
+ </placeholder>
+ </menu>
+ </menu>
+ </menubar>
+ <popup name="PopupDocumentManager">
+ <menu name="MenuView" action="ActionMenuView">
+ <placeholder name="PlaceholderViewEditorPopup">
+ <menuitem name="LineNumbersMargin" action="ActionViewEditorLinenumbers" />
+ <menuitem name="MarkersMargin" action="ActionViewEditorMarkers" />
+ <menuitem name="CodeFoldMargin" action="ActionViewEditorFolds" />
+ <menuitem name="IndentationGuides" action="ActionViewEditorGuides" />
+ <menuitem name="LineWrapping" action="ActionViewEditorWrapping" />
+ </placeholder>
+ </menu>
+ </popup>
+</ui>
diff --git a/plugins/scintilla/plugin.c b/plugins/scintilla/plugin.c
index 7926c3c..847f60d 100644
--- a/plugins/scintilla/plugin.c
+++ b/plugins/scintilla/plugin.c
@@ -38,6 +38,7 @@
#define PREFS_GLADE PACKAGE_DATA_DIR "/glade/anjuta-editor-scintilla.ui"
#define ICON_FILE "anjuta-editor-scintilla-plugin-48.png"
+#define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-scintilla.xml"
static gpointer parent_class;
@@ -63,6 +64,8 @@ struct _EditorPlugin{
/* Settings */
GSettings *settings;
+ GtkActionGroup *group;
+ gint uiid;
AnjutaPreferences* prefs;
};
@@ -73,6 +76,138 @@ struct _EditorPluginClass{
void (* style_changed) ();
};
+/* Editor preferences
+ *---------------------------------------------------------------------------*/
+
+static void
+on_editor_linenos_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_LINENUMBERS_MARGIN, state);
+}
+
+static void
+on_editor_markers_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_MARKER_MARGIN, state);
+}
+
+static void
+on_editor_codefold_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_FOLD_MARGIN, state);
+}
+
+static void
+on_editor_indentguides_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (user_data);
+
+ state = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ g_settings_set_boolean (plugin->settings,
+ VIEW_INDENTATION_GUIDES, state);
+}
+
+static void
+on_editor_whitespaces_activate (GtkAction *action, gpointer user_data)
+{
+ gboolean state;
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (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;
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (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;
+ EditorPlugin* plugin = ANJUTA_PLUGIN_EDITOR (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},
+ { "ActionViewEditorFolds", NULL, N_("_Code Fold Margin"), NULL,
+ N_("Show/Hide code fold margin"),
+ G_CALLBACK (on_editor_codefold_activate), FALSE},
+ { "ActionViewEditorGuides", NULL, N_("_Indentation Guides"), NULL,
+ N_("Show/Hide indentation guides"),
+ G_CALLBACK (on_editor_indentguides_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 (EditorPlugin* plugin, AnjutaUI *ui)
+{
+ static const gchar *prefs[] = {
+ VIEW_LINENUMBERS_MARGIN,
+ VIEW_MARKER_MARGIN,
+ VIEW_FOLD_MARGIN,
+ VIEW_INDENTATION_GUIDES,
+ 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);
+ }
+}
+
+
/* Keep an up to date list of type name
*---------------------------------------------------------------------------*/
@@ -174,6 +309,7 @@ activate_plugin (AnjutaPlugin *plugin)
IAnjutaSymbolManager *manager;
IAnjutaSymbolQuery *query_project;
IAnjutaSymbolQuery *query_system;
+ AnjutaUI *ui;
manager = anjuta_shell_get_interface (plugin->shell,
IAnjutaSymbolManager, NULL);
@@ -230,7 +366,16 @@ activate_plugin (AnjutaPlugin *plugin)
editor->query_project = query_project;
editor->query_system = query_system;
-
+ /* Add menu entries */
+ ui = anjuta_shell_get_ui (plugin->shell, NULL);
+ editor->group = anjuta_ui_add_toggle_action_group_entries (ui, "ActionGroupEditorView",
+ _("Editor view settings"),
+ actions_view,
+ G_N_ELEMENTS (actions_view),
+ GETTEXT_PACKAGE, TRUE, editor);
+ ui_states_init (editor, ui);
+ editor->uiid = anjuta_ui_merge (ui, UI_FILE);
+
return TRUE;
}
@@ -239,6 +384,12 @@ deactivate_plugin (AnjutaPlugin *plugin)
{
EditorPlugin* editor = ANJUTA_PLUGIN_EDITOR (plugin);
IAnjutaSymbolManager *manager = anjuta_shell_get_interface (plugin->shell, IAnjutaSymbolManager, NULL);
+ AnjutaUI *ui;
+
+ /* Remove menu items */
+ ui = anjuta_shell_get_ui (ANJUTA_PLUGIN (plugin)->shell, NULL);
+ anjuta_ui_unmerge (ui, editor->uiid);
+ anjuta_ui_remove_action_group (ui, editor->group);
/* Disconnect signals */
g_signal_handlers_disconnect_by_func (G_OBJECT (manager), G_CALLBACK (on_project_symbol_scanned), editor->query_project);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]