[gtk+] GtkMenuSectionBox: Always show separators for labeled sections



commit f3ba001a1de2c961494e191910dd5017f769bdf1
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Apr 29 11:48:52 2014 -0400

    GtkMenuSectionBox: Always show separators for labeled sections
    
    ...unless they are empty.

 gtk/gtkmenusectionbox.c |   11 ++++++++---
 tests/popover.ui        |    3 ++-
 2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkmenusectionbox.c b/gtk/gtkmenusectionbox.c
index 62ab318..935ddf5 100644
--- a/gtk/gtkmenusectionbox.c
+++ b/gtk/gtkmenusectionbox.c
@@ -84,16 +84,21 @@ gtk_menu_section_box_sync_separators (GtkMenuSectionBox *box,
                                       gint              *n_items)
 {
   gboolean should_have_separator;
+  gboolean has_separator;
+  gboolean has_label;
   gint n_items_before = *n_items;
 
   gtk_container_foreach (GTK_CONTAINER (box->item_box), gtk_menu_section_box_sync_item, n_items);
 
-  should_have_separator = n_items_before > 0 && *n_items > n_items_before;
-
   if (box->separator == NULL)
     return;
 
-  if (should_have_separator == (gtk_widget_get_parent (box->separator) != NULL))
+  has_separator = gtk_widget_get_parent (box->separator) != NULL;
+  has_label = !GTK_IS_SEPARATOR (box->separator);
+
+  should_have_separator = (has_label || n_items_before > 0) && *n_items > n_items_before;
+
+  if (should_have_separator == has_separator)
     return;
 
   if (should_have_separator)
diff --git a/tests/popover.ui b/tests/popover.ui
index 74fa0bf..f9a843e 100644
--- a/tests/popover.ui
+++ b/tests/popover.ui
@@ -1,7 +1,8 @@
 <interface>
   <menu id="menu">
     <section>
-      <attribute name="display-hint">horizontal-buttons</attribute>
+      <!--<attribute name="display-hint">horizontal-buttons</attribute>-->
+      <attribute name="label">Edit</attribute>
       <item>
         <attribute name="label">Cut</attribute>
         <attribute name="action">top.cut</attribute>


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