Merge lp:~mhr3/libunity/api-tweaks into lp:libunity

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 242
Merged at revision: 240
Proposed branch: lp:~mhr3/libunity/api-tweaks
Merge into: lp:libunity
Diff against target: 169 lines (+60/-14)
10 files modified
configure.ac (+1/-1)
debian/changelog (+7/-0)
debian/libunity9.symbols (+1/-0)
protocol/protocol-scope-discovery.vala (+18/-2)
src/unity-utils.vala (+23/-1)
test/data/unity/scopes/masterscope_b.scope (+2/-2)
test/data/unity/scopes/masterscope_b/brokenscope.scope (+2/-2)
test/data/unity/scopes/masterscope_b/subscope1.scope (+2/-2)
test/data/unity/scopes/masterscope_b/subscope2.scope (+2/-2)
test/data/unity/scopes/test_masterscope.scope (+2/-2)
To merge this branch: bzr merge lp:~mhr3/libunity/api-tweaks
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Paweł Stołowski (community) Approve
Review via email: mp+171057@code.launchpad.net

Commit message

Add unity_object_unref wrapper, deprecate the DBusName and DBusPath keys in .scope files, use UniqueName & GroupName instead (same as what the API uses).

Description of the change

Add unity_object_unref wrapper, deprecate the DBusName and DBusPath keys in .scope files, use UniqueName & GroupName instead (same as what the API uses).

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks good overall, just two comments:

86 + if (o.get_type ().name ().has_prefix ("Unity"))

This check looks a bit shaky, but I recon we can't do much more... So, how about renaming object_unref to unity_object_unref to emphasize this requirement?

82 + public static void object_unref (void* object)
What's the use case / who is going to use it? Can you add a docstring?

review: Needs Fixing
lp:~mhr3/libunity/api-tweaks updated
242. By Michal Hruby

Add proper doc string

Revision history for this message
Michal Hruby (mhr3) wrote :

> Looks good overall, just two comments:
>
> 86 + if (o.get_type ().name ().has_prefix ("Unity"))
>
> This check looks a bit shaky, but I recon we can't do much more... So, how
> about renaming object_unref to unity_object_unref to emphasize this
> requirement?

That's already the name, note the Unity namespace.

>
> 82 + public static void object_unref (void* object)
> What's the use case / who is going to use it? Can you add a docstring?

It's *the* destructor for everything.

Revision history for this message
Paweł Stołowski (stolowski) wrote :

Ok, thanks for clarification, let's get it it.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

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 2013-06-18 17:29:18 +0000
3+++ configure.ac 2013-06-24 16:07:47 +0000
4@@ -1,5 +1,5 @@
5 # When releasing also remember to update the soname as instructed below
6-AC_INIT(libunity, 7.0.4)
7+AC_INIT(libunity, 7.0.5)
8
9 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
10 AM_CONFIG_HEADER(config.h)
11
12=== modified file 'debian/changelog'
13--- debian/changelog 2013-06-21 04:02:47 +0000
14+++ debian/changelog 2013-06-24 16:07:47 +0000
15@@ -1,3 +1,10 @@
16+libunity (7.0.5-0ubuntu1) UNRELEASED; urgency=low
17+
18+ * Add unity_object_unref wrapper.
19+ * Use GroupName and UniqueName in the .scope files.
20+
21+ -- Michal Hruby <michal.hruby@canonical.com> Mon, 24 Jun 2013 11:28:15 +0100
22+
23 libunity (7.0.4daily13.06.21-0ubuntu1) saucy; urgency=low
24
25 [ Michal Hruby ]
26
27=== modified file 'debian/libunity9.symbols'
28--- debian/libunity9.symbols 2013-06-21 15:35:04 +0000
29+++ debian/libunity9.symbols 2013-06-24 16:07:47 +0000
30@@ -572,6 +572,7 @@
31 unity_music_preview_get_type@Base 5.90.0
32 unity_music_preview_new@Base 5.90.0
33 unity_music_preview_track_state_get_type@Base 5.92.0
34+ unity_object_unref@Base 0replaceme
35 unity_options_filter_add_option@Base 4.0.0
36 unity_options_filter_construct@Base 4.0.0
37 unity_options_filter_find_and_update_option@Base 4.0.0
38
39=== modified file 'protocol/protocol-scope-discovery.vala'
40--- protocol/protocol-scope-discovery.vala 2013-06-11 10:24:17 +0000
41+++ protocol/protocol-scope-discovery.vala 2013-06-24 16:07:47 +0000
42@@ -234,8 +234,24 @@
43
44 // required fields
45 this.name = dgettext(this.domain, file.get_string (SCOPE_GROUP, "Name"));
46- this.dbus_name = file.get_string (SCOPE_GROUP, "DBusName");
47- this.dbus_path = file.get_string (SCOPE_GROUP, "DBusPath");
48+ // support deprecated DBusName / DBusPath, but require the new
49+ // GroupName & UniqueName
50+ if (file.has_key (SCOPE_GROUP, "DBusName"))
51+ {
52+ this.dbus_name = file.get_string (SCOPE_GROUP, "DBusName");
53+ }
54+ else
55+ {
56+ this.dbus_name = file.get_string (SCOPE_GROUP, "GroupName");
57+ }
58+ if (file.has_key (SCOPE_GROUP, "DBusPath"))
59+ {
60+ this.dbus_path = file.get_string (SCOPE_GROUP, "DBusPath");
61+ }
62+ else
63+ {
64+ this.dbus_path = file.get_string (SCOPE_GROUP, "UniqueName");
65+ }
66 this.icon = file.get_string (SCOPE_GROUP, "Icon");
67 this.type = file.get_string (SCOPE_GROUP, "Type");
68
69
70=== modified file 'src/unity-utils.vala'
71--- src/unity-utils.vala 2013-06-21 15:27:07 +0000
72+++ src/unity-utils.vala 2013-06-24 16:07:47 +0000
73@@ -21,7 +21,28 @@
74 using GLib;
75 using Gee;
76
77-namespace Unity.Internal {
78+namespace Unity {
79+
80+ /**
81+ * Destroy an object.
82+ *
83+ * Unreferences object returned by one of unity_*_new constructors.
84+ */
85+ public static void object_unref (void* object)
86+ {
87+ Object* o_ptr = (Object*) object;
88+ // we don't want people using unity_object_unref for non Unity classes
89+ if (o_ptr is Object && o_ptr->get_type ().name ().has_prefix ("Unity"))
90+ {
91+ delete o_ptr;
92+ }
93+ else
94+ {
95+ critical ("Unable to unref object, invalid object type");
96+ }
97+ }
98+
99+namespace Internal {
100
101 /* Cateories: [id, display_name, icon, renderer_name, hints] */
102 internal const string[] CATEGORIES_SCHEMA = {"s", "s", "s", "s", "a{sv}"};
103@@ -287,3 +308,4 @@
104 }
105
106 } /* namespace Unity.Internal */
107+} /* namespace Unity */
108
109=== modified file 'test/data/unity/scopes/masterscope_b.scope'
110--- test/data/unity/scopes/masterscope_b.scope 2013-06-10 12:02:11 +0000
111+++ test/data/unity/scopes/masterscope_b.scope 2013-06-24 16:07:47 +0000
112@@ -1,6 +1,6 @@
113 [Scope]
114-DBusName=com.canonical.Unity.Scope.MasterB
115-DBusPath=/com/canonical/unity/scope/masterb
116+GroupName=com.canonical.Unity.Scope.MasterB
117+UniqueName=/com/canonical/unity/scope/masterb
118 Icon=/usr/share/unity/6/icon2.svg
119 IsMaster=true
120 RequiredMetadata=bid[s];a[s];b[y];
121
122=== modified file 'test/data/unity/scopes/masterscope_b/brokenscope.scope'
123--- test/data/unity/scopes/masterscope_b/brokenscope.scope 2012-12-04 17:19:39 +0000
124+++ test/data/unity/scopes/masterscope_b/brokenscope.scope 2013-06-24 16:07:47 +0000
125@@ -1,3 +1,3 @@
126 [Scope]
127-DBusName=com.canonical.Unity.Scope.Subscope1
128-DBusPath=/com/canonical/unity/scope/subscope1
129+GroupName=com.canonical.Unity.Scope.Subscope1
130+UniqueName=/com/canonical/unity/scope/subscope1
131
132=== modified file 'test/data/unity/scopes/masterscope_b/subscope1.scope'
133--- test/data/unity/scopes/masterscope_b/subscope1.scope 2013-04-23 18:21:33 +0000
134+++ test/data/unity/scopes/masterscope_b/subscope1.scope 2013-06-24 16:07:47 +0000
135@@ -1,6 +1,6 @@
136 [Scope]
137-DBusName=com.canonical.Unity.Scope.Subscope1
138-DBusPath=/com/canonical/unity/scope/subscope1
139+GroupName=com.canonical.Unity.Scope.Subscope1
140+UniqueName=/com/canonical/unity/scope/subscope1
141 Icon=/usr/share/unity/6/icon-sub1.svg
142 RequiredMetadata=bid[s];
143 OptionalMetadata=
144
145=== modified file 'test/data/unity/scopes/masterscope_b/subscope2.scope'
146--- test/data/unity/scopes/masterscope_b/subscope2.scope 2013-04-03 15:22:36 +0000
147+++ test/data/unity/scopes/masterscope_b/subscope2.scope 2013-06-24 16:07:47 +0000
148@@ -1,6 +1,6 @@
149 [Scope]
150-DBusName=com.canonical.Unity.Scope.Subscope2
151-DBusPath=/com/canonical/unity/scope/subscope2
152+GroupName=com.canonical.Unity.Scope.Subscope2
153+UniqueName=/com/canonical/unity/scope/subscope2
154 Icon=/usr/share/unity/6/icon-sub2.svg
155 Keywords=pooh;
156 Type=various
157
158=== modified file 'test/data/unity/scopes/test_masterscope.scope'
159--- test/data/unity/scopes/test_masterscope.scope 2013-04-03 15:22:36 +0000
160+++ test/data/unity/scopes/test_masterscope.scope 2013-06-24 16:07:47 +0000
161@@ -1,6 +1,6 @@
162 [Scope]
163-DBusName=com.canonical.Unity.Scope.Test
164-DBusPath=/com/canonical/Unity/MasterScope/Test
165+GroupName=com.canonical.Unity.Scope.Test
166+UniqueName=/com/canonical/Unity/MasterScope/Test
167 Icon=/usr/share/unity/6/icon1.svg
168 IsMaster=true
169 RequiredMetadata=required_string[s];required_int[i];

Subscribers

People subscribed via source and target branches