Merge lp:~raof/gnome-control-center/install-gcm-on-demand into lp:~ubuntu-desktop/gnome-control-center/ubuntu

Proposed by Chris Halse Rogers
Status: Merged
Merged at revision: 338
Proposed branch: lp:~raof/gnome-control-center/install-gcm-on-demand
Merge into: lp:~ubuntu-desktop/gnome-control-center/ubuntu
Diff against target: 266 lines (+239/-1)
3 files modified
debian/changelog (+7/-1)
debian/patches/59_install_gcm_components_on_demand.patch (+231/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~raof/gnome-control-center/install-gcm-on-demand
Reviewer Review Type Date Requested Status
Ubuntu Desktop Pending
Review via email: mp+91767@code.launchpad.net

Description of the change

Improve the colour capplet to install gnome-color-manager on demand,
using the PackageKit session installer interface. Fixes the “Calibrate…”
and “View Profile” buttons without requiring us to install 33MB of Argyll
on the CDs.

This is also submitted upstream:
https://bugzilla.gnome.org/show_bug.cgi?id=669529

To post a comment you must log in.
338. By Chris Halse Rogers

Close ‘Calibrate doesn't work’ bug from changelog

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2012-02-06 17:29:31 +0000
+++ debian/changelog 2012-02-07 07:32:18 +0000
@@ -17,7 +17,13 @@
17 context hints (LP: #922543)17 context hints (LP: #922543)
18 - Rename tabs to look and User Interface to Background (LP: #918580)18 - Rename tabs to look and User Interface to Background (LP: #918580)
1919
20 -- Didier Roche <didrocks@ubuntu.com> Mon, 06 Feb 2012 15:45:09 +010020 [ Christopher James Halse Rogers ]
21 * debian/patches/59_install_gcm_components_on_demand.patch:
22 - Install gnome-color-manager tools on-demand. Fixes the "calibrate"
23 and "View profile" buttons without requiring us to install 33MB of
24 Arygll on the CDs. (LP: #868803)
25
26 -- Christopher James Halse Rogers <raof@ubuntu.com> Tue, 07 Feb 2012 16:57:46 +1100
2127
22gnome-control-center (1:3.2.2-2ubuntu5) precise; urgency=low28gnome-control-center (1:3.2.2-2ubuntu5) precise; urgency=low
2329
2430
=== added file 'debian/patches/59_install_gcm_components_on_demand.patch'
--- debian/patches/59_install_gcm_components_on_demand.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/59_install_gcm_components_on_demand.patch 2012-02-07 07:32:18 +0000
@@ -0,0 +1,231 @@
1diff --git a/panels/color/cc-color-panel.c b/panels/color/cc-color-panel.c
2index 5e31479..e6a823e 100644
3--- a/panels/color/cc-color-panel.c
4+++ b/panels/color/cc-color-panel.c
5@@ -25,6 +25,7 @@
6 #include <colord.h>
7 #include <gtk/gtk.h>
8 #include <gdk/gdkx.h>
9+#include <gio/gio.h>
10
11 #include "cc-color-panel.h"
12
13@@ -234,32 +235,148 @@ gcm_prefs_file_chooser_get_icc_profile (CcColorPanel *prefs)
14 }
15
16 static void
17-gcm_prefs_calibrate_cb (GtkWidget *widget, CcColorPanel *prefs)
18+gcm_packagekit_finished_cb (GObject *source, GAsyncResult *res, gpointer user_data)
19 {
20+ GPtrArray *argv = (GPtrArray *)user_data;
21+ GVariant *reply;
22+ GError *error = NULL;
23 gboolean ret;
24+
25+ reply = g_dbus_proxy_call_finish (G_DBUS_PROXY (source), res, &error);
26+ g_variant_unref (reply);
27+
28+ if (error != NULL)
29+ {
30+ g_warning ("failed to install required component: %s", error->message);
31+ g_ptr_array_unref (argv);
32+ g_error_free (error);
33+ return;
34+ }
35+
36+ ret = g_spawn_async (NULL, (gchar**) argv->pdata, NULL, 0,
37+ NULL, NULL, NULL, &error);
38+ g_ptr_array_unref (argv);
39+ if (!ret)
40+ {
41+ g_warning ("failed to run command: %s", error->message);
42+ g_error_free (error);
43+ }
44+}
45+
46+struct gcm_packagekit_closure_data
47+{
48+ GPtrArray *argv;
49+ guint xid;
50+};
51+
52+static void
53+gcm_packagekit_proxy_ready_cb (GObject *source, GAsyncResult *res, gpointer user_data)
54+{
55+ struct gcm_packagekit_closure_data *data =
56+ (struct gcm_packagekit_closure_data *)user_data;
57+ GDBusProxy *session_installer;
58+ GVariantBuilder *builder;
59 GError *error = NULL;
60+
61+ session_installer = g_dbus_proxy_new_for_bus_finish (res, &error);
62+ if (error != NULL)
63+ {
64+ g_warning ("failed to connect to PackageKit interface: %s",
65+ error->message);
66+ g_ptr_array_unref (data->argv);
67+ g_free (data);
68+ g_error_free (error);
69+ return;
70+ }
71+
72+ builder = g_variant_builder_new (G_VARIANT_TYPE ("as"));
73+ g_variant_builder_add (builder, "s",
74+ g_ptr_array_index (data->argv, 0));
75+ g_dbus_proxy_call (session_installer,
76+ "InstallProvideFiles",
77+ g_variant_new ("(uass)",
78+ data->xid,
79+ builder,
80+ "hide-finished"
81+ ),
82+ G_DBUS_CALL_FLAGS_NONE,
83+ -1,
84+ NULL,
85+ &gcm_packagekit_finished_cb,
86+ data->argv);
87+
88+ g_free (data);
89+ g_variant_builder_unref (builder);
90+}
91+
92+static void
93+gcm_prefs_install_component (guint xid, GPtrArray *argv)
94+{
95+ struct gcm_packagekit_closure_data *data;
96+ data = g_malloc (sizeof (*data));
97+ data->argv = argv;
98+ data->xid = xid;
99+ g_ptr_array_ref (data->argv);
100+
101+ g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
102+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES |
103+ G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS,
104+ NULL,
105+ "org.freedesktop.PackageKit",
106+ "/org/freedesktop/PackageKit",
107+ "org.freedesktop.PackageKit.Modify",
108+ NULL,
109+ &gcm_packagekit_proxy_ready_cb,
110+ data);
111+}
112+
113+static void
114+gcm_prefs_run_maybe_install (guint xid, gchar *filename, GPtrArray *argv)
115+{
116+ gboolean ret;
117+ GError *error = NULL;
118+
119+ ret = g_spawn_async (NULL, (gchar**) argv->pdata, NULL, 0,
120+ NULL, NULL, NULL, &error);
121+ if (!ret)
122+ {
123+ if ((error->domain == g_spawn_error_quark ()) &&
124+ (error->code == G_SPAWN_ERROR_NOENT))
125+ {
126+ gcm_prefs_install_component (xid, argv);
127+ }
128+ else
129+ {
130+ g_warning ("failed to run command: %s", error->message);
131+ }
132+ g_error_free (error);
133+ }
134+}
135+
136+static void
137+gcm_prefs_calibrate_cb (GtkWidget *widget, CcColorPanel *prefs)
138+{
139 guint xid;
140 GPtrArray *argv;
141+ gchar *calibrater_filename;
142 CcColorPanelPrivate *priv = prefs->priv;
143
144 /* get xid */
145 xid = gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (priv->main_window)));
146
147+ calibrater_filename = g_build_filename (BINDIR, "gcm-calibrate", NULL);
148+
149 /* run with modal set */
150 argv = g_ptr_array_new_with_free_func (g_free);
151- g_ptr_array_add (argv, g_build_filename (BINDIR, "gcm-calibrate", NULL));
152+ g_ptr_array_add (argv, calibrater_filename);
153 g_ptr_array_add (argv, g_strdup ("--device"));
154 g_ptr_array_add (argv, g_strdup (cd_device_get_id (priv->current_device)));
155 g_ptr_array_add (argv, g_strdup ("--parent-window"));
156 g_ptr_array_add (argv, g_strdup_printf ("%i", xid));
157 g_ptr_array_add (argv, NULL);
158- ret = g_spawn_async (NULL, (gchar**) argv->pdata, NULL, 0,
159- NULL, NULL, NULL, &error);
160- if (!ret)
161- {
162- g_warning ("failed to run calibrate: %s", error->message);
163- g_error_free (error);
164- }
165+
166+ gcm_prefs_run_maybe_install (xid, calibrater_filename, argv);
167+
168 g_ptr_array_unref (argv);
169 }
170
171@@ -551,10 +668,9 @@ gcm_prefs_profile_view_cb (GtkWidget *widget, CcColorPanel *prefs)
172 GtkTreeModel *model;
173 GtkTreeSelection *selection;
174 gchar *options = NULL;
175+ gchar *viewer_filename;
176 GPtrArray *argv = NULL;
177 guint xid;
178- gboolean ret;
179- GError *error = NULL;
180 CcColorPanelPrivate *priv = prefs->priv;
181
182 /* get the selected row */
183@@ -572,21 +688,17 @@ gcm_prefs_profile_view_cb (GtkWidget *widget, CcColorPanel *prefs)
184 /* get xid */
185 xid = gdk_x11_window_get_xid (gtk_widget_get_window (GTK_WIDGET (priv->main_window)));
186
187+ viewer_filename = g_build_filename (BINDIR, "gcm-viewer", NULL);
188 /* open up gcm-viewer as a info pane */
189 argv = g_ptr_array_new_with_free_func (g_free);
190- g_ptr_array_add (argv, g_build_filename (BINDIR, "gcm-viewer", NULL));
191+ g_ptr_array_add (argv, viewer_filename);
192 g_ptr_array_add (argv, g_strdup ("--profile"));
193 g_ptr_array_add (argv, g_strdup (cd_profile_get_id (profile)));
194 g_ptr_array_add (argv, g_strdup ("--parent-window"));
195 g_ptr_array_add (argv, g_strdup_printf ("%i", xid));
196 g_ptr_array_add (argv, NULL);
197- ret = g_spawn_async (NULL, (gchar**) argv->pdata, NULL, 0,
198- NULL, NULL, NULL, &error);
199- if (!ret)
200- {
201- g_warning ("failed to run calibrate: %s", error->message);
202- g_error_free (error);
203- }
204+
205+ gcm_prefs_run_maybe_install (xid, viewer_filename, argv);
206
207 if (argv != NULL)
208 g_ptr_array_unref (argv);
209@@ -896,7 +1008,6 @@ gcm_prefs_profile_clicked (CcColorPanel *prefs, CdProfile *profile, CdDevice *de
210 {
211 GtkWidget *widget;
212 CdDeviceRelation relation;
213- gchar *s;
214 CcColorPanelPrivate *priv = prefs->priv;
215
216 /* get profile */
217@@ -927,13 +1038,7 @@ gcm_prefs_profile_clicked (CcColorPanel *prefs, CdProfile *profile, CdDevice *de
218 /* allow getting profile info */
219 widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
220 "toolbutton_profile_view"));
221- if ((s = g_find_program_in_path ("gcm-viewer")))
222- {
223- gtk_widget_set_sensitive (widget, TRUE);
224- g_free (s);
225- }
226- else
227- gtk_widget_set_sensitive (widget, FALSE);
228+ gtk_widget_set_sensitive (widget, TRUE);
229
230 /* hide device specific stuff */
231 widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
0232
=== modified file 'debian/patches/series'
--- debian/patches/series 2012-02-06 17:10:34 +0000
+++ debian/patches/series 2012-02-07 07:32:18 +0000
@@ -18,6 +18,7 @@
1856_use_ubuntu_info_branding.patch1856_use_ubuntu_info_branding.patch
1957_use_nonsymbolic_keyboard_icon.patch1957_use_nonsymbolic_keyboard_icon.patch
2058_ubuntu_icon_views_redesign.patch2058_ubuntu_icon_views_redesign.patch
2159_install_gcm_components_on_demand.patch
2190_force_fallback.patch2290_force_fallback.patch
2291_configure_cheese.patch2391_configure_cheese.patch
2390_git_sound_tab_order.patch2490_git_sound_tab_order.patch

Subscribers

People subscribed via source and target branches