This change makes the main window show immediately after launching Geany so it's immediately visible Geany started. With big files/projects this gives users better feedback about it's starting than not showing anything until all the files are ready.
This is a separated patch suggested by @codebrainz in https://github.com/geany/geany/pull/576. It might be a bit risky for Geany 1.27 because plugins might make some assumptions when geany-startup-complete is called so this one might need some more testing. Possible candidate for early 1.28 merge. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/924
-- Commit Summary --
* Open files session files after entering main loop
-- File Changes --
M src/libmain.c (59)
-- Patch Links --
https://github.com/geany/geany/pull/924.patch https://github.com/geany/geany/pull/924.diff
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924
Might be useful to clarify the API docs for the `geany-startup-complete` signal.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-190422591
IMO it'd be cleaner to put this args struct on the stack here, and pass a pointer to it as the user_data for the idle callback, rather than a global variable. It's in the main function and enters gtk_main() below, so the lifetime should be fine.
Good point, done.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-190654915
Might be useful to clarify the API docs for the geany-startup-complete signal.
Actually I think if the plugin uses the signal things will be fine. The thing that might go wrong is when a plugin implicitly assumed that when it runs an idle function on startup, everything will be initialized when the idle function is started. This was the case before but now the plugin's idle function can be run before on_startup_complete().
Now I hope nobody does this but still it will be safer to merge this pull request at the beginning of a release cycle so there's more testing.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-190658065
This was the case before but now the plugin's idle function can be run before on_startup_complete().
So it probably needs to be documented what the signal actually means :)
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-190659402
@elextr It's documented here
https://github.com/geany/geany/blob/master/src/libmain.c#L421
I haven't changed anything about that. However, thanks for pointing this out - it should be fired at the same time as main_window_realized is set to TRUE because the signal and the variable are kind of related. I moved main_window_realized = TRUE into on_startup_complete() so plugins will have it set to FALSE if their idle calls are invoked before.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-190744368
I moved main_window_realized = TRUE into on_startup_complete() so plugins will have it set to FALSE if their idle calls are invoked before.
Is this documented in the plugin docs?
And the signal is actually documented [here](http://www.geany.org/manual/reference/pluginsignals_8c.html#a8e81ea2fd5fc025...) which doesn't sound like its right any more.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-190997130
@elextr I haven't changed absolutely anything about the moment the signal is fired - there's no diff related to this signal, just have a look at the patch.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-191190011
The thing that might go wrong is when a plugin implicitly assumed that when it runs an idle function on startup, everything will be initialized when the idle function is started. This was the case before but now the plugin's idle function can be run before on_startup_complete().
Sounds like a change of the signal's semantics to me.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-191192339
Sounds like a change of the signal's semantics to me.
But not of the signal itself - the signal works as before. It's a change of Geany's initialization behavior which isn't documented anywhere (and because we might need to change things in the future, I think we shouldn't specify the initialization process in too much detail).
In other words - plugins should use the signal to make sure initialization is finished (already documented); relying on implicit, undocumented Geany behavior is undefined and may change release to release (already the case with other things).
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-191223358
Is the initialisation complete when the signal is emitted or not?
If it is, fine, but then why can it cause problems with some plugins?
If it is required that plugins do nothing (or nothing using the idle loop, or a timer?) until this signal then that needs to be documented, though I would argue that it would be better to fix it so plugins need not worry.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-191233581
Is the initialisation complete when the signal is emitted or not?
Yes, it is completed (the same way as before).
Maybe I was a bit unclear about what I meant in the very first message in the pull request - sorry for that.
If it is, fine, but then why can it cause problems with some plugins?
The signal itself doesn't cause any problems - if plugins use something like
``` g_signal_connect(geany_object, "geany-startup-complete", on_startup_complete, NULL); ```
everything is fine. However if plugins don't use geany-startup-complete and rely on the fact that the initialization is completed before entering the main loop, which was the case before this patch, e.g. using
``` g_idle_add(on_startup_complete, NULL); ```
when loaded, then things will break because startup won't be completed at this point.
If it is required that plugins do nothing (or nothing using the idle loop, or a timer?) until this signal then that needs to be documented, though I would argue that it would be better to fix it so plugins > need not worry.
Plugins can do anything they wish in the idle call (idle loop will already be running at that point), they just shouldn't assume initialization is finished (the missing part at this point will be document/project opening).
I could move plugin initialization inside on_startup_complete() but I'd have to move more things there and I'm slightly worried I might break more things on the way.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-191252467
@techee thanks for the clear explanation
If the only missing initialisation is opening docs and projects then it should be ok.
Since Geany can be opened without any documents or projects open, the plugins must already gracefully handle that situation, and adjust as the docs and/or projects are opened.
--- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/924#issuecomment-191263448
Closed #924.
github-comments@lists.geany.org