Merge lp:~macslow/notify-osd/fix.810325 into lp:notify-osd/oneiric

Proposed by Mirco Müller
Status: Needs review
Proposed branch: lp:~macslow/notify-osd/fix.810325
Merge into: lp:notify-osd/oneiric
Diff against target: 140 lines (+50/-8)
3 files modified
src/bubble.c (+13/-7)
src/defaults.c (+36/-1)
src/defaults.h (+1/-0)
To merge this branch: bzr merge lp:~macslow/notify-osd/fix.810325
Reviewer Review Type Date Requested Status
Canonical Desktop Experience Team Pending
Review via email: mp+68537@code.launchpad.net

Description of the change

The background-color for a bubble will be read from a GSettings key ("com.canonical.Unity average-bg-color"). If that key isn't available the old dark grey will be used.

To ensure there's enough contrast between the bubble background and its contents only 75% of the read background-color is applied.

For this to work Unity with lp:~unity-team/unity/fix.810325 merged in has to be running.

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

One issue with that patch is that it makes notify-osd depends on unity by the way gsettings schemas are working (or you would need to do hacks to check if the unity schemas is installed and fallback to a default value if it's not). Wouldn't it make sense to add an unity dbus method to export the value and query the value over dbus? it would make easier to do handle non unity scenarios.

otherwise small comment, it seems your indentation is mixing tabs and space

lp:~macslow/notify-osd/fix.810325 updated
445. By Mirco Müller

really make sure the average-color is read at startup

Unmerged revisions

445. By Mirco Müller

really make sure the average-color is read at startup

444. By Mirco Müller

apply only 75% of the average-color to keep enough contrast to the text and icon, pick up the average upon startup... not only on wallpaper-change

443. By Mirco Müller

trying to fix LP: #810325

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 2011-07-08 15:42:45 +0000
3+++ src/bubble.c 2011-07-21 01:06:19 +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 2011-07-13 17:22:48 +0000
49+++ src/defaults.c 2011-07-21 01:06:19 +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,26 @@
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)
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 void
86 defaults_refresh_screen_dimension_properties (Defaults *self)
87 {
88@@ -403,6 +427,10 @@
89 NULL);
90 }
91
92+ _avg_bg_color_changed (self->unity_settings,
93+ GSETTINGS_AVG_BG_COL_KEY,
94+ self);
95+
96 /* FIXME: calling this here causes a segfault */
97 /* chain up to the parent class */
98 /*G_OBJECT_CLASS (defaults_parent_class)->constructed (gobject);*/
99@@ -417,6 +445,7 @@
100
101 g_object_unref (defaults->nosd_settings);
102 g_object_unref (defaults->gnome_settings);
103+ g_object_unref (defaults->unity_settings);
104
105 if (defaults->bubble_shadow_color)
106 {
107@@ -482,7 +511,8 @@
108 {
109 /* "connect" to the required GSettings schemas */
110 self->nosd_settings = g_settings_new (NOTIFY_OSD_SCHEMA);
111- self->gnome_settings = g_settings_new (GNOME_DESKTOP_SCHEMA);;
112+ self->gnome_settings = g_settings_new (GNOME_DESKTOP_SCHEMA);
113+ self->unity_settings = g_settings_new (UNITY_SCHEMA);
114
115 g_signal_connect (self->gnome_settings,
116 "changed",
117@@ -494,6 +524,11 @@
118 G_CALLBACK (_gravity_changed),
119 self);
120
121+ g_signal_connect (self->unity_settings,
122+ "changed",
123+ G_CALLBACK (_avg_bg_color_changed),
124+ self);
125+
126 // use fixed slot-allocation for async. and sync. bubbles
127 self->slot_allocation = SLOT_ALLOCATION_FIXED;
128 }
129
130=== modified file 'src/defaults.h'
131--- src/defaults.h 2011-07-13 17:22:48 +0000
132+++ src/defaults.h 2011-07-21 01:06:19 +0000
133@@ -76,6 +76,7 @@
134 /* private */
135 GSettings* nosd_settings;
136 GSettings* gnome_settings;
137+ GSettings* unity_settings;
138 gint desktop_width;
139 gint desktop_height;
140 gint desktop_top;

Subscribers

People subscribed via source and target branches