#include <gtk/gtk.h>
static void
-change_theme_state (GSimpleAction *action,
+change_dark_state (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
g_simple_action_set_state (action, state);
}
+static char *current_theme;
+static gboolean current_dark;
+
+static void
+change_theme_state (GSimpleAction *action,
+ GVariant *state,
+ gpointer user_data)
+{
+ GtkSettings *settings = gtk_settings_get_default ();
+ const char *s;
+ const char *theme;
+ gboolean prefer_dark = FALSE;
+
+ s = g_variant_get_string (state, NULL);
+
+ if (strcmp (s, "adwaita") == 0)
+ {
+ theme = "Adwaita";
+ prefer_dark = FALSE;
+ }
+ else if (strcmp (s, "adwaita-dark") == 0)
+ {
+ theme = "Adwaita";
+ prefer_dark = TRUE;
+ }
+ else if (strcmp (s, "highcontrast") == 0)
+ {
+ theme = "HighContrast";
+ prefer_dark = FALSE;
+ }
+ else if (strcmp (s, "highcontrast-inverse") == 0)
+ {
+ theme = "HighContrastInverse";
+ prefer_dark = FALSE;
+ }
+ else if (strcmp (s, "current") == 0)
+ {
+ theme = current_theme;
+ prefer_dark = current_dark;
+ }
+ else
+ return;
+
+ g_object_set (G_OBJECT (settings),
+ "gtk-theme-name", theme,
+ "gtk-application-prefer-dark-theme", prefer_dark,
+ NULL);
+
+ g_simple_action_set_state (action, state);
+}
+
static GtkWidget *page_stack;
static void
GtkCssProvider *provider;
GMenuModel *model;
static GActionEntry win_entries[] = {
- { "dark", NULL, NULL, "false", change_theme_state },
+ { "dark", NULL, NULL, "false", change_dark_state },
+ { "theme", NULL, "s", "'current'", change_theme_state },
{ "transition", NULL, NULL, "false", change_transition_state },
{ "search", activate_search, NULL, NULL, NULL },
{ "delete", activate_delete, NULL, NULL, NULL },
GPermission *permission;
GAction *action;
+ g_object_get (gtk_settings_get_default (),
+ "gtk-theme-name", ¤t_theme,
+ "gtk-application-prefer-dark-theme", ¤t_dark,
+ NULL);
+
g_type_ensure (my_text_view_get_type ());
provider = gtk_css_provider_new ();
<attribute name="label" translatable="yes">Get Busy</attribute>
<attribute name="action">win.busy</attribute>
</item>
- <item>
- <attribute name="label" translatable="yes">Dark Theme</attribute>
- <attribute name="action">win.dark</attribute>
- </item>
+ <submenu>
+ <attribute name="label" translatable="yes">Theme</attribute>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Current theme</attribute>
+ <attribute name="action">win.theme</attribute>
+ <attribute name="target">current</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Adwaita</attribute>
+ <attribute name="action">win.theme</attribute>
+ <attribute name="target">adwaita</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Adwaita dark</attribute>
+ <attribute name="action">win.theme</attribute>
+ <attribute name="target">adwaita-dark</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">High contrast</attribute>
+ <attribute name="action">win.theme</attribute>
+ <attribute name="target">highcontrast</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">High contrast inverse</attribute>
+ <attribute name="action">win.theme</attribute>
+ <attribute name="target">highcontrast-inverse</attribute>
+ </item>
+ </section>
+ </submenu>
<item>
<attribute name="label" translatable="yes">Slide Pages</attribute>
<attribute name="action">win.transition</attribute>