Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make GUI-only Windows binary more discoverable #784

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

tleedjarv
Copy link
Contributor

@tleedjarv tleedjarv commented Aug 31, 2022

Another fix for #778.

The following normally text-only output is now handled differently by the GUI-only binary:

  • -version output is displayed in a GUI message box.
  • -doc produces a generic message explaining the GUI-only binary.
  • -ui text produces a generic message explaining the GUI-only binary.
  • -help produces a generic message explaining the GUI-only binary.
  • command line parsing errors are displayed in a GUI message box.
  • GTK init errors are displayed in a GUI message box.

@rivy could you also test and see how this fits into your workflow.

@acolomb
Copy link

acolomb commented Aug 31, 2022

My only concern here is about errors involving the GUI system itself, such as when GTK cannot be initialized. I think those are dumped to the console either way, and obviously a GUI window for those is impossible.

Could we just pop up a console window in that last case? I'd assume it's something like GApplication failing to initialize or other error return codes from early GTK functions.

@tleedjarv
Copy link
Contributor Author

My only concern here is about errors involving the GUI system itself, such as when GTK cannot be initialized. I think those are dumped to the console either way, and obviously a GUI window for those is impossible.

Could we just pop up a console window in that last case? I'd assume it's something like GApplication failing to initialize or other error return codes from early GTK functions.

Will give it a try. Don't know yet how to test that, though.

I don't think it's going to be too useful for a user because there will be no meaningful error message. lablgtk uses the gtk_init_check() function https://docs.gtk.org/gtk3/func.init_check.html and this only returns FALSE on errors, without actual error message. But it might still be better than just "silently crashing". At least the user knows that gtk init failed, even though it's impossible to tell why.

Some output (for example -version and command line parsing errors) is
produced only as text. GUI-only Windows binary will silently hide such
output. Make it more discoverable by presenting the output as a GUI
message box. If that's not possible then explain to the user that this
is a GUI-only executable.
@tleedjarv tleedjarv force-pushed the improve-win-console+gui branch from 9017923 to 65f1483 Compare August 31, 2022 14:09
@tleedjarv
Copy link
Contributor Author

tleedjarv commented Aug 31, 2022

Now GTK init errors are also displayed in a message box.

@acolomb
Copy link

acolomb commented Aug 31, 2022

Message box provided by GTK? How is that supposed to work when the first initialization fails?

Could we instead detect when something is sent to the standard output stream, and open a console window unconditionally of what part produced the output?

As for testing GTK errors, you might have luck setting some invalid configuration via environment variables. GDK_BACKEND comes to mind for example, which should make it impossible to open any GUI when using an invalid value. See here for some hints: https://jan.newmarch.name/Wayland/GTK/

@tleedjarv
Copy link
Contributor Author

Message box provided by GTK? How is that supposed to work when the first initialization fails?

No, of course not. None of this PR uses GTK. If that was feasible or possible then we wouldn't need this PR in the first place. This is Windows only, it uses the Windows native GUI (just see in the code, it's very short).

Could we instead detect when something is sent to the standard output stream, and open a console window unconditionally of what part produced the output?

Not feasible.

@acolomb
Copy link

acolomb commented Aug 31, 2022

Alright, that sounds fair. Sorry I didn't have a chance to look at the code changes while traveling.

@tleedjarv
Copy link
Contributor Author

As for testing GTK errors, you might have luck setting some invalid configuration via environment variables. GDK_BACKEND comes to mind for example, which should make it impossible to open any GUI when using an invalid value.

Thanks for the hint @acolomb. This worked (to make GTK init fail). Now, a native Windows message box is displayed with the error. Note that this is strictly an improvement because previously (since always) the error would have been displayed in the console window but the console window would be closed immediately with application exit (unless run from command line) and the user wouldn't see anything.

@gdt gdt merged commit 8dec7de into bcpierce00:master Sep 1, 2022
@tleedjarv tleedjarv deleted the improve-win-console+gui branch September 1, 2022 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants