! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Custom action keyboard shortcut doesn't use the current, selected, path and f...
Status:
RESOLVED: FIXED

Comments

Description hapical 2019-02-06 01:36:02 CET
way to reproduce:

-create a script, I named it 'test':

	#!/bin/bash
	notify-send "$1"

-create a custom action, add a keyboard shortcut, appearance condition what you want.
	Command:  /path_to_script/test %f

-use the custom action with right click on one file, not with keyboard shortcut. You will see that notify-send output it's ok, the right path and file name.

-select another file, press the keyboard shortcut now, see notify-send output!!, it's the previous file not the current one. That behave will be the same with another files until we use right click to execute custom action.
Comment 1 alexxcons editbugs 2019-02-06 22:52:41 CET
Thanksfor reprting! I can reproduce the bug.
Comment 2 Andre Miranda editbugs 2019-02-13 02:11:49 CET
I can also reproduce this bug, unfortunately it seems to be caused by a design flaw not predicted when I introduced the hotkeys.
The trouble is that the hotkey needs the context menu to be created to the selected files and that only happens when right click is issued.
Needs further investigation...
Comment 3 Reuben Green editbugs 2019-09-20 14:33:55 CEST
Created attachment 9043 
attempt at a fix

Here is my go at fixing this. However, I'm certainly not an expert in gtk, so please treat with caution!

After a little debugging, I think the problem is that the function thunar_standard_view_merge_custom_actions, which generates the menu items which are activated by pressing keys when a file is selected, is currently being run only during thunar_standard_view_context_menu, with the result that the menu items are only refreshed when a context menu is run. Thus the menu items are not updated to reflect a change in the file selection.

The attached patch solves this by moving the call to thunar_standard_view_merge_custom_actions into thunar_standard_view_selection_changed, so that the menu items are regenerated whenever the selection changes and thus should always have the correct path. I have also removed the selected_items argument to thunar_standard_view_merge_custom_actions, since at the moment this parameter is not really being used. Indeed, the existing code just gets the list of selected items from the ThunarStandardView immediately before passing this directly to thunar_standard_view_merge_custom_actions, so I've changed thunar_standard_view_merge_custom_actions to retrieve the selected items itself.

One more thing: while testing this patch, I noticed that when running thunar in a terminal in "View as Detailed List" mode, I get a variable (i.e. between none and lots) number of xfconf-WARNINGs of the form

(thunar:12028): xfconf-WARNING **: 13:26:13.116: Failed to set property "thunar::/last-details-view-column-widths": Operation was cancelled

I don't think these are caused by my patch, since I also get them with a thunar compiled from the master branch. It's *possible* that after applying my patch there are slightly more of these warnings, but the number of them is highly variable both with and without the patch so I can't really tell. In any case, I don't think my patch is the root cause of them. I'll open another bug for this.
Comment 4 Reuben Green editbugs 2019-09-20 15:00:32 CEST
Ah, I see that the xfconf-WARNING issue is a known bug (Bug #15305)
Comment 5 Git Bot editbugs 2019-09-22 23:47:17 CEST
Reuben Green referenced this bugreport in commit adca28cea8eeb8efd457cd794271eee72867c23d

Ensure user customizable action uses currently selected file path (Bug #15119)

https://git.xfce.org/xfce/thunar/commit?id=adca28cea8eeb8efd457cd794271eee72867c23d
Comment 6 Git Bot editbugs 2019-09-22 23:48:43 CEST
Reuben Green referenced this bugreport in commit 1b568d86396e3ec298ca7f06cb7b47db62224e02

Ensure user customizable action uses currently selected file path (Bug #15119)

https://git.xfce.org/xfce/thunar/commit?id=1b568d86396e3ec298ca7f06cb7b47db62224e02
Comment 7 alexxcons editbugs 2019-09-22 23:50:34 CEST
Thanks for that nice fix, well done !

Works fine for me and the reasoning makes sense.

I pushed it to master and 4.14.
Comment 8 Andre Miranda editbugs 2019-09-25 18:45:05 CEST
Thanks Reuben for the fix, I really appreciate it.
Comment 9 Yury Martynov 2019-10-17 00:30:08 CEST
*** Bug 16055 has been marked as a duplicate of this bug. ***

Bug #15119

Reported by:
hapical
Reported on: 2019-02-06
Last modified on: 2019-10-17
Duplicates (1):
  • 16055 UCA and some errors while using a keyboard shortcut

People

Assignee:
Xfce Bug Triage
CC List:
6 users

Version

Attachments

attempt at a fix (4.59 KB, patch)
2019-09-20 14:33 CEST , Reuben Green
no flags

Additional information