[gnome-software] Show 'Add-ons' in a seporate group on the installed shell



commit 7dd0842739cd513cb254033023ffa203d83de124
Author: Richard Hughes <richard hughsie com>
Date:   Thu Oct 17 10:08:05 2013 +0100

    Show 'Add-ons' in a seporate group on the installed shell
    
    Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=709562

 src/gs-shell-installed.c |   40 +++++++++++++++++++++++++++++++++++++---
 src/gtk-style-hc.css     |    8 ++++++++
 src/gtk-style.css        |    8 ++++++++
 3 files changed, 53 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index a6aa573..aced745 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -336,8 +336,9 @@ gs_shell_installed_get_app_sort_key (GsApp *app)
 {
        GString *key;
 
-       /* sort installed, removing, other */
        key = g_string_sized_new (64);
+
+       /* sort installed, removing, other */
        switch (gs_app_get_state (app)) {
        case GS_APP_STATE_INSTALLING:
                g_string_append (key, "1:");
@@ -350,6 +351,16 @@ gs_shell_installed_get_app_sort_key (GsApp *app)
                break;
        }
 
+       /* sort desktop files, then addons */
+       switch (gs_app_get_id_kind (app)) {
+       case GS_APP_ID_KIND_DESKTOP:
+               g_string_append (key, "1:");
+               break;
+       default:
+               g_string_append (key, "2:");
+               break;
+       }
+
        /* sort normal, system, other */
        switch (gs_app_get_kind (app)) {
        case GS_APP_KIND_NORMAL:
@@ -405,6 +416,11 @@ gs_shell_installed_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 */
@@ -418,8 +434,26 @@ gs_shell_installed_list_header_func (GtkListBoxRow *row,
        if (header != NULL)
                return;
 
-       /* set new */
-       header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+       /* calculate the transition between different ID kinds */
+       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) {
+               /* TRANSLATORS: This is the header dividing the normal
+                * applications and the addons */
+               header = gtk_label_new (_("Add-ons"));
+               g_object_set (header,
+                             "xalign", 0.0,
+                             NULL);
+               context = gtk_widget_get_style_context (header);
+               gtk_style_context_add_class (context, "header-label");
+       } else {
+               header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+       }
        gtk_list_box_row_set_header (row, header);
 }
 
diff --git a/src/gtk-style-hc.css b/src/gtk-style-hc.css
index 78d5efa..307dd59 100644
--- a/src/gtk-style-hc.css
+++ b/src/gtk-style-hc.css
@@ -20,3 +20,11 @@
        font-weight: bold;
        font-size: 14px;
 }
+
+.header-label {
+       font-size: 11px;
+       padding: 6px;
+       background-image: none;
+       background-color: #ffffff;
+       border-color: #000000;
+}
diff --git a/src/gtk-style.css b/src/gtk-style.css
index a9e69dd..ef5f580 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -61,6 +61,14 @@ GtkNotebook.main-notebook-software > GtkScrolledWindow {
        text-shadow: none;
 }
 
+.header-label {
+       font-size: 11px;
+       padding: 6px;
+       background-image: none;
+       background-color: #babdb6;
+       border-color: #000000;
+}
+
 .image-list {
        background-color: transparent;
 }


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