diff --git a/src/main.c b/src/main.c index 9bfb43c30a0437697d4a1c89e6f32f5d1e641aa2..691069959252c45db3038c44bfc7543077f313af 100644 --- a/src/main.c +++ b/src/main.c @@ -69,7 +69,7 @@ on_shutdown_signal (gpointer unused) } -static void +G_NORETURN static void print_version (void) { printf ("Phosh %s - A Wayland shell for mobile devices\n", PHOSH_VERSION); @@ -92,15 +92,14 @@ on_shell_ready (PhoshShell *shell, GTimer *timer) int main(int argc, char *argv[]) { - g_autoptr(GOptionContext) opt_context = NULL; - GError *err = NULL; + g_autoptr (GOptionContext) opt_context = NULL; + g_autoptr (GError) err = NULL; gboolean unlocked = FALSE, locked = FALSE, version = FALSE; - g_autoptr(PhoshWayland) wl = NULL; - g_autoptr(PhoshShell) shell = NULL; + g_autoptr (PhoshWayland) wl = NULL; + g_autoptr (PhoshShell) shell = NULL; g_autoptr (PhoshBackgroundCache) background_cache = NULL; g_autoptr (GTimer) timer = g_timer_new (); g_autoptr (PhoshWallClock) wall_clock = phosh_wall_clock_new (); - const GOptionEntry options [] = { {"unlocked", 'U', 0, G_OPTION_ARG_NONE, &unlocked, "Don't start with screen locked", NULL}, @@ -116,13 +115,11 @@ int main(int argc, char *argv[]) g_option_context_add_group (opt_context, gtk_get_option_group (FALSE)); if (!g_option_context_parse (opt_context, &argc, &argv, &err)) { g_warning ("%s", err->message); - g_clear_error (&err); return 1; } - if (version) { + if (version) print_version (); - } phosh_log_set_log_domains (g_getenv("G_MESSAGES_DEBUG")); diff --git a/tools/custom-quick-settings-standalone.c b/tools/custom-quick-settings-standalone.c index 44b8aec001e665283d1ef08a539a35fd4c84dbe9..25ddad3781aca09094a1f08a8d8c5d2340e1e290 100644 --- a/tools/custom-quick-settings-standalone.c +++ b/tools/custom-quick-settings-standalone.c @@ -58,7 +58,7 @@ get_plugin_dirs (GStrv plugins) static GtkWidget * -setup_plugins (GStrv plugin_dirs, GStrv plugins) +setup_plugins (GStrv plugin_dirs, GStrv plugins, const char *const *enabled) { GtkWidget *flow_box; g_autoptr (PhoshPluginLoader) loader = NULL; @@ -70,18 +70,23 @@ setup_plugins (GStrv plugin_dirs, GStrv plugins) "min-children-per-line", 2, "max-children-per-line", 3, "selection-mode", GTK_SELECTION_NONE, + "valign", GTK_ALIGN_START, "homogeneous", TRUE, NULL); loader = phosh_plugin_loader_new (plugin_dirs, PHOSH_EXTENSION_POINT_QUICK_SETTING_WIDGET); for (int i = 0; i < g_strv_length (plugins); i++) { char *plugin = plugins[i]; - GtkWidget* widget = phosh_plugin_loader_load_plugin (loader, plugin); + GtkWidget* widget; + if (!g_strv_contains (enabled, plugin)) + continue; + + widget = phosh_plugin_loader_load_plugin (loader, plugin); if (widget == NULL) { g_warning ("Unable to load plugin: %s", plugin); } else { - g_print ("Adding custom quick setting '%s'", plugin); + g_print ("Adding custom quick setting '%s'\n", plugin); gtk_container_add (GTK_CONTAINER (flow_box), widget); } } @@ -95,14 +100,38 @@ main (int argc, char *argv[]) { GtkWidget *win; GtkWidget *flow_box; + g_autoptr (GOptionContext) opt_context = NULL; + g_autoptr (GError) err = NULL; + g_autoptr (GStrvBuilder) plugins_builder = g_strv_builder_new (); g_auto (GStrv) plugins = g_strsplit (PLUGINS, " ", -1); g_auto (GStrv) plugin_dirs = NULL; + g_auto (GStrv) enabled = NULL; + const GOptionEntry options [] = { + { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } + }; + + opt_context = g_option_context_new ("- spawn your quick setting"); + g_option_context_add_main_entries (opt_context, options, NULL); + g_option_context_add_group (opt_context, gtk_get_option_group (FALSE)); + if (!g_option_context_parse (opt_context, &argc, &argv, &err)) { + g_warning ("%s", err->message); + return 1; + } gtk_init (&argc, &argv); hdy_init (); css_setup (); + if (argc < 2) { + g_print ("Pass at least one plugin name\n"); + return 1; + } + + for (int i = 1; i < argc; i++) + g_strv_builder_add (plugins_builder, argv[i]); + enabled = g_strv_builder_end (plugins_builder); + g_object_set (gtk_settings_get_default (), "gtk-application-prefer-dark-theme", TRUE, NULL); @@ -113,7 +142,7 @@ main (int argc, char *argv[]) gtk_widget_show (win); plugin_dirs = get_plugin_dirs (plugins); - flow_box = setup_plugins (plugin_dirs, plugins); + flow_box = setup_plugins (plugin_dirs, plugins, (const char * const *)enabled); gtk_widget_show (flow_box); gtk_container_add (GTK_CONTAINER (win), flow_box);