[gnome-terminal] profile: editor: Add highlight colour prefs



commit 0bca006d61d36f042ccc0631c210751696551f1d
Author: Christian Persch <chpe gnome org>
Date:   Tue Feb 16 18:59:09 2016 +0100

    profile: editor: Add highlight colour prefs
    
    Since we also just added the cursor colour prefs, we can as well
    offer prefs for all the colours VTE has API to change.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=122413

 src/org.gnome.Terminal.gschema.xml |   15 +++++++++++++
 src/profile-editor.c               |   32 ++++++++++++++++++++++++++++
 src/profile-preferences.ui         |   41 ++++++++++++++++++++++++++++++++++++
 src/terminal-schemas.h             |    3 ++
 src/terminal-screen.c              |   22 +++++++++++++++++-
 5 files changed, 111 insertions(+), 2 deletions(-)
---
diff --git a/src/org.gnome.Terminal.gschema.xml b/src/org.gnome.Terminal.gschema.xml
index 635b6c7..f4204e0 100644
--- a/src/org.gnome.Terminal.gschema.xml
+++ b/src/org.gnome.Terminal.gschema.xml
@@ -152,6 +152,21 @@
       <summary>Cursor foreground colour</summary>
       <description>Custom color for the foreground of the text character at the terminal's cursor position, 
as a color specification (can be HTML-style hex digits, or a color name such as "red"). This is ignored if 
cursor-colors-set is false.</description>
     </key>
+    <key name="highlight-colors-set" type="b">
+      <default>false</default>
+      <summary>Whether to use custom highlight colors</summary>
+      <description>If true, use the highlight colors from the profile.</description>
+    </key>
+    <key name="highlight-background-color" type="s">
+      <default>'#000000'</default>
+      <summary>Highlight background color</summary>
+      <description>Custom color of the background of the terminal's highlight, as a color specification (can 
be HTML-style hex digits, or a color name such as "red"). This is ignored if highlight-colors-set is 
false.</description>
+    </key>
+    <key name="highlight-foreground-color" type="s">
+      <default>'#ffffff'</default>
+      <summary>Highlight foreground colour</summary>
+      <description>Custom color for the foreground of the text character at the terminal's highlight 
position, as a color specification (can be HTML-style hex digits, or a color name such as "red"). This is 
ignored if highlight-colors-set is false.</description>
+    </key>
     <key name="allow-bold" type="b">
       <default>true</default>
       <summary>Whether to allow bold text</summary>
diff --git a/src/profile-editor.c b/src/profile-editor.c
index b6dbcd9..1386bf6 100644
--- a/src/profile-editor.c
+++ b/src/profile-editor.c
@@ -1028,6 +1028,38 @@ terminal_profile_edit (GSettings  *profile,
                                 (GSettingsBindGetMapping) s_to_rgba,
                                 (GSettingsBindSetMapping) rgba_to_s,
                                 NULL, NULL);
+  g_settings_bind (profile, TERMINAL_PROFILE_HIGHLIGHT_COLORS_SET_KEY,
+                   gtk_builder_get_object (builder,
+                                           "highlight-colors-checkbutton"),
+                   "active", G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
+  g_settings_bind (profile, TERMINAL_PROFILE_HIGHLIGHT_COLORS_SET_KEY,
+                   gtk_builder_get_object (builder,
+                                           "highlight-foreground-colorpicker"),
+                   "sensitive",
+                   G_SETTINGS_BIND_GET |
+                   G_SETTINGS_BIND_NO_SENSITIVITY);
+  g_settings_bind (profile, TERMINAL_PROFILE_HIGHLIGHT_COLORS_SET_KEY,
+                   gtk_builder_get_object (builder,
+                                           "highlight-background-colorpicker"),
+                   "sensitive",
+                   G_SETTINGS_BIND_GET |
+                   G_SETTINGS_BIND_NO_SENSITIVITY);
+  g_settings_bind_with_mapping (profile, TERMINAL_PROFILE_HIGHLIGHT_FOREGROUND_COLOR_KEY,
+                                gtk_builder_get_object (builder,
+                                                        "highlight-foreground-colorpicker"),
+                                "rgba",
+                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET | G_SETTINGS_BIND_NO_SENSITIVITY,
+                                (GSettingsBindGetMapping) s_to_rgba,
+                                (GSettingsBindSetMapping) rgba_to_s,
+                                NULL, NULL);
+  g_settings_bind_with_mapping (profile, TERMINAL_PROFILE_HIGHLIGHT_BACKGROUND_COLOR_KEY,
+                                gtk_builder_get_object (builder,
+                                                        "highlight-background-colorpicker"),
+                                "rgba",
+                                G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET | G_SETTINGS_BIND_NO_SENSITIVITY,
+                                (GSettingsBindGetMapping) s_to_rgba,
+                                (GSettingsBindSetMapping) rgba_to_s,
+                                NULL, NULL);
   g_settings_bind_with_mapping (profile, TERMINAL_PROFILE_CURSOR_SHAPE_KEY,
                                 gtk_builder_get_object (builder,
                                                         "cursor-shape-combobox"),
diff --git a/src/profile-preferences.ui b/src/profile-preferences.ui
index 3bfbeb4..9c00946 100644
--- a/src/profile-preferences.ui
+++ b/src/profile-preferences.ui
@@ -947,6 +947,7 @@
                                         <property name="label" translatable="yes">_Underline 
color:</property>
                                         <property name="can_focus">True</property>
                                         <property name="receives_default">False</property>
+                                        <property name="halign">start</property>
                                         <property name="use_underline">True</property>
                                         <property name="xalign">0</property>
                                         <property name="draw_indicator">True</property>
@@ -962,6 +963,7 @@
                                         <property name="visible">True</property>
                                         <property name="can_focus">True</property>
                                         <property name="receives_default">False</property>
+                                        <property name="halign">start</property>
                                         <property name="use_underline">True</property>
                                         <property name="xalign">0</property>
                                         <property name="draw_indicator">True</property>
@@ -972,6 +974,45 @@
                                       </packing>
                                     </child>
                                     <child>
+                                      <object class="GtkCheckButton" id="highlight-colors-checkbutton">
+                                        <property name="label" translatable="yes">_Highlight 
color:</property>
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">False</property>
+                                        <property name="halign">start</property>
+                                        <property name="use_underline">True</property>
+                                        <property name="draw_indicator">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">0</property>
+                                        <property name="top_attach">5</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkColorButton" id="highlight-foreground-colorpicker">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="halign">start</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">1</property>
+                                        <property name="top_attach">5</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkColorButton" id="highlight-background-colorpicker">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <property name="halign">start</property>
+                                      </object>
+                                      <packing>
+                                        <property name="left_attach">2</property>
+                                        <property name="top_attach">5</property>
+                                      </packing>
+                                    </child>
+                                    <child>
                                       <placeholder/>
                                     </child>
                                     <child>
diff --git a/src/terminal-schemas.h b/src/terminal-schemas.h
index 941b342..4b734a3 100644
--- a/src/terminal-schemas.h
+++ b/src/terminal-schemas.h
@@ -50,6 +50,9 @@ G_BEGIN_DECLS
 #define TERMINAL_PROFILE_EXIT_ACTION_KEY                "exit-action"
 #define TERMINAL_PROFILE_FONT_KEY                       "font"
 #define TERMINAL_PROFILE_FOREGROUND_COLOR_KEY           "foreground-color"
+#define TERMINAL_PROFILE_HIGHLIGHT_COLORS_SET_KEY       "highlight-colors-set"
+#define TERMINAL_PROFILE_HIGHLIGHT_BACKGROUND_COLOR_KEY "highlight-background-color"
+#define TERMINAL_PROFILE_HIGHLIGHT_FOREGROUND_COLOR_KEY "highlight-foreground-color"
 #define TERMINAL_PROFILE_LOGIN_SHELL_KEY                "login-shell"
 #define TERMINAL_PROFILE_NAME_KEY                       "name"
 #define TERMINAL_PROFILE_PALETTE_KEY                    "palette"
diff --git a/src/terminal-screen.c b/src/terminal-screen.c
index 7c94aac..e34f749 100644
--- a/src/terminal-screen.c
+++ b/src/terminal-screen.c
@@ -850,6 +850,9 @@ terminal_screen_profile_changed_cb (GSettings     *profile,
       prop_name == I_(TERMINAL_PROFILE_CURSOR_COLORS_SET_KEY) ||
       prop_name == I_(TERMINAL_PROFILE_CURSOR_BACKGROUND_COLOR_KEY) ||
       prop_name == I_(TERMINAL_PROFILE_CURSOR_FOREGROUND_COLOR_KEY) ||
+      prop_name == I_(TERMINAL_PROFILE_HIGHLIGHT_COLORS_SET_KEY) ||
+      prop_name == I_(TERMINAL_PROFILE_HIGHLIGHT_BACKGROUND_COLOR_KEY) ||
+      prop_name == I_(TERMINAL_PROFILE_HIGHLIGHT_FOREGROUND_COLOR_KEY) ||
       prop_name == I_(TERMINAL_PROFILE_PALETTE_KEY))
     update_color_scheme (screen);
 
@@ -913,8 +916,12 @@ update_color_scheme (TerminalScreen *screen)
   GSettings *profile = priv->profile;
   gs_free GdkRGBA *colors;
   gsize n_colors;
-  GdkRGBA fg, bg, bold, theme_fg, theme_bg, cursor_bg, cursor_fg;
-  GdkRGBA *boldp, *cursor_bgp = NULL, *cursor_fgp = NULL;
+  GdkRGBA fg, bg, bold, theme_fg, theme_bg;
+  GdkRGBA cursor_bg, cursor_fg;
+  GdkRGBA highlight_bg, highlight_fg;
+  GdkRGBA *boldp;
+  GdkRGBA *cursor_bgp = NULL, *cursor_fgp = NULL;
+  GdkRGBA *highlight_bgp = NULL, *highlight_fgp = NULL;
   GtkStyleContext *context;
   gboolean use_theme_colors;
 
@@ -947,12 +954,23 @@ update_color_scheme (TerminalScreen *screen)
         cursor_fgp = &cursor_fg;
     }
 
+  if (g_settings_get_boolean (profile, TERMINAL_PROFILE_HIGHLIGHT_COLORS_SET_KEY) &&
+      !use_theme_colors)
+    {
+      if (terminal_g_settings_get_rgba (profile, TERMINAL_PROFILE_HIGHLIGHT_BACKGROUND_COLOR_KEY, 
&highlight_bg))
+        highlight_bgp = &highlight_bg;
+      if (terminal_g_settings_get_rgba (profile, TERMINAL_PROFILE_HIGHLIGHT_FOREGROUND_COLOR_KEY, 
&highlight_fg))
+        highlight_fgp = &highlight_fg;
+    }
+
   colors = terminal_g_settings_get_rgba_palette (priv->profile, TERMINAL_PROFILE_PALETTE_KEY, &n_colors);
   vte_terminal_set_colors (VTE_TERMINAL (screen), &fg, &bg,
                            colors, n_colors);
   vte_terminal_set_color_bold (VTE_TERMINAL (screen), boldp);
   vte_terminal_set_color_cursor (VTE_TERMINAL (screen), cursor_bgp);
   vte_terminal_set_color_cursor_foreground (VTE_TERMINAL (screen), cursor_fgp);
+  vte_terminal_set_color_highlight (VTE_TERMINAL (screen), highlight_bgp);
+  vte_terminal_set_color_highlight_foreground (VTE_TERMINAL (screen), highlight_fgp);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]