[Xfce4-commits] [apps/xfce4-terminal] 01/01: Add an option to use system theme colors

noreply at xfce.org noreply at xfce.org
Fri Feb 22 20:33:22 CET 2019


This is an automated email from the git hooks/post-receive script.

f   2   4   0   4       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-terminal.

commit 6cd4fcb05c8503676097eb2658bd3f056aeaa556
Author: Igor <f2404 at yandex.ru>
Date:   Fri Feb 22 14:31:58 2019 -0500

    Add an option to use system theme colors
    
    For text (foreground) and background.
    
    Fixes bug #14808
---
 terminal/terminal-preferences-dialog.c | 15 ++++++++++++++-
 terminal/terminal-preferences.c        | 11 +++++++++++
 terminal/terminal-preferences.glade    | 18 +++++++++++++++++-
 terminal/terminal-screen.c             | 34 ++++++++++++++++++++++++++++++++--
 4 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c
index e2081b0..13c3227 100644
--- a/terminal/terminal-preferences-dialog.c
+++ b/terminal/terminal-preferences-dialog.c
@@ -182,7 +182,7 @@ terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog)
                                        "binding-backspace", "binding-delete",
                                        "binding-ambiguous-width", "background-mode",
                                        "background-image-style", "color-background-vary",
-                                       "color-bold-is-bright",
+                                       "color-bold-is-bright", "color-use-theme",
                                        "dropdown-keep-open-default", "dropdown-keep-above",
                                        "dropdown-toggle-focus", "dropdown-status-icon",
                                        "dropdown-move-to-active", "dropdown-always-show-tabs",
@@ -381,6 +381,19 @@ error:
     gtk_scale_add_mark (GTK_SCALE (object), i, GTK_POS_BOTTOM, NULL);
 
   /* inverted custom colors and set sensitivity */
+  object = gtk_builder_get_object (GTK_BUILDER (dialog), "color-use-theme");
+  terminal_return_if_fail (G_IS_OBJECT (object));
+  object2 = gtk_builder_get_object (GTK_BUILDER (dialog), "color-foreground");
+  terminal_return_if_fail (G_IS_OBJECT (object2));
+  g_object_bind_property (object, "active",
+                          object2, "sensitive",
+                          G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE);
+  object2 = gtk_builder_get_object (GTK_BUILDER (dialog), "color-background");
+  terminal_return_if_fail (G_IS_OBJECT (object2));
+  g_object_bind_property (object, "active",
+                          object2, "sensitive",
+                          G_BINDING_INVERT_BOOLEAN | G_BINDING_SYNC_CREATE);
+
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "color-cursor-custom");
   terminal_return_if_fail (G_IS_OBJECT (object));
   g_object_bind_property (G_OBJECT (dialog->preferences), "color-cursor-use-default",
diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index 9c25447..8b11f68 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -64,6 +64,7 @@ enum
   PROP_COLOR_BOLD_USE_DEFAULT,
   PROP_COLOR_PALETTE,
   PROP_COLOR_BOLD_IS_BRIGHT,
+  PROP_COLOR_USE_THEME,
   PROP_COMMAND_LOGIN_SHELL,
   PROP_COMMAND_UPDATE_RECORDS,
   PROP_RUN_CUSTOM_COMMAND,
@@ -543,6 +544,16 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
+   * TerminalPreferences:color-use-theme:
+   **/
+  preferences_props[PROP_COLOR_USE_THEME] =
+      g_param_spec_boolean ("color-use-theme",
+                            NULL,
+                            "ColorUseTheme",
+                            FALSE,
+                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
+  /**
    * TerminalPreferences:tab-activity-color:
    **/
   preferences_props[PROP_TAB_ACTIVITY_COLOR] =
diff --git a/terminal/terminal-preferences.glade b/terminal/terminal-preferences.glade
index 9ba3ea3..e9c1670 100644
--- a/terminal/terminal-preferences.glade
+++ b/terminal/terminal-preferences.glade
@@ -2393,6 +2393,22 @@ or not supported by your Window Manager.</property>
                           </packing>
                         </child>
                         <child>
+                          <object class="GtkCheckButton" id="color-use-theme">
+                            <property name="label" translatable="yes">_Use system theme colors for text and background</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">2</property>
+                            <property name="width">6</property>
+                          </packing>
+                        </child>
+                        <child>
                           <object class="GtkCheckButton" id="color-background-vary">
                             <property name="label" translatable="yes">_Vary the background color for each tab</property>
                             <property name="visible">True</property>
@@ -2405,7 +2421,7 @@ or not supported by your Window Manager.</property>
                           </object>
                           <packing>
                             <property name="left_attach">0</property>
-                            <property name="top_attach">2</property>
+                            <property name="top_attach">3</property>
                             <property name="width">6</property>
                           </packing>
                         </child>
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index da88239..0be37e7 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -102,6 +102,7 @@ static void       terminal_screen_set_property                  (GObject
                                                                  GParamSpec            *pspec);
 static void       terminal_screen_realize                       (GtkWidget             *widget);
 static void       terminal_screen_unrealize                     (GtkWidget             *widget);
+static void       terminal_screen_style_updated                 (GtkWidget             *widget);
 static gboolean   terminal_screen_draw                          (GtkWidget             *widget,
                                                                  cairo_t               *cr,
                                                                  gpointer               user_data);
@@ -227,6 +228,7 @@ terminal_screen_class_init (TerminalScreenClass *klass)
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
   gtkwidget_class->realize = terminal_screen_realize;
   gtkwidget_class->unrealize = terminal_screen_unrealize;
+  gtkwidget_class->style_updated = terminal_screen_style_updated;
 
   /**
    * TerminalScreen:custom-title:
@@ -513,6 +515,16 @@ terminal_screen_unrealize (GtkWidget *widget)
 
 
 
+static void
+terminal_screen_style_updated (GtkWidget *widget)
+{
+  (*GTK_WIDGET_CLASS (terminal_screen_parent_class)->style_updated) (widget);
+
+  terminal_screen_update_colors (TERMINAL_SCREEN (widget));
+}
+
+
+
 static gboolean
 terminal_screen_draw (GtkWidget *widget,
                       cairo_t   *cr,
@@ -1025,6 +1037,9 @@ terminal_screen_update_colors (TerminalScreen *screen)
   gdouble    hsv[N_HSV];
   gdouble    sat_min, sat_max;
   gboolean   bold_is_bright;
+  gboolean   use_theme;
+
+  GtkStyleContext *context = gtk_widget_get_style_context (gtk_widget_get_toplevel (GTK_WIDGET (screen)));
 
   g_object_get (screen->preferences,
                 "color-palette", &palette_str,
@@ -1033,6 +1048,7 @@ terminal_screen_update_colors (TerminalScreen *screen)
                 "color-bold-use-default", &bold_use_default,
                 "color-background-vary", &vary_bg,
                 "color-bold-is-bright", &bold_is_bright,
+                "color-use-theme", &use_theme,
                 NULL);
 
   if (G_LIKELY (palette_str != NULL))
@@ -1053,12 +1069,26 @@ terminal_screen_update_colors (TerminalScreen *screen)
     }
 
   if (G_LIKELY (screen->custom_bg_color == NULL))
-    has_bg = terminal_preferences_get_color (screen->preferences, "color-background", &bg);
+    {
+      has_bg = terminal_preferences_get_color (screen->preferences, "color-background", &bg);
+      if (use_theme || !has_bg)
+        {
+          gtk_style_context_get_background_color (context, GTK_STATE_ACTIVE, &bg);
+          has_bg = TRUE;
+        }
+    }
   else
     has_bg = gdk_rgba_parse (&bg, screen->custom_bg_color);
 
   if (G_LIKELY (screen->custom_fg_color == NULL))
-    has_fg = terminal_preferences_get_color (screen->preferences, "color-foreground", &fg);
+    {
+      has_fg = terminal_preferences_get_color (screen->preferences, "color-foreground", &fg);
+      if (use_theme || !has_fg)
+        {
+          gtk_style_context_get_color (context, GTK_STATE_ACTIVE, &fg);
+          has_fg = TRUE;
+        }
+    }
   else
     has_fg = gdk_rgba_parse (&fg, screen->custom_fg_color);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list