Merge lp:~macslow/notify-osd/fix.810325-2 into lp:~canonical-dx-team/notify-osd/precise

Proposed by Mirco Müller
Status: Merged
Approved by: Mirco Müller
Approved revision: 451
Merged at revision: 452
Proposed branch: lp:~macslow/notify-osd/fix.810325-2
Merge into: lp:~canonical-dx-team/notify-osd/precise
Diff against target: 177 lines (+87/-8)
3 files modified
src/bubble.c (+13/-7)
src/defaults.c (+73/-1)
src/defaults.h (+1/-0)
To merge this branch: bzr merge lp:~macslow/notify-osd/fix.810325-2
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+92000@code.launchpad.net

This proposal supersedes a proposal from 2012-02-08.

Description of the change

Updated version of the branch for supporting tinting the notification-bubble background with the average color pulled from the Unity schema. This is optional and checked at runtime if available. So if notify-osd is run under a system without Unity or with an older Unity not providing the average-color, notify-osd just falls back to the regular dark grey tint.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

The code seems fine for me but I can't test since Unity 5.2 doesn't seem to include the key you are using, is that pending an Unity merge to land?

Revision history for this message
Mirco Müller (macslow) wrote :

Yes, the unity-part of this is in unity trunk to be released with 5.4.

Revision history for this message
Mirco Müller (macslow) wrote :

I just want to make sure I get this into a notify-osd release so it doesn't slip feature freeze.

Revision history for this message
Sebastien Bacher (seb128) wrote :

well, approving since the code seems fine assuming that you test ran it with an unity having the required changes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/bubble.c'
2--- src/bubble.c 2012-02-07 12:29:02 +0000
3+++ src/bubble.c 2012-02-08 09:29:20 +0000
4@@ -663,11 +663,17 @@
5 }
6
7 // clear, render top-left part of shadow/background in scratch-surface
8- cairo_scale (cr, 1.0f, 1.0f);
9+ cairo_scale (cr, 1.0f, 1.0f);
10 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
11 cairo_paint (cr);
12 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
13
14+ GdkColor color;
15+ gchar* color_string = NULL;
16+ color_string = defaults_get_bubble_bg_color (d);
17+ gdk_color_parse (color_string, &color);
18+ g_free (color_string);
19+
20 if (priv->composited)
21 {
22 _draw_shadow (
23@@ -689,16 +695,16 @@
24 cairo_fill (cr);
25 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
26 cairo_set_source_rgba (cr,
27- BUBBLE_BG_COLOR_R,
28- BUBBLE_BG_COLOR_G,
29- BUBBLE_BG_COLOR_B,
30+ 0.75 * ((double) color.red / 65535.0),
31+ 0.75 * ((double) color.green / 65535.0),
32+ 0.75 * ((double) color.blue / 65535.0),
33 BUBBLE_BG_COLOR_A);
34 }
35 else
36 cairo_set_source_rgb (cr,
37- BUBBLE_BG_COLOR_R,
38- BUBBLE_BG_COLOR_G,
39- BUBBLE_BG_COLOR_B);
40+ 0.75 * ((double) color.red / 65535.0),
41+ 0.75 * ((double) color.green / 65535.0),
42+ 0.75 * ((double) color.blue / 65535.0));
43
44 draw_round_rect (
45 cr,
46
47=== modified file 'src/defaults.c'
48--- src/defaults.c 2012-02-07 12:29:02 +0000
49+++ src/defaults.c 2012-02-08 09:29:20 +0000
50@@ -154,6 +154,10 @@
51 #define GNOME_DESKTOP_SCHEMA "org.gnome.desktop.interface"
52 #define GSETTINGS_FONT_KEY "font-name"
53
54+/* unity settings */
55+#define UNITY_SCHEMA "com.canonical.Unity"
56+#define GSETTINGS_AVG_BG_COL_KEY "average-bg-color"
57+
58 static guint g_defaults_signals[LAST_SIGNAL] = { 0 };
59
60 /*-- internal API ------------------------------------------------------------*/
61@@ -285,6 +289,61 @@
62 g_signal_emit (defaults, g_defaults_signals[GRAVITY_CHANGED], 0);
63 }
64
65+static void
66+_avg_bg_color_changed (GSettings* settings,
67+ gchar* key,
68+ gpointer data)
69+{
70+ Defaults* defaults = NULL;
71+ gchar* color_string = NULL;
72+
73+ if (!data || !settings)
74+ return;
75+
76+ defaults = (Defaults*) data;
77+ if (!IS_DEFAULTS (defaults))
78+ return;
79+
80+ color_string = g_settings_get_string (settings, key);
81+ g_object_set (defaults, "bubble-bg-color", color_string, NULL);
82+ g_free (color_string);
83+}
84+
85+GSettings*
86+_get_unity_schema ()
87+{
88+ // check for availability of unity-schema
89+ const gchar* const* schema_list = NULL;
90+ int i = 0;
91+ gboolean match = FALSE;
92+ schema_list = g_settings_list_schemas (); // no need to free/unref list
93+ for (i = 0; schema_list[i]; i++)
94+ if (g_strcmp0 (UNITY_SCHEMA, schema_list[i]) == 0)
95+ {
96+ match = TRUE;
97+ break;
98+ }
99+ if (!match)
100+ return NULL;
101+
102+ // be really paranoid and check for "avg. bg-color" key
103+ GSettings* settings = g_settings_new (UNITY_SCHEMA);
104+ gchar** keys = NULL;
105+ keys = g_settings_list_keys (settings);
106+ i = 0;
107+ match = FALSE;
108+ while (keys[i] && !match)
109+ {
110+ match = g_strcmp0 (keys[i], GSETTINGS_AVG_BG_COL_KEY) == 0 ? TRUE : FALSE;
111+ i++;
112+ }
113+ g_strfreev (keys);
114+ if (!match)
115+ return NULL;
116+
117+ return settings;
118+}
119+
120 void
121 defaults_refresh_screen_dimension_properties (Defaults *self)
122 {
123@@ -403,6 +462,10 @@
124 NULL);
125 }
126
127+ _avg_bg_color_changed (self->unity_settings,
128+ GSETTINGS_AVG_BG_COL_KEY,
129+ self);
130+
131 /* FIXME: calling this here causes a segfault */
132 /* chain up to the parent class */
133 /*G_OBJECT_CLASS (defaults_parent_class)->constructed (gobject);*/
134@@ -417,6 +480,7 @@
135
136 g_object_unref (defaults->nosd_settings);
137 g_object_unref (defaults->gnome_settings);
138+ g_object_unref (defaults->unity_settings);
139
140 if (defaults->bubble_shadow_color)
141 {
142@@ -482,7 +546,8 @@
143 {
144 /* "connect" to the required GSettings schemas */
145 self->nosd_settings = g_settings_new (NOTIFY_OSD_SCHEMA);
146- self->gnome_settings = g_settings_new (GNOME_DESKTOP_SCHEMA);;
147+ self->gnome_settings = g_settings_new (GNOME_DESKTOP_SCHEMA);
148+ self->unity_settings = _get_unity_schema ();
149
150 g_signal_connect (self->gnome_settings,
151 "changed",
152@@ -493,6 +558,13 @@
153 "changed",
154 G_CALLBACK (_gravity_changed),
155 self);
156+ if (self->unity_settings)
157+ {
158+ g_signal_connect (self->unity_settings,
159+ "changed",
160+ G_CALLBACK (_avg_bg_color_changed),
161+ self);
162+ }
163
164 // use fixed slot-allocation for async. and sync. bubbles
165 self->slot_allocation = SLOT_ALLOCATION_FIXED;
166
167=== modified file 'src/defaults.h'
168--- src/defaults.h 2012-02-07 12:29:02 +0000
169+++ src/defaults.h 2012-02-08 09:29:20 +0000
170@@ -76,6 +76,7 @@
171 /* private */
172 GSettings* nosd_settings;
173 GSettings* gnome_settings;
174+ GSettings* unity_settings;
175 gint desktop_width;
176 gint desktop_height;
177 gint desktop_top;

Subscribers

People subscribed via source and target branches