[gnome-control-center] Fit three columns of search results



commit 796d4ebafad432e9d9723781e831f3cf3f25c838
Author: Jon McCann <jmccann redhat com>
Date:   Tue Apr 10 18:04:38 2012 -0400

    Fit three columns of search results
    
    And center labels vertically that have no search matching text.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673869

 shell/gnome-control-center.c  |    8 ++++++--
 shell/shell-search-renderer.c |   15 +++++++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 7543341..067d2c2 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -595,14 +595,18 @@ setup_search (GnomeControlCenter *shell)
   priv->search_view = search_view = cc_shell_item_view_new ();
   gtk_icon_view_set_item_orientation (GTK_ICON_VIEW (search_view),
                                       GTK_ORIENTATION_HORIZONTAL);
-  gtk_icon_view_set_spacing (GTK_ICON_VIEW (search_view), 6);
-  gtk_icon_view_set_margin (GTK_ICON_VIEW (search_view), 12);
+  gtk_icon_view_set_spacing (GTK_ICON_VIEW (search_view), 0);
+  gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (search_view), 20);
+  gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (search_view), 20);
+  gtk_icon_view_set_margin (GTK_ICON_VIEW (search_view), 20);
+  gtk_icon_view_set_item_padding (GTK_ICON_VIEW (search_view), 0);
   gtk_icon_view_set_model (GTK_ICON_VIEW (search_view),
                            GTK_TREE_MODEL (priv->search_filter));
 
   renderer = gtk_cell_renderer_pixbuf_new ();
   g_object_set (renderer,
                 "follow-state", TRUE,
+                "xpad", 10,
                 NULL);
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (search_view),
                               renderer, FALSE);
diff --git a/shell/shell-search-renderer.c b/shell/shell-search-renderer.c
index 6032af8..a64a4bf 100644
--- a/shell/shell-search-renderer.c
+++ b/shell/shell-search-renderer.c
@@ -42,6 +42,12 @@ enum
   PROP_SEARCH_STRING
 };
 
+#define FIXED_WIDTH 740
+#define MARGIN 20
+#define COLUMN_SPACING 20
+#define ICON_SIZE 48
+#define ICON_PADDING 10
+#define FIXED_SEARCH_LABEL_WIDTH ((FIXED_WIDTH - 2*MARGIN - 3*ICON_SIZE - 6*ICON_PADDING - 2*COLUMN_SPACING)/3. - 2)
 
 static void
 shell_search_renderer_get_property (GObject    *object,
@@ -215,7 +221,7 @@ get_size (GtkCellRenderer *cell,
 
   shell_search_renderer_set_layout (SHELL_SEARCH_RENDERER (cell), widget);
 
-  pango_layout_set_width (priv->layout, PANGO_SCALE * 180);
+  pango_layout_set_width (priv->layout, PANGO_SCALE * FIXED_SEARCH_LABEL_WIDTH);
   pango_layout_get_pixel_extents (priv->layout, NULL, &rect);
 
   if (width) *width = rect.width;
@@ -281,6 +287,8 @@ shell_search_renderer_render (GtkCellRenderer      *cell,
   ShellSearchRendererPrivate *priv = SHELL_SEARCH_RENDERER (cell)->priv;
   PangoRectangle rect;
   GtkStyleContext *context;
+  gint layout_height;
+  gint vcenter_offset;
 
   context = gtk_widget_get_style_context (widget);
 
@@ -288,11 +296,14 @@ shell_search_renderer_render (GtkCellRenderer      *cell,
 
   pango_layout_get_pixel_extents (priv->layout, NULL, &rect);
 
+  pango_layout_get_pixel_size (priv->layout, NULL, &layout_height);
+  vcenter_offset = (cell_area->height - layout_height) / 2;
+
   cairo_save (cr);
 
   gtk_render_layout (context, cr,
                      cell_area->x,
-                     cell_area->y,
+                     cell_area->y + vcenter_offset,
                      priv->layout);
 
   cairo_restore (cr);



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