[gnome-software] Make the category view sidebar match the mockup more closely



commit 9195fa0a750a25bacf10af0010d282b280461d9c
Author: Elad Alfassa <elad fedoraproject org>
Date:   Wed May 7 00:27:11 2014 +0300

    Make the category view sidebar match the mockup more closely
    
    Minor edits by Kalev Lember <kalevlember gmail com>.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=729682

 src/gs-shell-category.c  |   39 +--------------------------------------
 src/gs-shell-category.ui |   36 ++++++++++++++++--------------------
 src/gtk-style.css        |   14 ++++++++++++++
 3 files changed, 31 insertions(+), 58 deletions(-)
---
diff --git a/src/gs-shell-category.c b/src/gs-shell-category.c
index 6f4fd28..27ee0bf 100644
--- a/src/gs-shell-category.c
+++ b/src/gs-shell-category.c
@@ -39,7 +39,6 @@ struct GsShellCategoryPrivate {
        GtkWidget       *col1_placeholder;
 
        GtkWidget       *category_detail_grid;
-       GtkWidget       *frame_filter;
        GtkWidget       *listbox_filter;
        GtkWidget       *scrolledwindow_category;
        GtkWidget       *scrolledwindow_filter;
@@ -161,16 +160,6 @@ gs_shell_category_populate_filtered (GsShellCategory *shell)
 }
 
 static void
-add_separator (GtkListBoxRow *row, GtkListBoxRow *before, gpointer data)
-{
-       if (!before) {
-               return;
-       }
-
-       gtk_list_box_row_set_header (row, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
-}
-
-static void
 filter_selected (GtkListBox *filters, GtkListBoxRow *row, gpointer data)
 {
        GsShellCategory *shell = GS_SHELL_CATEGORY (data);
@@ -195,9 +184,6 @@ gs_shell_category_create_filter_list (GsShellCategory *shell, GsCategory *catego
 
        gs_container_remove_all (GTK_CONTAINER (priv->category_detail_grid));
 
-       gtk_frame_set_shadow_type (GTK_FRAME (priv->frame_filter), GTK_SHADOW_IN);
-       gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolledwindow_filter), 
GTK_SHADOW_NONE);
-
        list = gs_category_get_subcategories (category);
        if (!list)
                return;
@@ -213,7 +199,7 @@ gs_shell_category_create_filter_list (GsShellCategory *shell, GsCategory *catego
                        continue;
                row = gtk_label_new (gs_category_get_name (s));
                g_object_set_data_full (G_OBJECT (row), "category", g_object_ref (s), g_object_unref);
-               g_object_set (row, "xalign", 0.0, "margin", 6, NULL);
+               g_object_set (row, "xalign", 0.0, "margin", 10, NULL);
                gtk_widget_show (row);
                gtk_list_box_insert (GTK_LIST_BOX (priv->listbox_filter), row, -1);
                if (subcategory == s)
@@ -308,28 +294,11 @@ gs_shell_category_class_init (GsShellCategoryClass *klass)
        gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/Software/gs-shell-category.ui");
 
        gtk_widget_class_bind_template_child_private (widget_class, GsShellCategory, category_detail_grid);
-       gtk_widget_class_bind_template_child_private (widget_class, GsShellCategory, frame_filter);
        gtk_widget_class_bind_template_child_private (widget_class, GsShellCategory, listbox_filter);
        gtk_widget_class_bind_template_child_private (widget_class, GsShellCategory, scrolledwindow_category);
        gtk_widget_class_bind_template_child_private (widget_class, GsShellCategory, scrolledwindow_filter);
 }
 
-static void
-scrollbar_mapped_cb (GtkWidget *sb, GtkScrolledWindow *swin)
-{
-       GtkWidget *frame;
-
-       frame = gtk_bin_get_child (GTK_BIN (gtk_bin_get_child (GTK_BIN (swin))));
-       if (gtk_widget_get_mapped (GTK_WIDGET (sb))) {
-               gtk_scrolled_window_set_shadow_type (swin, GTK_SHADOW_IN);
-               gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
-       }
-       else {
-               gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
-               gtk_scrolled_window_set_shadow_type (swin, GTK_SHADOW_NONE);
-       }
-}
-
 static gboolean
 key_event (GtkWidget *listbox, GdkEvent *event, GsShellCategory *shell)
 {
@@ -365,7 +334,6 @@ gs_shell_category_setup (GsShellCategory *shell_category,
                         GCancellable *cancellable)
 {
        GsShellCategoryPrivate *priv = shell_category->priv;
-       GtkWidget *widget;
        GtkAdjustment *adj;
 
        priv->plugin_loader = g_object_ref (plugin_loader);
@@ -374,11 +342,6 @@ gs_shell_category_setup (GsShellCategory *shell_category,
        priv->shell = shell;
 
        g_signal_connect (priv->listbox_filter, "row-selected", G_CALLBACK (filter_selected), shell_category);
-       gtk_list_box_set_header_func (GTK_LIST_BOX (priv->listbox_filter), add_separator, NULL, NULL);
-
-       widget = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->scrolledwindow_filter));
-       g_signal_connect (widget, "map", G_CALLBACK (scrollbar_mapped_cb), priv->scrolledwindow_filter);
-       g_signal_connect (widget, "unmap", G_CALLBACK (scrollbar_mapped_cb), priv->scrolledwindow_filter);
 
        adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolledwindow_category));
        gtk_container_set_focus_vadjustment (GTK_CONTAINER (priv->category_detail_grid), adj);
diff --git a/src/gs-shell-category.ui b/src/gs-shell-category.ui
index ca85e6e..fcb80b8 100644
--- a/src/gs-shell-category.ui
+++ b/src/gs-shell-category.ui
@@ -8,36 +8,28 @@
         <child>
           <object class="GtkScrolledWindow" id="scrolledwindow_filter">
             <property name="visible">True</property>
-            <property name="margin-top">15</property>
-            <property name="margin-bottom">15</property>
-            <property name="margin-start">12</property>
+            <property name="margin-top">0</property>
+            <property name="margin-bottom">0</property>
+            <property name="margin-start">0</property>
             <property name="margin-end">12</property>
             <property name="can_focus">True</property>
             <property name="hscrollbar_policy">never</property>
             <property name="vscrollbar_policy">automatic</property>
-            <property name="shadow_type">none</property>
+            <property name="shadow_type">in</property>
             <property name="valign">fill</property>
+            <style>
+              <class name="category-sidebar"/>
+            </style>
             <child>
-              <object class="GtkFrame" id="frame_filter">
+              <object class="GtkListBox" id="listbox_filter">
                 <property name="visible">True</property>
-                <property name="shadow_type">in</property>
+                <property name="selection_mode">browse</property>
                 <property name="halign">fill</property>
-                <property name="valign">start</property>
-                <style>
-                  <class name="view"/>
-                </style>
-                <child>
-                  <object class="GtkListBox" id="listbox_filter">
-                    <property name="visible">True</property>
-                    <property name="selection_mode">browse</property>
-                    <property name="halign">fill</property>
-                  </object>
-                </child>
               </object>
             </child>
           </object>
           <packing>
-            <property name="relative_size">1.0</property>
+            <property name="relative_size">0.5</property>
           </packing>
         </child>
         <child>
@@ -47,6 +39,10 @@
             <property name="can_focus">False</property>
             <property name="hscrollbar_policy">never</property>
             <property name="vscrollbar_policy">automatic</property>
+            <property name="margin_start">12</property>
+            <property name="margin_end">12</property>
+            <property name="margin_top">12</property>
+            <property name="margin_bottom">12</property>
             <style>
               <class name="main-scrolled-software"/>
             </style>
@@ -56,8 +52,8 @@
                 <property name="can_focus">False</property>
                 <child>
                   <object class="GtkGrid" id="category_detail_grid">
-                    <property name="margin_start">12</property>
-                    <property name="margin_end">12</property>
+                    <property name="margin_start">15</property>
+                    <property name="margin_end">15</property>
                     <property name="margin_top">12</property>
                     <property name="margin_bottom">12</property>
                     <property name="halign">fill</property>
diff --git a/src/gtk-style.css b/src/gtk-style.css
index c79cb48..a7d8f91 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -138,3 +138,17 @@ GtkBox.star {
     border-radius: 4px;
     padding: 0px 4px;
 }
+
+.category-sidebar {
+       border-radius: 0;
+       border-bottom-width: 0;
+       border-top-width: 0;
+}
+
+.category-sidebar GtkListBoxRow {
+       padding-left: 6px;
+}
+
+.category-sidebar GtkListBoxRow:dir(rtl) {
+       padding-right: 6px;
+}


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