[gnome-builder/wip/gtk4-port: 1284/1774] libide/editor: use section for additional items




commit f010f8fdd89c31d88eb2c69fff79ae5618578448
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jun 1 13:52:11 2022 -0700

    libide/editor: use section for additional items
    
    This ensures that we get a separator bar in the GtkPopoverMenu.

 src/libide/editor/ide-editor-utils.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-utils.c b/src/libide/editor/ide-editor-utils.c
index d5fd62077..4c61e0717 100644
--- a/src/libide/editor/ide-editor-utils.c
+++ b/src/libide/editor/ide-editor-utils.c
@@ -58,14 +58,16 @@ sort_by_name (gconstpointer a,
 GMenuModel *
 ide_editor_encoding_menu_new (const char *action_name)
 {
+  g_autoptr(GMenu) menu = NULL;
   GHashTable *submenus;
-  GMenu *menu;
+  GMenu *top_menu;
   GSList *all;
 
   g_return_val_if_fail (action_name, NULL);
 
+  top_menu = g_menu_new ();
+
   submenus = g_hash_table_new (g_str_hash, g_str_equal);
-  menu = g_menu_new ();
   all = g_slist_sort (gtk_source_encoding_get_all (), sort_by_name);
 
   /* Always place UTF8 at the top in it's own section */
@@ -76,9 +78,12 @@ ide_editor_encoding_menu_new (const char *action_name)
     g_menu_item_set_action_and_target (item, action_name, "s", "UTF-8");
     g_menu_item_set_attribute (item, "role", "s", "check");
     g_menu_append_item (section, item);
-    g_menu_append_section (menu, NULL, G_MENU_MODEL (section));
+    g_menu_append_section (top_menu, NULL, G_MENU_MODEL (section));
   }
 
+  menu = g_menu_new ();
+  g_menu_append_section (top_menu, NULL, G_MENU_MODEL (menu));
+
   for (const GSList *l = all; l; l = l->next)
     {
       GtkSourceEncoding *encoding = l->data;
@@ -107,7 +112,7 @@ ide_editor_encoding_menu_new (const char *action_name)
   g_hash_table_unref (submenus);
   g_slist_free (all);
 
-  return G_MENU_MODEL (menu);
+  return G_MENU_MODEL (top_menu);
 }
 
 void


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