Web lists-archives.com

[PATCH] gtkplacessidebar: insert bookmark by dnd in correct position




Hi,
I would like to ask review for following GtkPlacesSidebar bug:

https://bugzilla.gnome.org/show_bug.cgi?id=742727

The bug was originally reported in Nautilus. Patch attached.

Regards,
From 7058590d54a107e4e25953287e4030b409a5ad25 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nelson=20Ben=C3=ADtez=20Le=C3=B3n?=
 <nbenitezl+gnome@xxxxxxxxx>
Date: Sun, 11 Jan 2015 01:11:14 +0500
Subject: [PATCH] gtkplacessidebar: insert bookmark by dnd in correct position

Add needed COLUMN INDEX to "new bookmark" row based on previous
bookmark index plus one.

Fixes bug 742727
---
 gtk/gtkplacessidebar.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 23903a9..f6faff6 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -1690,14 +1690,33 @@ start_drop_feedback (GtkPlacesSidebar        *sidebar,
       if (need_feedback_row)
         {
           GtkTreeIter iter;
+          GtkTreeIter iter_prev;
+          GtkTreePath *path_prev;
+          gint new_bookmark_col_index;
+          SectionType section_type;
+
+          /* Use column index of previous bookmark to calculate index for "new bookmark" */
+          path_prev = gtk_tree_path_new_from_indices (sidebar->new_bookmark_index - 1, -1);
+          if (gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), &iter_prev, path_prev))
+            gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter_prev,
+                                PLACES_SIDEBAR_COLUMN_SECTION_TYPE, &section_type,
+                                PLACES_SIDEBAR_COLUMN_INDEX, &new_bookmark_col_index, -1);
+
+          if (section_type != SECTION_BOOKMARKS)
+            new_bookmark_col_index = 0;
+          else
+            new_bookmark_col_index++;
 
           sidebar->new_bookmark_index = new_bookmark_index;
           gtk_list_store_insert_with_values (sidebar->store, &iter, sidebar->new_bookmark_index,
                                              PLACES_SIDEBAR_COLUMN_ROW_TYPE, PLACES_DROP_FEEDBACK,
                                              PLACES_SIDEBAR_COLUMN_SECTION_TYPE, SECTION_BOOKMARKS,
                                              PLACES_SIDEBAR_COLUMN_NAME, _("New bookmark"),
+                                             PLACES_SIDEBAR_COLUMN_INDEX, new_bookmark_col_index,
                                              PLACES_SIDEBAR_COLUMN_NO_EJECT, TRUE,
                                              -1);
+
+          gtk_tree_path_free (path_prev);
         }
 
       new_path = gtk_tree_path_new_from_indices (sidebar->new_bookmark_index, -1);
-- 
2.1.0

_______________________________________________
gtk-devel-list mailing list
gtk-devel-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-devel-list