[gnome-text-editor] page: give access to indentation options from context menu
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] page: give access to indentation options from context menu
- Date: Tue, 22 Feb 2022 01:45:58 +0000 (UTC)
commit f9cdf8e38a6112560f01bf1aa42867c56cea9f59
Author: Christian Hergert <chergert redhat com>
Date: Mon Feb 21 17:45:18 2022 -0800
page: give access to indentation options from context menu
This gives some overrides to the compiled-form of settings within the
options menu of a document so that the layers can be merged into some
form of understanding to the user.
Related #200
src/editor-page-private.h | 1 +
src/editor-page.c | 3 ++
src/editor-page.ui | 78 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+)
---
diff --git a/src/editor-page-private.h b/src/editor-page-private.h
index 4000b16..c99c3b9 100644
--- a/src/editor-page-private.h
+++ b/src/editor-page-private.h
@@ -58,6 +58,7 @@ struct _EditorPage
GtkInfoBar *changed_infobar;
GtkInfoBar *infobar;
GtkEventController *vim;
+ GMenu *indent_menu;
guint close_requested : 1;
guint moving : 1;
diff --git a/src/editor-page.c b/src/editor-page.c
index da05066..9eb24a3 100644
--- a/src/editor-page.c
+++ b/src/editor-page.c
@@ -813,6 +813,7 @@ editor_page_class_init (EditorPageClass *klass)
gtk_widget_class_bind_template_child (widget_class, EditorPage, box);
gtk_widget_class_bind_template_child (widget_class, EditorPage, goto_line_entry);
gtk_widget_class_bind_template_child (widget_class, EditorPage, goto_line_revealer);
+ gtk_widget_class_bind_template_child (widget_class, EditorPage, indent_menu);
gtk_widget_class_bind_template_child (widget_class, EditorPage, infobar);
gtk_widget_class_bind_template_child (widget_class, EditorPage, map);
gtk_widget_class_bind_template_child (widget_class, EditorPage, overlay);
@@ -840,6 +841,8 @@ editor_page_init (EditorPage *self)
gtk_widget_init_template (GTK_WIDGET (self));
+ editor_source_view_prepend_extra_menu (EDITOR_SOURCE_VIEW (self->view),
+ G_MENU_MODEL (self->indent_menu));
_editor_revealer_auto_hide (self->search_revealer);
_editor_revealer_auto_hide (self->goto_line_revealer);
diff --git a/src/editor-page.ui b/src/editor-page.ui
index 46bb76d..4787d72 100644
--- a/src/editor-page.ui
+++ b/src/editor-page.ui
@@ -150,4 +150,82 @@
</object>
</child>
</template>
+ <menu id="indent_menu">
+ <section>
+ <submenu>
+ <attribute name="label" translatable="yes">Indentation</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Automatic Indentation</attribute>
+ <attribute name="action">view.auto-indent</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Tabs</attribute>
+ <attribute name="action">view.indent-style</attribute>
+ <attribute name="target" type="s">'tab'</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Spaces</attribute>
+ <attribute name="action">view.indent-style</attribute>
+ <attribute name="target" type="s">'space'</attribute>
+ </item>
+ </section>
+ <section>
+ <submenu>
+ <attribute name="label" translatable="yes">Spaces _Per Tab</attribute>
+ <item>
+ <attribute name="label" translatable="yes">2</attribute>
+ <attribute name="action">view.tab-width</attribute>
+ <attribute name="target" type="u">2</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">4</attribute>
+ <attribute name="action">view.tab-width</attribute>
+ <attribute name="target" type="u">4</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">6</attribute>
+ <attribute name="action">view.tab-width</attribute>
+ <attribute name="target" type="u">6</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">8</attribute>
+ <attribute name="action">view.tab-width</attribute>
+ <attribute name="target" type="u">8</attribute>
+ </item>
+ </submenu>
+ <submenu>
+ <attribute name="label" translatable="yes">Spaces Per Indent</attribute>
+ <item>
+ <attribute name="label" translatable="yes">Use Tab Size</attribute>
+ <attribute name="action">view.indent-width</attribute>
+ <attribute name="target" type="i">-1</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">2</attribute>
+ <attribute name="action">view.indent-width</attribute>
+ <attribute name="target" type="i">2</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">4</attribute>
+ <attribute name="action">view.indent-width</attribute>
+ <attribute name="target" type="i">4</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">6</attribute>
+ <attribute name="action">view.indent-width</attribute>
+ <attribute name="target" type="i">6</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">8</attribute>
+ <attribute name="action">view.indent-width</attribute>
+ <attribute name="target" type="i">8</attribute>
+ </item>
+ </submenu>
+ </section>
+ </submenu>
+ </section>
+ </menu>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]