Merge lp:~mhr3/libunity/icon-size-hint into lp:libunity

Proposed by Michal Hruby on 2012-09-24
Status: Merged
Approved by: Paweł Stołowski on 2012-09-25
Approved revision: 181
Merged at revision: 180
Proposed branch: lp:~mhr3/libunity/icon-size-hint
Merge into: lp:libunity
Diff against target: 115 lines (+31/-1)
4 files modified
configure.ac (+1/-1)
protocol/protocol-icon.vala (+10/-0)
src/unity-icon.vala (+16/-0)
test/vala/test-previews.vala (+4/-0)
To merge this branch: bzr merge lp:~mhr3/libunity/icon-size-hint
Reviewer Review Type Date Requested Status
Paweł Stołowski 2012-09-24 Approve on 2012-09-25
Review via email: mp+126014@code.launchpad.net

Commit message

Added size hint to AnnotatedIcon

Description of the change

Added size hint property to AnnotatedIcon. This will allow us to specify size when passing icons to unity.

To post a comment you must log in.
Paweł Stołowski (stolowski) wrote :

Looking good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'configure.ac'
2--- configure.ac 2012-09-18 16:39:48 +0000
3+++ configure.ac 2012-09-24 13:55:31 +0000
4@@ -1,5 +1,5 @@
5 # When releasing also remember to update the soname as instructed below
6-AC_INIT(libunity, 6.5.2)
7+AC_INIT(libunity, 6.7.0)
8
9 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10 AM_CONFIG_HEADER(config.h)
11
12=== modified file 'protocol/protocol-icon.vala'
13--- protocol/protocol-icon.vala 2012-09-14 10:56:35 +0000
14+++ protocol/protocol-icon.vala 2012-09-24 13:55:31 +0000
15@@ -57,6 +57,7 @@
16 public Icon icon { get; set; }
17 public string ribbon { get; set; }
18 public CategoryType category { get; set; default = CategoryType.NONE; }
19+ public bool use_small_icon { get; set; }
20
21 public AnnotatedIcon (Icon? base_icon)
22 {
23@@ -128,6 +129,13 @@
24 icon._hints.remove ("ribbon");
25 }
26
27+ unowned Variant small_icon_variant = icon.get_hint ("use-small-icon");
28+ if (small_icon_variant != null)
29+ {
30+ icon.use_small_icon = small_icon_variant.get_boolean ();
31+ icon._hints.remove ("use-small-icon");
32+ }
33+
34 return icon;
35 }
36
37@@ -142,6 +150,8 @@
38 add_hint ("category", new Variant.uint32 (category));
39 if (ribbon != null && ribbon[0] != '\0')
40 add_hint ("ribbon", ribbon);
41+ if (use_small_icon)
42+ add_hint ("use-small-icon", new Variant.boolean (true));
43
44 Variant dict = _hints;
45 tokens.add (dict.print (true));
46
47=== modified file 'src/unity-icon.vala'
48--- src/unity-icon.vala 2012-09-14 10:56:35 +0000
49+++ src/unity-icon.vala 2012-09-24 13:55:31 +0000
50@@ -53,6 +53,13 @@
51 N_CATEGORIES
52 }
53
54+ public enum IconSizeHint
55+ {
56+ DEFAULT,
57+ SMALL,
58+ LARGE
59+ }
60+
61 /*
62 * AnnotatedIcon can be used to add various icon and text overlays to an icon.
63 * Add desired overlays using properties of this class and use the to_string()
64@@ -88,6 +95,15 @@
65 set { _pai.category = (Protocol.CategoryType) value; }
66 }
67
68+ public IconSizeHint size_hint
69+ {
70+ get
71+ {
72+ return _pai.use_small_icon ? IconSizeHint.SMALL : IconSizeHint.DEFAULT;
73+ }
74+ set { _pai.use_small_icon = value == IconSizeHint.SMALL; }
75+ }
76+
77 public AnnotatedIcon (Icon base_icon)
78 {
79 Object (icon: base_icon);
80
81=== modified file 'test/vala/test-previews.vala'
82--- test/vala/test-previews.vala 2012-09-17 17:27:42 +0000
83+++ test/vala/test-previews.vala 2012-09-24 13:55:31 +0000
84@@ -87,6 +87,7 @@
85 var anno_icon = new Protocol.AnnotatedIcon (icon);
86 anno_icon.ribbon = "You can't buy the internet!";
87 anno_icon.category = Protocol.CategoryType.CLOTHES;
88+ anno_icon.use_small_icon = true;
89 var serialized = anno_icon.to_string ();
90
91 var deserialized = Icon.new_for_string (serialized);
92@@ -96,6 +97,7 @@
93 assert (de_anno != null);
94 assert (de_anno.ribbon == "You can't buy the internet!");
95 assert (de_anno.category == Protocol.CategoryType.CLOTHES);
96+ assert (de_anno.use_small_icon == true);
97 }
98
99 static void test_annotated_icon_with_metadata ()
100@@ -104,6 +106,7 @@
101 icon.append_name ("outernet");
102 var anno_icon = new Unity.AnnotatedIcon (icon);
103 anno_icon.ribbon = "You can't buy the internet!";
104+ anno_icon.size_hint = Unity.IconSizeHint.SMALL;
105 var serialized = anno_icon.to_string ();
106
107 var deserialized = Icon.new_for_string (serialized);
108@@ -114,6 +117,7 @@
109 assert (de_anno.ribbon == "You can't buy the internet!");
110 assert (de_anno.category == Protocol.CategoryType.NONE);
111 assert (de_anno.icon.equal (icon));
112+ assert (de_anno.use_small_icon == true);
113 }
114
115 static void test_preview_generic ()

Subscribers

People subscribed via source and target branches