[gnome-software] Never show two 'Add-ons' headers in the updates panel



commit 71bfea5ec699dbb56984291740a0d46fee59e42a
Author: Richard Hughes <richard hughsie com>
Date:   Fri Oct 25 11:31:51 2013 +0100

    Never show two 'Add-ons' headers in the updates panel
    
    We need to refresh the headers after the list is sorted.

 src/gs-shell-updates.c |   36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)
---
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index faaaae8..caeca99 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -355,6 +355,21 @@ gs_shell_updates_activated_cb (GtkListBox *list_box,
 }
 
 /**
+ * gs_shell_updates_is_addon_id_kind
+ **/
+static gboolean
+gs_shell_updates_is_addon_id_kind (GsApp *app)
+{
+       GsAppIdKind id_kind;
+       id_kind = gs_app_get_id_kind (app);
+       if (id_kind == GS_APP_ID_KIND_DESKTOP)
+               return FALSE;
+       if (id_kind == GS_APP_ID_KIND_WEBAPP)
+               return FALSE;
+       return TRUE;
+}
+
+/**
  * gs_shell_updates_list_header_func
  **/
 static void
@@ -362,33 +377,22 @@ gs_shell_updates_list_header_func (GtkListBoxRow *row,
                                   GtkListBoxRow *before,
                                   gpointer user_data)
 {
-       GsAppIdKind id_kind_after;
-       GsAppIdKind id_kind_before;
        GsAppWidget *aw1;
        GsAppWidget *aw2;
        GtkStyleContext *context;
        GtkWidget *header;
 
        /* first entry */
+       gtk_list_box_row_set_header (row, NULL);
        header = gtk_list_box_row_get_header (row);
-       if (before == NULL) {
-               gtk_list_box_row_set_header (row, NULL);
+       if (before == NULL)
                return;
-       }
 
-       /* already set */
-       if (header != NULL)
-               return;
-
-       /* calculate the transition between different ID kinds */
+       /* desktop -> addons */
        aw1 = GS_APP_WIDGET (gtk_bin_get_child (GTK_BIN (before)));
        aw2 = GS_APP_WIDGET (gtk_bin_get_child (GTK_BIN (row)));
-       id_kind_before = gs_app_get_id_kind (gs_app_widget_get_app (aw1));
-       id_kind_after = gs_app_get_id_kind (gs_app_widget_get_app (aw2));
-
-       /* desktop -> addons */
-       if (id_kind_before == GS_APP_ID_KIND_DESKTOP &&
-           id_kind_after != GS_APP_ID_KIND_DESKTOP) {
+       if (!gs_shell_updates_is_addon_id_kind (gs_app_widget_get_app (aw1)) &&
+           gs_shell_updates_is_addon_id_kind (gs_app_widget_get_app (aw2))) {
                /* TRANSLATORS: This is the header dividing the normal
                 * applications and the addons */
                header = gtk_label_new (_("Add-ons"));


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