Geany 1.29, en_AU.UTF-8 GTK 3.18.9, GLib 2.48.1
Nothing happens when a file is selected from the file selector on the split window.
@codebrainz has confirmed with gtk3, doesn't happen with gtk2.
Suspect [this](https://github.com/geany/geany/commit/1a36eeaf4d6a5cab39d2cfd2c69a1a2f6e2bce...) from @techee which changes the splitwindow widget tree, but it doesn't revert cleanly to try easily.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149
[from IRC]
@codebrainz investigations have shown that the callback attached to the splitwindow file selection menu (in `ui_menu_add_document_items()`) is not activated, reason unknown.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-234839470
The reason the `activate` callback isn't called is because the handler connected to the menu's `show` is called once when the doclist menu is shown and once when it's hidden. In that handler, it clears the menu menu before adding current documents, but since it's after the menu is selected but before the `activate` handlers are run, and it deletes all the items, the handlers are never called.
It can be witnessed by using this completely silly work-around which ensures the `show` signal handler is only run every other time (just the "shows" not the "hides"):
```c diff --git a/plugins/splitwindow.c b/plugins/splitwindow.c index 4f0dec3..e2f1240 100644 --- a/plugins/splitwindow.c +++ b/plugins/splitwindow.c @@ -249,11 +249,22 @@ static void on_doc_menu_item_clicked(gpointer item, GeanyDocument *doc)
static void on_doc_menu_show(GtkMenu *menu) { - /* clear the old menu items */ - gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback) gtk_widget_destroy, NULL); + static gboolean toggle = FALSE;
- ui_menu_add_document_items(menu, edit_window.editor->document, - G_CALLBACK(on_doc_menu_item_clicked)); + if (!toggle) + { + /* clear the old menu items */ + gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback) gtk_widget_destroy, NULL); + + ui_menu_add_document_items(menu, edit_window.editor->document, + G_CALLBACK(on_doc_menu_item_clicked)); + + toggle = TRUE; + } + else + { + toggle = FALSE; + } } ```
It might be a GTK+ bug?
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-234845602
I should note that if it uses the `show-menu` signal for the `GtkMenuToolButton` the same effect happens, even if re-creating a new menu each time as the docs hint to. The `show-menu` signal is called when the menu is shown, and then again after an item is selected and the menu is hidden.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-234845751
Connecting to `map-event` instead of `show` seems to work-around the problem:
```diff diff --git a/plugins/splitwindow.c b/plugins/splitwindow.c index 4f0dec3..c6b91e4 100644 --- a/plugins/splitwindow.c +++ b/plugins/splitwindow.c @@ -247,13 +247,15 @@ static void on_doc_menu_item_clicked(gpointer item, GeanyDocument *doc) }
-static void on_doc_menu_show(GtkMenu *menu) +static gboolean on_doc_menu_show(GtkMenu *menu, GdkEvent *event, gpointer unused) { /* clear the old menu items */ gtk_container_foreach(GTK_CONTAINER(menu), (GtkCallback) gtk_widget_destroy, NULL);
ui_menu_add_document_items(menu, edit_window.editor->document, G_CALLBACK(on_doc_menu_item_clicked)); + + return FALSE; }
@@ -275,7 +277,7 @@ static GtkWidget *create_toolbar(void)
item = gtk_menu_new(); gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(tool_item), item); - g_signal_connect(item, "show", G_CALLBACK(on_doc_menu_show), NULL); + g_signal_connect(item, "map-event", G_CALLBACK(on_doc_menu_show), NULL);
tool_item = gtk_tool_item_new(); gtk_tool_item_set_expand(tool_item, TRUE); ```
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-234847390
In my splitwindow2 I also use map-event for when the tab becomes visible to the user (there is also a corresponding unmap-event). IIUC "show" is called everytime one calls gtk_widget_show() which can be more than once?
So, LGTM.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-235799865
`:map-event` is ugly IMO, because it's a mere implementation detail at best. Doing it properly would be listening to [`GtkMenuToolButton::show-menu`](https://developer.gnome.org/gtk3/stable/GtkMenuToolButton.html#GtkMenuToolBu...). However, just like `GtkWidget::show` on the menu itself, it somehow is emitted twice under GTK >= 3.16. See the [just-filed bug](https://bugzilla.gnome.org/show_bug.cgi?id=769287).
I'm not sure what to do. This is clearly a GTK bug, so I'm not very keen on adding a hack just for it until it gets fixed.
IIUC "show" is called everytime one calls gtk_widget_show() which can be more than once?
No, it's only emitted if the visible state changed. What happens here is that the menu is effectively shown twice.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-236049030
Will a fix accepted by GTK get backported? LTS distros won't upgrade their GTK, though they will release bugfix versions IIUC.
On 29 July 2016 at 08:53, Colomban Wendling notifications@github.com wrote:
:map-event is ugly IMO, because it's a mere implementation detail at best. Doing it properly would be listening to GtkMenuToolButton::show-menu https://developer.gnome.org/gtk3/stable/GtkMenuToolButton.html#GtkMenuToolButton-show-menu. However, just like GtkWidget::show on the menu itself, it somehow is emitted twice under GTK >= 3.16. See the just-filed bug https://bugzilla.gnome.org/show_bug.cgi?id=769287.
I'm not sure what to do. This is clearly a GTK bug, so I'm not very keen on adding a hack just for it until it gets fixed.
IIUC "show" is called everytime one calls gtk_widget_show() which can be more than once?
No, it's only emitted if the visible state changed. What happens here is that the menu is effectively shown twice.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/geany/geany/issues/1149#issuecomment-236049030, or mute the thread https://github.com/notifications/unsubscribe-auth/AAxgTT6kGgnavSW-_UpHgByF0DDj8xiPks5qaTL_gaJpZM4JTxOO .
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-236054630
They generally backport the fixes on the stable branches, so yeah it's very possible.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-236054803
@b4n thanks for looking into it and submitting a bug report
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-236076975
@codebrainz thanks for your analysis prior to that.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/geany/geany/issues/1149#issuecomment-236078139
Backports to 3.18 and 3.20 don't look like being "soon" and maybe never (see the GTK versioning blogs pointing at 3.22 as LTS). Possible solutions on our end should be investigated further. Or the splitwindow plugin replaced by one fo the alternate improved versions.
Closed #1149 via #1272.
github-comments@lists.geany.org