aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fiv.c23
-rw-r--r--fiv.gschema.xml4
2 files changed, 20 insertions, 7 deletions
diff --git a/fiv.c b/fiv.c
index d5d2871..75ee314 100644
--- a/fiv.c
+++ b/fiv.c
@@ -1099,6 +1099,16 @@ show_help_shortcuts(void)
gtk_widget_show(window);
}
+static void
+toggle_sunlight(void)
+{
+ GtkSettings *settings = gtk_settings_get_default();
+ const char *property = "gtk-application-prefer-dark-theme";
+ gboolean set = FALSE;
+ g_object_get(settings, property, &set, NULL);
+ g_object_set(settings, property, !set, NULL);
+}
+
// Cursor keys, e.g., simply cannot be bound through accelerators
// (and GtkWidget::keynav-failed would arguably be an awful solution).
//
@@ -1116,13 +1126,8 @@ on_key_press(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event,
{
switch (event->state & gtk_accelerator_get_default_mod_mask()) {
case GDK_MOD1_MASK | GDK_SHIFT_MASK:
- if (event->keyval == GDK_KEY_D) {
- GtkSettings *settings = gtk_settings_get_default();
- const char *property = "gtk-application-prefer-dark-theme";
- gboolean set = FALSE;
- g_object_get(settings, property, &set, NULL);
- g_object_set(settings, property, !set, NULL);
- }
+ if (event->keyval == GDK_KEY_D)
+ toggle_sunlight();
break;
case GDK_CONTROL_MASK:
case GDK_CONTROL_MASK | GDK_SHIFT_MASK:
@@ -1907,6 +1912,10 @@ main(int argc, char *argv[])
gtk_icon_theme_add_resource_path(
gtk_icon_theme_get_default(), "/org/gnome/design/IconLibrary/");
+ GSettings *settings = g_settings_new(PROJECT_NS PROJECT_NAME);
+ if (g_settings_get_boolean(settings, "dark-theme"))
+ toggle_sunlight();
+
GtkCssProvider *provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(
provider, stylesheet, sizeof stylesheet - 1, NULL);
diff --git a/fiv.gschema.xml b/fiv.gschema.xml
index d52eb46..dfddfd1 100644
--- a/fiv.gschema.xml
+++ b/fiv.gschema.xml
@@ -10,5 +10,9 @@
double buffering.
</description>
</key>
+ <key name='dark-theme' type='b'>
+ <default>false</default>
+ <summary>Use a dark theme variant</summary>
+ </key>
</schema>
</schemalist>