gplugin/gplugin

Add option in viewer to directly show a plugin page

16 months ago, Elliott Sales de Andrade
bc5116596aba
Parents a4ee5a7bbbe9
Children e425162a4e4e
Add option in viewer to directly show a plugin page

Testing Done:
Ran `gplugin-gtk4-viewer -p gplugin/native-basic-plugin` and it opened the `basic plugin (C)` page directly.
Ran `gplugin-gtk4-viewer -p asfalskjf` and it exited with an error.

Reviewed at https://reviews.imfreedom.org/r/2148/
--- a/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Sat Dec 17 01:44:54 2022 -0600
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Sat Dec 17 01:46:32 2022 -0600
@@ -28,6 +28,7 @@
* Globals
*****************************************************************************/
static gboolean show_internal = FALSE;
+static char *show_plugin = NULL;
/******************************************************************************
* Helpers
@@ -76,9 +77,20 @@
activate_cb(GApplication *app)
{
GtkWindow *window = NULL;
+ GPluginPlugin *plugin = NULL;
g_return_if_fail(GTK_IS_APPLICATION(app));
+ if(show_plugin != NULL) {
+ GPluginManager *manager = NULL;
+
+ manager = gplugin_manager_get_default();
+ plugin = gplugin_manager_find_plugin(manager, show_plugin);
+ if(!GPLUGIN_IS_PLUGIN(plugin)) {
+ g_error("Failed to find plugin with ID %s", show_plugin);
+ }
+ }
+
window = gtk_application_get_active_window(GTK_APPLICATION(app));
if(window == NULL) {
GPluginGtkView *view = NULL;
@@ -99,6 +111,10 @@
backend = g_memory_settings_backend_new();
gplugin_gtk_view_set_settings_backend(view, backend);
g_object_unref(backend);
+
+ if(plugin != NULL) {
+ gplugin_gtk_view_show_plugin(view, plugin);
+ }
}
gtk_window_present(window);
@@ -113,6 +129,9 @@
"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,
+ }, {
"version", 'V', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
NULL, "Display the version and exit", NULL,
}, {