Merge lp:~darkxst/ubuntu/saucy/gnome-control-center/lp1184812ud into lp:~ubuntu-desktop/gnome-control-center/ubuntu

Proposed by Tim Lunn
Status: Merged
Merged at revision: 569
Proposed branch: lp:~darkxst/ubuntu/saucy/gnome-control-center/lp1184812ud
Merge into: lp:~ubuntu-desktop/gnome-control-center/ubuntu
Diff against target: 840 lines (+801/-1)
4 files modified
debian/changelog (+7/-0)
debian/control (+2/-1)
debian/patches/git_move_rr_labeler.patch (+791/-0)
debian/patches/series (+1/-0)
To merge this branch: bzr merge lp:~darkxst/ubuntu/saucy/gnome-control-center/lp1184812ud
Reviewer Review Type Date Requested Status
Jeremy Bícha Approve
Review via email: mp+166011@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeremy Bícha (jbicha) wrote :

Thanks! Uploaded.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-05-27 07:53:29 +0000
+++ debian/changelog 2013-05-28 10:47:25 +0000
@@ -1,3 +1,10 @@
1gnome-control-center (1:3.6.3-0ubuntu27) saucy; urgency=low
2
3 * Rebuild for gnome-desktop 3.8 transition (LP: #1184812)
4 - debian/patches/git_move_rr_labeler.patch
5
6 -- Tim Lunn <tim@feathertop.org> Tue, 28 May 2013 10:23:39 +1000
7
1gnome-control-center (1:3.6.3-0ubuntu26) saucy; urgency=low8gnome-control-center (1:3.6.3-0ubuntu26) saucy; urgency=low
29
3 * debian/patches/git_no_glxinfo.patch:10 * debian/patches/git_no_glxinfo.patch:
411
=== modified file 'debian/control'
--- debian/control 2013-04-29 17:17:03 +0000
+++ debian/control 2013-05-28 10:47:25 +0000
@@ -7,7 +7,7 @@
7Priority: optional7Priority: optional
8Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>8Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
9XSBC-Original-Maintainer: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>9XSBC-Original-Maintainer: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>
10Uploaders: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>10Uploaders: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>, Jeremy Bicha <jbicha@ubuntu.com>
11Standards-Version: 3.9.311Standards-Version: 3.9.3
12Build-Depends: autotools-dev,12Build-Depends: autotools-dev,
13 cdbs (>= 0.4.41),13 cdbs (>= 0.4.41),
@@ -81,6 +81,7 @@
81 gsettings-desktop-schemas (>= 3.5.91),81 gsettings-desktop-schemas (>= 3.5.91),
82Recommends: cups-pk-helper,82Recommends: cups-pk-helper,
83 gnome-session-bin,83 gnome-session-bin,
84 ubuntu-system-service,
84 iso-codes,85 iso-codes,
85 mousetweaks,86 mousetweaks,
86 policykit-1-gnome,87 policykit-1-gnome,
8788
=== added file 'debian/patches/git_move_rr_labeler.patch'
--- debian/patches/git_move_rr_labeler.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/git_move_rr_labeler.patch 2013-05-28 10:47:25 +0000
@@ -0,0 +1,791 @@
1From e35a109d299011b800cb085f3d57ad7c012ed6dc Mon Sep 17 00:00:00 2001
2From: Bastien Nocera <hadess@hadess.net>
3Date: Wed, 21 Nov 2012 21:13:44 +0000
4Subject: display: Move GnomeRRLabeler here
5
6And rename to CcRRLabeler.
7---
8--- a/panels/display/Makefile.am
9+++ b/panels/display/Makefile.am
10@@ -19,6 +19,8 @@
11 display-module.c \
12 cc-display-panel.c \
13 cc-display-panel.h \
14+ cc-rr-labeler.c \
15+ cc-rr-labeler.h \
16 scrollarea.c \
17 scrollarea.h \
18 $(MARSHALFILES)
19--- a/panels/display/cc-display-panel.c
20+++ b/panels/display/cc-display-panel.c
21@@ -31,12 +31,13 @@
22 #define GNOME_DESKTOP_USE_UNSTABLE_API
23 #include <libgnome-desktop/gnome-rr.h>
24 #include <libgnome-desktop/gnome-rr-config.h>
25-#include <libgnome-desktop/gnome-rr-labeler.h>
26 #include <gdk/gdkx.h>
27 #include <X11/Xlib.h>
28 #include <glib/gi18n.h>
29 #include <gdesktop-enums.h>
30
31+#include "cc-rr-labeler.h"
32+
33 CC_PANEL_REGISTER (CcDisplayPanel, cc_display_panel)
34
35 #define DISPLAY_PANEL_PRIVATE(o) \
36@@ -75,7 +76,7 @@
37 {
38 GnomeRRScreen *screen;
39 GnomeRRConfig *current_configuration;
40- GnomeRRLabeler *labeler;
41+ CcRRLabeler *labeler;
42 GnomeRROutputInfo *current_output;
43
44 GSettings *clock_settings;
45@@ -196,7 +197,7 @@
46 self->priv->focus_id);
47 }
48
49- gnome_rr_labeler_hide (self->priv->labeler);
50+ cc_rr_labeler_hide (self->priv->labeler);
51 g_object_unref (self->priv->labeler);
52
53 G_OBJECT_CLASS (cc_display_panel_parent_class)->finalize (object);
54@@ -289,13 +290,13 @@
55 self->priv->current_output = NULL;
56
57 if (self->priv->labeler) {
58- gnome_rr_labeler_hide (self->priv->labeler);
59+ cc_rr_labeler_hide (self->priv->labeler);
60 g_object_unref (self->priv->labeler);
61 }
62
63- self->priv->labeler = gnome_rr_labeler_new (self->priv->current_configuration);
64+ self->priv->labeler = cc_rr_labeler_new (self->priv->current_configuration);
65 if (gtk_widget_has_focus (self->priv->panel))
66- gnome_rr_labeler_show (self->priv->labeler);
67+ cc_rr_labeler_show (self->priv->labeler);
68
69 select_current_output_from_dialog_position (self);
70
71@@ -673,7 +674,7 @@
72 tmp = g_strdup (gnome_rr_output_info_get_display_name (self->priv->current_output));
73
74 str = g_strdup_printf ("<b>%s</b>", tmp);
75- gnome_rr_labeler_get_rgba_for_output (self->priv->labeler, self->priv->current_output, &color);
76+ cc_rr_labeler_get_rgba_for_output (self->priv->labeler, self->priv->current_output, &color);
77 use_color = TRUE;
78 g_free (tmp);
79 }
80@@ -2073,7 +2074,7 @@
81 cairo_rectangle (cr, x, y, w * scale + 0.5, h * scale + 0.5);
82 cairo_clip_preserve (cr);
83
84- gnome_rr_labeler_get_rgba_for_output (self->priv->labeler, output, &output_color);
85+ cc_rr_labeler_get_rgba_for_output (self->priv->labeler, output, &output_color);
86 r = output_color.red;
87 g = output_color.green;
88 b = output_color.blue;
89@@ -2581,9 +2582,9 @@
90 if (self->priv->labeler == NULL)
91 return;
92 if (gtk_window_has_toplevel_focus (window))
93- gnome_rr_labeler_show (self->priv->labeler);
94+ cc_rr_labeler_show (self->priv->labeler);
95 else
96- gnome_rr_labeler_hide (self->priv->labeler);
97+ cc_rr_labeler_hide (self->priv->labeler);
98 }
99
100 static void
101@@ -2673,7 +2674,7 @@
102 int monitor_width = 30;
103 int monitor_height = 15;
104
105- gnome_rr_labeler_get_rgba_for_output (self->priv->labeler, output, &color);
106+ cc_rr_labeler_get_rgba_for_output (self->priv->labeler, output, &color);
107
108 cairo_surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, monitor_width, monitor_height);
109 cr = cairo_create (cairo_surface);
110--- /dev/null
111+++ b/panels/display/cc-rr-labeler.c
112@@ -0,0 +1,601 @@
113+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
114+ *
115+ * cc-rr-labeler.c - Utility to label monitors to identify them
116+ * while they are being configured.
117+ *
118+ * Copyright 2008, Novell, Inc.
119+ *
120+ * This file is part of the Gnome Library.
121+ *
122+ * The Gnome Library is free software; you can redistribute it and/or
123+ * modify it under the terms of the GNU Library General Public License as
124+ * published by the Free Software Foundation; either version 2 of the
125+ * License, or (at your option) any later version.
126+ *
127+ * The Gnome Library is distributed in the hope that it will be useful,
128+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
129+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
130+ * Library General Public License for more details.
131+ *
132+ * You should have received a copy of the GNU Library General Public
133+ * License along with the Gnome Library; see the file COPYING.LIB. If not,
134+ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
135+ * Boston, MA 02110-1301, USA.
136+ *
137+ * Author: Federico Mena-Quintero <federico@novell.com>
138+ */
139+
140+#include <config.h>
141+#include <glib/gi18n-lib.h>
142+#include <gtk/gtk.h>
143+
144+#include <X11/Xproto.h>
145+#include <X11/Xlib.h>
146+#include <X11/Xutil.h>
147+#include <X11/Xatom.h>
148+#include <gdk/gdkx.h>
149+
150+#include "cc-rr-labeler.h"
151+
152+struct _CcRRLabelerPrivate {
153+ GnomeRRConfig *config;
154+
155+ int num_outputs;
156+
157+ GdkRGBA *palette;
158+ GtkWidget **windows;
159+
160+ GdkScreen *screen;
161+ Atom workarea_atom;
162+};
163+
164+enum {
165+ PROP_0,
166+ PROP_CONFIG,
167+ PROP_LAST
168+};
169+
170+G_DEFINE_TYPE (CcRRLabeler, cc_rr_labeler, G_TYPE_OBJECT);
171+
172+static void cc_rr_labeler_finalize (GObject *object);
173+static void setup_from_config (CcRRLabeler *labeler);
174+
175+static GdkFilterReturn
176+screen_xevent_filter (GdkXEvent *xevent,
177+ GdkEvent *event,
178+ CcRRLabeler *labeler)
179+{
180+ XEvent *xev;
181+
182+ xev = (XEvent *) xevent;
183+
184+ if (xev->type == PropertyNotify &&
185+ xev->xproperty.atom == labeler->priv->workarea_atom) {
186+ /* update label positions */
187+ if (labeler->priv->windows != NULL) {
188+ cc_rr_labeler_hide (labeler);
189+ cc_rr_labeler_show (labeler);
190+ }
191+ }
192+
193+ return GDK_FILTER_CONTINUE;
194+}
195+
196+static void
197+cc_rr_labeler_init (CcRRLabeler *labeler)
198+{
199+ GdkWindow *gdkwindow;
200+
201+ labeler->priv = G_TYPE_INSTANCE_GET_PRIVATE (labeler, GNOME_TYPE_RR_LABELER, CcRRLabelerPrivate);
202+
203+ labeler->priv->workarea_atom = XInternAtom (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
204+ "_NET_WORKAREA",
205+ True);
206+
207+ labeler->priv->screen = gdk_screen_get_default ();
208+ /* code is not really designed to handle multiple screens so *shrug* */
209+ gdkwindow = gdk_screen_get_root_window (labeler->priv->screen);
210+ gdk_window_add_filter (gdkwindow, (GdkFilterFunc) screen_xevent_filter, labeler);
211+ gdk_window_set_events (gdkwindow, gdk_window_get_events (gdkwindow) | GDK_PROPERTY_CHANGE_MASK);
212+}
213+
214+static void
215+cc_rr_labeler_set_property (GObject *gobject, guint property_id, const GValue *value, GParamSpec *param_spec)
216+{
217+ CcRRLabeler *self = CC_RR_LABELER (gobject);
218+
219+ switch (property_id) {
220+ case PROP_CONFIG:
221+ self->priv->config = GNOME_RR_CONFIG (g_value_dup_object (value));
222+ return;
223+ default:
224+ G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, property_id, param_spec);
225+ }
226+}
227+
228+static GObject *
229+cc_rr_labeler_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties)
230+{
231+ CcRRLabeler *self = (CcRRLabeler*) G_OBJECT_CLASS (cc_rr_labeler_parent_class)->constructor (type, n_construct_properties, construct_properties);
232+
233+ setup_from_config (self);
234+
235+ return (GObject*) self;
236+}
237+
238+static void
239+cc_rr_labeler_class_init (CcRRLabelerClass *klass)
240+{
241+ GObjectClass *object_class;
242+
243+ g_type_class_add_private (klass, sizeof (CcRRLabelerPrivate));
244+
245+ object_class = (GObjectClass *) klass;
246+
247+ object_class->set_property = cc_rr_labeler_set_property;
248+ object_class->finalize = cc_rr_labeler_finalize;
249+ object_class->constructor = cc_rr_labeler_constructor;
250+
251+ g_object_class_install_property (object_class, PROP_CONFIG, g_param_spec_object ("config",
252+ "Configuration",
253+ "RandR configuration to label",
254+ GNOME_TYPE_RR_CONFIG,
255+ G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
256+ G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));
257+}
258+
259+static void
260+cc_rr_labeler_finalize (GObject *object)
261+{
262+ CcRRLabeler *labeler;
263+ GdkWindow *gdkwindow;
264+
265+ labeler = CC_RR_LABELER (object);
266+
267+ gdkwindow = gdk_screen_get_root_window (labeler->priv->screen);
268+ gdk_window_remove_filter (gdkwindow, (GdkFilterFunc) screen_xevent_filter, labeler);
269+
270+ if (labeler->priv->config != NULL) {
271+ g_object_unref (labeler->priv->config);
272+ }
273+
274+ if (labeler->priv->windows != NULL) {
275+ cc_rr_labeler_hide (labeler);
276+ g_free (labeler->priv->windows);
277+ }
278+
279+ g_free (labeler->priv->palette);
280+
281+ G_OBJECT_CLASS (cc_rr_labeler_parent_class)->finalize (object);
282+}
283+
284+static int
285+count_outputs (GnomeRRConfig *config)
286+{
287+ int i;
288+ GnomeRROutputInfo **outputs = gnome_rr_config_get_outputs (config);
289+
290+ for (i = 0; outputs[i] != NULL; i++)
291+ ;
292+
293+ return i;
294+}
295+
296+static void
297+make_palette (CcRRLabeler *labeler)
298+{
299+ /* The idea is that we go around an hue color wheel. We want to start
300+ * at red, go around to green/etc. and stop at blue --- because magenta
301+ * is evil. Eeeeek, no magenta, please!
302+ *
303+ * Purple would be nice, though. Remember that we are watered down
304+ * (i.e. low saturation), so that would be like Like berries with cream.
305+ * Mmmmm, berries.
306+ */
307+ double start_hue;
308+ double end_hue;
309+ int i;
310+
311+ g_assert (labeler->priv->num_outputs > 0);
312+
313+ labeler->priv->palette = g_new (GdkRGBA, labeler->priv->num_outputs);
314+
315+ start_hue = 0.0; /* red */
316+ end_hue = 2.0/3; /* blue */
317+
318+ for (i = 0; i < labeler->priv->num_outputs; i++) {
319+ double h, s, v;
320+ double r, g, b;
321+
322+ h = start_hue + (end_hue - start_hue) / labeler->priv->num_outputs * i;
323+ s = 1.0 / 3;
324+ v = 1.0;
325+
326+ gtk_hsv_to_rgb (h, s, v, &r, &g, &b);
327+
328+ labeler->priv->palette[i].red = r;
329+ labeler->priv->palette[i].green = g;
330+ labeler->priv->palette[i].blue = b;
331+ labeler->priv->palette[i].alpha = 1.0;
332+ }
333+}
334+
335+static void
336+rounded_rectangle (cairo_t *cr,
337+ gint x,
338+ gint y,
339+ gint width,
340+ gint height,
341+ gint x_radius,
342+ gint y_radius)
343+{
344+ gint x1, x2;
345+ gint y1, y2;
346+ gint xr1, xr2;
347+ gint yr1, yr2;
348+
349+ x1 = x;
350+ x2 = x1 + width;
351+ y1 = y;
352+ y2 = y1 + height;
353+
354+ x_radius = MIN (x_radius, width / 2.0);
355+ y_radius = MIN (y_radius, width / 2.0);
356+
357+ xr1 = x_radius;
358+ xr2 = x_radius / 2.0;
359+ yr1 = y_radius;
360+ yr2 = y_radius / 2.0;
361+
362+ cairo_move_to (cr, x1 + xr1, y1);
363+ cairo_line_to (cr, x2 - xr1, y1);
364+ cairo_curve_to (cr, x2 - xr2, y1, x2, y1 + yr2, x2, y1 + yr1);
365+ cairo_line_to (cr, x2, y2 - yr1);
366+ cairo_curve_to (cr, x2, y2 - yr2, x2 - xr2, y2, x2 - xr1, y2);
367+ cairo_line_to (cr, x1 + xr1, y2);
368+ cairo_curve_to (cr, x1 + xr2, y2, x1, y2 - yr2, x1, y2 - yr1);
369+ cairo_line_to (cr, x1, y1 + yr1);
370+ cairo_curve_to (cr, x1, y1 + yr2, x1 + xr2, y1, x1 + xr1, y1);
371+ cairo_close_path (cr);
372+}
373+
374+#define LABEL_WINDOW_EDGE_THICKNESS 2
375+#define LABEL_WINDOW_PADDING 12
376+/* Look for panel-corner in:
377+ * http://git.gnome.org/browse/gnome-shell/tree/data/theme/gnome-shell.css
378+ * to match the corner radius */
379+#define LABEL_CORNER_RADIUS 6 + LABEL_WINDOW_EDGE_THICKNESS
380+
381+static void
382+label_draw_background_and_frame (GtkWidget *widget, cairo_t *cr, gboolean for_shape)
383+{
384+ GdkRGBA shape_color = { 0, 0, 0, 1 };
385+ GdkRGBA *rgba;
386+ GtkAllocation allocation;
387+
388+ rgba = g_object_get_data (G_OBJECT (widget), "rgba");
389+ gtk_widget_get_allocation (widget, &allocation);
390+
391+ cairo_save (cr);
392+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
393+
394+ /* edge outline */
395+ if (for_shape)
396+ gdk_cairo_set_source_rgba (cr, &shape_color);
397+ else
398+ cairo_set_source_rgba (cr, 0, 0, 0, 0.5);
399+
400+ rounded_rectangle (cr,
401+ LABEL_WINDOW_EDGE_THICKNESS / 2.0,
402+ LABEL_WINDOW_EDGE_THICKNESS / 2.0,
403+ allocation.width - LABEL_WINDOW_EDGE_THICKNESS,
404+ allocation.height - LABEL_WINDOW_EDGE_THICKNESS,
405+ LABEL_CORNER_RADIUS, LABEL_CORNER_RADIUS);
406+ cairo_set_line_width (cr, LABEL_WINDOW_EDGE_THICKNESS);
407+ cairo_stroke (cr);
408+
409+ /* fill */
410+ if (for_shape) {
411+ gdk_cairo_set_source_rgba (cr, &shape_color);
412+ } else {
413+ rgba->alpha = 0.75;
414+ gdk_cairo_set_source_rgba (cr, rgba);
415+ }
416+
417+ rounded_rectangle (cr,
418+ LABEL_WINDOW_EDGE_THICKNESS,
419+ LABEL_WINDOW_EDGE_THICKNESS,
420+ allocation.width - LABEL_WINDOW_EDGE_THICKNESS * 2,
421+ allocation.height - LABEL_WINDOW_EDGE_THICKNESS * 2,
422+ LABEL_CORNER_RADIUS - LABEL_WINDOW_EDGE_THICKNESS / 2.0,
423+ LABEL_CORNER_RADIUS - LABEL_WINDOW_EDGE_THICKNESS / 2.0);
424+ cairo_fill (cr);
425+
426+ cairo_restore (cr);
427+}
428+
429+static void
430+maybe_update_shape (GtkWidget *widget)
431+{
432+ cairo_t *cr;
433+ cairo_surface_t *surface;
434+ cairo_region_t *region;
435+
436+ /* fallback to XShape only for non-composited clients */
437+ if (gtk_widget_is_composited (widget)) {
438+ gtk_widget_shape_combine_region (widget, NULL);
439+ return;
440+ }
441+
442+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
443+ CAIRO_CONTENT_COLOR_ALPHA,
444+ gtk_widget_get_allocated_width (widget),
445+ gtk_widget_get_allocated_height (widget));
446+
447+ cr = cairo_create (surface);
448+ label_draw_background_and_frame (widget, cr, TRUE);
449+ cairo_destroy (cr);
450+
451+ region = gdk_cairo_region_create_from_surface (surface);
452+ gtk_widget_shape_combine_region (widget, region);
453+
454+ cairo_surface_destroy (surface);
455+ cairo_region_destroy (region);
456+}
457+
458+static gboolean
459+label_window_draw_event_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
460+{
461+ if (gtk_widget_is_composited (widget)) {
462+ /* clear any content */
463+ cairo_save (cr);
464+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
465+ cairo_set_source_rgba (cr, 0, 0, 0, 0);
466+ cairo_paint (cr);
467+ cairo_restore (cr);
468+ }
469+
470+ maybe_update_shape (widget);
471+ label_draw_background_and_frame (widget, cr, FALSE);
472+
473+ return FALSE;
474+}
475+
476+static void
477+position_window (CcRRLabeler *labeler,
478+ GtkWidget *window,
479+ int x,
480+ int y)
481+{
482+ GdkRectangle workarea;
483+ GdkRectangle monitor;
484+ int monitor_num;
485+
486+ monitor_num = gdk_screen_get_monitor_at_point (labeler->priv->screen, x, y);
487+ gdk_screen_get_monitor_workarea (labeler->priv->screen, monitor_num, &workarea);
488+ gdk_screen_get_monitor_geometry (labeler->priv->screen,
489+ monitor_num,
490+ &monitor);
491+ gdk_rectangle_intersect (&monitor, &workarea, &workarea);
492+
493+ gtk_window_move (GTK_WINDOW (window), workarea.x, workarea.y);
494+}
495+
496+static void
497+label_window_realize_cb (GtkWidget *widget)
498+{
499+ cairo_region_t *region;
500+
501+ /* make the whole window ignore events */
502+ region = cairo_region_create ();
503+ gtk_widget_input_shape_combine_region (widget, region);
504+ cairo_region_destroy (region);
505+
506+ maybe_update_shape (widget);
507+}
508+
509+static void
510+label_window_composited_changed_cb (GtkWidget *widget, CcRRLabeler *labeler)
511+{
512+ if (gtk_widget_get_realized (widget))
513+ maybe_update_shape (widget);
514+}
515+
516+static GtkWidget *
517+create_label_window (CcRRLabeler *labeler, GnomeRROutputInfo *output, GdkRGBA *rgba)
518+{
519+ GtkWidget *window;
520+ GtkWidget *widget;
521+ char *str;
522+ const char *display_name;
523+ GdkRGBA black = { 0, 0, 0, 1.0 };
524+ int x, y;
525+ GdkScreen *screen;
526+ GdkVisual *visual;
527+
528+ window = gtk_window_new (GTK_WINDOW_POPUP);
529+ gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_TOOLTIP);
530+ gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
531+ gtk_widget_set_app_paintable (window, TRUE);
532+ screen = gtk_widget_get_screen (window);
533+ visual = gdk_screen_get_rgba_visual (screen);
534+
535+ if (visual != NULL)
536+ gtk_widget_set_visual (window, visual);
537+
538+ gtk_container_set_border_width (GTK_CONTAINER (window), LABEL_WINDOW_PADDING + LABEL_WINDOW_EDGE_THICKNESS);
539+
540+ /* This is semi-dangerous. The color is part of the labeler->palette
541+ * array. Note that in cc_rr_labeler_finalize(), we are careful to
542+ * free the palette only after we free the windows.
543+ */
544+ g_object_set_data (G_OBJECT (window), "rgba", rgba);
545+
546+ g_signal_connect (window, "draw",
547+ G_CALLBACK (label_window_draw_event_cb), labeler);
548+ g_signal_connect (window, "realize",
549+ G_CALLBACK (label_window_realize_cb), labeler);
550+ g_signal_connect (window, "composited-changed",
551+ G_CALLBACK (label_window_composited_changed_cb), labeler);
552+
553+ if (gnome_rr_config_get_clone (labeler->priv->config)) {
554+ /* Keep this string in sync with gnome-control-center/capplets/display/xrandr-capplet.c:get_display_name() */
555+
556+ /* Translators: this is the feature where what you see on your
557+ * laptop's screen is the same as your external projector.
558+ * Here, "Mirrored" is being used as an adjective. For example,
559+ * the Spanish translation could be "Pantallas en Espejo".
560+ */
561+ display_name = _("Mirrored Displays");
562+ } else
563+ display_name = gnome_rr_output_info_get_display_name (output);
564+
565+ str = g_strdup_printf ("<b>%s</b>", display_name);
566+ widget = gtk_label_new (NULL);
567+ gtk_label_set_markup (GTK_LABEL (widget), str);
568+ g_free (str);
569+
570+ /* Make the label explicitly black. We don't want it to follow the
571+ * theme's colors, since the label is always shown against a light
572+ * pastel background. See bgo#556050
573+ */
574+ gtk_widget_override_color (widget,
575+ gtk_widget_get_state_flags (widget),
576+ &black);
577+
578+ gtk_container_add (GTK_CONTAINER (window), widget);
579+
580+ /* Should we center this at the top edge of the monitor, instead of using the upper-left corner? */
581+ gnome_rr_output_info_get_geometry (output, &x, &y, NULL, NULL);
582+ position_window (labeler, window, x, y);
583+
584+ gtk_widget_show_all (window);
585+
586+ return window;
587+}
588+
589+static void
590+setup_from_config (CcRRLabeler *labeler)
591+{
592+ labeler->priv->num_outputs = count_outputs (labeler->priv->config);
593+
594+ make_palette (labeler);
595+
596+ cc_rr_labeler_show (labeler);
597+}
598+
599+/**
600+ * cc_rr_labeler_new:
601+ * @config: Configuration of the screens to label
602+ *
603+ * Create a GUI element that will display colored labels on each connected monitor.
604+ * This is useful when users are required to identify which monitor is which, e.g. for
605+ * for configuring multiple monitors.
606+ * The labels will be shown by default, use cc_rr_labeler_hide to hide them.
607+ *
608+ * Returns: A new #CcRRLabeler
609+ */
610+CcRRLabeler *
611+cc_rr_labeler_new (GnomeRRConfig *config)
612+{
613+ g_return_val_if_fail (GNOME_IS_RR_CONFIG (config), NULL);
614+
615+ return g_object_new (GNOME_TYPE_RR_LABELER, "config", config, NULL);
616+}
617+
618+/**
619+ * cc_rr_labeler_show:
620+ * @labeler: A #CcRRLabeler
621+ *
622+ * Show the labels.
623+ */
624+void
625+cc_rr_labeler_show (CcRRLabeler *labeler)
626+{
627+ int i;
628+ gboolean created_window_for_clone;
629+ GnomeRROutputInfo **outputs;
630+
631+ g_return_if_fail (GNOME_IS_RR_LABELER (labeler));
632+
633+ if (labeler->priv->windows != NULL)
634+ return;
635+
636+ labeler->priv->windows = g_new (GtkWidget *, labeler->priv->num_outputs);
637+
638+ created_window_for_clone = FALSE;
639+
640+ outputs = gnome_rr_config_get_outputs (labeler->priv->config);
641+
642+ for (i = 0; i < labeler->priv->num_outputs; i++) {
643+ if (!created_window_for_clone && gnome_rr_output_info_is_active (outputs[i])) {
644+ labeler->priv->windows[i] = create_label_window (labeler, outputs[i], labeler->priv->palette + i);
645+
646+ if (gnome_rr_config_get_clone (labeler->priv->config))
647+ created_window_for_clone = TRUE;
648+ } else
649+ labeler->priv->windows[i] = NULL;
650+ }
651+}
652+
653+/**
654+ * cc_rr_labeler_hide:
655+ * @labeler: A #CcRRLabeler
656+ *
657+ * Hide ouput labels.
658+ */
659+void
660+cc_rr_labeler_hide (CcRRLabeler *labeler)
661+{
662+ int i;
663+ CcRRLabelerPrivate *priv;
664+
665+ g_return_if_fail (GNOME_IS_RR_LABELER (labeler));
666+
667+ priv = labeler->priv;
668+
669+ if (priv->windows == NULL)
670+ return;
671+
672+ for (i = 0; i < priv->num_outputs; i++)
673+ if (priv->windows[i] != NULL) {
674+ gtk_widget_destroy (priv->windows[i]);
675+ priv->windows[i] = NULL;
676+ }
677+ g_free (priv->windows);
678+ priv->windows = NULL;
679+}
680+
681+/**
682+ * cc_rr_labeler_get_rgba_for_output:
683+ * @labeler: A #CcRRLabeler
684+ * @output: Output device (i.e. monitor) to query
685+ * @rgba_out: (out): Color of selected monitor.
686+ *
687+ * Get the color used for the label on a given output (monitor).
688+ */
689+void
690+cc_rr_labeler_get_rgba_for_output (CcRRLabeler *labeler, GnomeRROutputInfo *output, GdkRGBA *rgba_out)
691+{
692+ int i;
693+ GnomeRROutputInfo **outputs;
694+
695+ g_return_if_fail (GNOME_IS_RR_LABELER (labeler));
696+ g_return_if_fail (GNOME_IS_RR_OUTPUT_INFO (output));
697+ g_return_if_fail (rgba_out != NULL);
698+
699+ outputs = gnome_rr_config_get_outputs (labeler->priv->config);
700+
701+ for (i = 0; i < labeler->priv->num_outputs; i++)
702+ if (outputs[i] == output) {
703+ *rgba_out = labeler->priv->palette[i];
704+ return;
705+ }
706+
707+ g_warning ("trying to get the color for unknown GnomeOutputInfo %p; returning magenta!", output);
708+
709+ rgba_out->red = 1.0;
710+ rgba_out->green = 0;
711+ rgba_out->blue = 1.0;
712+ rgba_out->alpha = 1.0;
713+}
714--- /dev/null
715+++ b/panels/display/cc-rr-labeler.h
716@@ -0,0 +1,64 @@
717+/* gnome-rr-labeler.h - Utility to label monitors to identify them
718+ * while they are being configured.
719+ *
720+ * Copyright 2008, Novell, Inc.
721+ *
722+ * This file is part of the Gnome Library.
723+ *
724+ * The Gnome Library is free software; you can redistribute it and/or
725+ * modify it under the terms of the GNU Library General Public License as
726+ * published by the Free Software Foundation; either version 2 of the
727+ * License, or (at your option) any later version.
728+ *
729+ * The Gnome Library is distributed in the hope that it will be useful,
730+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
731+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
732+ * Library General Public License for more details.
733+ *
734+ * You should have received a copy of the GNU Library General Public
735+ * License along with the Gnome Library; see the file COPYING.LIB. If not,
736+ * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
737+ * Boston, MA 02110-1301, USA.
738+ *
739+ * Author: Federico Mena-Quintero <federico@novell.com>
740+ */
741+
742+#ifndef CC_RR_LABELER_H
743+#define CC_RR_LABELER_H
744+
745+#define GNOME_DESKTOP_USE_UNSTABLE_API
746+#include <libgnome-desktop/gnome-rr-config.h>
747+
748+#define GNOME_TYPE_RR_LABELER (cc_rr_labeler_get_type ())
749+#define CC_RR_LABELER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNOME_TYPE_RR_LABELER, CcRRLabeler))
750+#define CC_RR_LABELER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNOME_TYPE_RR_LABELER, CcRRLabelerClass))
751+#define GNOME_IS_RR_LABELER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNOME_TYPE_RR_LABELER))
752+#define GNOME_IS_RR_LABELER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_RR_LABELER))
753+#define CC_RR_LABELER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNOME_TYPE_RR_LABELER, CcRRLabelerClass))
754+
755+typedef struct _CcRRLabeler CcRRLabeler;
756+typedef struct _CcRRLabelerClass CcRRLabelerClass;
757+typedef struct _CcRRLabelerPrivate CcRRLabelerPrivate;
758+
759+struct _CcRRLabeler {
760+ GObject parent;
761+
762+ /*< private >*/
763+ CcRRLabelerPrivate *priv;
764+};
765+
766+struct _CcRRLabelerClass {
767+ GObjectClass parent_class;
768+};
769+
770+GType cc_rr_labeler_get_type (void);
771+
772+CcRRLabeler *cc_rr_labeler_new (GnomeRRConfig *config);
773+
774+void cc_rr_labeler_show (CcRRLabeler *labeler);
775+
776+void cc_rr_labeler_hide (CcRRLabeler *labeler);
777+
778+void cc_rr_labeler_get_rgba_for_output (CcRRLabeler *labeler, GnomeRROutputInfo *output, GdkRGBA *rgba_out);
779+
780+#endif
781--- a/configure.ac
782+++ b/configure.ac
783@@ -119,7 +119,7 @@
784 gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION
785 polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
786 gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION)
787-PKG_CHECK_MODULES(DISPLAY_PANEL, $COMMON_MODULES gnome-desktop-3.0 >= 3.1.0)
788+PKG_CHECK_MODULES(DISPLAY_PANEL, $COMMON_MODULES gnome-desktop-3.0 >= 3.1.0 x11)
789 PKG_CHECK_MODULES(INFO_PANEL, $COMMON_MODULES libgtop-2.0 gl x11
790 polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION webkitgtk-3.0)
791 PKG_CHECK_MODULES(KEYBOARD_PANEL, $COMMON_MODULES x11)
0792
=== modified file 'debian/patches/series'
--- debian/patches/series 2013-04-16 14:27:14 +0000
+++ debian/patches/series 2013-05-28 10:47:25 +0000
@@ -36,3 +36,4 @@
36git_no_glxinfo.patch36git_no_glxinfo.patch
37unity_notice_info.patch37unity_notice_info.patch
3838
39git_move_rr_labeler.patch

Subscribers

People subscribed via source and target branches