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
=== modified file 'src/bubble.c'
--- src/bubble.c 2011-07-08 15:42:45 +0000
+++ src/bubble.c 2011-07-21 01:06:19 +0000
@@ -663,11 +663,17 @@
663 }663 }
664664
665 // clear, render top-left part of shadow/background in scratch-surface665 // clear, render top-left part of shadow/background in scratch-surface
666 cairo_scale (cr, 1.0f, 1.0f);666 cairo_scale (cr, 1.0f, 1.0f);
667 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);667 cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
668 cairo_paint (cr);668 cairo_paint (cr);
669 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);669 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
670670
671 GdkColor color;
672 gchar* color_string = NULL;
673 color_string = defaults_get_bubble_bg_color (d);
674 gdk_color_parse (color_string, &color);
675 g_free (color_string);
676
671 if (priv->composited)677 if (priv->composited)
672 {678 {
673 _draw_shadow (679 _draw_shadow (
@@ -689,16 +695,16 @@
689 cairo_fill (cr);695 cairo_fill (cr);
690 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);696 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
691 cairo_set_source_rgba (cr,697 cairo_set_source_rgba (cr,
692 BUBBLE_BG_COLOR_R,698 0.75 * ((double) color.red / 65535.0),
693 BUBBLE_BG_COLOR_G,699 0.75 * ((double) color.green / 65535.0),
694 BUBBLE_BG_COLOR_B,700 0.75 * ((double) color.blue / 65535.0),
695 BUBBLE_BG_COLOR_A);701 BUBBLE_BG_COLOR_A);
696 }702 }
697 else703 else
698 cairo_set_source_rgb (cr,704 cairo_set_source_rgb (cr,
699 BUBBLE_BG_COLOR_R,705 0.75 * ((double) color.red / 65535.0),
700 BUBBLE_BG_COLOR_G,706 0.75 * ((double) color.green / 65535.0),
701 BUBBLE_BG_COLOR_B);707 0.75 * ((double) color.blue / 65535.0));
702708
703 draw_round_rect (709 draw_round_rect (
704 cr,710 cr,
705711
=== modified file 'src/defaults.c'
--- src/defaults.c 2011-07-13 17:22:48 +0000
+++ src/defaults.c 2011-07-21 01:06:19 +0000
@@ -154,6 +154,10 @@
154#define GNOME_DESKTOP_SCHEMA "org.gnome.desktop.interface"154#define GNOME_DESKTOP_SCHEMA "org.gnome.desktop.interface"
155#define GSETTINGS_FONT_KEY "font-name"155#define GSETTINGS_FONT_KEY "font-name"
156156
157/* unity settings */
158#define UNITY_SCHEMA "com.canonical.Unity"
159#define GSETTINGS_AVG_BG_COL_KEY "average-bg-color"
160
157static guint g_defaults_signals[LAST_SIGNAL] = { 0 };161static guint g_defaults_signals[LAST_SIGNAL] = { 0 };
158162
159/*-- internal API ------------------------------------------------------------*/163/*-- internal API ------------------------------------------------------------*/
@@ -285,6 +289,26 @@
285 g_signal_emit (defaults, g_defaults_signals[GRAVITY_CHANGED], 0);289 g_signal_emit (defaults, g_defaults_signals[GRAVITY_CHANGED], 0);
286}290}
287291
292static void
293_avg_bg_color_changed (GSettings* settings,
294 gchar* key,
295 gpointer data)
296{
297 Defaults* defaults = NULL;
298 gchar* color_string = NULL;
299
300 if (!data)
301 return;
302
303 defaults = (Defaults*) data;
304 if (!IS_DEFAULTS (defaults))
305 return;
306
307 color_string = g_settings_get_string (settings, key);
308 g_object_set (defaults, "bubble-bg-color", color_string, NULL);
309 g_free (color_string);
310}
311
288void312void
289defaults_refresh_screen_dimension_properties (Defaults *self)313defaults_refresh_screen_dimension_properties (Defaults *self)
290{314{
@@ -403,6 +427,10 @@
403 NULL);427 NULL);
404 }428 }
405429
430 _avg_bg_color_changed (self->unity_settings,
431 GSETTINGS_AVG_BG_COL_KEY,
432 self);
433
406 /* FIXME: calling this here causes a segfault */434 /* FIXME: calling this here causes a segfault */
407 /* chain up to the parent class */435 /* chain up to the parent class */
408 /*G_OBJECT_CLASS (defaults_parent_class)->constructed (gobject);*/436 /*G_OBJECT_CLASS (defaults_parent_class)->constructed (gobject);*/
@@ -417,6 +445,7 @@
417445
418 g_object_unref (defaults->nosd_settings);446 g_object_unref (defaults->nosd_settings);
419 g_object_unref (defaults->gnome_settings);447 g_object_unref (defaults->gnome_settings);
448 g_object_unref (defaults->unity_settings);
420449
421 if (defaults->bubble_shadow_color)450 if (defaults->bubble_shadow_color)
422 {451 {
@@ -482,7 +511,8 @@
482{511{
483 /* "connect" to the required GSettings schemas */512 /* "connect" to the required GSettings schemas */
484 self->nosd_settings = g_settings_new (NOTIFY_OSD_SCHEMA);513 self->nosd_settings = g_settings_new (NOTIFY_OSD_SCHEMA);
485 self->gnome_settings = g_settings_new (GNOME_DESKTOP_SCHEMA);; 514 self->gnome_settings = g_settings_new (GNOME_DESKTOP_SCHEMA);
515 self->unity_settings = g_settings_new (UNITY_SCHEMA);
486516
487 g_signal_connect (self->gnome_settings,517 g_signal_connect (self->gnome_settings,
488 "changed",518 "changed",
@@ -494,6 +524,11 @@
494 G_CALLBACK (_gravity_changed),524 G_CALLBACK (_gravity_changed),
495 self);525 self);
496526
527 g_signal_connect (self->unity_settings,
528 "changed",
529 G_CALLBACK (_avg_bg_color_changed),
530 self);
531
497 // use fixed slot-allocation for async. and sync. bubbles532 // use fixed slot-allocation for async. and sync. bubbles
498 self->slot_allocation = SLOT_ALLOCATION_FIXED;533 self->slot_allocation = SLOT_ALLOCATION_FIXED;
499}534}
500535
=== modified file 'src/defaults.h'
--- src/defaults.h 2011-07-13 17:22:48 +0000
+++ src/defaults.h 2011-07-21 01:06:19 +0000
@@ -76,6 +76,7 @@
76 /* private */76 /* private */
77 GSettings* nosd_settings;77 GSettings* nosd_settings;
78 GSettings* gnome_settings;78 GSettings* gnome_settings;
79 GSettings* unity_settings;
79 gint desktop_width;80 gint desktop_width;
80 gint desktop_height;81 gint desktop_height;
81 gint desktop_top;82 gint desktop_top;

Subscribers

People subscribed via source and target branches