[gnome-logs] Fix boot menu when only one boot exists



commit 5244716c4abd106ad49d5101c6b77fbdc3a4c3bb
Author: Lars Uebernickel <lars uebernic de>
Date:   Tue Sep 15 23:53:48 2015 +0200

    Fix boot menu when only one boot exists
    
    The boot menu and subtitle were empty when only a single boot existed in
    the journal. Turn around loop logic to make it more clear and get rid of
    this edge case.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=755085

 src/gl-eventtoolbar.c |    4 ++--
 src/gl-journal.c      |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/gl-eventtoolbar.c b/src/gl-eventtoolbar.c
index c650e23..951b320 100644
--- a/src/gl-eventtoolbar.c
+++ b/src/gl-eventtoolbar.c
@@ -84,7 +84,7 @@ gl_event_toolbar_add_boots (GlEventToolbar *toolbar,
     boot_menu = g_menu_new ();
     section = g_menu_new ();
 
-    for (i = boot_ids->len - 1; i >= boot_ids->len - 5 && i >= 0; i--)
+    for (i = MAX (boot_ids->len, 5) - 5; i < boot_ids->len; i++)
     {
         gchar *boot_match;
         gchar *time_display;
@@ -106,7 +106,7 @@ gl_event_toolbar_add_boots (GlEventToolbar *toolbar,
         variant = g_variant_new_string (boot_match);
         g_menu_item_set_action_and_target_value (item, "win.view-boot",
                                                  variant);
-        g_menu_append_item (section, item);
+        g_menu_prepend_item (section, item);
 
         g_free (time_display);
         g_object_unref (item);
diff --git a/src/gl-journal.c b/src/gl-journal.c
index a9a459e..6b3d4d5 100644
--- a/src/gl-journal.c
+++ b/src/gl-journal.c
@@ -76,7 +76,7 @@ gl_journal_get_current_boot_time (GlJournal *journal,
 
     boot_ids = gl_journal_get_boot_ids (journal);
 
-    for (i = boot_ids->len - 1; i >= boot_ids->len - 5 && i >= 0; i--)
+    for (i = 0; i < boot_ids->len; i++)
     {
         GlJournalBootID *boot_id;
 


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