From 949912b55fd386962c6a06a8e2339010b0cf9217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 13 Sep 2018 15:36:23 +0200 Subject: [PATCH 1/2] Move main and signal handler to separate file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't want PhoshShell GObject cluttered with other code. Signed-off-by: Guido Günther --- src/main.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ src/meson.build | 1 + src/phosh.c | 51 -------------------------------------- 3 files changed, 67 insertions(+), 51 deletions(-) create mode 100644 src/main.c diff --git a/src/main.c b/src/main.c new file mode 100644 index 000000000..735a1f61e --- /dev/null +++ b/src/main.c @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2018 Purism SPC + * SPDX-License-Identifier: GPL-3.0+ + * Author: Guido Günther + */ + +#define G_LOG_DOMAIN "phosh-main" + +#include "config.h" + +#include "phosh.h" +#include "phosh-wayland.h" + +#include +#include + + +static gboolean +sigterm_cb (gpointer unused) +{ + g_debug ("Cleaning up"); + gtk_main_quit (); + return FALSE; +} + + +int main(int argc, char *argv[]) +{ + g_autoptr(GSource) sigterm = NULL; + GMainContext *context = NULL; + g_autoptr(GOptionContext) opt_context = NULL; + GError *err = NULL; + gboolean unlocked = FALSE; + g_autoptr(PhoshWayland) wl = NULL; + g_autoptr(PhoshShell) shell = NULL; + + const GOptionEntry options [] = { + {"unlocked", 'U', 0, G_OPTION_ARG_NONE, &unlocked, + "Don't start with screen locked", NULL}, + { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } + }; + + opt_context = g_option_context_new ("- A phone graphical shell"); + g_option_context_add_main_entries (opt_context, options, NULL); + g_option_context_add_group (opt_context, gtk_get_option_group (TRUE)); + g_option_context_parse (opt_context, &argc, &argv, &err); + + textdomain (GETTEXT_PACKAGE); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + gtk_init (&argc, &argv); + + sigterm = g_unix_signal_source_new (SIGTERM); + context = g_main_context_default (); + g_source_set_callback (sigterm, sigterm_cb, NULL, NULL); + g_source_attach (sigterm, context); + + wl = phosh_wayland_get_default (); + shell = phosh_shell_get_default (); + if (!unlocked) + phosh_shell_lock (shell); + + gtk_main (); + + return EXIT_SUCCESS; +} diff --git a/src/meson.build b/src/meson.build index f7eeef181..ad2ef3d25 100644 --- a/src/meson.build +++ b/src/meson.build @@ -29,6 +29,7 @@ phosh_sources = [ 'lockscreen-manager.h', 'lockshield.c', 'lockshield.h', + 'main.c', 'monitor-manager.c', 'monitor-manager.h', 'system-prompt.c', diff --git a/src/phosh.c b/src/phosh.c index 927bd5c94..5659e5699 100644 --- a/src/phosh.c +++ b/src/phosh.c @@ -637,54 +637,3 @@ phosh_shell_get_default (void) } return instance; } - - -static gboolean -sigterm_cb (gpointer unused) -{ - g_debug ("Cleaning up"); - gtk_main_quit (); - return FALSE; -} - - -int main(int argc, char *argv[]) -{ - g_autoptr(GSource) sigterm = NULL; - GMainContext *context = NULL; - g_autoptr(GOptionContext) opt_context = NULL; - GError *err = NULL; - gboolean unlocked = FALSE; - g_autoptr(PhoshWayland) wl = NULL; - g_autoptr(PhoshShell) shell = NULL; - - const GOptionEntry options [] = { - {"unlocked", 'U', 0, G_OPTION_ARG_NONE, &unlocked, - "Don't start with screen locked", NULL}, - { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } - }; - - opt_context = g_option_context_new ("- A phone graphical shell"); - g_option_context_add_main_entries (opt_context, options, NULL); - g_option_context_add_group (opt_context, gtk_get_option_group (TRUE)); - g_option_context_parse (opt_context, &argc, &argv, &err); - - textdomain (GETTEXT_PACKAGE); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - gtk_init (&argc, &argv); - - sigterm = g_unix_signal_source_new (SIGTERM); - context = g_main_context_default (); - g_source_set_callback (sigterm, sigterm_cb, NULL, NULL); - g_source_attach (sigterm, context); - - wl = phosh_wayland_get_default (); - shell = phosh_shell_get_default (); - if (!unlocked) - phosh_shell_lock (shell); - - gtk_main (); - - return EXIT_SUCCESS; -} -- GitLab From c05917b41bdd991418be63a9ac51a1d0623fa798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 13 Sep 2018 15:40:37 +0200 Subject: [PATCH 2/2] Rename phosh to shell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This matches the GObject in that file. Signed-off-by: Guido Günther --- src/app.c | 2 +- src/background.c | 2 +- src/favorites.c | 2 +- src/lockscreen-manager.c | 2 +- src/main.c | 2 +- src/meson.build | 4 ++-- src/monitor-manager.c | 2 +- src/settings.c | 2 +- src/{phosh.c => shell.c} | 2 +- src/{phosh.h => shell.h} | 0 src/system-prompter.c | 2 +- tests/phoshstub.c | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) rename src/{phosh.c => shell.c} (99%) rename src/{phosh.h => shell.h} (100%) diff --git a/src/app.c b/src/app.c index 12e52dc86..363438c57 100644 --- a/src/app.c +++ b/src/app.c @@ -8,7 +8,7 @@ #include "config.h" #include "app.h" -#include "phosh.h" +#include "shell.h" #include diff --git a/src/background.c b/src/background.c index f2c783e41..c326f1b45 100644 --- a/src/background.c +++ b/src/background.c @@ -8,7 +8,7 @@ #define G_LOG_DOMAIN "phosh-background" #include "background.h" -#include "phosh.h" +#include "shell.h" #include "panel.h" #include diff --git a/src/favorites.c b/src/favorites.c index e8b66de03..ec11a235b 100644 --- a/src/favorites.c +++ b/src/favorites.c @@ -14,7 +14,7 @@ #include "favorites.h" #include "app.h" -#include "phosh.h" +#include "shell.h" #include "phosh-private-client-protocol.h" #include "phosh-wayland.h" diff --git a/src/lockscreen-manager.c b/src/lockscreen-manager.c index 72dcc98de..df457f299 100644 --- a/src/lockscreen-manager.c +++ b/src/lockscreen-manager.c @@ -9,7 +9,7 @@ #include "lockscreen-manager.h" #include "lockscreen.h" #include "lockshield.h" -#include "phosh.h" +#include "shell.h" #include "monitor-manager.h" #include "monitor/monitor.h" #include "phosh-wayland.h" diff --git a/src/main.c b/src/main.c index 735a1f61e..30b0c568e 100644 --- a/src/main.c +++ b/src/main.c @@ -8,7 +8,7 @@ #include "config.h" -#include "phosh.h" +#include "shell.h" #include "phosh-wayland.h" #include diff --git a/src/meson.build b/src/meson.build index ad2ef3d25..96cb56687 100644 --- a/src/meson.build +++ b/src/meson.build @@ -32,14 +32,14 @@ phosh_sources = [ 'main.c', 'monitor-manager.c', 'monitor-manager.h', + 'shell.c', + 'shell.h', 'system-prompt.c', 'system-prompt.h', 'system-prompter.c', 'system-prompter.h', 'panel.c', 'panel.h', - 'phosh.c', - 'phosh.h', 'phosh-wayland.c', 'phosh-wayland.h', 'settings.c', diff --git a/src/monitor-manager.c b/src/monitor-manager.c index d51928ee7..bf6d0fcc3 100644 --- a/src/monitor-manager.c +++ b/src/monitor-manager.c @@ -13,7 +13,7 @@ #include "gamma-control-client-protocol.h" #include "phosh-wayland.h" -#include "phosh.h" +#include "shell.h" #include diff --git a/src/settings.c b/src/settings.c index 02284f834..95bd085f5 100644 --- a/src/settings.c +++ b/src/settings.c @@ -9,7 +9,7 @@ #include -#include "phosh.h" +#include "shell.h" #include "settings.h" #include "settings/brightness.h" diff --git a/src/phosh.c b/src/shell.c similarity index 99% rename from src/phosh.c rename to src/shell.c index 5659e5699..48908312d 100644 --- a/src/phosh.c +++ b/src/shell.c @@ -20,7 +20,7 @@ #include #include "config.h" -#include "phosh.h" +#include "shell.h" #include "phosh-wayland.h" #include "monitor/monitor.h" diff --git a/src/phosh.h b/src/shell.h similarity index 100% rename from src/phosh.h rename to src/shell.h diff --git a/src/system-prompter.c b/src/system-prompter.c index be90dd954..f7c04e6d2 100644 --- a/src/system-prompter.c +++ b/src/system-prompter.c @@ -10,7 +10,7 @@ #include "system-prompt.h" #include "system-prompter.h" -#include "phosh.h" +#include "shell.h" #include "phosh-wayland.h" /** diff --git a/tests/phoshstub.c b/tests/phoshstub.c index ea6010ab5..96ac92c73 100644 --- a/tests/phoshstub.c +++ b/tests/phoshstub.c @@ -2,7 +2,7 @@ #include #include "phosh-wayland.h" -#include "phosh.h" +#include "shell.h" PhoshShell* phosh_shell_get_default (void) -- GitLab