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
=== modified file 'com.canonical.Unity.gschema.xml'
--- com.canonical.Unity.gschema.xml 2012-02-04 05:28:23 +0000
+++ com.canonical.Unity.gschema.xml 2012-02-07 15:00:26 +0000
@@ -20,6 +20,11 @@
20 <summary>Whether the home screen should be expanded.</summary>20 <summary>Whether the home screen should be expanded.</summary>
21 <description>Whether the home screen should be expanded.</description>21 <description>Whether the home screen should be expanded.</description>
22 </key>22 </key>
23 <key type="s" name="average-bg-color">
24 <default>'#757550507B7BFFFF'</default>
25 <summary>Average background color</summary>
26 <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>
27 </key>
23 </schema>28 </schema>
24 <schema path="/desktop/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity">29 <schema path="/desktop/unity/launcher/" id="com.canonical.Unity.Launcher" gettext-domain="unity">
25 <key type="as" name="favorites">30 <key type="as" name="favorites">
2631
=== modified file 'plugins/unityshell/src/BGHash.cpp'
--- plugins/unityshell/src/BGHash.cpp 2012-01-04 09:33:05 +0000
+++ plugins/unityshell/src/BGHash.cpp 2012-02-07 15:00:26 +0000
@@ -35,6 +35,8 @@
35 int level_of_recursion;35 int level_of_recursion;
36 const int MAX_LEVEL_OF_RECURSION = 16;36 const int MAX_LEVEL_OF_RECURSION = 16;
37 const int MIN_LEVEL_OF_RECURSION = 2;37 const int MIN_LEVEL_OF_RECURSION = 2;
38 std::string AVG_BG_COLOR = "average-bg-color";
39 std::string UNITY_SCHEMA = "com.canonical.Unity";
38}40}
39namespace unity {41namespace unity {
4042
@@ -373,6 +375,19 @@
373 _current_color.blue * 0.7f,375 _current_color.blue * 0.7f,
374 0.5)376 0.5)
375 );377 );
378 GSettings* settings = NULL;
379 GdkColor color = {0,
380 (guint16) (_current_color.red * 65535.0 * 0.7f),
381 (guint16) (_current_color.green * 65535.0 * 0.7f),
382 (guint16) (_current_color.blue * 65535.0 * 0.7f)};
383
384 settings = g_settings_new (UNITY_SCHEMA.c_str());
385 if (settings)
386 {
387 unity::glib::String color_string(gdk_color_to_string(&color));
388 g_settings_set_string(settings, AVG_BG_COLOR.c_str(), color_string);
389 g_object_unref (settings);
390 }
376 }391 }
377392
378 GdkPixbuf *BGHash::GetPixbufFromBG ()393 GdkPixbuf *BGHash::GetPixbufFromBG ()