[gnome-builder/wip/gtk4-port: 1285/1774] plugins/editorui: show "Linux" unless you're on another Unix




commit 615def1ab27fa6b87ec53fdee80f26c95a1a9925
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 1 14:11:43 2022 -0700

    plugins/editorui: show "Linux" unless you're on another Unix
    
    If you are on a BSD, macOS, etc, we can show Unix instead of Linux.

 .../editorui/gbp-editorui-application-addin.c        | 20 ++++++++++++++++++++
 src/plugins/editorui/gtk/menus.ui                    |  6 ++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/editorui/gbp-editorui-application-addin.c 
b/src/plugins/editorui/gbp-editorui-application-addin.c
index aae1aa2d0..567490d0b 100644
--- a/src/plugins/editorui/gbp-editorui-application-addin.c
+++ b/src/plugins/editorui/gbp-editorui-application-addin.c
@@ -341,6 +341,24 @@ new_editor_workspace_action (GSimpleAction *action,
   ide_workbench_focus_workspace (workbench, IDE_WORKSPACE (workspace));
 }
 
+static void
+update_menus (IdeApplication *app)
+{
+  g_autoptr(GMenuItem) lf = NULL;
+  GMenu *menu;
+
+  g_assert (IDE_IS_APPLICATION (app));
+
+  menu = ide_application_get_menu_by_id (app, "editorui-line-ends-section");
+#if !defined(G_OS_UNIX) || defined(__linux__)
+  lf = g_menu_item_new ("Linux (LF)", NULL);
+#else
+  lf = g_menu_item_new ("Unix (LF)", NULL);
+#endif
+  g_menu_item_set_action_and_target (lf, "editor.newline", "s", "lf");
+  g_menu_prepend_item (menu, lf);
+}
+
 static GActionEntry actions[] = {
   { "new-editor-workspace", new_editor_workspace_action },
 };
@@ -357,6 +375,8 @@ gbp_editorui_application_addin_load (IdeApplicationAddin *addin,
                                    actions,
                                    G_N_ELEMENTS (actions),
                                    addin);
+
+  update_menus (application);
 }
 
 static void
diff --git a/src/plugins/editorui/gtk/menus.ui b/src/plugins/editorui/gtk/menus.ui
index aecbdcb69..2f6c2b5ef 100644
--- a/src/plugins/editorui/gtk/menus.ui
+++ b/src/plugins/editorui/gtk/menus.ui
@@ -56,10 +56,12 @@
   <menu id="editorui-line-ends-menu">
     <section id="editorui-line-ends-section">
       <attribute name="label">Line Ending</attribute>
-      <item>
+      <!--item>
+        This item is inserted automatically when the application starts
+        so that we can alter what label is shown.
         <attribute name="label">Linux (LF)</attribute>
         <attribute name="action">editorui.newline('lf')</attribute>
-      </item>
+      </item-->
       <item>
         <attribute name="label">Windows (CR/LF)</attribute>
         <attribute name="action">editorui.newline('crlf')</attribute>


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