diff --git a/src/app.c b/src/app.c index 12e52dc86441ddb2b0445f627dc82df3538b6442..363438c57c562e940e2a02bde5698f2fef6fa222 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 f2c783e416496665104ad770ff9bcc847fc34f49..c326f1b4530af34ad94b2c82303afbd60fd45906 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 e8b66de03e859d9137b238971840760b5ec498e4..ec11a235b8405f6f49106df8d94e46b6bb94e79f 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 72dcc98de47346d2286ed4c0d98e906c6b192744..df457f29943500c64c23fdec144a1872a4e31859 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 new file mode 100644 index 0000000000000000000000000000000000000000..30b0c568ec0646dd559b2fbe9f677d3a65353bf8 --- /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 "shell.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 f7eeef181a6d346e82f7eb195a0a7968d0e9eb8e..96cb56687efcfbd8b3bcbe56b59c688732cebe0b 100644 --- a/src/meson.build +++ b/src/meson.build @@ -29,16 +29,17 @@ phosh_sources = [ 'lockscreen-manager.h', 'lockshield.c', 'lockshield.h', + '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 d51928ee759c9cf1c8977b7ad2dea5bf0c1bb8f1..bf6d0fcc38c6687e8749184bb4d08d660450ddbe 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 02284f834327d6d5f7c54d031eb9b4bdbf91f45f..95bd085f5e372940285f2415ffa0b58ce1eaf4ba 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 92% rename from src/phosh.c rename to src/shell.c index 927bd5c9470c364e62adef56549cb4c67d7158dc..48908312d9d74d717b95cc4222572053b88def46 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" @@ -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; -} 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 be90dd9540323b8d56268790312a523dae6c1eb5..f7c04e6d2f1dea44a1937afe35cc06796eb2a7ae 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 ea6010ab5f3349b7627c74601e4944c67e9cad02..96ac92c739496d16ab82f6f67fddfba1e130ad22 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)