[vte/vte-next] Make 'selection-background-color' a style property



commit 9c64e610ccde19020acde786fc5b8b7e4519722f
Author: Christian Persch <chpe gnome org>
Date:   Sun May 22 20:59:51 2011 +0200

    Make 'selection-background-color' a style property

 doc/reference/vte-sections.txt |    1 -
 src/vte.c                      |   31 +++++++++++++++++++++++--------
 src/vte.h                      |    2 --
 src/vteapp.c                   |   20 +++++++++++---------
 4 files changed, 34 insertions(+), 20 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 6ac6677..b9d8102 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -27,7 +27,6 @@ vte_terminal_set_scroll_on_output
 vte_terminal_set_scroll_on_keystroke
 vte_terminal_set_color_foreground_rgba
 vte_terminal_set_color_background_rgba
-vte_terminal_set_color_highlight_rgba
 vte_terminal_set_colors_rgba
 vte_terminal_set_default_colors
 vte_terminal_get_background_pattern
diff --git a/src/vte.c b/src/vte.c
index 55e7147..77fdd94 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -2531,8 +2531,8 @@ _vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
         _vte_invalidate_cursor_once(terminal, FALSE);
 }
 
-/**
- * vte_terminal_set_color_highlight_rgba:
+/*
+ *_ vte_terminal_set_color_highlight_rgba:
  * @terminal: a #VteTerminal
  * @highlight_background: (allow-none): the new color to use for highlighted text, or %NULL
  *
@@ -2542,23 +2542,23 @@ _vte_terminal_set_color_cursor_rgba(VteTerminal *terminal,
  *
  * Since: 0.28
  */
-void
-vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
-				      const GdkRGBA *rgba)
+static void
+_vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
+                                       const GdkRGBA *rgba)
 {
-        g_return_if_fail(VTE_IS_TERMINAL(terminal));
-
         if (rgba != NULL) {
                 _vte_debug_print(VTE_DEBUG_MISC,
                                 "Set highlight color to rgba(%.3f,%.3f,%.3f,%.3f).\n",
                                 rgba->red, rgba->green, rgba->blue, rgba->alpha);
-                vte_terminal_set_color_internal(terminal, VTE_DEF_HL, rgba, TRUE);
+                vte_terminal_set_color_internal(terminal, VTE_DEF_HL, rgba, FALSE);
                 terminal->pvt->highlight_color_set = TRUE;
         } else {
                 _vte_debug_print(VTE_DEBUG_MISC,
                                 "Cleared highlight color.\n");
                 terminal->pvt->highlight_color_set = TRUE;
         }
+
+        /* FIXMEchpe: need to do any invalidation? */
 }
 
 /**
@@ -4297,6 +4297,8 @@ vte_terminal_update_style_colors(VteTerminal *terminal)
           color = _vte_style_context_get_color(context, "dim-foreground-color", &rgba);
         _vte_terminal_set_color_dim_rgba(terminal, color);
 
+        color = _vte_style_context_get_color(context, "selection-background-color", &rgba);
+        _vte_terminal_set_color_highlight_rgba(terminal, color);
 }
 
 static void
@@ -11743,6 +11745,19 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                      GDK_TYPE_RGBA,
                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+        /**
+         * VteTerminal:selection-background-color:
+         *
+         * The selection background color. If unset, selected text is reversed.
+         *
+         * Since: 0.30
+         */
+        gtk_widget_class_install_style_property
+                (widget_class,
+                 g_param_spec_boxed ("selection-background-color", NULL, NULL,
+                                     GDK_TYPE_RGBA,
+                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
         /* Keybindings */
 	binding_set = gtk_binding_set_by_class(klass);
 
diff --git a/src/vte.h b/src/vte.h
index 357c376..c99e7c1 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -232,8 +232,6 @@ void vte_terminal_set_color_foreground_rgba(VteTerminal *terminal,
 					    const GdkRGBA *rgba);
 void vte_terminal_set_color_background_rgba(VteTerminal *terminal,
 					    const GdkRGBA *rgba);
-void vte_terminal_set_color_highlight_rgba(VteTerminal *terminal,
-					   const GdkRGBA *rgba);
 void vte_terminal_set_colors_rgba(VteTerminal *terminal,
 				  const GdkRGBA *foreground,
 				  const GdkRGBA *background,
diff --git a/src/vteapp.c b/src/vteapp.c
index 0db922f..28985a4 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -544,7 +544,7 @@ main(int argc, char **argv)
 	gboolean audible = TRUE,
 		 debug = FALSE, dingus = FALSE, dbuffer = TRUE,
 		 console = FALSE, scroll = FALSE, keep = FALSE,
-		 icon_title = FALSE, shell = TRUE, highlight_set = FALSE,
+		 icon_title = FALSE, shell = TRUE,
 		 reverse = FALSE, use_geometry_hints = TRUE,
 		 use_scrolled_window = FALSE,
 		 show_object_notifications = FALSE;
@@ -565,7 +565,8 @@ main(int argc, char **argv)
         char *border_width_string = NULL;
         char *css = NULL;
         char *css_file = NULL;
-	GdkRGBA fore, back, highlight, cursor;
+        char *selection_background_color_string = NULL;
+	GdkRGBA fore, back, cursor;
 	const GOptionEntry options[]={
 		{
 			"background", 'B', 0,
@@ -619,9 +620,9 @@ main(int argc, char **argv)
 			"Set the size (in characters) and position", "GEOMETRY"
 		},
 		{
-			"highlight", 'h', 0,
-			G_OPTION_ARG_NONE, &highlight_set,
-			"Enable distinct highlight color for selection", NULL
+			"selection-color", 'h', 0,
+			G_OPTION_ARG_STRING, &selection_background_color_string,
+			"Use distinct highlight color for selection", NULL
 		},
 		{
 			"icon-title", 'i', 0,
@@ -798,6 +799,11 @@ main(int argc, char **argv)
                                         cursor_color_string);
                 g_free(cursor_color_string);
         }
+        if (selection_background_color_string) {
+                g_string_append_printf (css_string, "VteTerminal { -VteTerminal-selection-background-color: %s; }\n",
+                                        selection_background_color_string);
+                g_free(selection_background_color_string);
+        }
         if (cursor_shape_string) {
                 g_string_append_printf (css_string, "VteTerminal { -VteTerminal-cursor-shape: %s; }\n",
                                         cursor_shape_string);
@@ -815,7 +821,6 @@ main(int argc, char **argv)
 		fore.red = fore.green = fore.blue = 1.0; fore.alpha = 1.0;
 	}
 
-	highlight.red = highlight.green = highlight.blue = 0.75; highlight.alpha = 1.0;
 	cursor.red = 1.0; cursor.green = cursor.blue = 0.5; cursor.alpha = 1.0;
 
 	gdk_window_set_debug_updates(debug);
@@ -962,9 +967,6 @@ main(int argc, char **argv)
         }
 
 	vte_terminal_set_colors_rgba(terminal, &fore, &back, NULL, 0);
-	if (highlight_set) {
-		vte_terminal_set_color_highlight_rgba(terminal, &highlight);
-	}
 	if (termcap != NULL) {
 		vte_terminal_set_emulation(terminal, termcap);
 	}



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