[vte/vte-next: 76/114] Make 'cursor-shape' a style property



commit c09c2465b072de06f81191225d7da785419f39a4
Author: Christian Persch <chpe gnome org>
Date:   Tue May 17 21:44:21 2011 +0200

    Make 'cursor-shape' a style property

 doc/reference/vte-sections.txt |    2 -
 src/vte.c                      |   90 ++++++++++-----------------------------
 src/vte.h                      |    5 --
 src/vteapp.c                   |   12 +++---
 4 files changed, 29 insertions(+), 80 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 67278f3..19830b5 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -36,8 +36,6 @@ vte_terminal_set_default_colors
 vte_terminal_get_background_pattern
 vte_terminal_set_background_pattern
 vte_terminal_set_scroll_background
-vte_terminal_set_cursor_shape
-vte_terminal_get_cursor_shape
 vte_terminal_get_cursor_blink_mode
 vte_terminal_set_cursor_blink_mode
 vte_terminal_set_scrollback_lines
diff --git a/src/vte.c b/src/vte.c
index 9e7ec6a..b412dae 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -141,7 +141,6 @@ enum {
         PROP_BACKGROUND_PATTERN,
         PROP_BACKSPACE_BINDING,
         PROP_CURSOR_BLINK_MODE,
-        PROP_CURSOR_SHAPE,
         PROP_DELETE_BINDING,
         PROP_EMULATION,
         PROP_ENCODING,
@@ -4238,12 +4237,14 @@ vte_terminal_update_style(VteTerminal *terminal)
         GtkWidget *widget = &terminal->widget;
         float aspect;
         gboolean allow_bold;
+        int cursor_shape;
 
         vte_terminal_set_font(terminal, pvt->fontdesc);
         vte_terminal_set_padding(terminal);
 
         gtk_widget_style_get(widget,
                              "allow-bold", &allow_bold,
+                             "cursor-shape", &cursor_shape,
                              "cursor-aspect-ratio", &aspect,
                              NULL);
 
@@ -4252,6 +4253,11 @@ vte_terminal_update_style(VteTerminal *terminal)
                 _vte_invalidate_all (terminal);
         }
 
+        if ((VteTerminalCursorShape)cursor_shape != pvt->cursor_shape) {
+                pvt->cursor_shape = (VteTerminalCursorShape)cursor_shape;
+                _vte_invalidate_cursor_once(terminal, FALSE);
+        }
+
         if (aspect != pvt->cursor_aspect_ratio) {
                 pvt->cursor_aspect_ratio = aspect;
                 _vte_invalidate_cursor_once(terminal, FALSE);
@@ -10574,9 +10580,6 @@ vte_terminal_get_property (GObject *object,
                 case PROP_CURSOR_BLINK_MODE:
                         g_value_set_enum (value, vte_terminal_get_cursor_blink_mode (terminal));
                         break;
-                case PROP_CURSOR_SHAPE:
-                        g_value_set_enum (value, vte_terminal_get_cursor_shape (terminal));
-                        break;
                 case PROP_DELETE_BINDING:
                         g_value_set_enum (value, pvt->delete_binding);
                         break;
@@ -10663,9 +10666,6 @@ vte_terminal_set_property (GObject *object,
                 case PROP_CURSOR_BLINK_MODE:
                         vte_terminal_set_cursor_blink_mode (terminal, g_value_get_enum (value));
                         break;
-                case PROP_CURSOR_SHAPE:
-                        vte_terminal_set_cursor_shape (terminal, g_value_get_enum (value));
-                        break;
                 case PROP_DELETE_BINDING:
                         vte_terminal_set_delete_binding (terminal, g_value_get_enum (value));
                         break;
@@ -11370,22 +11370,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                     VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE,
                                     VTE_CURSOR_BLINK_SYSTEM,
                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-     
-        /**
-         * VteTerminal:cursor-shape:
-         *
-         * Controls the shape of the cursor.
-         * 
-         * Since: 0.20
-         */
-        g_object_class_install_property
-                (gobject_class,
-                 PROP_CURSOR_SHAPE,
-                 g_param_spec_enum ("cursor-shape", NULL, NULL,
-                                    VTE_TYPE_TERMINAL_CURSOR_SHAPE,
-                                    VTE_CURSOR_SHAPE_BLOCK,
-                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-     
+
         /**
          * VteTerminal:delete-binding:
          *
@@ -11631,6 +11616,20 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                        TRUE,
                                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+        /**
+         * VteTerminal:cursor-shape:
+         *
+         * Controls the shape of the cursor.
+         *
+         * Since: 0.30
+         */
+        gtk_widget_class_install_style_property
+                (widget_class,
+                 g_param_spec_enum ("cursor-shape", NULL, NULL,
+                                    VTE_TYPE_TERMINAL_CURSOR_SHAPE,
+                                    VTE_CURSOR_SHAPE_BLOCK,
+                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
         /* Keybindings */
 	binding_set = gtk_binding_set_by_class(klass);
 
@@ -11648,6 +11647,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                          "VteTerminal {\n"
                                            "padding: 1 1 1 1;\n"
                                            "-VteTerminal-allow-bold: true;\n"
+                                           "-VteTerminal-cursor-shape: block;\n"
                                          "}\n",
                                          -1, NULL);
 }
@@ -12120,50 +12120,6 @@ vte_terminal_get_cursor_blink_mode(VteTerminal *terminal)
 }
 
 /**
- * vte_terminal_set_cursor_shape:
- * @terminal: a #VteTerminal
- * @shape: the #VteTerminalCursorShape to use
- *
- * Sets the shape of the cursor drawn.
- *
- * Since: 0.20
- */
-void
-vte_terminal_set_cursor_shape(VteTerminal *terminal, VteTerminalCursorShape shape)
-{
-        VteTerminalPrivate *pvt;
-
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-        pvt = terminal->pvt;
-
-        if (pvt->cursor_shape == shape)
-                return;
-
-        pvt->cursor_shape = shape;
-	_vte_invalidate_cursor_once(terminal, FALSE);
-
-        g_object_notify(G_OBJECT(terminal), "cursor-shape");
-}
-
-/**
- * vte_terminal_get_cursor_shape:
- * @terminal: a #VteTerminal
- *
- * Returns the currently set cursor shape.
- *
- * Return value: cursor shape.
- *
- * Since: 0.17.6
- */
-VteTerminalCursorShape
-vte_terminal_get_cursor_shape(VteTerminal *terminal)
-{
-        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), VTE_CURSOR_SHAPE_BLOCK);
-
-        return terminal->pvt->cursor_shape;
-}
-
-/**
  * vte_terminal_set_scrollback_lines:
  * @terminal: a #VteTerminal
  * @lines: the length of the history buffer
diff --git a/src/vte.h b/src/vte.h
index 3d2782d..7d8d970 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -259,11 +259,6 @@ void vte_terminal_set_cursor_blink_mode(VteTerminal *terminal,
 					VteTerminalCursorBlinkMode mode);
 VteTerminalCursorBlinkMode vte_terminal_get_cursor_blink_mode(VteTerminal *terminal);
 
-/* Set cursor shape */
-void vte_terminal_set_cursor_shape(VteTerminal *terminal,
-				   VteTerminalCursorShape shape);
-VteTerminalCursorShape vte_terminal_get_cursor_shape(VteTerminal *terminal);
-
 /* Set the number of scrollback lines, above or at an internal minimum. */
 void vte_terminal_set_scrollback_lines(VteTerminal *terminal, glong lines);
 
diff --git a/src/vteapp.c b/src/vteapp.c
index eb4eb95..4d96bda 100644
--- a/src/vteapp.c
+++ b/src/vteapp.c
@@ -737,7 +737,6 @@ main(int argc, char **argv)
 	GOptionContext *context;
 	GError *error = NULL;
 	VteTerminalCursorBlinkMode cursor_blink_mode = VTE_CURSOR_BLINK_SYSTEM;
-	VteTerminalCursorShape cursor_shape = VTE_CURSOR_SHAPE_BLOCK;
 	GtkPolicyType scrollbar_policy = GTK_POLICY_ALWAYS;
 	VtePtyFlags pty_flags = VTE_PTY_DEFAULT;
         GString *css_string;
@@ -765,10 +764,6 @@ main(int argc, char **argv)
 		cursor_blink_mode = parse_enum(VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE, cursor_blink_mode_string);
 		g_free(cursor_blink_mode_string);
 	}
-	if (cursor_shape_string) {
-		cursor_shape = parse_enum(VTE_TYPE_TERMINAL_CURSOR_SHAPE, cursor_shape_string);
-		g_free(cursor_shape_string);
-	}
 	if (scrollbar_policy_string) {
 		scrollbar_policy = parse_enum(GTK_TYPE_POLICY_TYPE, scrollbar_policy_string);
 		g_free(scrollbar_policy_string);
@@ -802,6 +797,12 @@ main(int argc, char **argv)
                 g_string_append_c (css_string, '\n');
         }
 
+        if (cursor_shape_string) {
+                g_string_append_printf (css_string, "VteTerminal { -VteTerminal-cursor-shape: %s; }\n",
+                                        cursor_shape_string);
+                g_free(cursor_shape_string);
+        }
+
 	if (!reverse) {
 		back.red = back.green = back.blue = 1.0; back.alpha = 1.0;
 		fore.red = fore.green = fore.blue = 0.0; fore.alpha = 1.0;
@@ -967,7 +968,6 @@ main(int argc, char **argv)
 	if (termcap != NULL) {
 		vte_terminal_set_emulation(terminal, termcap);
 	}
-	vte_terminal_set_cursor_shape(terminal, cursor_shape);
 
 	/* Set the default font. */
         if (font) {



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