Fixes #3414. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/3415
-- Commit Summary --
* Fix Save As saves CLI opened file instead of new document
-- File Changes --
M src/document.c (4)
-- Patch Links --
https://github.com/geany/geany/pull/3415.patch https://github.com/geany/geany/pull/3415.diff
@ntrel commented on this pull request.
@@ -628,7 +628,9 @@ static GeanyDocument *document_create(const gchar *utf8_filename)
{ doc = document_get_current(); /* remove the empty document first */ - if (doc != NULL && doc->file_name == NULL && ! doc->changed) + if (doc != NULL && doc->file_name == NULL && ! doc->changed && + // check save as dialog isn't running + gtk_window_is_active(GTK_WINDOW(main_widgets.window)))
Unfortunately this is false when the window doesn't have focus, so it won't close the empty document any more when using a terminal window to open a file.
@ntrel commented on this pull request.
@@ -628,7 +628,9 @@ static GeanyDocument *document_create(const gchar *utf8_filename)
{ doc = document_get_current(); /* remove the empty document first */ - if (doc != NULL && doc->file_name == NULL && ! doc->changed) + if (doc != NULL && doc->file_name == NULL && ! doc->changed && + // check save as dialog isn't running + gtk_window_is_active(GTK_WINDOW(main_widgets.window)))
So it looks like this function would be a solution (comparing the result to the main window): https://docs.gtk.org/gtk3/method.Application.get_active_window.html
But we don't use GtkApplication, also I'm not sure if it would mean having to update all our window creation code too.
Well, Application also handles opening stuff in a primary instance, could replace all of socket.c and possibly the root cause of the original problem ;-)
IIRC Application has been discussed a few times, but the level of intrusion was judged to be quite high, and nobody is guaranteeing portability, IIUC gtk_application is based on g_application which is linked to Gnome (again IIUC, no guarantees its right).
In the end nobody wanted to do it. How "little" you could get away with is unknown.
@ntrel pushed 1 commit.
18ef09fbfe930cb8a4505c79c6ed4bbe1f394201 Fix Save As saves CLI opened file instead of new document
I tried to make Geany use GtkApplication but failed. Fixed this by implementing a function `ui_has_modal` myself.
@cwendling commented on this pull request.
@@ -628,7 +628,9 @@ static GeanyDocument *document_create(const gchar *utf8_filename)
{ doc = document_get_current(); /* remove the empty document first */ - if (doc != NULL && doc->file_name == NULL && ! doc->changed) + if (doc != NULL && doc->file_name == NULL && ! doc->changed && + // check save as dialog isn't running + gtk_window_is_active(GTK_WINDOW(main_widgets.window)))
Not sure if that would actually account for dialogs as well, I would think it's mostly to select the MRU one in a multi-window app.
[…] IIUC gtk_application is based on g_application which is linked to Gnome (again IIUC, no guarantees its right).
I don't have any clue that this is true at any level :) GApplication is the base, yes, but it's from GIO, which we (and more importantly, GTK) use anyway. GApplication is the non-GUI base, GtkApplication is an additional layer for GTK stuff.
github-comments@lists.geany.org