Commit 7d5fc065 authored by Christian Persch's avatar Christian Persch
Browse files

prefs: Add pref to use dark theme variant

Now that there is gtk+ API to reset the setting, let's bring back
the pref.

Note that the pref defaults to following the global pref. If your
distribution has set a different default (e.g. by using a gsettings
override), DO NOT complain to upstream about this!

This reverts commit 5f6c514a.

https://bugzilla.gnome.org/show_bug.cgi?id=649358
https://bugzilla.gnome.org/show_bug.cgi?id=707206
https://bugzilla.gnome.org/show_bug.cgi?id=742040
https://bugzilla.gnome.org/show_bug.cgi?id=742333
https://bugzilla.gnome.org/show_bug.cgi?id=755008
parent 9ce64250
......@@ -41,6 +41,12 @@
<!-- <value nick='never' value='2'/> -->
</enum>
<enum id='org.gnome.Terminal.ThemeVariant'>
<value nick='system' value='0'/>
<value nick='light' value='1'/>
<value nick='dark' value='2'/>
</enum>
<enum id='org.gnome.Terminal.ExitAction'>
<value nick='close' value='0'/>
<value nick='restart' value='1'/>
......@@ -663,6 +669,11 @@
<summary>The position of the tab bar</summary>
</key>
<key name="theme-variant" enum="org.gnome.Terminal.ThemeVariant">
<default>'system'</default>
<summary>Which theme variant to use</summary>
</key>
<!-- <child name="profiles" schema="org.gnome.Terminal.ProfilesList" /> -->
<child name="keybindings" schema="org.gnome.Terminal.Legacy.Keybindings" />
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<requires lib="gtk+" version="3.0"/>
<object class="GtkListStore" id="new-terminal-mode-liststore">
<columns>
<!-- column-name gchararray -->
<!-- column-name label -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes" comments="Open new terminal in new window">Window</col>
<col id="1" translatable="no">window</col>
<col id="1">window</col>
</row>
<row>
<col id="0" translatable="yes" comments="Open new terminal in new tab">Tab</col>
<col id="1" translatable="no">tab</col>
<col id="1">tab</col>
</row>
</data>
</object>
<object class="GtkListStore" id="theme-variant-liststore">
<columns>
<!-- column-name label -->
<column type="gchararray"/>
<!-- column-name id -->
<column type="gchararray"/>
</columns>
<data>
<row>
<col id="0" translatable="yes" context="theme variant">Default</col>
<col id="1">system</col>
</row>
<row>
<col id="0" translatable="yes" context="theme variant">Light</col>
<col id="1">light</col>
</row>
<row>
<col id="0" translatable="yes" context="theme variant">Dark</col>
<col id="1">dark</col>
</row>
</data>
</object>
......@@ -23,7 +47,6 @@
<property name="border_width">0</property>
<property name="title" translatable="yes">Preferences</property>
<property name="role">gnome-terminal-preferences</property>
<property name="type_hint">normal</property>
<child>
<object class="GtkBox" id="dialogue-content-box">
<property name="visible">True</property>
......@@ -44,8 +67,8 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="spacing">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkCheckButton" id="default-show-menubar-checkbutton">
<property name="label" translatable="yes">Show _menubar by default in new terminals</property>
......@@ -69,7 +92,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
......@@ -87,7 +109,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
......@@ -99,11 +120,25 @@
</packing>
</child>
<child>
<object class="GtkBox" id="hbox140">
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<property name="orientation">horizontal</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="theme-variant-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Theme _variant:</property>
<property name="use_underline">True</property>
<property name="ellipsize">middle</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label480">
<property name="visible">True</property>
......@@ -113,9 +148,26 @@
<property name="mnemonic_widget">new-terminal-mode-combobox</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="theme-variant-combobox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">theme-variant-liststore</property>
<property name="id_column">1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
......@@ -123,21 +175,25 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">new-terminal-mode-liststore</property>
<property name="id-column">1</property>
<property name="id_column">1</property>
<child>
<object class="GtkCellRendererText" id="renderer1"/>
<object class="GtkCellRendererText" id="renderer2"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
......@@ -156,11 +212,9 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">12</property>
<property name="n_rows">2</property>
<property name="column_spacing">12</property>
<property name="row_spacing">6</property>
<property name="n_rows">2</property>
<property name="n_columns">1</property>
<property name="homogeneous">False</property>
<child>
<object class="GtkCheckButton" id="disable-shortcuts-checkbutton">
<property name="label" translatable="yes">_Enable shortcuts</property>
......@@ -168,17 +222,12 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options">fill</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
......@@ -199,11 +248,8 @@
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options">expand|fill</property>
</packing>
</child>
</object>
......@@ -272,7 +318,7 @@
</child>
<child>
<object class="GtkButton" id="clone-profile-button">
<property name="label" translatable="yes">_Clone</property>
<property name="label">_Clone</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
......@@ -338,9 +384,9 @@
<object class="GtkLabel" id="default-profile-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Profile used when launching a new terminal:</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -385,10 +431,10 @@
<object class="GtkLabel" id="encodings-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">E_ncodings shown in menu:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">encodings-treeview</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -412,12 +458,12 @@
<property name="headers_clickable">False</property>
<property name="rules_hint">True</property>
<property name="enable_search">False</property>
<accessibility>
<relation type="labelled-by" target="encodings-label"/>
</accessibility>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"/>
</child>
<accessibility>
<relation type="labelled-by" target="encodings-label"/>
</accessibility>
</object>
</child>
</object>
......@@ -468,9 +514,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">start</property>
<property name="position">0</property>
<property name="secondary">False</property>
</packing>
</child>
<child>
......
......@@ -56,6 +56,8 @@
#define SYSTEM_PROXY_SETTINGS_SCHEMA "org.gnome.system.proxy"
#define GTK_SETTING_PREFER_DARK_THEME "gtk-application-prefer-dark-theme"
/*
* Session state is stored entirely in the RestartCommand command line.
*
......@@ -305,6 +307,25 @@ terminal_app_encoding_list_notify_cb (GSettings *settings,
g_signal_emit (app, signals[ENCODING_LIST_CHANGED], 0);
}
#if GTK_CHECK_VERSION (3, 19, 0)
static void
terminal_app_theme_variant_changed_cb (GSettings *settings,
const char *key,
GtkSettings *gtk_settings)
{
TerminalThemeVariant theme;
theme = g_settings_get_enum (settings, key);
if (theme == TERMINAL_THEME_VARIANT_SYSTEM)
gtk_settings_reset (gtk_settings, GTK_SETTING_PREFER_DARK_THEME);
else
g_object_set (gtk_settings,
GTK_SETTING_PREFER_DARK_THEME,
theme == TERMINAL_THEME_VARIANT_DARK,
NULL);
}
#endif /* GTK+ 3.19 */
/* App menu callbacks */
static void
......@@ -410,6 +431,20 @@ terminal_app_init (TerminalApp *app)
/* Terminal global settings */
app->global_settings = g_settings_new (TERMINAL_SETTING_SCHEMA);
#if GTK_CHECK_VERSION (3, 19, 0)
{
GtkSettings *gtk_settings;
gtk_settings = gtk_settings_get_default ();
terminal_app_theme_variant_changed_cb (app->global_settings,
TERMINAL_SETTING_THEME_VARIANT_KEY, gtk_settings);
g_signal_connect (app->global_settings,
"changed::" TERMINAL_SETTING_THEME_VARIANT_KEY,
G_CALLBACK (terminal_app_theme_variant_changed_cb),
gtk_settings);
}
#endif /* GTK+ 3.19 */
/* Check if we need to migrate from gconf to dconf */
maybe_migrate_settings (app);
......
......@@ -47,6 +47,12 @@ typedef enum {
TERMINAL_CJK_WIDTH_WIDE = 2
} TerminalCJKWidth;
typedef enum {
TERMINAL_THEME_VARIANT_SYSTEM = 0,
TERMINAL_THEME_VARIANT_LIGHT = 1,
TERMINAL_THEME_VARIANT_DARK = 2
} TerminalThemeVariant;
G_END_DECLS
#endif /* TERMINAL_ENUMS_H */
......@@ -560,7 +560,7 @@ terminal_prefs_show_preferences (GtkWindow *transient_parent,
GtkWidget *show_menubar_button, *disable_mnemonics_button, *disable_menu_accel_button;
GtkWidget *disable_shortcuts_button;
GtkWidget *tree_view_container, *new_button, *edit_button, *clone_button, *remove_button;
GtkWidget *new_terminal_mode_combo;
GtkWidget *theme_variant_label, *theme_variant_combo, *new_terminal_mode_combo;
GtkWidget *default_hbox, *default_label;
GtkWidget *close_button, *help_button;
GtkTreeSelection *selection;
......@@ -584,6 +584,8 @@ terminal_prefs_show_preferences (GtkWindow *transient_parent,
"close-button", &close_button,
"help-button", &help_button,
"default-show-menubar-checkbutton", &show_menubar_button,
"theme-variant-label", &theme_variant_label,
"theme-variant-combobox", &theme_variant_combo,
"new-terminal-mode-combobox", &new_terminal_mode_combo,
"disable-mnemonics-checkbutton", &disable_mnemonics_button,
"disable-shortcuts-checkbutton", &disable_shortcuts_button,
......@@ -613,6 +615,17 @@ terminal_prefs_show_preferences (GtkWindow *transient_parent,
"active",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
#if GTK_CHECK_VERSION (3, 19, 0)
g_settings_bind (settings,
TERMINAL_SETTING_THEME_VARIANT_KEY,
theme_variant_combo,
"active-id",
G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
#else
gtk_widget_set_visible (theme_variant_label, FALSE);
gtk_widget_set_visible (theme_variant_combo, FALSE);
#endif /* GTK+ 3.19 */
g_settings_bind (settings,
TERMINAL_SETTING_NEW_TERMINAL_MODE_KEY,
new_terminal_mode_combo,
......
......@@ -74,6 +74,7 @@ G_BEGIN_DECLS
#define TERMINAL_SETTING_SHELL_INTEGRATION_KEY "shell-integration-enabled"
#define TERMINAL_SETTING_TAB_POLICY_KEY "tab-policy"
#define TERMINAL_SETTING_TAB_POSITION_KEY "tab-position"
#define TERMINAL_SETTING_THEME_VARIANT_KEY "theme-variant"
#define TERMINAL_SETTINGS_LIST_LIST_KEY "list"
#define TERMINAL_SETTINGS_LIST_DEFAULT_KEY "default"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment