Merge lp:~kamstrup/libunity/gi-friendly-api-tweaks into lp:libunity

Proposed by Mikkel Kamstrup Erlandsen
Status: Merged
Merged at revision: 73
Proposed branch: lp:~kamstrup/libunity/gi-friendly-api-tweaks
Merge into: lp:libunity
Diff against target: 290 lines (+62/-29)
6 files modified
configure.ac (+2/-2)
src/unity-lens-category.vala (+2/-2)
src/unity-lens-filters.vala (+21/-10)
src/unity-lens-private.vala (+8/-4)
src/unity-lens.vala (+12/-6)
src/unity-scope-private.vala (+17/-5)
To merge this branch: bzr merge lp:~kamstrup/libunity/gi-friendly-api-tweaks
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+74594@code.launchpad.net

Description of the change

See attached bug. There's an API break here and branches for the lenses (and unity tests) are coming in hot.

I also fixed some string properties to be GIcons because that is better in line with the rest of the libunity api (now that we break api anyway).

To post a comment you must log in.
76. By Mikkel Kamstrup Erlandsen

Bump soname, and bump to an odd micro version number (to indicate dev version)

Revision history for this message
Neil J. Patel (njpatel) wrote :

Looks good, approved.

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 2011-08-04 09:49:49 +0000
3+++ configure.ac 2011-09-08 14:01:10 +0000
4@@ -1,5 +1,5 @@
5 # When releasing also remember to update the soname as instructed below
6-AC_INIT(libunity, 4.0.0)
7+AC_INIT(libunity, 4.0.1)
8
9 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10 AM_CONFIG_HEADER(config.h)
11@@ -16,7 +16,7 @@
12 # - If binary compatibility has been broken (eg removed or changed interfaces)
13 # change to C+1:0:0
14 # - If the interface is the same as the previous version, change to C:R+1:A
15-LIBUNITY_LT_CURRENT=5
16+LIBUNITY_LT_CURRENT=6
17 LIBUNITY_LT_REV=0
18 LIBUNITY_LT_AGE=0
19 LIBUNITY_LT_VERSION="$LIBUNITY_LT_CURRENT:$LIBUNITY_LT_REV:$LIBUNITY_LT_AGE"
20
21=== modified file 'src/unity-lens-category.vala'
22--- src/unity-lens-category.vala 2011-08-02 07:49:39 +0000
23+++ src/unity-lens-category.vala 2011-09-08 14:01:10 +0000
24@@ -33,11 +33,11 @@
25 public class Category : GLib.Object
26 {
27 public string name { get; construct; }
28- public string icon_hint { get; construct; }
29+ public Icon? icon_hint { get; construct; }
30 public CategoryRenderer default_renderer { get; construct; }
31
32 public Category (string name,
33- string icon_hint,
34+ Icon icon_hint,
35 CategoryRenderer renderer=CategoryRenderer.VERTICAL_TILE)
36 {
37 Object(name:name, icon_hint:icon_hint, default_renderer:renderer);
38
39=== modified file 'src/unity-lens-filters.vala'
40--- src/unity-lens-filters.vala 2011-08-05 15:04:52 +0000
41+++ src/unity-lens-filters.vala 2011-09-08 14:01:10 +0000
42@@ -47,7 +47,7 @@
43 {
44 public string id { get; construct; }
45 public string display_name { get; construct; }
46- public string icon_hint { get; construct; }
47+ public Icon? icon_hint { get; construct; }
48 public string renderer_name { get; construct set; }
49 public bool visible { get; construct set; }
50 public bool collapsed { get; construct; }
51@@ -88,10 +88,10 @@
52 {
53 public string id { get; construct; }
54 public string display_name { get; construct; }
55- public string icon_hint { get; construct; }
56+ public Icon icon_hint { get; construct; }
57 public bool active { get; internal construct set; }
58
59- public FilterOption (string id, string display_name, string icon_hint="", bool active=false)
60+ public FilterOption (string id, string display_name, Icon? icon_hint=null, bool active=false)
61 {
62 Object(id:id, display_name:display_name, icon_hint:icon_hint, active:active);
63 }
64@@ -104,7 +104,7 @@
65 {
66 public List<FilterOption> options;
67
68- public FilterOption add_option (string id, string display_name, string icon_hint="")
69+ public FilterOption add_option (string id, string display_name, Icon? icon_hint=null)
70 {
71 var option = new FilterOption(id, display_name, icon_hint);
72 options.append (option);
73@@ -159,7 +159,7 @@
74 }
75 }
76
77- internal void find_and_update_option (string id, string name, string icon_hint, bool active)
78+ internal void find_and_update_option (string id, string name, string icon_hint_s, bool active)
79 {
80 foreach (FilterOption option in options)
81 {
82@@ -171,6 +171,16 @@
83 }
84
85 // Create one as we didn't find it
86+ Icon? icon_hint = null;
87+ try
88+ {
89+ if (icon_hint_s != "")
90+ icon_hint = Icon.new_for_string (icon_hint_s);
91+ }
92+ catch (Error e)
93+ {
94+ warning ("Unable to parse GIcon data '%s': %s", icon_hint_s, e.message);
95+ }
96 var option = new FilterOption (id, name, icon_hint, active);
97 options.append (option);
98 }
99@@ -181,7 +191,8 @@
100
101 foreach (FilterOption option in options)
102 {
103- b.add ("(sssb)", option.id, option.display_name, option.icon_hint, option.active);
104+ var icon_string = option.icon_hint != null ? option.icon_hint.to_string () : "";
105+ b.add ("(sssb)", option.id, option.display_name, icon_string, option.active);
106 }
107
108 var hash = new HashTable<string, Variant> (null, null);
109@@ -200,7 +211,7 @@
110 {
111 public RadioOptionFilter (string id,
112 string display_name,
113- string icon_hint="",
114+ Icon? icon_hint=null,
115 bool collapsed=false)
116 {
117 Object (id:id, display_name:display_name,
118@@ -234,7 +245,7 @@
119 {
120 public CheckOptionFilter (string id,
121 string display_name,
122- string icon_hint="",
123+ Icon? icon_hint=null,
124 bool collapsed=false)
125 {
126 Object (id:id, display_name:display_name,
127@@ -253,7 +264,7 @@
128
129 public RatingsFilter(string id,
130 string display_name,
131- string icon_hint="",
132+ Icon? icon_hint=null,
133 bool collapsed=false)
134 {
135 Object (id:id, display_name:display_name, icon_hint:icon_hint, collapsed:collapsed,
136@@ -304,7 +315,7 @@
137 {
138 public MultiRangeFilter (string id,
139 string display_name,
140- string icon_hint="",
141+ Icon? icon_hint=null,
142 bool collapsed=false)
143 {
144 Object (id:id, display_name:display_name,
145
146=== modified file 'src/unity-lens-private.vala'
147--- src/unity-lens-private.vala 2011-08-06 08:29:54 +0000
148+++ src/unity-lens-private.vala 2011-09-08 14:01:10 +0000
149@@ -104,24 +104,28 @@
150 queue_info_changed ();
151 }
152
153- public void load_categories (Category[] categories)
154+ public void load_categories (List<Category> categories)
155 {
156 foreach (Category category in categories)
157 {
158+ string icon_hint_s = category.icon_hint != null ?
159+ category.icon_hint.to_string() : "";
160 _categories_model.append (category.name,
161- category.icon_hint,
162+ icon_hint_s,
163 category.renderer,
164 Tools.hash_table_to_asv (category.hints));
165 }
166 }
167
168- public void load_filters (Filter[] filters)
169+ public void load_filters (List<Filter> filters)
170 {
171 foreach (Filter filter in filters)
172 {
173+ string icon_hint_s = filter.icon_hint != null ?
174+ filter.icon_hint.to_string() : "";
175 _filters_model.append (filter.id,
176 filter.display_name,
177- filter.icon_hint,
178+ icon_hint_s,
179 filter.renderer_name,
180 Tools.hash_table_to_asv (filter.get_hints()),
181 filter.visible,
182
183=== modified file 'src/unity-lens.vala'
184--- src/unity-lens.vala 2011-08-03 17:59:59 +0000
185+++ src/unity-lens.vala 2011-09-08 14:01:10 +0000
186@@ -32,14 +32,17 @@
187 public string id { get; construct; }
188 public string dbus_path { get; construct; }
189 public string search_hint { get; set; }
190- public Filter[] filters {
191+ public List<Filter> filters {
192 get {
193 return _filters;
194 }
195 set {
196 if (_filters == null)
197 {
198- _filters = value;
199+ _filters = new List<Filter> ();
200+ foreach (Filter f in value)
201+ _filters.prepend (f);
202+ _filters.reverse ();
203 _pimpl.load_filters (_filters);
204 }
205 else
206@@ -48,14 +51,17 @@
207 }
208 }
209 }
210- public Category[] categories {
211+ public List<Category> categories {
212 get {
213 return _categories;
214 }
215 set {
216 if (_categories == null)
217 {
218- _categories = value;
219+ _categories = new List<Category> ();
220+ foreach (Category cat in value)
221+ _categories.prepend (cat);
222+ _categories.reverse ();
223 _pimpl.load_categories (_categories);
224 }
225 else
226@@ -64,8 +70,8 @@
227 }
228
229 private LensImpl _pimpl;
230- private Category[] _categories = null;
231- private Filter[] _filters = null;
232+ private List<Category> _categories = null;
233+ private List<Filter> _filters = null;
234
235 public Lens (string dbus_path_, string id_)
236 {
237
238=== modified file 'src/unity-scope-private.vala'
239--- src/unity-scope-private.vala 2011-08-06 08:29:54 +0000
240+++ src/unity-scope-private.vala 2011-09-08 14:01:10 +0000
241@@ -136,32 +136,44 @@
242 private void on_filter_added (Dee.Model model, Dee.ModelIter iter)
243 {
244 string renderer_name = model.get_string (iter, FilterColumn.RENDERER_NAME);
245-
246+ string icon_hint_s = model.get_string (iter, FilterColumn.ICON_HINT);
247+
248+ Icon? icon_hint = null;
249+ try
250+ {
251+ if (icon_hint_s != "")
252+ icon_hint = Icon.new_for_string (icon_hint_s);
253+ }
254+ catch (Error e)
255+ {
256+ warning ("Error parsing GIcon data '%s': %s", icon_hint_s, e.message);
257+ }
258+
259 Filter? filter = null;
260 if (renderer_name == "filter-ratings")
261 {
262 filter = new RatingsFilter (model.get_string (iter, FilterColumn.ID),
263 model.get_string (iter, FilterColumn.NAME),
264- model.get_string (iter, FilterColumn.ICON_HINT));
265+ icon_hint);
266 }
267 else if (renderer_name == "filter-radiooption")
268 {
269 filter = new RadioOptionFilter (model.get_string (iter, FilterColumn.ID),
270 model.get_string (iter, FilterColumn.NAME),
271- model.get_string (iter, FilterColumn.ICON_HINT));
272+ icon_hint);
273
274 }
275 else if (renderer_name == "filter-checkoption")
276 {
277 filter = new CheckOptionFilter (model.get_string (iter, FilterColumn.ID),
278 model.get_string (iter, FilterColumn.NAME),
279- model.get_string (iter, FilterColumn.ICON_HINT));
280+ icon_hint);
281 }
282 else if (renderer_name == "filter-multirange")
283 {
284 filter = new MultiRangeFilter (model.get_string (iter, FilterColumn.ID),
285 model.get_string (iter, FilterColumn.NAME),
286- model.get_string (iter, FilterColumn.ICON_HINT));
287+ icon_hint);
288 }
289
290 if (filter is Filter)

Subscribers

People subscribed via source and target branches