[vte/vte-next: 92/223] Make 'cursor-blink-mode' a style property



commit 1d7a555abb3ee23c3e252eeb99a785c356926a98
Author: Christian Persch <chpe gnome org>
Date:   Sun May 22 23:11:09 2011 +0200

    Make 'cursor-blink-mode' a style property

 doc/reference/vte-sections.txt |    2 -
 src/vte.c                      |  158 ++++++++++++++++------------------------
 src/vte.h                      |    5 -
 src/vteapp.c                   |   11 +--
 4 files changed, 67 insertions(+), 109 deletions(-)
---
diff --git a/doc/reference/vte-sections.txt b/doc/reference/vte-sections.txt
index 2dacbed..e383b46 100644
--- a/doc/reference/vte-sections.txt
+++ b/doc/reference/vte-sections.txt
@@ -27,8 +27,6 @@ vte_terminal_set_scroll_on_output
 vte_terminal_set_scroll_on_keystroke
 vte_terminal_get_background_pattern
 vte_terminal_set_background_pattern
-vte_terminal_get_cursor_blink_mode
-vte_terminal_set_cursor_blink_mode
 vte_terminal_set_scrollback_lines
 vte_terminal_set_font
 vte_terminal_set_font_from_string
diff --git a/src/vte.c b/src/vte.c
index 9b183ec..c6978bc 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -140,7 +140,6 @@ enum {
         PROP_AUDIBLE_BELL,
         PROP_BACKGROUND_PATTERN,
         PROP_BACKSPACE_BINDING,
-        PROP_CURSOR_BLINK_MODE,
         PROP_DELETE_BINDING,
         PROP_EMULATION,
         PROP_ENCODING,
@@ -4193,28 +4192,38 @@ vte_terminal_update_style_colors(VteTerminal *terminal,
 }
 
 static void
-vte_terminal_update_style(VteTerminal *terminal)
+vte_terminal_update_cursor_style(VteTerminal *terminal)
 {
         VteTerminalPrivate *pvt = terminal->pvt;
         GtkWidget *widget = &terminal->widget;
         float aspect;
-        gboolean allow_bold, scroll_background;
-        int cursor_shape;
-
-        vte_terminal_set_font(terminal, pvt->fontdesc);
-        vte_terminal_set_padding(terminal);
-        vte_terminal_update_style_colors(terminal, FALSE);
+        int cursor_shape, blink_mode;
+        gboolean blinks;
 
         gtk_widget_style_get(widget,
-                             "allow-bold", &allow_bold,
+                             "cursor-blink-mode", &blink_mode,
                              "cursor-shape", &cursor_shape,
                              "cursor-aspect-ratio", &aspect,
-                             "scroll-background", &scroll_background,
                              NULL);
 
-        if (allow_bold != pvt->allow_bold) {
-                pvt->allow_bold = allow_bold;
-                _vte_invalidate_all (terminal);
+        if ((VteTerminalCursorBlinkMode)blink_mode != pvt->cursor_blink_mode) {
+                pvt->cursor_blink_mode = (VteTerminalCursorBlinkMode)blink_mode;
+
+                switch ((VteTerminalCursorBlinkMode)blink_mode) {
+                case VTE_CURSOR_BLINK_SYSTEM:
+                        g_object_get(gtk_widget_get_settings(GTK_WIDGET(terminal)),
+                                                             "gtk-cursor-blink", &blinks,
+                                                             NULL);
+                        break;
+                case VTE_CURSOR_BLINK_ON:
+                        blinks = TRUE;
+                        break;
+                case VTE_CURSOR_BLINK_OFF:
+                        blinks = FALSE;
+                        break;
+                }
+
+                vte_terminal_set_cursor_blinks_internal(terminal, blinks);
         }
 
         if ((VteTerminalCursorShape)cursor_shape != pvt->cursor_shape) {
@@ -4226,6 +4235,29 @@ vte_terminal_update_style(VteTerminal *terminal)
                 pvt->cursor_aspect_ratio = aspect;
                 _vte_invalidate_cursor_once(terminal, FALSE);
         }
+}
+
+static void
+vte_terminal_update_style(VteTerminal *terminal)
+{
+        VteTerminalPrivate *pvt = terminal->pvt;
+        GtkWidget *widget = &terminal->widget;
+        gboolean allow_bold, scroll_background;
+
+        vte_terminal_set_font(terminal, pvt->fontdesc);
+        vte_terminal_set_padding(terminal);
+        vte_terminal_update_style_colors(terminal, FALSE);
+        vte_terminal_update_cursor_style(terminal);
+
+        gtk_widget_style_get(widget,
+                             "allow-bold", &allow_bold,
+                             "scroll-background", &scroll_background,
+                             NULL);
+
+        if (allow_bold != pvt->allow_bold) {
+                pvt->allow_bold = allow_bold;
+                _vte_invalidate_all (terminal);
+        }
 
         if (scroll_background != pvt->scroll_background) {
                   pvt->scroll_background = scroll_background;
@@ -10542,9 +10574,6 @@ vte_terminal_get_property (GObject *object,
                 case PROP_BACKSPACE_BINDING:
                         g_value_set_enum (value, pvt->backspace_binding);
                         break;
-                case PROP_CURSOR_BLINK_MODE:
-                        g_value_set_enum (value, vte_terminal_get_cursor_blink_mode (terminal));
-                        break;
                 case PROP_DELETE_BINDING:
                         g_value_set_enum (value, pvt->delete_binding);
                         break;
@@ -10625,9 +10654,6 @@ vte_terminal_set_property (GObject *object,
                 case PROP_BACKSPACE_BINDING:
                         vte_terminal_set_backspace_binding (terminal, g_value_get_enum (value));
                         break;
-                case PROP_CURSOR_BLINK_MODE:
-                        vte_terminal_set_cursor_blink_mode (terminal, g_value_get_enum (value));
-                        break;
                 case PROP_DELETE_BINDING:
                         vte_terminal_set_delete_binding (terminal, g_value_get_enum (value));
                         break;
@@ -11315,22 +11341,6 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
         /**
-         * VteTerminal:cursor-blink-mode:
-         *
-         * Sets whether or not the cursor will blink. Using %VTE_CURSOR_BLINK_SYSTEM
-         * will use the #GtkSettings::gtk-cursor-blink setting.
-         * 
-         * Since: 0.20
-         */
-        g_object_class_install_property
-                (gobject_class,
-                 PROP_CURSOR_BLINK_MODE,
-                 g_param_spec_enum ("cursor-blink-mode", NULL, NULL,
-                                    VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE,
-                                    VTE_CURSOR_BLINK_SYSTEM,
-                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
-        /**
          * VteTerminal:delete-binding:
          *
          * Controls what string or control sequence the terminal sends to its child
@@ -11560,6 +11570,22 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                        TRUE,
                                        G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+
+        /**
+         * VteTerminal:cursor-blink-mode:
+         *
+         * Sets whether or not the cursor will blink. Using %VTE_CURSOR_BLINK_SYSTEM
+         * will use the #GtkSettings::gtk-cursor-blink setting.
+         *
+         * Since: 0.30
+         */
+        gtk_widget_class_install_style_property
+                (widget_class,
+                 g_param_spec_enum ("cursor-blink-mode", NULL, NULL,
+                                    VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE,
+                                    VTE_CURSOR_BLINK_SYSTEM,
+                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
         /**
          * VteTerminal:cursor-shape:
          *
@@ -11609,6 +11635,7 @@ vte_terminal_class_init(VteTerminalClass *klass)
                                          "VteTerminal {\n"
                                            "padding: 1 1 1 1;\n"
                                            "-VteTerminal-allow-bold: true;\n"
+                                           "-VteTerminal-cursor-blink-mode: system;\n"
                                            "-VteTerminal-cursor-shape: block;\n"
                                            "-VteTerminal-scroll-background: false;\n"
 #include "vtepalettecss.h"
@@ -11992,67 +12019,6 @@ vte_terminal_set_cursor_blinks_internal(VteTerminal *terminal, gboolean blink)
 }
 
 /**
- * vte_terminal_set_cursor_blink_mode:
- * @terminal: a #VteTerminal
- * @mode: the #VteTerminalCursorBlinkMode to use
- *
- * Sets whether or not the cursor will blink. Using %VTE_CURSOR_BLINK_SYSTEM
- * will use the #GtkSettings::gtk-cursor-blink setting.
- *
- * Since: 0.17.1
- */
-void
-vte_terminal_set_cursor_blink_mode(VteTerminal *terminal, VteTerminalCursorBlinkMode mode)
-{
-        VteTerminalPrivate *pvt;
-        gboolean blinks;
-
-	g_return_if_fail(VTE_IS_TERMINAL(terminal));
-        pvt = terminal->pvt;
-
-        if (pvt->cursor_blink_mode == mode)
-                return;
-
-        pvt->cursor_blink_mode = mode;
-
-        switch (mode) {
-          case VTE_CURSOR_BLINK_SYSTEM:
-            g_object_get(gtk_widget_get_settings(GTK_WIDGET(terminal)),
-                                                 "gtk-cursor-blink", &blinks,
-                                                 NULL);
-            break;
-          case VTE_CURSOR_BLINK_ON:
-            blinks = TRUE;
-            break;
-          case VTE_CURSOR_BLINK_OFF:
-            blinks = FALSE;
-            break;
-        }
-
-        vte_terminal_set_cursor_blinks_internal(terminal, blinks);
-
-        g_object_notify(G_OBJECT(terminal), "cursor-blink-mode");
-}
-
-/**
- * vte_terminal_get_cursor_blink_mode:
- * @terminal: a #VteTerminal
- *
- * Returns the currently set cursor blink mode.
- *
- * Return value: cursor blink mode.
- *
- * Since: 0.17.1
- */
-VteTerminalCursorBlinkMode
-vte_terminal_get_cursor_blink_mode(VteTerminal *terminal)
-{
-        g_return_val_if_fail(VTE_IS_TERMINAL(terminal), VTE_CURSOR_BLINK_SYSTEM);
-
-        return terminal->pvt->cursor_blink_mode;
-}
-
-/**
  * 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 4a5bc0b..5f04e19 100644
--- a/src/vte.h
+++ b/src/vte.h
@@ -231,11 +231,6 @@ cairo_pattern_t *vte_terminal_get_background_pattern(VteTerminal *terminal);
 void vte_terminal_set_background_pattern(VteTerminal *terminal,
                                          cairo_pattern_t *pattern);
 
-/* Set whether or not the cursor blinks. */
-void vte_terminal_set_cursor_blink_mode(VteTerminal *terminal,
-					VteTerminalCursorBlinkMode mode);
-VteTerminalCursorBlinkMode vte_terminal_get_cursor_blink_mode(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 c59262b..63103fb 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;
 	GtkPolicyType scrollbar_policy = GTK_POLICY_ALWAYS;
 	VtePtyFlags pty_flags = VTE_PTY_DEFAULT;
         GString *css_string;
@@ -761,10 +760,6 @@ main(int argc, char **argv)
 		return 1;
 	}
 
-	if (cursor_blink_mode_string) {
-		cursor_blink_mode = parse_enum(VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE, cursor_blink_mode_string);
-		g_free(cursor_blink_mode_string);
-	}
 	if (scrollbar_policy_string) {
 		scrollbar_policy = parse_enum(GTK_TYPE_POLICY_TYPE, scrollbar_policy_string);
 		g_free(scrollbar_policy_string);
@@ -808,6 +803,11 @@ main(int argc, char **argv)
                                         selection_background_color_string);
                 g_free(selection_background_color_string);
         }
+        if (cursor_blink_mode_string) {
+                g_string_append_printf (css_string, "VteTerminal { -VteTerminal-cursor-blink-mode: %s; }\n",
+                                        cursor_blink_mode_string);
+                g_free(cursor_blink_mode_string);
+        }
         if (cursor_shape_string) {
                 g_string_append_printf (css_string, "VteTerminal { -VteTerminal-cursor-shape: %s; }\n",
                                         cursor_shape_string);
@@ -925,7 +925,6 @@ main(int argc, char **argv)
 	/* Set some defaults. */
 	vte_terminal_set_audible_bell(terminal, audible);
 	vte_terminal_set_visible_bell(terminal, !audible);
-	vte_terminal_set_cursor_blink_mode(terminal, cursor_blink_mode);
 	vte_terminal_set_scroll_on_output(terminal, FALSE);
 	vte_terminal_set_scroll_on_keystroke(terminal, TRUE);
 	vte_terminal_set_scrollback_lines(terminal, lines);



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