[Xfce4-commits] <terminal:master> Bundle palette colors into a single string.

Nick Schermer noreply at xfce.org
Sat Dec 22 22:22:05 CET 2012


Updating branch refs/heads/master
         to d4d09c0734fa48335496a710e184090686f159a9 (commit)
       from 3729e35d4f07595dee79f5fd736f2822e000c245 (commit)

commit d4d09c0734fa48335496a710e184090686f159a9
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Dec 21 22:24:27 2012 +0100

    Bundle palette colors into a single string.
    
    This is quicker in the code and saves a bunch of properties.

 terminal/terminal-preferences-dialog.c |  117 ++++++++++++++++-
 terminal/terminal-preferences-dialog.h |   14 --
 terminal/terminal-preferences.c        |  227 +++++++-------------------------
 terminal/terminal-screen.c             |   74 +++++------
 4 files changed, 197 insertions(+), 235 deletions(-)

diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c
index 321b9cb..8d0a5a5 100644
--- a/terminal/terminal-preferences-dialog.c
+++ b/terminal/terminal-preferences-dialog.c
@@ -36,6 +36,9 @@ static void terminal_preferences_dialog_finalize          (GObject
 static void terminal_preferences_dialog_response          (GtkWidget                 *widget,
                                                            gint                       response,
                                                            TerminalPreferencesDialog *dialog);
+static void terminal_preferences_dialog_palette_changed   (GtkWidget                 *button,
+                                                           TerminalPreferencesDialog *dialog);
+static void terminal_preferences_dialog_palette_notify    (TerminalPreferencesDialog *dialog);
 static void terminal_preferences_dialog_reset_compat      (GtkWidget                 *button,
                                                            TerminalPreferencesDialog *dialog);
 static void terminal_preferences_dialog_reset_word_chars  (GtkWidget                 *button,
@@ -52,6 +55,24 @@ static void terminal_preferences_dialog_encoding_changed  (GtkComboBox
 
 
 
+struct _TerminalPreferencesDialogClass
+{
+  GtkBuilderClass __parent__;
+};
+
+struct _TerminalPreferencesDialog
+{
+  GtkBuilder           __parent__;
+
+  TerminalPreferences *preferences;
+  GSList              *bindings;
+
+  gulong               bg_image_signal_id;
+  gulong               palette_signal_id;
+};
+
+
+
 G_DEFINE_TYPE (TerminalPreferencesDialog, terminal_preferences_dialog, GTK_TYPE_BUILDER)
 
 
@@ -101,7 +122,7 @@ terminal_preferences_dialog_init (TerminalPreferencesDialog *dialog)
                                        "shortcuts-no-mnemonics", "shortcuts-no-menukey",
                                        "binding-backspace", "binding-delete",
                                        "background-mode", "background-image-style"
-                                    };
+                                     };
   const gchar      *props_color[] =  { "color-foreground", "color-cursor",
                                        "color-background", "tab-activity-color",
                                        "color-selection"
@@ -152,9 +173,17 @@ error:
   for (i = 1; i <= 16; i++)
     {
       g_snprintf (palette_name, sizeof (palette_name), "color-palette%d", i);
-      BIND_PROPERTIES (palette_name, "color");
+      object = gtk_builder_get_object (GTK_BUILDER (dialog), palette_name);
+      terminal_return_if_fail (G_IS_OBJECT (object));
+      g_signal_connect (G_OBJECT (object), "color-set",
+          G_CALLBACK (terminal_preferences_dialog_palette_changed), dialog);
     }
 
+  /* watch color changes in property */
+  dialog->palette_signal_id = g_signal_connect_swapped (G_OBJECT (dialog->preferences),
+      "notify::color-palette", G_CALLBACK (terminal_preferences_dialog_palette_notify), dialog);
+  terminal_preferences_dialog_palette_notify (dialog);
+
   /* other properties */
   BIND_PROPERTIES ("font-name", "font-name");
   BIND_PROPERTIES ("title-initial", "text");
@@ -202,7 +231,7 @@ error:
   /* background image file */
   object = gtk_builder_get_object (GTK_BUILDER (dialog), "background-image-file");
   terminal_return_if_fail (G_IS_OBJECT (object));
-  dialog->signal_id = g_signal_connect (G_OBJECT (dialog->preferences),
+  dialog->bg_image_signal_id = g_signal_connect (G_OBJECT (dialog->preferences),
       "notify::background-image-file", G_CALLBACK (terminal_preferences_dialog_background_notify), object);
   terminal_preferences_dialog_background_notify (G_OBJECT (dialog->preferences), NULL, object);
   g_signal_connect (G_OBJECT (object), "file-set",
@@ -240,9 +269,11 @@ terminal_preferences_dialog_finalize (GObject *object)
 {
   TerminalPreferencesDialog *dialog = TERMINAL_PREFERENCES_DIALOG (object);
 
-  /* disconnect signal */
-  if (G_LIKELY (dialog->signal_id != 0))
-    g_signal_handler_disconnect (dialog->preferences, dialog->signal_id);
+  /* disconnect signals */
+  if (G_LIKELY (dialog->bg_image_signal_id != 0))
+    g_signal_handler_disconnect (dialog->preferences, dialog->bg_image_signal_id);
+  if (G_LIKELY (dialog->palette_signal_id != 0))
+    g_signal_handler_disconnect (dialog->preferences, dialog->palette_signal_id);
 
   /* release the preferences */
   g_object_unref (G_OBJECT (dialog->preferences));
@@ -281,6 +312,80 @@ terminal_preferences_dialog_response (GtkWidget                 *widget,
 
 
 static void
+terminal_preferences_dialog_palette_changed (GtkWidget                 *button,
+                                             TerminalPreferencesDialog *dialog)
+{
+  gchar     name[16];
+  guint     i;
+  GObject  *obj;
+  GdkColor  color;
+  gchar    *color_str;
+  GString  *array;
+
+  array = g_string_sized_new (225);
+
+  for (i = 1; i <= 16; i++)
+    {
+      /* get color value from button */
+      g_snprintf (name, sizeof (name), "color-palette%d", i);
+      obj = gtk_builder_get_object (GTK_BUILDER (dialog), name);
+      terminal_return_if_fail (GTK_IS_COLOR_BUTTON (obj));
+      gtk_color_button_get_color (GTK_COLOR_BUTTON (obj), &color);
+
+      /* append to string */
+      color_str = gdk_color_to_string (&color);
+      g_string_append (array, color_str);
+      g_free (color_str);
+
+      if (i != 16)
+        g_string_append_c (array, ';');
+    }
+
+  /* set property */
+  g_signal_handler_block (dialog->preferences, dialog->palette_signal_id);
+  g_object_set (dialog->preferences, "color-palette", array->str, NULL);
+  g_signal_handler_unblock (dialog->preferences, dialog->palette_signal_id);
+  g_string_free (array, TRUE);
+}
+
+
+
+static void
+terminal_preferences_dialog_palette_notify (TerminalPreferencesDialog *dialog)
+{
+  gchar    *color_str;
+  gchar   **colors;
+  guint     i;
+  gchar     name[16];
+  GObject  *obj;
+  GdkColor  color;
+
+  g_object_get (dialog->preferences, "color-palette", &color_str, NULL);
+  if (G_LIKELY (color_str != NULL))
+    {
+      /* make array */
+      colors = g_strsplit (color_str, ";", 16);
+      g_free (color_str);
+
+      /* apply values to buttons */
+      if (colors != NULL)
+        for (i = 0; colors[i] != NULL; i++)
+          {
+            g_snprintf (name, sizeof (name), "color-palette%d", i + 1);
+            obj = gtk_builder_get_object (GTK_BUILDER (dialog), name);
+            terminal_return_if_fail (GTK_IS_COLOR_BUTTON (obj));
+
+            if (gdk_color_parse (colors[i], &color))
+              gtk_color_button_set_color (GTK_COLOR_BUTTON (obj), &color);
+          }
+
+      g_strfreev (colors);
+    }
+}
+
+
+
+static void
 terminal_preferences_dialog_reset_compat (GtkWidget                 *button,
                                           TerminalPreferencesDialog *dialog)
 {
diff --git a/terminal/terminal-preferences-dialog.h b/terminal/terminal-preferences-dialog.h
index f255067..9e169fc 100644
--- a/terminal/terminal-preferences-dialog.h
+++ b/terminal/terminal-preferences-dialog.h
@@ -35,20 +35,6 @@ G_BEGIN_DECLS
 typedef struct _TerminalPreferencesDialogClass TerminalPreferencesDialogClass;
 typedef struct _TerminalPreferencesDialog      TerminalPreferencesDialog;
 
-struct _TerminalPreferencesDialogClass
-{
-  GtkBuilderClass __parent__;
-};
-
-struct _TerminalPreferencesDialog
-{
-  GtkBuilder           __parent__;
-
-  TerminalPreferences *preferences;
-  guint                signal_id;
-  GSList              *bindings;
-};
-
 GType      terminal_preferences_dialog_get_type (void) G_GNUC_CONST;
 
 GtkWidget *terminal_preferences_dialog_new      (GtkWindow *parent);
diff --git a/terminal/terminal-preferences.c b/terminal/terminal-preferences.c
index 911bac8..9eaa6fa 100644
--- a/terminal/terminal-preferences.c
+++ b/terminal/terminal-preferences.c
@@ -55,22 +55,7 @@ enum
   PROP_COLOR_CURSOR,
   PROP_COLOR_SELECTION,
   PROP_COLOR_SELECTION_USE_DEFAULT,
-  PROP_COLOR_PALETTE1,
-  PROP_COLOR_PALETTE2,
-  PROP_COLOR_PALETTE3,
-  PROP_COLOR_PALETTE4,
-  PROP_COLOR_PALETTE5,
-  PROP_COLOR_PALETTE6,
-  PROP_COLOR_PALETTE7,
-  PROP_COLOR_PALETTE8,
-  PROP_COLOR_PALETTE9,
-  PROP_COLOR_PALETTE10,
-  PROP_COLOR_PALETTE11,
-  PROP_COLOR_PALETTE12,
-  PROP_COLOR_PALETTE13,
-  PROP_COLOR_PALETTE14,
-  PROP_COLOR_PALETTE15,
-  PROP_COLOR_PALETTE16,
+  PROP_COLOR_PALETTE,
   PROP_COMMAND_UPDATE_RECORDS,
   PROP_COMMAND_LOGIN_SHELL,
   PROP_ENCODING,
@@ -352,7 +337,7 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
       g_param_spec_string ("color-foreground",
                            "color-foreground",
                            "ColorForeground",
-                           "#ffffffffffff",
+                           "#ffffff",
                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
@@ -362,7 +347,7 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
       g_param_spec_string ("color-background",
                            "color-background",
                            "ColorBackground",
-                           "#000000000000",
+                           "#000000",
                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
@@ -372,7 +357,7 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
       g_param_spec_string ("color-cursor",
                            "color-cursor",
                            "ColorCursor",
-                           "#0000ffff0000",
+                           "#00ff00",
                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
@@ -382,7 +367,7 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
       g_param_spec_string ("color-selection",
                            "color-selection",
                            "ColorSelection",
-                           "#ffffffffffff",
+                           "#ffffff",
                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
@@ -396,163 +381,28 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
                             G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
-   * TerminalPreferences:color-palette1:
+   * TerminalPreferences:color-palette:
    **/
-  preferences_props[PROP_COLOR_PALETTE1] =
-      g_param_spec_string ("color-palette1",
-                           "color-palette1",
-                           "ColorPalette1",
-                           "#000000000000",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette2:
-   **/
-  preferences_props[PROP_COLOR_PALETTE2] =
-      g_param_spec_string ("color-palette2",
-                           "color-palette2",
-                           "ColorPalette2",
-                           "#aaaa00000000",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette3:
-   **/
-  preferences_props[PROP_COLOR_PALETTE3] =
-      g_param_spec_string ("color-palette3",
-                           "color-palette3",
-                           "ColorPalette3",
-                           "#0000aaaa0000",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette4:
-   **/
-  preferences_props[PROP_COLOR_PALETTE4] =
-      g_param_spec_string ("color-palette4",
-                           "color-palette4",
-                           "ColorPalette4",
-                           "#aaaa55550000",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette5:
-   **/
-  preferences_props[PROP_COLOR_PALETTE5] =
-      g_param_spec_string ("color-palette5",
-                           "color-palette5",
-                           "ColorPalette5",
-                           "#00000000aaaa",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette6:
-   **/
-  preferences_props[PROP_COLOR_PALETTE6] =
-      g_param_spec_string ("color-palette6",
-                           "color-palette6",
-                           "ColorPalette6",
-                           "#aaaa0000aaaa",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette7:
-   **/
-  preferences_props[PROP_COLOR_PALETTE7] =
-      g_param_spec_string ("color-palette7",
-                           "color-palette7",
-                           "ColorPalette7",
-                           "#0000aaaaaaaa",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette8:
-   **/
-  preferences_props[PROP_COLOR_PALETTE8] =
-      g_param_spec_string ("color-palette8",
-                           "color-palette8",
-                           "ColorPalette8",
-                           "#aaaaaaaaaaaa",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette9:
-   **/
-  preferences_props[PROP_COLOR_PALETTE9] =
-      g_param_spec_string ("color-palette9",
-                           "color-palette9",
-                           "ColorPalette9",
-                           "#555555555555",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette10:
-   **/
-  preferences_props[PROP_COLOR_PALETTE10] =
-      g_param_spec_string ("color-palette10",
-                           "color-palette10",
-                           "ColorPalette10",
-                           "#ffff55555555",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette11:
-   **/
-  preferences_props[PROP_COLOR_PALETTE11] =
-      g_param_spec_string ("color-palette11",
-                           "color-palette11",
-                           "ColorPalette11",
-                           "#5555ffff5555",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette12:
-   **/
-  preferences_props[PROP_COLOR_PALETTE12] =
-      g_param_spec_string ("color-palette12",
-                           "color-palette12",
-                           "ColorPalette12",
-                           "#ffffffff5555",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette13:
-   **/
-  preferences_props[PROP_COLOR_PALETTE13] =
-      g_param_spec_string ("color-palette13",
-                           "color-palette13",
-                           "ColorPalette13",
-                           "#55555555ffff",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette14:
-   **/
-  preferences_props[PROP_COLOR_PALETTE14] =
-      g_param_spec_string ("color-palette14",
-                           "color-palette14",
-                           "ColorPalette14",
-                           "#ffff5555ffff",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette15:
-   **/
-  preferences_props[PROP_COLOR_PALETTE15] =
-      g_param_spec_string ("color-palette15",
-                           "color-palette15",
-                           "ColorPalette15",
-                           "#5555ffffffff",
-                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
-
-  /**
-   * TerminalPreferences:color-palette16:
-   **/
-  preferences_props[PROP_COLOR_PALETTE16] =
-      g_param_spec_string ("color-palette16",
-                           "color-palette16",
-                           "ColorPalette16",
-                           "#ffffffffffff",
+  preferences_props[PROP_COLOR_PALETTE] =
+      g_param_spec_string ("color-palette",
+                           "color-palette",
+                           "ColorPalette",
+                           "#000000;"
+                           "#aa0000;"
+                           "#00aa00;"
+                           "#aa5500;"
+                           "#0000aa;"
+                           "#aa00aa;"
+                           "#00aaaa;"
+                           "#aaaaaa;"
+                           "#555555;"
+                           "#ff5555;"
+                           "#55ff55;"
+                           "#ffff55;"
+                           "#5555ff;"
+                           "#ff55ff;"
+                           "#55ffff;"
+                           "#ffffff",
                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
@@ -562,7 +412,7 @@ terminal_preferences_class_init (TerminalPreferencesClass *klass)
       g_param_spec_string ("tab-activity-color",
                            "tab-activity-color",
                            "TabActivityColor",
-                           "#afff00000000",
+                           "#af0000",
                            G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 
   /**
@@ -1072,12 +922,16 @@ terminal_preferences_load (TerminalPreferences *preferences)
   GValue        src = { 0, };
   GValue       *value;
   guint         n;
+  gboolean      migrate_colors = FALSE;
+  gchar         color_name[16];
+  GString      *array;
 
   filename = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, TERMINALRC);
   if (G_UNLIKELY (filename == NULL))
     {
       /* old location of the Terminal days */
       filename = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, TERMINALRC_OLD);
+      migrate_colors = TRUE;
       if (G_UNLIKELY (filename == NULL))
         return;
     }
@@ -1135,6 +989,25 @@ terminal_preferences_load (TerminalPreferences *preferences)
         }
     }
 
+  /* migrate old terminal color properties into a single string */
+  if (G_UNLIKELY (migrate_colors))
+    {
+      /* concat all values */
+      array = g_string_sized_new (225);
+      for (n = 1; n <= 16; n++)
+        {
+          g_snprintf (color_name, sizeof (color_name), "ColorPalette%d", n);
+          string = xfce_rc_read_entry (rc, color_name, "#000000");
+          g_string_append (array, string);
+          if (n != 16)
+            g_string_append_c (array, ';');
+        }
+
+      /* set property */
+      g_object_set (G_OBJECT (preferences), "color-palette", array->str, NULL);
+      g_string_free (array, TRUE);
+    }
+
   g_value_unset (&src);
 
   xfce_rc_close (rc);
diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index 20ac693..799fd5e 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -271,22 +271,7 @@ terminal_screen_init (TerminalScreen *screen)
                     "swapped-signal::notify::color-cursor", G_CALLBACK (terminal_screen_update_colors), screen,
                     "swapped-signal::notify::color-selection", G_CALLBACK (terminal_screen_update_colors), screen,
                     "swapped-signal::notify::color-selection-use-default", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette1", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette2", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette3", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette4", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette5", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette6", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette7", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette8", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette9", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette10", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette11", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette12", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette13", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette14", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette15", G_CALLBACK (terminal_screen_update_colors), screen,
-                    "swapped-signal::notify::color-palette16", G_CALLBACK (terminal_screen_update_colors), screen,
+                    "swapped-signal::notify::color-palette", G_CALLBACK (terminal_screen_update_colors), screen,
                     "swapped-signal::notify::font-allow-bold", G_CALLBACK (terminal_screen_update_font), screen,
                     "swapped-signal::notify::font-name", G_CALLBACK (terminal_screen_update_font), screen,
                     "swapped-signal::notify::misc-bell", G_CALLBACK (terminal_screen_update_misc_bell), screen,
@@ -808,30 +793,44 @@ terminal_screen_update_encoding (TerminalScreen *screen)
 static void
 terminal_screen_update_colors (TerminalScreen *screen)
 {
-  GdkColor palette[16];
-  GdkColor bg;
-  GdkColor fg;
-  GdkColor cursor;
-  GdkColor selection;
-  gboolean use_default;
-  gchar    name[32];
-  guint    n;
-  gboolean has_bg;
-  gboolean has_fg;
-  gboolean has_cursor;
-  gboolean has_pallette;
+  GdkColor   palette[16];
+  GdkColor   bg;
+  GdkColor   fg;
+  GdkColor   cursor;
+  GdkColor   selection;
+  gboolean   use_default;
+  guint      n = 0;
+  gboolean   has_bg;
+  gboolean   has_fg;
+  gboolean   has_cursor;
+  gboolean   valid_palette = FALSE;
+  gchar     *palette_str;
+  gchar    **colors;
+
+  g_object_get (screen->preferences,
+                "color-palette", &palette_str,
+                "color-selection-use-default", &use_default,
+                NULL);
+
+  if (G_LIKELY (palette_str != NULL))
+    {
+      colors = g_strsplit (palette_str, ";", 16);
+      g_free (palette_str);
+
+      if (colors != NULL)
+        for (; colors[n] != NULL && n < 16; n++)
+          if (!gdk_color_parse (colors[n], palette + n))
+            break;
+
+      g_strfreev (colors);
+      valid_palette = (n == 16);
+    }
 
   has_bg = terminal_preferences_get_color (screen->preferences, "color-background", &bg);
   has_fg = terminal_preferences_get_color (screen->preferences, "color-foreground", &fg);
   has_cursor = terminal_preferences_get_color (screen->preferences, "color-cursor", &cursor);
 
-  for (n = 0, has_pallette = TRUE; has_pallette && n < 16; ++n)
-    {
-      g_snprintf (name, sizeof (name), "color-palette%u", n + 1);
-      has_pallette = terminal_preferences_get_color (screen->preferences, name, palette + n);
-    }
-
-  if (G_LIKELY (has_pallette))
+  if (G_LIKELY (valid_palette))
     {
       vte_terminal_set_colors (VTE_TERMINAL (screen->terminal),
                                has_fg ? &fg : NULL,
@@ -841,14 +840,13 @@ terminal_screen_update_colors (TerminalScreen *screen)
   else
     {
       vte_terminal_set_default_colors (VTE_TERMINAL (screen->terminal));
-      g_warning ("One of the terminal colors (color-palette%u) was not parsed "
-                 "successfully. The default palette has been applied.", n);
+      g_warning ("One of the terminal colors was not parsed successfully. "
+                 "The default palette has been applied.");
     }
 
   vte_terminal_set_background_tint_color (VTE_TERMINAL (screen->terminal), has_bg ? &bg : NULL);
   vte_terminal_set_color_cursor (VTE_TERMINAL (screen->terminal), has_cursor ? &cursor : NULL);
 
-  g_object_get (G_OBJECT (screen->preferences), "color-selection-use-default", &use_default, NULL);
   if (!use_default)
     use_default = !terminal_preferences_get_color (screen->preferences, "color-selection", &selection);
   vte_terminal_set_color_highlight (VTE_TERMINAL (screen->terminal), use_default ? NULL : &selection);


More information about the Xfce4-commits mailing list