gplugin/gplugin

Use windows subsystem for GTK viewer

5 months ago, Elliott Sales de Andrade
80064de29bcd
Parents edc551ec9d3a
Children 0178488d90a3
Use windows subsystem for GTK viewer

This stops a console window from popping up if you run the viewer directly (from Explorer or a shortcut, etc.)

Also, modernize the `GOptionEntry` list.

Testing Done:
Compiled on Windows, and opened the viewer from Explorer.

Reviewed at https://reviews.imfreedom.org/r/2819/
--- a/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Wed Nov 15 15:29:37 2023 -0600
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Wed Nov 15 16:04:50 2023 -0600
@@ -126,17 +126,27 @@
/* clang-format off */
static GOptionEntry entries[] = {
{
- "internal", 'i', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
- &show_internal, "Show internal plugins", NULL,
- }, {
- "show-plugin", 'p', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING,
- &show_plugin, "Show page for a plugin on start", NULL,
+ .long_name = "internal",
+ .short_name = 'i',
+ .flags = G_OPTION_FLAG_NONE,
+ .arg = G_OPTION_ARG_NONE,
+ .arg_data = &show_internal,
+ .description = "Show internal plugins",
}, {
- "version", 'V', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
- NULL, "Display the version and exit", NULL,
+ .long_name = "show-plugin",
+ .short_name = 'p',
+ .flags = G_OPTION_FLAG_NONE,
+ .arg = G_OPTION_ARG_STRING,
+ .arg_data = &show_plugin,
+ .description = "Show page for a plugin on start",
}, {
- NULL, 0, 0, 0, NULL, NULL, NULL,
+ .long_name = "version",
+ .short_name = 'V',
+ .flags = G_OPTION_FLAG_NONE,
+ .arg = G_OPTION_ARG_NONE,
+ .description = "Display the version and exit",
},
+ G_OPTION_ENTRY_NULL
};
/* clang-format on */
@@ -174,3 +184,18 @@
return ret;
}
+
+#ifdef _WIN32
+#include <windows.h>
+
+int APIENTRY
+WinMain(
+ G_GNUC_UNUSED HINSTANCE hInstance,
+ G_GNUC_UNUSED HINSTANCE hPrevInstance,
+ G_GNUC_UNUSED LPSTR lpszCmdLine,
+ G_GNUC_UNUSED int nCmdShow)
+{
+ /* NOTE: g_application_run ignores argc and argv on Windows. */
+ return main(0, NULL);
+}
+#endif
--- a/gplugin-gtk4-viewer/meson.build Wed Nov 15 15:29:37 2023 -0600
+++ b/gplugin-gtk4-viewer/meson.build Wed Nov 15 16:04:50 2023 -0600
@@ -16,6 +16,7 @@
'gplugin-gtk-viewer-window.c',
gplugin_gtk4_viewer_resources,
dependencies : [gplugin_dep, gplugin_gtk4_dep],
+ win_subsystem : 'windows',
install : get_option('install-gplugin-gtk4-viewer')
)