Merge lp:~unity-team/unity/unity.fix-810325-2 into lp:unity

Proposed by Mirco Müller
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 1912
Proposed branch: lp:~unity-team/unity/unity.fix-810325-2
Merge into: lp:unity
Diff against target: 48 lines (+20/-0)
2 files modified
com.canonical.Unity.gschema.xml (+5/-0)
plugins/unityshell/src/BGHash.cpp (+15/-0)
To merge this branch: bzr merge lp:~unity-team/unity/unity.fix-810325-2
Reviewer Review Type Date Requested Status
Gord Allott (community) Approve
Review via email: mp+91808@code.launchpad.net

Description of the change

The updated Unity-part of fixing LP: #810325. This makes sure the average color - computed after a change of wallpaper - is exposed via Unity's GSettings schema. That in turn can get picked up by other applications... notify-osd in this case.

To post a comment you must log in.
Revision history for this message
Gord Allott (gordallott) wrote :

few things need fixing

24 + const gchar* AVG_BG_COLOR = "average-bg-color\0";
25 + const gchar* UNITY_SCHEMA = "com.canonical.Unity\0";

should use std::string not gchar*'s

35 + gchar* color_string = NULL;

should use unity::glib::String, from UnityCore/GlibWrapper.h - it will handle freeing when scope is lost for you and you can use it with methods.

41 + settings = g_settings_new (UNITY_SCHEMA);

we have a gsettings pointer in the object already, "client", should use that instead of creating another instance

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

Fixes stated issues.

Revision history for this message
Gord Allott (gordallott) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'com.canonical.Unity.gschema.xml'
2--- com.canonical.Unity.gschema.xml 2012-02-04 05:28:23 +0000
3+++ com.canonical.Unity.gschema.xml 2012-02-07 15:00:26 +0000
4@@ -20,6 +20,11 @@
5 <summary>Whether the home screen should be expanded.</summary>
6 <description>Whether the home screen should be expanded.</description>
7 </key>
8+ <key type="s" name="average-bg-color">
9+ <default>'#757550507B7BFFFF'</default>
10+ <summary>Average background color</summary>
11+ <description>The average color derived from the currently set desktop-wallpaper. This is written/updated by the Unity-process and read by NotifyOSD-process for example.</description>
12+ </key>
13 </schema>
14 <schema path="/desktop/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity">
15 <key type="as" name="favorites">
16
17=== modified file 'plugins/unityshell/src/BGHash.cpp'
18--- plugins/unityshell/src/BGHash.cpp 2012-01-04 09:33:05 +0000
19+++ plugins/unityshell/src/BGHash.cpp 2012-02-07 15:00:26 +0000
20@@ -35,6 +35,8 @@
21 int level_of_recursion;
22 const int MAX_LEVEL_OF_RECURSION = 16;
23 const int MIN_LEVEL_OF_RECURSION = 2;
24+ std::string AVG_BG_COLOR = "average-bg-color";
25+ std::string UNITY_SCHEMA = "com.canonical.Unity";
26 }
27 namespace unity {
28
29@@ -373,6 +375,19 @@
30 _current_color.blue * 0.7f,
31 0.5)
32 );
33+ GSettings* settings = NULL;
34+ GdkColor color = {0,
35+ (guint16) (_current_color.red * 65535.0 * 0.7f),
36+ (guint16) (_current_color.green * 65535.0 * 0.7f),
37+ (guint16) (_current_color.blue * 65535.0 * 0.7f)};
38+
39+ settings = g_settings_new (UNITY_SCHEMA.c_str());
40+ if (settings)
41+ {
42+ unity::glib::String color_string(gdk_color_to_string(&color));
43+ g_settings_set_string(settings, AVG_BG_COLOR.c_str(), color_string);
44+ g_object_unref (settings);
45+ }
46 }
47
48 GdkPixbuf *BGHash::GetPixbufFromBG ()