summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-07-23 14:11:22 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-07-23 14:11:22 -0400
commit155c45eba5a92e8b2b4cc131817f58badf7d6826 (patch)
tree2ee34b1198de3bd2b195a62efe7dadf0cea42907
parentd576069cecbc7de2dbb53c9a218f3125bef27ed7 (diff)
downloadgtk+-155c45eba5a92e8b2b4cc131817f58badf7d6826.tar.gz
GtkPlacesSidebar: Fix editing of bookmarks
This was silently broken - the code was just assuming that the text cell renderer is item no. 6 on the list of all cells. That doesn't work so well if the cell renderers are set up elsewhere and get rearranged. Fix this by keeping an explicit pointer to the the text cell.
-rw-r--r--gtk/gtkplacessidebar.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 3f6ea69cbb..20d8ad849f 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -126,6 +126,7 @@ struct _GtkPlacesSidebar {
GtkTreeView *tree_view;
GtkCellRenderer *eject_icon_cell_renderer;
+ GtkCellRenderer *text_cell_renderer;
GtkListStore *store;
GtkBookmarksManager *bookmarks_manager;
GVolumeMonitor *volume_monitor;
@@ -2462,8 +2463,6 @@ rename_selected_bookmark (GtkPlacesSidebar *sidebar)
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeViewColumn *column;
- GtkCellRenderer *cell;
- GList *renderers;
PlaceType type;
if (get_selected_iter (sidebar, &iter))
@@ -2477,12 +2476,9 @@ rename_selected_bookmark (GtkPlacesSidebar *sidebar)
path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->store), &iter);
column = gtk_tree_view_get_column (GTK_TREE_VIEW (sidebar->tree_view), 0);
- renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
- cell = g_list_nth_data (renderers, 6);
- g_list_free (renderers);
- g_object_set (cell, "editable", TRUE, NULL);
+ g_object_set (sidebar->text_cell_renderer, "editable", TRUE, NULL);
gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (sidebar->tree_view),
- path, column, cell, TRUE);
+ path, column, sidebar->text_cell_renderer, TRUE);
gtk_tree_path_free (path);
}
}
@@ -3812,6 +3808,7 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
/* normal text renderer */
cell = gtk_cell_renderer_text_new ();
+ sidebar->text_cell_renderer = cell;
gtk_tree_view_column_pack_start (col, cell, TRUE);
g_object_set (G_OBJECT (cell), "editable", FALSE, NULL);
gtk_tree_view_column_set_attributes (col, cell,