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

Proposed by Chris Halse Rogers on 2012-02-07
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 2012-02-07 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 on 2012-02-07

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

Subscribers

People subscribed via source and target branches