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



commit 169c8ae0121d91e3d98a922cd7c55b9d5061c30c
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 aef6af2..5f9bc13 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 15e8493..6b39d58 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -2529,8 +2529,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
  *
@@ -2540,23 +2540,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 = FALSE;
         }
+
+        /* FIXMEchpe: need to do any invalidation? */
 }
 
 /**
@@ -4295,6 +4295,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
@@ -11741,6 +11743,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 46fbfb3..d9a7c1d 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 2da3464..1e91796 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -549,7 +549,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;
@@ -570,7 +570,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,
@@ -624,9 +625,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,
@@ -803,6 +804,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);
@@ -820,7 +826,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);
@@ -967,9 +972,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]