From 6a9a9f1010288327b3f2db3d5c4fbd61288e1f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 4 Jun 2024 10:40:40 +0200 Subject: [PATCH 1/6] main: Use automatic cleanup for err MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- src/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 9bfb43c30..e0c5821d5 100644 --- a/src/main.c +++ b/src/main.c @@ -92,11 +92,11 @@ 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 (); @@ -116,7 +116,6 @@ 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; } -- GitLab From 98195ddb6154746cb6cca7ba56981b082d4fc2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 4 Jun 2024 10:40:41 +0200 Subject: [PATCH 2/6] main: Use G_NORETURN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes clang happy Signed-off-by: Guido Günther --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index e0c5821d5..6b1be53ff 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); -- GitLab From fb5f6b5ca98405644ed8145fcb992812b6c018cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 4 Jun 2024 10:40:41 +0200 Subject: [PATCH 3/6] main: Fix indent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gbp-Dch: Ignore Signed-off-by: Guido Günther --- src/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 6b1be53ff..691069959 100644 --- a/src/main.c +++ b/src/main.c @@ -100,7 +100,6 @@ int main(int argc, char *argv[]) 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}, @@ -119,9 +118,8 @@ int main(int argc, char *argv[]) return 1; } - if (version) { + if (version) print_version (); - } phosh_log_set_log_domains (g_getenv("G_MESSAGES_DEBUG")); -- GitLab From f395aa549f55db45718fbd6a05e6e1ef369f0cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 4 Jun 2024 10:40:42 +0200 Subject: [PATCH 4/6] tools/custom-quick-setting: Accept list of plugins to show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to skip plugins the e.g. need the shell singleton Signed-off-by: Guido Günther --- tools/custom-quick-settings-standalone.c | 34 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/tools/custom-quick-settings-standalone.c b/tools/custom-quick-settings-standalone.c index 44b8aec00..7108e3d57 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; @@ -76,8 +76,12 @@ setup_plugins (GStrv plugin_dirs, GStrv plugins) 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 { @@ -95,14 +99,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 +141,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); -- GitLab From fa2e06ff6126581a78d8404a2c118c4d628368f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 4 Jun 2024 10:40:43 +0200 Subject: [PATCH 5/6] tools/custom-quick-setting: Use newline when printing plugin name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Guido Günther --- tools/custom-quick-settings-standalone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/custom-quick-settings-standalone.c b/tools/custom-quick-settings-standalone.c index 7108e3d57..91c94bf3e 100644 --- a/tools/custom-quick-settings-standalone.c +++ b/tools/custom-quick-settings-standalone.c @@ -85,7 +85,7 @@ setup_plugins (GStrv plugin_dirs, GStrv plugins, const char *const *enabled) 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); } } -- GitLab From 2054801d51f6d4c4bc3dc45377c2026b0a647db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 4 Jun 2024 10:40:43 +0200 Subject: [PATCH 6/6] tools/custom-quick-setting: Top align flowbox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This avoids vexpanding the quick settings itself. Signed-off-by: Guido Günther --- tools/custom-quick-settings-standalone.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/custom-quick-settings-standalone.c b/tools/custom-quick-settings-standalone.c index 91c94bf3e..25ddad378 100644 --- a/tools/custom-quick-settings-standalone.c +++ b/tools/custom-quick-settings-standalone.c @@ -70,6 +70,7 @@ setup_plugins (GStrv plugin_dirs, GStrv plugins, const char *const *enabled) "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); -- GitLab