[devhelp] Add a separator after the "All books" book selection item



commit d5161e37131e7ac9f2edb6b209c2022409e2651a
Author: Frédéric Péters <fpeters 0d be>
Date:   Thu Sep 3 17:24:02 2009 +0200

    Add a separator after the "All books" book selection item

 src/dh-search.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/dh-search.c b/src/dh-search.c
index 58be0ee..39be229 100644
--- a/src/dh-search.c
+++ b/src/dh-search.c
@@ -471,6 +471,19 @@ book_cmp (DhLink **a, DhLink **b)
         return dh_util_cmp_book (*a, *b);
 }
 
+static gboolean
+search_combo_row_separator_func (GtkTreeModel *model,
+                                 GtkTreeIter  *iter,
+                                 gpointer      data)
+{
+        char *label;
+        char *link;
+
+        gtk_tree_model_get (model, iter, 0, &label, 1, &link, -1);
+
+        return (link == NULL && label == NULL);
+}
+
 static GtkWidget *
 search_combo_create (DhSearch *search,
                      GList    *keywords)
@@ -491,6 +504,13 @@ search_combo_create (DhSearch *search,
                             1, NULL,
                             -1);
 
+        /* Add a separator */
+        gtk_list_store_append (store, &iter); 
+        gtk_list_store_set (store, &iter,
+                            0, NULL,
+                            1, NULL,
+                            -1);
+
         books = g_array_sized_new (FALSE, FALSE, sizeof(DhLink*), 50);
         for (l = keywords; l; l = l->next) {
                 DhLink *link = l->data;
@@ -519,6 +539,10 @@ search_combo_create (DhSearch *search,
         combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
         g_object_unref (store);
 
+        gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
+                                              search_combo_row_separator_func,
+                                              NULL, NULL);
+
         cell = gtk_cell_renderer_text_new ();
         gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo),
                                     cell,



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