[Github-comments] [geany/geany] Split window file selector does not work (#1149)

Matthew Brush notifications at xxxxx
Mon Jul 25 05:44:46 UTC 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20160724/bfb6da4c/attachment.html>


More information about the Github-comments mailing list