Commit ba09124f authored by Allison Karlitskaya's avatar Allison Karlitskaya

GtkMenuTracker: tweak separator logic

Ignacio Casal Quinteiro reported a problem whereby an empty section at
the start of a menu has a separator placed after it.  This was caused by
the implementation of the logic that separators should be inserted at
the top of all non-empty sections that are not the first section.  This
logic is obviously incorrect in the case that the first section is empty
(in which case we would not expect to see a separator at the top of the
second section).

Change the logic so that we only insert separators when we see a
non-zero number of actual items in the menu before us.

https://bugzilla.gnome.org/show_bug.cgi?id=721119
parent f90016f0
......@@ -141,8 +141,8 @@ gtk_menu_tracker_section_find_model (GtkMenuTrackerSection *section,
*
* could_have_separator is true in two situations:
*
* - our parent section had with_separators defined and we are not the
* first section (ie: we should add a separator if we have content in
* - our parent section had with_separators defined and there are items
* before us (ie: we should add a separator if we have content in
* order to divide us from the items above)
*
* - if we had a 'label' attribute set for this section
......@@ -177,7 +177,7 @@ gtk_menu_tracker_section_sync_separators (GtkMenuTrackerSection *section,
{
gboolean could_have_separator;
could_have_separator = (section->with_separators && i > 0) ||
could_have_separator = (section->with_separators && n_items > 0) ||
g_menu_model_get_item_attribute (section->model, i, "label", "s", NULL);
n_items += gtk_menu_tracker_section_sync_separators (subsection, tracker, offset + n_items,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment