Merge branch 'phosh-dark' into 'master'
Use dark theme when run in a Phosh session Closes #242 See merge request World/Phosh/squeekboard!482
This commit is contained in:
@ -51,8 +51,6 @@ struct squeekboard {
|
|||||||
|
|
||||||
|
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
static gboolean opt_system = FALSE;
|
|
||||||
static gchar *opt_address = NULL;
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
quit (void)
|
quit (void)
|
||||||
@ -247,9 +245,50 @@ session_register(void) {
|
|||||||
g_signal_connect (_client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), NULL);
|
g_signal_connect (_client_proxy, "g-signal", G_CALLBACK (client_proxy_signal), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
phosh_theme_init (void)
|
||||||
|
{
|
||||||
|
GtkSettings *gtk_settings;
|
||||||
|
const char *desktop;
|
||||||
|
gboolean phosh_session;
|
||||||
|
g_auto (GStrv) components = NULL;
|
||||||
|
|
||||||
|
desktop = g_getenv ("XDG_CURRENT_DESKTOP");
|
||||||
|
if (!desktop) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
components = g_strsplit (desktop, ":", -1);
|
||||||
|
phosh_session = g_strv_contains ((const char * const *)components, "Phosh");
|
||||||
|
|
||||||
|
if (!phosh_session) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_settings = gtk_settings_get_default ();
|
||||||
|
g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme", TRUE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
g_autoptr (GError) err = NULL;
|
||||||
|
g_autoptr(GOptionContext) opt_context = NULL;
|
||||||
|
|
||||||
|
const GOptionEntry options [] = {
|
||||||
|
{ NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
|
||||||
|
};
|
||||||
|
opt_context = g_option_context_new ("- A on screen keyboard");
|
||||||
|
|
||||||
|
g_option_context_add_main_entries (opt_context, options, NULL);
|
||||||
|
g_option_context_add_group (opt_context, gtk_get_option_group (TRUE));
|
||||||
|
if (!g_option_context_parse (opt_context, &argc, &argv, &err)) {
|
||||||
|
g_warning ("%s", err->message);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!gtk_init_check (&argc, &argv)) {
|
if (!gtk_init_check (&argc, &argv)) {
|
||||||
g_printerr ("Can't init GTK\n");
|
g_printerr ("Can't init GTK\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
@ -257,6 +296,8 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
eek_init ();
|
eek_init ();
|
||||||
|
|
||||||
|
phosh_theme_init ();
|
||||||
|
|
||||||
// Set up Wayland
|
// Set up Wayland
|
||||||
gdk_set_allowed_backends ("wayland");
|
gdk_set_allowed_backends ("wayland");
|
||||||
GdkDisplay *gdk_display = gdk_display_get_default ();
|
GdkDisplay *gdk_display = gdk_display_get_default ();
|
||||||
@ -301,46 +342,12 @@ main (int argc, char **argv)
|
|||||||
// TODO: make dbus errors non-always-fatal
|
// TODO: make dbus errors non-always-fatal
|
||||||
// dbus is not strictly necessary for the useful operation
|
// dbus is not strictly necessary for the useful operation
|
||||||
// if text-input is used, as it can bring the keyboard in and out
|
// if text-input is used, as it can bring the keyboard in and out
|
||||||
GBusType bus_type;
|
|
||||||
if (opt_system) {
|
|
||||||
bus_type = G_BUS_TYPE_SYSTEM;
|
|
||||||
} else if (opt_address) {
|
|
||||||
bus_type = G_BUS_TYPE_NONE;
|
|
||||||
} else {
|
|
||||||
bus_type = G_BUS_TYPE_SESSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
GDBusConnection *connection = NULL;
|
GDBusConnection *connection = NULL;
|
||||||
GError *error = NULL;
|
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &err);
|
||||||
switch (bus_type) {
|
if (connection == NULL) {
|
||||||
case G_BUS_TYPE_SYSTEM:
|
g_printerr ("Can't connect to the bus: %s. "
|
||||||
case G_BUS_TYPE_SESSION:
|
"Visibility switching unavailable.", err->message);
|
||||||
error = NULL;
|
|
||||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
|
||||||
if (connection == NULL) {
|
|
||||||
g_printerr ("Can't connect to the bus: %s. "
|
|
||||||
"Visibility switching unavailable.", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case G_BUS_TYPE_NONE:
|
|
||||||
error = NULL;
|
|
||||||
connection = g_dbus_connection_new_for_address_sync (opt_address,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
if (connection == NULL) {
|
|
||||||
g_printerr ("Can't connect to the bus at %s: %s\n",
|
|
||||||
opt_address,
|
|
||||||
error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
g_assert_not_reached ();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
guint owner_id = 0;
|
guint owner_id = 0;
|
||||||
DBusHandler *service = NULL;
|
DBusHandler *service = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user