[gnome-calendar/search-improvements] search-view: show properly a thin line before every result



commit a3c96d87da2a0d8fca0b5ed7cf92d8b6533d5b87
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Jan 7 17:20:58 2015 -0200

    search-view: show properly a thin line before every result
    
    This time, do not rely on CSS hacks.

 src/gcal-search-view.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/gcal-search-view.c b/src/gcal-search-view.c
index 8a7f327..fb515b2 100644
--- a/src/gcal-search-view.c
+++ b/src/gcal-search-view.c
@@ -88,6 +88,10 @@ static void           free_row_data                             (RowEventData
 
 static gboolean       show_no_results_page                      (GcalSearchView       *view);
 
+static void           display_header_func                       (GtkListBoxRow        *row,
+                                                                 GtkListBoxRow        *before,
+                                                                 gpointer              user_data);
+
 static void           gcal_data_model_subscriber_interface_init (ECalDataModelSubscriberInterface *iface);
 
 static void           gcal_search_view_constructed              (GObject        *object);
@@ -404,6 +408,28 @@ show_no_results_page (GcalSearchView *view)
   return G_SOURCE_REMOVE;
 }
 
+/**
+ * display_header_func:
+ *
+ * Shows a separator before each row.
+ *
+ */
+static void
+display_header_func (GtkListBoxRow *row,
+                     GtkListBoxRow *before,
+                     gpointer       user_data)
+{
+  if (before)
+    {
+      GtkWidget *header;
+
+      header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+      gtk_widget_show (header);
+
+      gtk_list_box_row_set_header (row, header);
+    }
+}
+
 static void
 gcal_search_view_class_init (GcalSearchViewClass *klass)
 {
@@ -497,6 +523,7 @@ gcal_search_view_constructed (GObject *object)
 
   /* make the listbox sorted */
   gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->listbox), (GtkListBoxSortFunc) sort_by_event, object, 
NULL);
+  gtk_list_box_set_header_func (GTK_LIST_BOX (priv->listbox), display_header_func, NULL, NULL);
 
   /* don't fill the list with all events on startup */
   gcal_search_view_search (GCAL_SEARCH_VIEW (object), NULL, NULL);


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