Fix #886: Path copying does not work until the user left-clicks a node in the treeview
authorColin Clark <colin.clark@cclark.uk>
Thu, 29 Apr 2021 12:26:54 +0000 (13:26 +0100)
committerColin Clark <colin.clark@cclark.uk>
Thu, 29 Apr 2021 12:26:54 +0000 (13:26 +0100)
https://github.com/BestImageViewer/geeqie/issues/886

Change the press callback to select the item on right-click also.
Other functions such as Rename/Delete are now available on right-click.

src/view_dir.c

index 170cc78..be0fdb0 100644 (file)
@@ -1187,9 +1187,36 @@ gboolean vd_press_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
 {
        ViewDir *vd = data;
        gboolean ret = FALSE;
+       FileData *fd;
+       GtkTreePath *tpath;
+       GtkTreeIter iter;
+       NodeData *nd = NULL;
+       GtkTreeModel *store;
 
        if (bevent->button == MOUSE_BUTTON_RIGHT)
                {
+               if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), bevent->x, bevent->y, &tpath, NULL, NULL, NULL))
+                       {
+                       store = gtk_tree_view_get_model(GTK_TREE_VIEW(widget));
+                       gtk_tree_model_get_iter(store, &iter, tpath);
+
+                       switch (vd->type)
+                               {
+                               case DIRVIEW_LIST:
+                                       gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &fd, -1);
+                                       vd->click_fd = fd;
+                                       break;
+                               case DIRVIEW_TREE:
+                                       gtk_tree_model_get(store, &iter, DIR_COLUMN_POINTER, &nd, -1);
+                                       vd->click_fd = (nd) ? nd->fd : NULL;
+                               }
+
+                       if (vd->click_fd)
+                               {
+                               vd_color_set(vd, vd->click_fd, TRUE);
+                               }
+                       }
+
                vd->popup = vd_pop_menu(vd, vd->click_fd);
                gtk_menu_popup(GTK_MENU(vd->popup), NULL, NULL, NULL, NULL,
                               bevent->button, bevent->time);