[gnome-builder] editor: ensure menu-id is set and menu is shown



commit 4e72f98b7684c776ac2018711cf18b8cea71ae5c
Author: Christian Hergert <chergert redhat com>
Date:   Sun Oct 22 16:44:00 2017 -0700

    editor: ensure menu-id is set and menu is shown
    
    We never finished this part of the sidebar implementation, and
    now we'll need it for unit tests.

 src/libide/editor/ide-editor-sidebar.c     |   23 +++++++++++++++++++----
 src/libide/editor/ide-editor-sidebar.ui    |    3 ++-
 src/libide/testing/ide-test-editor-addin.c |    4 ++--
 3 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-sidebar.c b/src/libide/editor/ide-editor-sidebar.c
index 1f38e96..37ca1dd 100644
--- a/src/libide/editor/ide-editor-sidebar.c
+++ b/src/libide/editor/ide-editor-sidebar.c
@@ -47,7 +47,8 @@ struct _IdeEditorSidebar
   GtkListBox        *open_pages_list_box;
   GtkBox            *open_pages_section;
   GtkLabel          *section_title;
-  GtkImage          *section_menu_button;
+  DzlMenuButton     *section_menu_button;
+  GtkImage          *section_image;
   GtkStack          *stack;
 };
 
@@ -57,16 +58,29 @@ static void
 ide_editor_sidebar_update_title (IdeEditorSidebar *self)
 {
   g_autofree gchar *title = NULL;
+  const gchar *icon_name = NULL;
+  const gchar *menu_id = NULL;
   GtkWidget *visible_child;
 
   g_assert (IDE_IS_EDITOR_SIDEBAR (self));
 
   if (NULL != (visible_child = gtk_stack_get_visible_child (self->stack)))
-    gtk_container_child_get (GTK_CONTAINER (self->stack), visible_child,
-                             "title", &title,
-                             NULL);
+    {
+      menu_id = g_object_get_data (G_OBJECT (visible_child),
+                                   "IDE_EDITOR_SIDEBAR_MENU_ID");
+      icon_name = g_object_get_data (G_OBJECT (visible_child),
+                                     "IDE_EDITOR_SIDEBAR_MENU_ICON_NAME");
+      gtk_container_child_get (GTK_CONTAINER (self->stack), visible_child,
+                               "title", &title,
+                               NULL);
+    }
 
   gtk_label_set_label (self->section_title, title);
+  g_object_set (self->section_menu_button,
+                "icon-name", icon_name,
+                "menu-id", menu_id,
+                "visible", menu_id != NULL,
+                NULL);
 }
 
 static void
@@ -127,6 +141,7 @@ ide_editor_sidebar_class_init (IdeEditorSidebarClass *klass)
   gtk_widget_class_bind_template_child (widget_class, IdeEditorSidebar, open_pages_list_box);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorSidebar, open_pages_section);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorSidebar, section_menu_button);
+  gtk_widget_class_bind_template_child (widget_class, IdeEditorSidebar, section_image);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorSidebar, section_title);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorSidebar, stack);
   gtk_widget_class_bind_template_child (widget_class, IdeEditorSidebar, stack_switcher);
diff --git a/src/libide/editor/ide-editor-sidebar.ui b/src/libide/editor/ide-editor-sidebar.ui
index 83a3478..be623a1 100644
--- a/src/libide/editor/ide-editor-sidebar.ui
+++ b/src/libide/editor/ide-editor-sidebar.ui
@@ -78,7 +78,8 @@
                       </object>
                     </child>
                     <child>
-                      <object class="GtkMenuButton" id="section_menu_button">
+                      <object class="DzlMenuButton" id="section_menu_button">
+                        <property name="margin-right">6</property>
                         <style>
                           <class name="image-button"/>
                           <class name="flat"/>
diff --git a/src/libide/testing/ide-test-editor-addin.c b/src/libide/testing/ide-test-editor-addin.c
index 570aef0..b3a0173 100644
--- a/src/libide/testing/ide-test-editor-addin.c
+++ b/src/libide/testing/ide-test-editor-addin.c
@@ -66,8 +66,8 @@ ide_test_editor_addin_load (IdeEditorAddin       *addin,
                                   "tests",
                                   _("Unit Tests"),
                                   "builder-unit-tests-symbolic",
-                                  NULL,
-                                  NULL,
+                                  "testing-menu",
+                                  "pan-down-symbolic",
                                   GTK_WIDGET (self->panel),
                                   400);
 }


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