[Xfce4-commits] <midori:master> Render dummy history items as separators

Christian Dywan noreply at xfce.org
Thu Feb 4 00:26:01 CET 2010


Updating branch refs/heads/master
         to 94aebbf1fe31a318391cee8c6d2e4e5ef8f9fd29 (commit)
       from 4d05be6a5eb96113c1224a56bdae07d11ec3fcb3 (commit)

commit 94aebbf1fe31a318391cee8c6d2e4e5ef8f9fd29
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Feb 3 23:48:07 2010 +0100

    Render dummy history items as separators
    
    Until we find a better way this should reduce confusion about
    'empty' folders appearing.

 panels/midori-history.c |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/panels/midori-history.c b/panels/midori-history.c
index a50b7d8..bfd9ba6 100644
--- a/panels/midori-history.c
+++ b/panels/midori-history.c
@@ -256,9 +256,10 @@ midori_history_read_from_db (MidoriHistory* history,
 
             gtk_tree_store_insert_with_values (model, &root_iter, NULL,
                                                0, 0, item, 1, sdate, -1);
-            /* FIXME: Always show expanders even if no child nodes? */
+            /* That's an invisible dummy, so we always have an expander */
+            /* FIXME: Hide this row */
             gtk_tree_store_insert_with_values (model, &iter, &root_iter,
-                0, 0, item, 1, katze_item_get_name (item), -1);
+                0, 0, NULL, 1, NULL, -1);
 
             if (age > 1 && age < 7)
                 g_free (sdate);
@@ -354,11 +355,12 @@ midori_history_cursor_or_row_changed_cb (GtkTreeView*   treeview,
 
         gtk_tree_model_get (model, &iter, 0, &item, -1);
 
-        is_page = !KATZE_IS_ARRAY (item) && katze_item_get_uri (item);
+        is_page = item && katze_item_get_uri (item);
         gtk_widget_set_sensitive (history->bookmark, is_page);
         gtk_widget_set_sensitive (history->delete, TRUE);
 
-        g_object_unref (item);
+        if (item)
+            g_object_unref (item);
     }
     else
     {
@@ -503,11 +505,13 @@ midori_history_treeview_render_icon_cb (GtkTreeViewColumn* column,
                                         GtkWidget*         treeview)
 {
     KatzeItem* item;
-    GdkPixbuf* pixbuf = NULL;
+    GdkPixbuf* pixbuf;
 
     gtk_tree_model_get (model, iter, 0, &item, -1);
 
-    if (katze_item_get_uri (item))
+    if (!item)
+        pixbuf = NULL;
+    else if (katze_item_get_uri (item))
         pixbuf = katze_load_cached_icon (katze_item_get_uri (item), treeview);
     else
         pixbuf = gtk_widget_render_icon (treeview, GTK_STOCK_DIRECTORY,
@@ -516,9 +520,10 @@ midori_history_treeview_render_icon_cb (GtkTreeViewColumn* column,
     g_object_set (renderer, "pixbuf", pixbuf, NULL);
 
     if (pixbuf)
+    {
         g_object_unref (pixbuf);
-
-    g_object_unref (item);
+        g_object_unref (item);
+    }
 }
 
 #if HAVE_SQLITE
@@ -538,6 +543,10 @@ midori_history_row_activated_cb (GtkTreeView*       treeview,
     if (gtk_tree_model_get_iter (model, &iter, path))
     {
         gtk_tree_model_get (model, &iter, 0, &item, -1);
+
+        if (!item)
+            return;
+
         uri = katze_item_get_uri (item);
         if (uri && *uri)
         {
@@ -731,6 +740,9 @@ midori_history_button_release_event_cb (GtkWidget*      widget,
 
         gtk_tree_model_get (model, &iter, 0, &item, -1);
 
+        if (!item)
+            return FALSE;
+
         if (event->button == 2)
         {
             const gchar* uri = katze_item_get_uri (item);
@@ -828,6 +840,22 @@ midori_history_row_collapsed_cb (GtkTreeView *treeview,
 }
 #endif
 
+static gboolean
+midori_history_row_sep_func (GtkTreeModel*  model,
+                             GtkTreeIter*   iter,
+                             MidoriHistory* history)
+{
+    KatzeItem* item;
+
+    gtk_tree_model_get (model, iter, 0, &item, -1);
+
+    if (item == NULL)
+        return TRUE;
+
+    g_object_unref (item);
+    return FALSE;
+}
+
 static void
 midori_history_init (MidoriHistory* history)
 {
@@ -844,6 +872,8 @@ midori_history_init (MidoriHistory* history)
     model = gtk_tree_store_new (2, KATZE_TYPE_ITEM, G_TYPE_STRING);
     treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
+    gtk_tree_view_set_row_separator_func (GTK_TREE_VIEW (treeview),
+        (GtkTreeViewRowSeparatorFunc)midori_history_row_sep_func, history, NULL);
     column = gtk_tree_view_column_new ();
     renderer_pixbuf = gtk_cell_renderer_pixbuf_new ();
     gtk_tree_view_column_pack_start (column, renderer_pixbuf, FALSE);



More information about the Xfce4-commits mailing list