Skip to content

Commit c51a8e5

Browse files
committed
nemo-places-sidebar.c: Fix bookmark renaming.
Caused by commit 4eabc45: - The packing order of cells changed, breaking the g_list_nth_data lookup. - Even with that fixed, new motion handlers would cause the keyboard edit grab to reset, immediately canceling rename mode. Fixes #3513.
1 parent 2e3c6fc commit c51a8e5

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/nemo-places-sidebar.c

+17-8
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ typedef struct {
8686
GtkTreeView *tree_view;
8787
GtkTreeViewColumn *eject_column;
8888
GtkCellRenderer *eject_icon_cell_renderer;
89+
GtkCellRenderer *editable_renderer;
8990
char *uri;
9091
GtkTreeStore *store;
9192
GtkTreeModel *store_filter;
@@ -2620,8 +2621,6 @@ rename_selected_bookmark (NemoPlacesSidebar *sidebar)
26202621
GtkTreeIter iter;
26212622
GtkTreePath *path;
26222623
GtkTreeViewColumn *column;
2623-
GtkCellRenderer *cell;
2624-
GList *renderers;
26252624
PlaceType type;
26262625

26272626
if (get_selected_iter (sidebar, &iter)) {
@@ -2635,12 +2634,9 @@ rename_selected_bookmark (NemoPlacesSidebar *sidebar)
26352634

26362635
path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->store_filter), &iter);
26372636
column = gtk_tree_view_get_column (GTK_TREE_VIEW (sidebar->tree_view), 2);
2638-
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
2639-
cell = g_list_nth_data (renderers, 5);
2640-
g_list_free (renderers);
2641-
g_object_set (cell, "editable", TRUE, NULL);
2637+
g_object_set (sidebar->editable_renderer, "editable", TRUE, NULL);
26422638
gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (sidebar->tree_view),
2643-
path, column, cell, TRUE);
2639+
path, column, sidebar->editable_renderer, TRUE);
26442640
gtk_tree_path_free (path);
26452641
}
26462642
}
@@ -3708,11 +3704,17 @@ motion_notify_cb (GtkWidget *widget,
37083704
GtkTreeModel *model;
37093705
GtkTreePath *path = NULL;
37103706
GtkTreePath *store_path = NULL;
3707+
gboolean editing;
37113708

37123709
if (event->type != GDK_MOTION_NOTIFY) {
37133710
return TRUE;
37143711
}
37153712

3713+
g_object_get (sidebar->editable_renderer, "editing", &editing, NULL);
3714+
if (editing) {
3715+
return GDK_EVENT_PROPAGATE;
3716+
}
3717+
37163718
model = gtk_tree_view_get_model (GTK_TREE_VIEW (sidebar->tree_view));
37173719

37183720
if (over_eject_button (sidebar, event->x, event->y, &path)) {
@@ -3736,10 +3738,17 @@ leave_notify_cb (GtkWidget *widget,
37363738
GdkEventCrossing *event,
37373739
NemoPlacesSidebar *sidebar)
37383740
{
3741+
gboolean editing;
3742+
37393743
if (event->type != GDK_LEAVE_NOTIFY) {
37403744
return TRUE;
37413745
}
37423746

3747+
g_object_get (sidebar->editable_renderer, "editing", &editing, NULL);
3748+
if (editing) {
3749+
return GDK_EVENT_PROPAGATE;
3750+
}
3751+
37433752
ClearHoverData data = { sidebar, NULL };
37443753
gtk_tree_model_foreach (GTK_TREE_MODEL (sidebar->store), (GtkTreeModelForeachFunc) clear_eject_hover, &data);
37453754

@@ -4194,7 +4203,7 @@ nemo_places_sidebar_init (NemoPlacesSidebar *sidebar)
41944203
sidebar, NULL);
41954204

41964205
/* normal text renderer */
4197-
cell = nemo_cell_renderer_disk_new ();
4206+
cell = sidebar->editable_renderer = nemo_cell_renderer_disk_new ();
41984207
NEMO_CELL_RENDERER_DISK (cell)->direction = gtk_widget_get_direction (GTK_WIDGET (tree_view));
41994208
gtk_tree_view_column_pack_start (primary_column, cell, TRUE);
42004209
g_object_set (G_OBJECT (cell), "editable", FALSE, NULL);

0 commit comments

Comments
 (0)