~ubuntu-branches/ubuntu/lucid/gnome-terminal/lucid-updates

« back to all changes in this revision

Viewing changes to debian/patches/03_add_new_profiles_on_upgrade.patch

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2010-03-23 21:41:22 UTC
  • Revision ID: james.westby@ubuntu.com-20100323214122-33ybqw824ud7c5j3
Tags: 2.29.6-0ubuntu5
* Revert the previous changes to add a new profile, as changing
  the default profile on upgrade is suboptimal, and there are better
  ways to implement the visual changes
  - Removed patches:
    + 02_rename_default_profile.patch
    + 03_add_new_profiles_on_upgrade.patch
    + 04_change_fallback_profile.patch
  - Delete debian/gnome-terminal-ambiance.schemas
  - Delete ebian/gnome-termina-data.gconf-defaults
  - debian/rules:
    + Don't install custom schema
* Add debian/patches/02_add_transparency_properties.patch:
  - This patch allows the background transparency to be controlled from
    the GTK theme (using "TerminalScreen::background-darkness"). In
    addition to this, the background colour and text colour are already
    themable from the GTK theme (by setting the "text[NORMAL]" and
    "base[NORMAL]" colours for the TerminalScreen class)
* debian/gnome-terminal-data.postinst:
  - Fix up the system gconf defaults when upgrading from a previous 
    unstable version which had the extra profile. Users upgrading from
    this will probably still need to remove the "Ambiance" profile
    manually from their configuration though (there's not an easy way
    to do this automatically, and it only affects users upgrading
    from previous unstable versions)
* This fixes LP: #532511 and LP: #542144

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
diff -Nur -x '*.orig' -x '*~' gnome-terminal-2.29.6/src/terminal-app.c gnome-terminal-2.29.6.new/src/terminal-app.c
2
 
--- gnome-terminal-2.29.6/src/terminal-app.c    2009-12-09 19:37:35.000000000 +0000
3
 
+++ gnome-terminal-2.29.6.new/src/terminal-app.c        2010-03-04 21:22:16.759818334 +0000
4
 
@@ -1175,6 +1175,117 @@
5
 
   gtk_dialog_set_response_sensitive (dialog, GTK_RESPONSE_ACCEPT, name[0] != '\0');
6
 
 }
7
 
 
8
 
+static void
9
 
+copy_to_list (gpointer data,
10
 
+              gpointer user_data)
11
 
+{
12
 
+  const char *name = (const char *) data;
13
 
+  GSList **profile_list = (GSList **) user_data;
14
 
+
15
 
+  *profile_list = g_slist_prepend (*profile_list, g_strdup (name));  
16
 
+}
17
 
+
18
 
+static void
19
 
+copy_value_to_list (gpointer data,
20
 
+                    gpointer user_data)
21
 
+{
22
 
+  GConfValue *val = (GConfValue *) data;
23
 
+  GSList **list = (GSList **) user_data;
24
 
+  const char *name;
25
 
+
26
 
+  name = gconf_value_get_string (val);
27
 
+  *list = g_slist_prepend (*list, g_strdup (name));
28
 
+}
29
 
+
30
 
+static void
31
 
+remove_value_from_list (gpointer data,
32
 
+                        gpointer user_data)
33
 
+{
34
 
+  GConfValue *val = (GConfValue *) data;
35
 
+  GSList **profiles_to_add = (GSList **) user_data;
36
 
+  GSList *node;
37
 
+  const char *name;
38
 
+
39
 
+  name = gconf_value_get_string (val);
40
 
+  if (name != NULL) {
41
 
+    node = g_slist_find_custom (*profiles_to_add, name, (GCompareFunc) g_strcmp0);
42
 
+    if (node != NULL) {
43
 
+      *profiles_to_add = g_slist_delete_link (*profiles_to_add, node);
44
 
+    }
45
 
+  }
46
 
+}
47
 
+
48
 
+static void
49
 
+add_basename_to_list (gpointer data,
50
 
+                      gpointer user_data)
51
 
+{
52
 
+  const char *path = (const char *) data;
53
 
+  GSList **list = (GSList **) user_data;
54
 
+  const char *basename;
55
 
+
56
 
+  basename = strrchr (path, '/');
57
 
+  if (++basename != NULL) {
58
 
+    *list = g_slist_prepend (*list, g_strdup (basename));
59
 
+  }
60
 
+}
61
 
+
62
 
+static void
63
 
+terminal_app_catch_new_profiles (TerminalApp *app)
64
 
+{
65
 
+  GConfValue *val;
66
 
+  GSList *profile_list, *profiles_dirs;
67
 
+  GSList *profiles_to_add = NULL;
68
 
+  GSList *new_profile_list = NULL;
69
 
+  GError *error = NULL;
70
 
+
71
 
+  val = gconf_client_get (app->conf, PROFILE_LIST_KEY, &error);
72
 
+  if (error != NULL) {
73
 
+    g_warning ("Failed to read profile list: %s", error->message);
74
 
+    g_error_free (error);
75
 
+    goto out;
76
 
+  }
77
 
+
78
 
+  if (val != NULL && (val->type != GCONF_VALUE_LIST || gconf_value_get_list_type (val) != GCONF_VALUE_STRING)) {
79
 
+    g_warning ("Invalid profile list");
80
 
+    goto out;
81
 
+  }
82
 
+
83
 
+  profiles_dirs = gconf_client_all_dirs (app->conf, CONF_PROFILES_PREFIX, &error);
84
 
+  if (error != NULL) {
85
 
+    g_warning ("Failed to read profile directories: %s", error->message);
86
 
+    g_error_free (error);
87
 
+    goto out;
88
 
+  }
89
 
+
90
 
+  g_slist_foreach (profiles_dirs, (GFunc) add_basename_to_list, &profiles_to_add);
91
 
+
92
 
+  if (val != NULL) {
93
 
+    profile_list = gconf_value_get_list (val);
94
 
+    g_slist_foreach (profile_list, (GFunc) remove_value_from_list, &profiles_to_add);
95
 
+    g_slist_foreach (profile_list, (GFunc) copy_value_to_list, &new_profile_list);
96
 
+  }
97
 
+
98
 
+  g_slist_foreach (profiles_to_add, (GFunc) copy_to_list, &new_profile_list);
99
 
+
100
 
+  if (!gconf_client_set_list (app->conf, PROFILE_LIST_KEY, GCONF_VALUE_STRING, new_profile_list, &error)) {
101
 
+    g_warning ("Failed to update profile list: %s", error->message);
102
 
+    g_error_free (error);
103
 
+  }
104
 
+
105
 
+out:
106
 
+  if (val != NULL)
107
 
+    gconf_value_free (val);
108
 
+
109
 
+  g_slist_foreach (profiles_dirs, (GFunc) g_free, NULL);
110
 
+  g_slist_free (profiles_dirs);
111
 
+
112
 
+  g_slist_foreach (profiles_to_add, (GFunc) g_free, NULL);
113
 
+  g_slist_free (profiles_to_add);
114
 
+
115
 
+  g_slist_foreach (new_profile_list, (GFunc) g_free, NULL);
116
 
+  g_slist_free (new_profile_list);
117
 
+}
118
 
+
119
 
 void
120
 
 terminal_app_new_profile (TerminalApp     *app,
121
 
                           TerminalProfile *default_base_profile,
122
 
@@ -1440,6 +1551,8 @@
123
 
   gconf_client_notify (app->conf, ENABLE_MENU_BAR_ACCEL_KEY);
124
 
   gconf_client_notify (app->conf, ENABLE_MNEMONICS_KEY);
125
 
 
126
 
+  terminal_app_catch_new_profiles (app);
127
 
+
128
 
   /* Ensure we have valid settings */
129
 
   g_assert (app->default_profile_id != NULL);
130
 
   g_assert (app->system_font_desc != NULL);