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 Bicha Approve
Review via email: mp+166011@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeremy Bicha (jbicha) wrote :

Thanks! Uploaded.

review: Approve

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

Subscribers

People subscribed via source and target branches