[vte] widget: Initialize the color palette when the widget is initialized



commit f7a3c36cf36371bf0659f76cba6317c15d51a997
Author: Egmont Koblinger <egmont gmail com>
Date:   Mon Apr 14 17:19:02 2014 +0200

    widget: Initialize the color palette when the widget is initialized
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728051

 src/vte-private.h |    3 +--
 src/vte.c         |   25 ++++++++++++-------------
 2 files changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/vte-private.h b/src/vte-private.h
index 72bd232..9cc89a0 100644
--- a/src/vte-private.h
+++ b/src/vte-private.h
@@ -63,7 +63,7 @@ G_BEGIN_DECLS
  *   Colors set by SGR 256-color extension (38/48;5;index).
  *   These are direct indices into the color palette.
  *
- * 256 .. VTE_PALETTE_SIZE - 1 (261):
+ * 256 .. VTE_PALETTE_SIZE - 1 (262):
  *   Special values, such as default colors.
  *   These are direct indices into the color palette.
  *
@@ -365,7 +365,6 @@ struct _VteTerminalPrivate {
         * when realizing. */
        struct _vte_draw *draw;
 
-       gboolean palette_initialized;
        VtePaletteColor palette[VTE_PALETTE_SIZE];
 
        /* Mouse cursors. */
diff --git a/src/vte.c b/src/vte.c
index b91bb45..5a2b669 100644
--- a/src/vte.c
+++ b/src/vte.c
@@ -2226,7 +2226,11 @@ vte_terminal_new(void)
        return g_object_new(VTE_TYPE_TERMINAL, NULL);
 }
 
-/* Get the actually used color from the palette. */
+/*
+ * Get the actually used color from the palette.
+ * The return value can be NULL only if entry is one of VTE_CURSOR_BG,
+ * VTE_HIGHLIGHT_BG or VTE_HIGHLIGHT_FG.
+ */
 PangoColor *
 _vte_terminal_get_color(const VteTerminal *terminal, int entry)
 {
@@ -2635,12 +2639,7 @@ _vte_terminal_set_colors(VteTerminal *terminal,
 
                /* Set up the color entry. */
                _vte_terminal_set_color_internal(terminal, i, VTE_COLOR_SOURCE_API, unset ? NULL : &color);
-               if (!terminal->pvt->palette_initialized)
-                       terminal->pvt->palette[i].sources[VTE_COLOR_SOURCE_ESCAPE].is_set = FALSE;
        }
-
-       /* Track that we had a color palette set. */
-       terminal->pvt->palette_initialized = TRUE;
 }
 
 static PangoColor *
@@ -8132,6 +8131,7 @@ vte_terminal_init(VteTerminal *terminal)
 {
        VteTerminalPrivate *pvt;
        GtkStyleContext *context;
+       int i;
 
        _vte_debug_print(VTE_DEBUG_LIFECYCLE, "vte_terminal_init()\n");
 
@@ -8179,6 +8179,11 @@ vte_terminal_init(VteTerminal *terminal)
        pvt->screen = &terminal->pvt->normal_screen;
        _vte_terminal_set_default_attributes(terminal);
 
+       /* Set up the desired palette. */
+       vte_terminal_set_default_colors(terminal);
+       for (i = 0; i < VTE_PALETTE_SIZE; i++)
+               terminal->pvt->palette[i].sources[VTE_COLOR_SOURCE_ESCAPE].is_set = FALSE;
+
        /* Set up I/O encodings. */
         pvt->iso2022_utf8_ambiguous_width = VTE_ISO2022_DEFAULT_UTF8_AMBIGUOUS_WIDTH;
        pvt->iso2022 = _vte_iso2022_state_new(pvt->encoding,
@@ -8794,11 +8799,6 @@ vte_terminal_realize(GtkWidget *widget)
        /* Set the realized flag. */
        gtk_widget_set_realized (widget, TRUE);
 
-       /* Set up the desired palette. */
-       if (!terminal->pvt->palette_initialized) {
-               vte_terminal_set_default_colors(terminal);
-       }
-
        /* Set up input method support.  FIXME: do we need to handle the
         * "retrieve-surrounding" and "delete-surrounding" events? */
        if (terminal->pvt->im_context != NULL) {
@@ -12621,8 +12621,7 @@ vte_terminal_reset(VteTerminal *terminal,
                g_hash_table_destroy(pvt->dec_saved);
                pvt->dec_saved = g_hash_table_new(NULL, NULL);
        }
-       /* Reset the color palette. Only the 256 indexed colors, not the special ones.
-        * (XTerm doesn't reset the cursor color, the others are not alterable by escapes in vte.) */
+       /* Reset the color palette. Only the 256 indexed colors, not the special ones, as per xterm. */
        for (i = 0; i < 256; i++)
                terminal->pvt->palette[i].sources[VTE_COLOR_SOURCE_ESCAPE].is_set = FALSE;
        /* Reset the default attributes.  Reset the alternate attribute because


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