- open in geany and open external not starting - find in files don't have the clicked path You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/2161
-- Commit Summary --
* FIX: right-click on filebrowser plugin:
-- File Changes --
M plugins/filebrowser.c (7)
-- Patch Links --
https://github.com/geany/geany/pull/2161.patch https://github.com/geany/geany/pull/2161.diff
codebrainz commented on this pull request.
@@ -686,6 +688,7 @@ static GtkWidget *create_popup_menu(void)
gtk_container_add(GTK_CONTAINER(menu), item);
item = gtk_check_menu_item_new_with_mnemonic(_("Show _Hidden Files")); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),show_hidden_files);
Minor nitpick, but the space after the comma is missing.
codebrainz commented on this pull request.
@@ -736,13 +739,9 @@ static gboolean on_button_press(GtkWidget *widget, GdkEventButton *event, gpoint
} else if (event->button == 3) { - static GtkWidget *popup_menu = NULL;
While I dislike static local (or global) variables which allocate memory dynamically and never cleanup, moving this one to the global scope seems completely unrelated to this change. Or did I miss it being used elsewhere?
@GFdevelop can you explain a little more about what the problems are, steps to reproduce, and what this PR does to fix the problems? I don't doubt it's useful, I just can't reproduce the problems listed or understand how this fixes them.
GFdevelop commented on this pull request.
@@ -686,6 +688,7 @@ static GtkWidget *create_popup_menu(void)
gtk_container_add(GTK_CONTAINER(menu), item);
item = gtk_check_menu_item_new_with_mnemonic(_("Show _Hidden Files")); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item),show_hidden_files);
Sorry, a commit incoming.
GFdevelop commented on this pull request.
@@ -736,13 +739,9 @@ static gboolean on_button_press(GtkWidget *widget, GdkEventButton *event, gpoint
} else if (event->button == 3) { - static GtkWidget *popup_menu = NULL;
The old code have no sense...can you explain `if (popup_menu == NULL)`? https://github.com/geany/geany/blob/868da11715ed86d08c1c2c4deaf1b2aa6c209df4...
I have to revert this?
codebrainz commented on this pull request.
@@ -736,13 +739,9 @@ static gboolean on_button_press(GtkWidget *widget, GdkEventButton *event, gpoint
} else if (event->button == 3) { - static GtkWidget *popup_menu = NULL;
One of the meanings in C of `static` is that it's only initialized once for the whole runtime, so the above code initializes `popup_menu` to `NULL` for the only/one-time initialization. Then the `if (popup_menu == NULL)` branch says "if this is the first time through this code, assign `popup_menu` with some runtime value and then never enter this branch again." It's not terribly good code, IMO, but it isn't wrong either.
I have to revert this?
I'm not strictly opposed to the change, it just looks completely unrelated to the pull request and an argument could be made that if it's only used in one place, and it's going to leak memory anyway, then having the variable definition closer to the use of it is best.
BEFORE: as you can see the first time (when you open geany) that you use filebrowser the right-click button have no selection, the second time it work. ![before](https://user-images.githubusercontent.com/17930457/58218900-03984800-7d09-11...)
AFTER: Work first time and all times. ![after](https://user-images.githubusercontent.com/17930457/58218904-07c46580-7d09-11...)
GFdevelop commented on this pull request.
@@ -736,13 +739,9 @@ static gboolean on_button_press(GtkWidget *widget, GdkEventButton *event, gpoint
} else if (event->button == 3) { - static GtkWidget *popup_menu = NULL;
You are right, I push a commit to revert this and add space at line 691.
@GFdevelop thanks for the info. For me, when there's no selection and I right-click on an item, it first selects the item and the menu pops up as expected. Perhaps it's a difference in GTK+ versions (GTK 2.24.32 here and it looks like you might have GTK+3).
Anyway, if the crux of this PR fixes some GTK+ versions without affecting others, which it seems to do, then it looks OK to me at a glance.
@GFdevelop pushed 1 commit.
c22f9b11fcee3e414228bad078401e0b3fc31074 Small fix
With GTK+3 not working left-click button either the first time.
On Linux Mint 19.3 Cinnamon with git Geany and plugins I can't reproduce the problems in the original comment.
- double click and right click->open in geany both work - open external doesn't work because the configured application (nautilus) isn't present on my system, but I get a message to that effect, so the menu is working properly
- find in files uses the selected directory, _if_ you select FIF from the FB right click menu, not if you select FIF with the geany menu. That seems correct, plugins can't affect Geany actions.
``` 09:57:39: Geany INFO : Geany 1.36 (git >= 4bceddb4), en_AU.UTF-8 09:57:39: Geany INFO : GTK 3.22.30, GLib 2.56.4 ```
@GFdevelop
This is a recorded message, please always provide the version of Geany, Glib and GTK (see lines near the top of Help->Debug Messages) and the operating system and version you are using.
I think I have also seen this issue under windows. Will check and report the result.
@LarsGit223 thanks, its worth doing, but as the OP is on GTK-3 its unlikely to be windows.
``` OS: Arch Linux x86_64 Resolution: 1366x768 @ 60.05Hz DE: Budgie WM: Mutter(Budgie) ``` Current: ``` Geany 1.35, it_IT.UTF-8 GTK 3.24.8, GLib 2.60.2 ```
After installing the last GTK+2 package 1.32.0-1 https://git.archlinux.org/svntogit/community.git/log/trunk?h=packages/geany I can see that the issue exist on GTK+2 ``` Geany 1.32, it_IT.UTF-8 GTK 2.24.32, GLib 2.60.2 ``` To reproduce: 1. you need to have "Show hidden files" checked 2. close geany 3. open geany
Now, the first time, filebrowser fail to select file/folder.
Ok, with the key missing information that the problem only ever occurs on the very first time the plugin is right clicked per session I can reproduce.
As @codebrainz observed, the table row is not being selected on the first right click, its not focus, I can left click on a row first and still the first right click will not select a different row.
As @GFdevelop seems to have identified, but didn't explain, changing the value of the "hidden files" item in the popup seems to steal the selection from the file list.
This leads to a second reproducer. I can reproduce the problem by changing the "hidden files" option in the plugins preferences dialog in plugin manager, and the problem happens every time on the first right click after its changed.
This seems rather like a GTK strangeness, `gtk_check_menu_item_set_active()` only actually selecting the item when the value changes @b4n?
Unfortunately the solution here (moving the call to `gtk_check_menu_item_set_active()` to the popup creation) is wrong because the setting in the menu no longer follows the value set by the plugins preferences dialog.
The variable `popup_menu` needs to be moved from being a static in the `on_button_press()` function to a file wide static that is created in the plugin init, (as @codebrainz said) properly freed in plugin free and then it can be updated by the plugin preferences when thats changed and by the menu function when its changed in the menu and not on each time the menu is displayed.
Unfortunately the solution here (moving the call to `gtk_check_menu_item_set_active()` to the popup creation) is wrong because the setting in the menu no longer follows the value set by the plugins preferences dialog.
For me the value of preferences is followed.
@GFdevelop open plugin manager, select filebrowser, select preferences, change show hidden files option, ok, the file list changes to follow the new setting value, right click on the file list, the value of "show hidden files" in the menu is incorrect.
@GFdevelop open plugin manager, select filebrowser, select preferences, change show hidden files option, ok, the file list changes to follow the new setting value, right click on the file list, the value of "show hidden files" in the menu is incorrect.
You are right...I'm working on your request.
@elextr: I can reproduce a problem with the file browser, not sure if it is related to this issue or not:
**Good case:** 1. Start geany 2. Right click in the file browser 3. Select "Find in Files"
**Bad Case:** 1. Start geany 2. Left click on an item in the file browser 3. Right click in the file browser 4. "Find in Files" is grayed out/not sensitive and cannot be selected (Clicking in the editor and then right clicking in the file browser solves the issue)
This also only happens once after the start of Geany. Not during operation. Tested on Windows 7.
I can reproduce it now, with the added step of ticking the "Show hidden files" option, the first right click doesn't select the item first. (Ubuntu 18.04.2, GTK 2.24.32, GLib 2.56.4)
Unfortunately the solution here (moving the call to `gtk_check_menu_item_set_active()` to the popup creation) is wrong because the setting in the menu no longer follows the value set by the plugins preferences dialog.
In my first commit this not exist.
The variable `popup_menu` needs to be moved from being a static in the `on_button_press()` function to a file wide static that is created in the plugin init, (as @codebrainz said) properly freed in plugin free and then it can be updated by the plugin preferences when thats changed and by the menu function when its changed in the menu and not on each time the menu is displayed.
I don't understand, did you mean to declare the popup_menu in the plugin init and then passing as function argument? Or global (static) to file as my first commit?
@GFdevelop pushed 1 commit.
9de0575fccee826655beae8fa69bed56be616f75 FIXED: filebrowser "show hidden files" settings changes
@GFdevelop pushed 1 commit.
cfc672895f362fe96476f60e1f1d48bd9200bdb0 Fixed testing code
Any news about this pull request? Is this patch working?
github-comments@lists.geany.org