[gnome-builder/wip/gtk4-port: 342/343] plugins/editorui: add line endings menu




commit 3232e79fcb96d1edc71d46e383bfddf8e7e259b8
Author: Christian Hergert <chergert redhat com>
Date:   Sun Apr 3 18:31:24 2022 -0700

    plugins/editorui: add line endings menu

 src/plugins/editorui/gbp-editorui-workspace-addin.c | 17 +++++++++++++++++
 src/plugins/editorui/gtk/menus.ui                   | 17 +++++++++++++++++
 2 files changed, 34 insertions(+)
---
diff --git a/src/plugins/editorui/gbp-editorui-workspace-addin.c 
b/src/plugins/editorui/gbp-editorui-workspace-addin.c
index 50bca9ba5..1e7cd0e49 100644
--- a/src/plugins/editorui/gbp-editorui-workspace-addin.c
+++ b/src/plugins/editorui/gbp-editorui-workspace-addin.c
@@ -42,6 +42,9 @@ struct _GbpEditoruiWorkspaceAddin
   GtkMenuButton            *indentation;
   GtkLabel                 *indentation_label;
 
+  GtkMenuButton            *line_ends;
+  GtkLabel                 *line_ends_label;
+
   GtkMenuButton            *position;
   GbpEditoruiPositionLabel *position_label;
 
@@ -170,6 +173,19 @@ gbp_editorui_workspace_addin_load (IdeWorkspaceAddin *addin,
                                    self,
                                    G_CONNECT_SWAPPED);
 
+  /* Line ending */
+  menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "editorui-line-ends-menu");
+  self->line_ends_label = g_object_new (GTK_TYPE_LABEL,
+                                        "label", "LF",
+                                        NULL);
+  self->line_ends = g_object_new (GTK_TYPE_MENU_BUTTON,
+                                  "menu-model", menu,
+                                  "direction", GTK_ARROW_UP,
+                                  "visible", FALSE,
+                                  "child", self->line_ends_label,
+                                  NULL);
+  panel_statusbar_add_suffix (self->statusbar, GTK_WIDGET (self->line_ends));
+
   /* Indentation status, tabs/spaces/etc */
   menu = ide_application_get_menu_by_id (IDE_APPLICATION_DEFAULT, "editorui-indent-menu");
   self->indentation_label = g_object_new (GTK_TYPE_LABEL, NULL);
@@ -255,6 +271,7 @@ gbp_editorui_workspace_addin_page_changed (IdeWorkspaceAddin *addin,
   update_position (self);
 
   gtk_widget_set_visible (GTK_WIDGET (self->indentation), page != NULL);
+  gtk_widget_set_visible (GTK_WIDGET (self->line_ends), page != NULL);
   gtk_widget_set_visible (GTK_WIDGET (self->position), page != NULL);
 }
 
diff --git a/src/plugins/editorui/gtk/menus.ui b/src/plugins/editorui/gtk/menus.ui
index 0cc939bd6..d62c4fcd6 100644
--- a/src/plugins/editorui/gtk/menus.ui
+++ b/src/plugins/editorui/gtk/menus.ui
@@ -53,4 +53,21 @@
       </submenu>
     </section>
   </menu>
+  <menu id="editorui-line-ends-menu">
+    <section id="editorui-line-ends-section">
+      <attribute name="label">Line Ending</attribute>
+      <item>
+        <attribute name="label">Linux (LF)</attribute>
+        <attribute name="action">editorui.newline('lf')</attribute>
+      </item>
+      <item>
+        <attribute name="label">Windows (CR/LF)</attribute>
+        <attribute name="action">editorui.newline('crlf')</attribute>
+      </item>
+      <item>
+        <attribute name="label">Mac Classic (CR)</attribute>
+        <attribute name="action">editorui.newline('cr')</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]