[Xfce4-commits] [apps/xfce4-terminal] 01/01: Allow user-defined color palettes

noreply at xfce.org noreply at xfce.org
Thu Oct 20 11:13:45 CEST 2016


This is an automated email from the git hooks/post-receive script.

f2404 pushed a commit to branch master
in repository apps/xfce4-terminal.

commit f7153e992993e7fbe38f8a023664f7f53b1a380f
Author: Igor <f2404 at yandex.ru>
Date:   Thu Oct 20 12:13:00 2016 +0300

    Allow user-defined color palettes
    
    Looks for those under ~/.config/xfce4/terminal/colorschemes/
    Implements https://bugzilla.xfce.org/show_bug.cgi?id=12908
---
 terminal/terminal-preferences-dialog.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/terminal/terminal-preferences-dialog.c b/terminal/terminal-preferences-dialog.c
index 5e417d7..07b5fe1 100644
--- a/terminal/terminal-preferences-dialog.c
+++ b/terminal/terminal-preferences-dialog.c
@@ -686,10 +686,9 @@ terminal_preferences_dialog_presets_changed (GtkComboBox               *combobox
 static void
 terminal_preferences_dialog_presets_load (TerminalPreferencesDialog *dialog)
 {
-  gchar       **presets;
-  guint         n;
+  gchar       **global, **user, **presets;
+  guint         n_global, n_user, n_presets = 0, n;
   GObject      *object;
-  guint         n_presets = 0;
   XfceRc       *rc;
   GtkListStore *store;
   GtkTreeIter   iter;
@@ -697,9 +696,19 @@ terminal_preferences_dialog_presets_load (TerminalPreferencesDialog *dialog)
   gchar        *path;
 
   /* load schemes */
-  presets = xfce_resource_match (XFCE_RESOURCE_DATA, "xfce4/terminal/colorschemes/*", TRUE);
+  global = xfce_resource_match (XFCE_RESOURCE_DATA, "xfce4/terminal/colorschemes/*", TRUE);
+  user = xfce_resource_match (XFCE_RESOURCE_CONFIG, "xfce4/terminal/colorschemes/*", TRUE);
+  n_global = g_strv_length (global);
+  n_user = g_strv_length (user);
+  presets = g_new0 (gchar *, n_global + n_user);
   if (G_LIKELY (presets != NULL))
     {
+      /* copy pointers to global- and user-defined presets */
+      for (n = 0; n < n_global; n++)
+        presets[n] = global[n];
+      for (n = 0; n < n_user; n++)
+        presets[n_global + n] = user[n];
+
       /* create sorting store */
       store = gtk_list_store_new (N_PRESET_COLUMNS, G_TYPE_STRING,
                                   G_TYPE_BOOLEAN, G_TYPE_STRING);
@@ -708,10 +717,11 @@ terminal_preferences_dialog_presets_load (TerminalPreferencesDialog *dialog)
                                             GTK_SORT_ASCENDING);
 
       /* append files */
-      for (n = 0; presets[n] != NULL; n++)
+      for (n = 0; n < n_global + n_user && presets[n] != NULL; n++)
         {
           /* open the scheme */
-          path = xfce_resource_lookup (XFCE_RESOURCE_DATA, presets[n]);
+          path = xfce_resource_lookup (n < n_global ? XFCE_RESOURCE_DATA : XFCE_RESOURCE_CONFIG,
+                                       presets[n]);
           if (G_UNLIKELY (path == NULL))
             continue;
 
@@ -763,7 +773,9 @@ terminal_preferences_dialog_presets_load (TerminalPreferencesDialog *dialog)
       g_object_unref (store);
     }
 
-  g_strfreev (presets);
+  g_strfreev (global);
+  g_strfreev (user);
+  g_free (presets);
 
   if (n_presets == 0)
     {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list