[Xfce4-commits] <thunar:jannis/new-shortcuts-pane> Fix a typo in ThunarShortcutsModel; load model data after construction.

Jannis Pohlmann noreply at xfce.org
Fri Jul 15 21:10:38 CEST 2011


Updating branch refs/heads/jannis/new-shortcuts-pane
         to ea16d3831cea1458cb2a27157083f84eef73c4ba (commit)
       from 5a76213df5093a39199999e3ffb661a71dd20e42 (commit)

commit ea16d3831cea1458cb2a27157083f84eef73c4ba
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Fri Jun 10 00:17:09 2011 +0200

    Fix a typo in ThunarShortcutsModel; load model data after construction.
    
    This fixes a bug where shortcuts would not show up in new windows.

 thunar/thunar-shortcut-row.c    |    2 --
 thunar/thunar-shortcuts-model.c |    4 +---
 thunar/thunar-shortcuts-view.c  |   31 +++++++++++++++++++++----------
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/thunar/thunar-shortcut-row.c b/thunar/thunar-shortcut-row.c
index 8ae62ae..756fb79 100644
--- a/thunar/thunar-shortcut-row.c
+++ b/thunar/thunar-shortcut-row.c
@@ -1182,8 +1182,6 @@ thunar_shortcut_row_label_changed (ThunarShortcutRow *row)
 {
   _thunar_return_if_fail (THUNAR_IS_SHORTCUT_ROW (row));
 
-  g_debug ("label changed: %s", row->label);
-
   /* update the label widget */
   gtk_label_set_markup (GTK_LABEL (row->label_widget), row->label);
   gtk_widget_set_visible (row->label_widget, row->label != NULL && *row->label != '\0');
diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c
index 6ddb5f7..cd7c91a 100644
--- a/thunar/thunar-shortcuts-model.c
+++ b/thunar/thunar-shortcuts-model.c
@@ -634,7 +634,7 @@ thunar_shortcuts_model_iter_children (GtkTreeModel *tree_model,
           (*iter).stamp = model->stamp;
 #endif
           (*iter).user_data = GINT_TO_POINTER (category_index);
-          (*iter).user_data = GINT_TO_POINTER (0);
+          (*iter).user_data2 = GINT_TO_POINTER (0);
           return TRUE;
         }
     }
@@ -1631,8 +1631,6 @@ thunar_shortcuts_model_mount_added (ThunarShortcutsModel *model,
       location = g_mount_get_root (mount);
       eject_icon = g_themed_icon_new ("media-eject");
 
-      g_debug ("mount added: %s", g_mount_get_name (mount));
-
       /* create a shortcut for the mount */
       shortcut = g_object_new (THUNAR_TYPE_SHORTCUT,
                                "shortcut-type", THUNAR_SHORTCUT_STANDALONE_MOUNT,
diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c
index 3991c63..fcba86f 100644
--- a/thunar/thunar-shortcuts-view.c
+++ b/thunar/thunar-shortcuts-view.c
@@ -253,11 +253,14 @@ thunar_shortcuts_view_constructed (GObject *object)
 {
   ThunarShortcutsView *view = THUNAR_SHORTCUTS_VIEW (object);
   GtkTreeIter          iter;
+  GtkTreeIter          child_iter;
+  GtkTreePath         *path;
   const gchar         *markup_format = "<span size='medium' weight='bold' color='#353535'>%s</span>";
   GtkWidget           *box;
   GtkWidget           *expander;
   gboolean             category;
   gboolean             valid_iter = FALSE;
+  gboolean             valid_child = FALSE;
   gchar               *markup;
   gchar               *name;
 
@@ -272,9 +275,7 @@ thunar_shortcuts_view_constructed (GObject *object)
   valid_iter = gtk_tree_model_get_iter_first (view->model, &iter);
   while (valid_iter)
     {
-      /* TODO read values from the row and create an expander,
-       * shortcut row or drop placeholder, depending on the
-       * row values */
+      /* read category information from the model */
       gtk_tree_model_get (view->model, &iter,
                           THUNAR_SHORTCUTS_MODEL_COLUMN_CATEGORY, &category,
                           THUNAR_SHORTCUTS_MODEL_COLUMN_NAME, &name,
@@ -300,13 +301,23 @@ thunar_shortcuts_view_constructed (GObject *object)
           box = gtk_vbox_new (TRUE, 0);
           gtk_container_add (GTK_CONTAINER (expander), box);
           gtk_widget_show (box);
-        }
-      else
-        {
-          /* we will have to implement this at some point but right now, the
-           * model data is loaded in an idle handler, so there is no data other
-           * than categories during construction */
-          _thunar_assert_not_reached ();
+
+          /* check if the categories has any entries */
+          valid_child = gtk_tree_model_iter_children (view->model, &child_iter, &iter);
+          while (valid_child)
+            {
+              /* create a tree path for the shortcut */
+              path = gtk_tree_model_get_path (view->model, &child_iter);
+
+              /* add the shortcut */
+              thunar_shortcuts_view_row_inserted (view, path, &child_iter, view->model);
+
+              /* release the path */
+              gtk_tree_path_free (path);
+
+              /* advance to the next child row */
+              valid_child = gtk_tree_model_iter_next (view->model, &child_iter);
+            }
         }
 
       /* advance to the next row */



More information about the Xfce4-commits mailing list