Merge lp:~ted/hud/context-api into lp:hud/13.10

Proposed by Ted Gould
Status: Superseded
Proposed branch: lp:~ted/hud/context-api
Merge into: lp:hud/13.10
Prerequisite: lp:~ted/hud/libhud-docs
Diff against target: 1015 lines (+320/-108)
20 files modified
CMakeLists.txt (+2/-6)
data/com.canonical.hud.Application.xml (+6/-2)
debian/control (+10/-10)
debian/gir1.2-hud-2.install (+1/-1)
debian/libhud2-dev.install (+4/-4)
debian/libhud2.install (+1/-1)
debian/libhud2.symbols (+5/-3)
libhud-client/CMakeLists.txt (+4/-0)
libhud/CMakeLists.txt (+16/-12)
libhud/action-publisher.c (+121/-30)
libhud/action-publisher.h (+19/-2)
libhud/manager.c (+65/-6)
libhud/manager.h (+3/-0)
src/CMakeLists.txt (+4/-0)
src/application-source.c (+22/-9)
tests/CMakeLists.txt (+4/-0)
tests/hudtestutils.c (+1/-4)
tests/test-hud-action-publisher.c (+6/-8)
tests/test-hud-client-query.c (+17/-1)
tests/test-hud-manager.c (+9/-9)
To merge this branch: bzr merge lp:~ted/hud/context-api
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+158939@code.launchpad.net

This proposal supersedes a proposal from 2013-04-01.

This proposal has been superseded by a proposal from 2013-05-14.

Commit message

Allow applications to define a context for actions.

Description of the change

Provides a way to define contexts on action descriptions and change context on the manager. These are needed for applications to fully realize contexts.

To post a comment you must log in.
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote : Posted in a previous version of this proposal

98 +HudActionPublisher * hud_action_publisher_new (guint window_id,
99 + const gchar * context_id);

I would like to have a version of this function where the context_id is autogenerated if it's omitted. So we would have two functions:
hud_action_publisher_new (guint window_id);
hud_action_publisher_new_with_context_id (guint window_id, const gchar * context_id);

171 +void hud_manager_switch_window_context (HudManager * manager,
172 + guint windowid,
173 + const gchar * new_context);

as the action description already contains the windowId and contextId how about changing the signature of this function to hud_manager_switch_window_context (HudManager * manager, HudActionPublisher *publisher) ?

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote : Posted in a previous version of this proposal

> 171 +void hud_manager_switch_window_context (HudManager * manager,
> 172 + guint windowid,
> 173 + const gchar * new_context);
>
> as the action description already contains the windowId and contextId how
> about changing the signature of this function to
> hud_manager_switch_window_context (HudManager * manager, HudActionPublisher
> *publisher) ?

Also, windowId and contextId should be properties of the HudActionPublisher. You can access them through the build_id() but that is a bit clumsy.

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

On Wed, 2013-03-27 at 11:51 +0000, Antti Kaijanmäki wrote:

> > 171 +void hud_manager_switch_window_context (HudManager * manager,
> > 172 + guint windowid,
> > 173 + const gchar * new_context);
> >
> > as the action description already contains the windowId and contextId how
> > about changing the signature of this function to
> > hud_manager_switch_window_context (HudManager * manager, HudActionPublisher
> > *publisher) ?
>
> Also, windowId and contextId should be properties of the HudActionPublisher.. You can access them through the build_id() but that is a bit clumsy.

Makes sense. Added in r360.

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

On Wed, 2013-03-27 at 11:48 +0000, Antti Kaijanmäki wrote:

> 98 +HudActionPublisher * hud_action_publisher_new (guint window_id,
> 99 + const gchar * context_id);
>
> I would like to have a version of this function where the context_id is autogenerated if it's omitted. So we would have two functions:
> hud_action_publisher_new (guint window_id);
> hud_action_publisher_new_with_context_id (guint window_id, const gchar * context_id);

That's why I created the HUD_ACTION_PUBLISHER_NO_CONTEXT define. So
it'd just be a call like this:

  hud_action_publisher_new (5, HUD_ACTION_PUBLISHER_NO_CONTEXT)

In that case it wouldn't be autogenerated, just passed and kept as NULL.

> 171 +void hud_manager_switch_window_context (HudManager * manager,
> 172 + guint windowid,
> 173 + const gchar * new_context);
>
> as the action description already contains the windowId and contextId how about changing the signature of this function to hud_manager_switch_window_context (HudManager * manager, HudActionPublisher *publisher) ?

Makes sense. r361.

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote : Posted in a previous version of this proposal

> > I would like to have a version of this function where the context_id is
> autogenerated if it's omitted. So we would have two functions:
> > hud_action_publisher_new (guint window_id);
> > hud_action_publisher_new_with_context_id (guint window_id, const gchar *
> context_id);
>
> That's why I created the HUD_ACTION_PUBLISHER_NO_CONTEXT define. So
> it'd just be a call like this:
>
> hud_action_publisher_new (5, HUD_ACTION_PUBLISHER_NO_CONTEXT)
>
> In that case it wouldn't be autogenerated, just passed and kept as NULL.

OK, but say I create 3 action publishers with HUD_ACTION_PUBLISHER_NO_CONTEXT. How do I switch between them if they don't have context Ids?

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

On Thu, 2013-03-28 at 13:58 +0000, Antti Kaijanmäki wrote:

> OK, but say I create 3 action publishers with
> HUD_ACTION_PUBLISHER_NO_CONTEXT. How do I switch between them if they
> don't have context Ids?

Uhm, don't do that? :-)

I mean, an action publisher represents a context. If there's only one
context on a window, you can pass no context, if there's more you need
to provide context IDs or it's an error.

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote : Posted in a previous version of this proposal

> On Thu, 2013-03-28 at 13:58 +0000, Antti Kaijanmäki wrote:
>
> > OK, but say I create 3 action publishers with
> > HUD_ACTION_PUBLISHER_NO_CONTEXT. How do I switch between them if they
> > don't have context Ids?
>
>
> Uhm, don't do that? :-)
>
> I mean, an action publisher represents a context. If there's only one
> context on a window, you can pass no context, if there's more you need
> to provide context IDs or it's an error.

Yes, OK. So this relates back to the "who should generate all these IDs" discussion we had earlier. IMHO the app developer should not have to care about the context ID (or generate it). All he would need to do is create a new ActionPublisher and if he chooses not to generate the context ID then it should be generated by libhud. So if the developer passes NULL as a context Id then action_publisher_new() would generate one. Do we actually need action publishers with context id set to NULL anyway?

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

On Thu, 2013-03-28 at 14:43 +0000, Antti Kaijanmäki wrote:

> Yes, OK. So this relates back to the "who should generate all these
> IDs" discussion we had earlier. IMHO the app developer should not have
> to care about the context ID (or generate it). All he would need to do
> is create a new ActionPublisher and if he chooses not to generate the
> context ID then it should be generated by libhud. So if the developer
> passes NULL as a context Id then action_publisher_new() would generate
> one. Do we actually need action publishers with context id set to NULL
> anyway?

I'd guess that that context IDs are less of an issue of generating, and
more set by human-readable names. For instance in Gallery we could
imagine "overview" and "photo-view". So these would then be most
related to how they are used. Or a web browser could have a set of tabs
and use what ever ID was used there as well.

We could just generate the ID if one was not given. That's fine with
me. I was more thinking that you were saying that you'd want to switch
without switching contexts.

Adding generation of a base ID in r360

Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote : Posted in a previous version of this proposal

OK, couple of comments.

we don't need HUD_ACTION_PUBLISHER_NO_CONTEXT anymore. We can just document that when a NULL is passed then the context id is automatically generated.

Are we missing some commits from this repo? Commits mentioned in these comments seem to be missing:
https://code.launchpad.net/~ted/hud/context-api/+merge/155596/comments/340267
https://code.launchpad.net/~ted/hud/context-api/+merge/155596/comments/340269

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

On Fri, 2013-03-29 at 14:21 +0000, Antti Kaijanmäki wrote:

> we don't need HUD_ACTION_PUBLISHER_NO_CONTEXT anymore. We can just document that when a NULL is passed then the context id is automatically generated.

I'd prefer to do both. In that I think it makes the code more readable
to not have "0"s and "NULL"s as function parameters. I don't think it
hurts anything to leave it in.

> Are we missing some commits from this repo? Commits mentioned in these comments seem to be missing:
> https:��code.launchpad.net�~ted�hud�context-api�+merge�155596�comments�340267
> https:��code.launchpad.net�~ted�hud�context-api�+merge�155596�comments�340269

No clue. Looked all over, can't find them. Just redid them. They
should be there now.

Revision history for this message
Ted Gould (ted) wrote : Posted in a previous version of this proposal

I think this now has everything it needs on the libhud side of things. Putting it up for review.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:374
http://jenkins.qa.ubuntu.com/job/hud-ci/8/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/hud-raring-amd64-ci/12/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/hud-ci/8/rebuild

review: Needs Fixing (continuous-integration)
lp:~ted/hud/context-api updated
378. By Ted Gould

Merging in lp:hud

379. By Ted Gould

Migrating to new action publisher API

380. By Ted Gould

Dropping the unused iter

381. By Ted Gould

Making sure to remove the timeouts after we're done waiting

382. By Ted Gould

Switch to new HUD Action Publisher API.

383. By Ted Gould

Cut and paste error

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:383
http://jenkins.qa.ubuntu.com/job/hud-ci/9/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/hud-raring-amd64-ci/13/console

Click here to trigger a rebuild:
http://s-jenkins:8080/job/hud-ci/9/rebuild

review: Needs Fixing (continuous-integration)
lp:~ted/hud/context-api updated
384. By Ted Gould

Fixing the API of the application object

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:384
http://jenkins.qa.ubuntu.com/job/hud-ci/10/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/hud-raring-amd64-ci/14

Click here to trigger a rebuild:
http://s-jenkins:8080/job/hud-ci/10/rebuild

review: Approve (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

I'm happy with this API. approved.

review: Approve

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2013-04-12 16:05:14 +0000
3+++ CMakeLists.txt 2013-04-15 19:11:56 +0000
4@@ -6,15 +6,11 @@
5 set(PACKAGE ${CMAKE_PROJECT_NAME})
6 set(GETTEXT_PACKAGE ${CMAKE_PROJECT_NAME})
7
8-if(PROJECT_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR)
9- message(FATAL_ERROR "In-tree build attempt detected, aborting. Set your build dir outside your source dir, delete CMakeCache.txt from source root and try again.")
10-endif()
11-
12 option(ENABLE_DOCUMENTATION "Enable documentation." OFF)
13 option(ENABLE_TESTS "Enable tests." ON)
14 option(ENABLE_VOICE_TESTS "Enable voice tests" ON)
15 option(ENABLE_SCALABILITY_TESTS "Additional scalability tests that are potentially very slow to run." OFF)
16-option(FULL_WARNINGS "Full compiler warnings." OFF)
17+option(FULL_WARNINGS "Full compiler warnings." ON)
18 option(DEBUG_MESSAGES "Print debug messages." OFF)
19 option(LOCAL_INSTALL "Support local installation." OFF)
20 option(ENABLE_PLATFORM_API "Enable building for platform API." OFF)
21@@ -40,7 +36,7 @@
22 endif()
23
24 if(${FULL_WARNINGS})
25- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")
26+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
27 endif()
28
29 if(${DEBUG_MESSAGES})
30
31=== modified file 'data/com.canonical.hud.Application.xml'
32--- data/com.canonical.hud.Application.xml 2013-02-06 18:34:06 +0000
33+++ data/com.canonical.hud.Application.xml 2013-04-15 19:11:56 +0000
34@@ -9,8 +9,12 @@
35
36 <!-- Functions -->
37 <method name="AddSources">
38- <arg type="a(vso)" name="actions" direction="in" />
39- <arg type="a(vo)" name="descriptions" direction="in" />
40+ <arg type="a(usso)" name="actions" direction="in" />
41+ <arg type="a(uso)" name="descriptions" direction="in" />
42+ </method>
43+ <method name="SetWindowContext">
44+ <arg type="u" name="window" direction="in" />
45+ <arg type="s" name="context" direction="in" />
46 </method>
47
48 <!-- Signals -->
49
50=== modified file 'debian/control'
51--- debian/control 2013-04-12 15:31:34 +0000
52+++ debian/control 2013-04-15 19:11:56 +0000
53@@ -94,7 +94,7 @@
54 .
55 This package provides tools for working with Unity's HUD.
56
57-Package: libhud1
58+Package: libhud2
59 Section: libs
60 Architecture: any
61 Depends: ${shlibs:Depends},
62@@ -108,12 +108,12 @@
63 .
64 This package contains shared libraries to be used by applications.
65
66-Package: libhud1-dev
67+Package: libhud2-dev
68 Section: libdevel
69 Architecture: any
70 Depends: ${shlibs:Depends},
71 ${misc:Depends},
72- libhud1 (= ${binary:Version}),
73+ libhud2 (= ${binary:Version}),
74 libglib2.0-dev
75 Multi-Arch: same
76 Description: library for exporting items to the Unity HUD
77@@ -122,28 +122,28 @@
78 .
79 This package contains files that are needed to build applications.
80
81-Package: libhud1-doc
82+Package: libhud2-doc
83 Section: doc
84 Architecture: all
85 Depends: ${shlibs:Depends},
86 ${misc:Depends},
87- libhud1-dev (>= ${source:Version}),
88+ libhud2-dev (>= ${source:Version}),
89 Description: library for exporting items to the Unity HUD
90 Allows applications to add items into the HUD without requiring a
91 menubar or other parsed GUI elements.
92 .
93 This package contains developer documentation.
94
95-Package: gir1.2-hud-1
96+Package: gir1.2-hud-2
97 Section: libs
98 Architecture: any
99 Depends: ${shlibs:Depends},
100 ${misc:Depends},
101- libhud1 (= ${binary:Version}),
102+ libhud2 (= ${binary:Version}),
103 ${gir:Depends},
104 Pre-Depends: ${misc:Pre-Depends}
105 Recommends: hud (= ${binary:Version})
106-Description: typelib file for libhud1
107+Description: typelib file for libhud2
108 Allows applications to add items into the HUD without requiring a
109 menubar or other parsed GUI elements.
110 .
111@@ -170,7 +170,7 @@
112 Depends: ${shlibs:Depends},
113 ${misc:Depends},
114 libhud-gtk1 (= ${binary:Version}),
115- libhud1-dev (= ${binary:Version}),
116+ libhud2-dev (= ${binary:Version}),
117 libgtk-3-dev,
118 Multi-Arch: same
119 Description: GTK helpers for exporting items to the Unity HUD
120@@ -185,7 +185,7 @@
121 Depends: ${shlibs:Depends},
122 ${misc:Depends},
123 libhud-gtk1-dev (>= ${source:Version}),
124- libhud1-doc (>= ${source:Version}),
125+ libhud2-doc (>= ${source:Version}),
126 Description: GTK helpers for exporting items to the Unity HUD
127 Allows applications to add items into the HUD without requiring a
128 menubar or other parsed GUI elements using standard GTK features.
129
130=== renamed file 'debian/gir1.2-hud-1.install' => 'debian/gir1.2-hud-2.install'
131--- debian/gir1.2-hud-1.install 2013-03-21 11:35:24 +0000
132+++ debian/gir1.2-hud-2.install 2013-04-15 19:11:56 +0000
133@@ -1,1 +1,1 @@
134-usr/lib/*/girepository-1.0/Hud-1.typelib
135+usr/lib/*/girepository-1.0/Hud-2.typelib
136
137=== renamed file 'debian/libhud1-dev.install' => 'debian/libhud2-dev.install'
138--- debian/libhud1-dev.install 2013-03-27 18:22:19 +0000
139+++ debian/libhud2-dev.install 2013-04-15 19:11:56 +0000
140@@ -1,5 +1,5 @@
141-debian/tmp/usr/include/libhud-1/*
142+debian/tmp/usr/include/libhud-2/*
143 debian/tmp/usr/lib/*/libhud.so
144-debian/tmp/usr/lib/*/pkgconfig/hud-1.pc
145-debian/tmp/usr/share/gir-1.0/Hud-1.gir
146-debian/tmp/usr/share/vala/vapi/Hud-1.vapi
147+debian/tmp/usr/lib/*/pkgconfig/hud-2.pc
148+debian/tmp/usr/share/gir-1.0/Hud-2.gir
149+debian/tmp/usr/share/vala/vapi/Hud-2.vapi
150
151=== renamed file 'debian/libhud1-doc.install' => 'debian/libhud2-doc.install'
152=== renamed file 'debian/libhud1.install' => 'debian/libhud2.install'
153--- debian/libhud1.install 2012-11-27 22:37:34 +0000
154+++ debian/libhud2.install 2013-04-15 19:11:56 +0000
155@@ -1,1 +1,1 @@
156-debian/tmp/usr/lib/*/libhud.so.1*
157+debian/tmp/usr/lib/*/libhud.so.2*
158
159=== renamed file 'debian/libhud1.symbols' => 'debian/libhud2.symbols'
160--- debian/libhud1.symbols 2013-04-01 16:41:21 +0000
161+++ debian/libhud2.symbols 2013-04-15 19:11:56 +0000
162@@ -1,4 +1,4 @@
163-libhud.so.1 libhud1 #MINVER#
164+libhud.so.2 libhud2 #MINVER#
165 hud_action_description_get_action_name@Base 13.04.0
166 hud_action_description_get_action_target@Base 13.04.0
167 hud_action_description_get_type@Base 13.04.0
168@@ -12,9 +12,10 @@
169 hud_action_publisher_add_description@Base 13.04.0
170 hud_action_publisher_get_action_groups@Base 13.04.0-0ubuntu1~ppa2
171 hud_action_publisher_get_description_path@Base 13.04.0-0ubuntu1~ppa2
172- hud_action_publisher_get_id@Base 13.04.0-0ubuntu1~ppa2
173+ hud_action_publisher_get_context_id@Base 13.10.0
174 hud_action_publisher_get_type@Base 13.04.0
175- hud_action_publisher_new_for_id@Base 13.04.0-0ubuntu1~ppa2
176+ hud_action_publisher_get_window_id@Base 13.10.0
177+ hud_action_publisher_new@Base 13.10.0
178 hud_action_publisher_new_for_application@Base 13.04.0
179 hud_action_publisher_remove_action_group@Base 13.04.0
180 hud_manager_add_actions@Base 13.04.0
181@@ -22,3 +23,4 @@
182 hud_manager_new@Base 13.04.0-0ubuntu1~ppa2
183 hud_manager_new_for_application@Base 13.04.0-0ubuntu1~ppa2
184 hud_manager_remove_actions@Base 13.04.0
185+ hud_manager_switch_window_context@Base 13.10.0
186
187=== modified file 'libhud-client/CMakeLists.txt'
188--- libhud-client/CMakeLists.txt 2013-03-28 21:44:03 +0000
189+++ libhud-client/CMakeLists.txt 2013-04-15 19:11:56 +0000
190@@ -16,6 +16,10 @@
191
192 add_definitions( -DHUD_CLIENT_COMPILATION=1 )
193
194+if(${FULL_WARNINGS})
195+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
196+endif()
197+
198 ###########################
199 # Version Information
200 ###########################
201
202=== modified file 'libhud/CMakeLists.txt'
203--- libhud/CMakeLists.txt 2013-03-31 18:49:53 +0000
204+++ libhud/CMakeLists.txt 2013-04-15 19:11:56 +0000
205@@ -16,12 +16,16 @@
206
207 add_definitions( -DHUD_COMPILATION=1 )
208
209+if(${FULL_WARNINGS})
210+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
211+endif()
212+
213 ###########################
214 # Version Information
215 ###########################
216
217-set(API_VERSION 1)
218-set(ABI_VERSION 1)
219+set(API_VERSION 2)
220+set(ABI_VERSION 2)
221
222 ###########################
223 # Generated Lib Hud
224@@ -123,20 +127,20 @@
225 set(INTROSPECTION_GIRS)
226
227 set(_introspection_files ${HUD_SOURCES} ${HUD_HEADERS})
228- set(Hud_1_gir "hud")
229- set(Hud_1_gir_INCLUDES GObject-2.0)
230+ set(Hud_2_gir "hud")
231+ set(Hud_2_gir_INCLUDES GObject-2.0)
232
233 gir_get_cflags(_cflags)
234- set(Hud_1_gir_CFLAGS ${_cflags})
235+ set(Hud_2_gir_CFLAGS ${_cflags})
236
237- set(Hud_1_gir_LIBS hud)
238+ set(Hud_2_gir_LIBS hud)
239
240 list_make_absolute(_abs_introspection_files _introspection_files "${CMAKE_CURRENT_SOURCE_DIR}/")
241- set(Hud_1_gir_FILES ${_abs_introspection_files})
242- set(Hud_1_gir_SCANNERFLAGS --c-include "hud.h")
243- set(Hud_1_gir_EXPORT_PACKAGES "hud-${API_VERSION}")
244+ set(Hud_2_gir_FILES ${_abs_introspection_files})
245+ set(Hud_2_gir_SCANNERFLAGS --c-include "hud.h")
246+ set(Hud_2_gir_EXPORT_PACKAGES "hud-${API_VERSION}")
247
248- list(APPEND INTROSPECTION_GIRS Hud-1.gir)
249+ list(APPEND INTROSPECTION_GIRS Hud-2.gir)
250 gir_add_introspections(INTROSPECTION_GIRS)
251 else()
252 message("Not performing GIR as required tools not found")
253@@ -151,11 +155,11 @@
254
255 vapi_gen(hud-vapi
256 INPUT
257- Hud-1.gir
258+ Hud-2.gir
259 PACKAGES
260 gio-2.0
261 LIBRARY
262- Hud-1
263+ Hud-2
264 )
265
266 install(
267
268=== modified file 'libhud/action-publisher.c'
269--- libhud/action-publisher.c 2013-04-05 03:14:08 +0000
270+++ libhud/action-publisher.c 2013-04-15 19:11:56 +0000
271@@ -50,9 +50,11 @@
272 {
273 GObject parent_instance;
274
275+ guint window_id;
276+ gchar * context_id;
277+
278 GDBusConnection *bus;
279 GApplication *application;
280- GVariant * id;
281 gint export_id;
282 gchar *path;
283
284@@ -167,8 +169,6 @@
285 {
286 HudActionPublisher *self = HUD_ACTION_PUBLISHER(object);
287
288- g_clear_pointer(&self->id, g_variant_unref);
289-
290 g_clear_object(&self->aux);
291 g_clear_object(&self->application);
292
293@@ -188,6 +188,8 @@
294 static void
295 hud_action_publisher_finalize (GObject *object)
296 {
297+ g_clear_pointer (&HUD_ACTION_PUBLISHER(object)->context_id, g_free);
298+
299 G_OBJECT_CLASS (hud_action_publisher_parent_class)->finalize (object);
300 return;
301 }
302@@ -283,27 +285,33 @@
303 return publisher;
304 }
305
306+static guint context_count = 0;
307+
308 /**
309- * hud_action_publisher_new_for_id:
310- * @id: A window ID
311+ * hud_action_publisher_new:
312+ * @window_id: (allow-none): A window ID
313+ * @context_id: (allow-none): A context ID
314 *
315 * Creates a new #HudActionPublisher based on the window ID passed
316- * in via @id.
317+ * in via @window_id and context ID from @context_id.
318+ *
319+ * Either one of them can be not used by passing in eithe of the
320+ * defines #HUD_ACTION_PUBLISHER_ALL_WINDOWS or #HUD_ACTION_PUBLISHER_NO_CONTEXT
321+ * for the appropriate parameter.
322 *
323 * Return value: (transfer full): A new #HudActionPublisher object
324 */
325 HudActionPublisher *
326-hud_action_publisher_new_for_id (GVariant * id)
327+hud_action_publisher_new (guint window_id, const gchar * context_id)
328 {
329 HudActionPublisher * publisher;
330 publisher = g_object_new (HUD_TYPE_ACTION_PUBLISHER, NULL);
331- if (id != NULL)
332- {
333- publisher->id = g_variant_ref_sink(id);
334- }
335- else
336- {
337- publisher->id = g_variant_ref_sink(g_variant_new_int32(-1));
338+ publisher->window_id = window_id;
339+
340+ if (context_id != NULL) {
341+ publisher->context_id = g_strdup(context_id);
342+ } else {
343+ publisher->context_id = g_strdup_printf("action-publisher-context-%d", context_count++);
344 }
345
346 return publisher;
347@@ -410,6 +418,73 @@
348 }
349
350 /**
351+ * hud_action_publisher_remove_description:
352+ * @publisher: the #HudActionPublisher
353+ * @action_name: an action name
354+ * @action_target: (allow-none): an action target
355+ *
356+ * Removes the action descriptions that has the name @action_name and
357+ * the target value @action_target (including the possibility of %NULL).
358+ **/
359+void
360+hud_action_publisher_remove_description (HudActionPublisher *publisher,
361+ const gchar *action_name,
362+ GVariant *action_target)
363+{
364+ HudActionDescription tmp;
365+ GSequenceIter *iter;
366+
367+ tmp.identifier = format_identifier (action_name, action_target);
368+ iter = g_sequence_lookup (publisher->descriptions, &tmp, compare_descriptions, NULL);
369+ g_free (tmp.identifier);
370+
371+ if (iter)
372+ {
373+ gint position;
374+
375+ position = g_sequence_iter_get_position (iter);
376+ disconnect_handler (g_sequence_get (iter), publisher);
377+ g_sequence_remove (iter);
378+
379+ g_menu_model_items_changed (G_MENU_MODEL (publisher->aux), position, 1, 0);
380+ }
381+}
382+
383+/**
384+ * hud_action_publisher_remove_descriptions:
385+ * @publisher: the #HudActionPublisher
386+ * @action_name: an action name
387+ *
388+ * Removes all action descriptions that has the name @action_name and
389+ * any target value.
390+ **/
391+void
392+hud_action_publisher_remove_descriptions (HudActionPublisher *publisher,
393+ const gchar *action_name)
394+{
395+ HudActionDescription before, after;
396+ GSequenceIter *start, *end;
397+
398+ before.identifier = (gchar *) action_name;
399+ after.identifier = g_strconcat (action_name, "~", NULL);
400+ start = g_sequence_search (publisher->descriptions, &before, compare_descriptions, NULL);
401+ end = g_sequence_search (publisher->descriptions, &after, compare_descriptions, NULL);
402+ g_free (after.identifier);
403+
404+ if (start != end)
405+ {
406+ gint s, e;
407+
408+ s = g_sequence_iter_get_position (start);
409+ e = g_sequence_iter_get_position (end);
410+ g_sequence_foreach_range (start, end, disconnect_handler, publisher);
411+ g_sequence_remove_range (start, end);
412+
413+ g_menu_model_items_changed (G_MENU_MODEL (publisher->aux), s, e - s, 0);
414+ }
415+}
416+
417+/**
418 * hud_action_publisher_add_action_group:
419 * @publisher: a #HudActionPublisher
420 * @prefix: the action prefix for the group (like "app")
421@@ -456,7 +531,7 @@
422 * hud_action_publisher_remove_action_group:
423 * @publisher: a #HudActionPublisher
424 * @prefix: the action prefix for the group (like "app")
425- * @identifier: (allow none): an identifier, or %NULL
426+ * @identifier: (allow-none): an identifier, or %NULL
427 *
428 * Informs the HUD that an action group no longer exists.
429 *
430@@ -472,19 +547,35 @@
431 }
432
433 /**
434- * hud_action_publisher_get_id:
435- * @publisher: A #HudActionPublisher object
436- *
437- * Grabs the ID for this publisher
438- *
439- * Return value: (transfer none): The ID this publisher was created with
440- */
441-GVariant *
442-hud_action_publisher_get_id (HudActionPublisher *publisher)
443-{
444- g_return_val_if_fail(HUD_IS_ACTION_PUBLISHER(publisher), NULL);
445- return publisher->id;
446-}
447+ * hud_action_publisher_get_window_id:
448+ * @publisher: A #HudActionPublisher object
449+ *
450+ * Gets the window ID for this publisher
451+ *
452+ * Return value: The Window ID associtaed with this action publisher
453+ */
454+guint
455+hud_action_publisher_get_window_id (HudActionPublisher *publisher)
456+{
457+ g_return_val_if_fail(HUD_IS_ACTION_PUBLISHER(publisher), 0);
458+ return publisher->window_id;
459+}
460+
461+/**
462+ * hud_action_publisher_get_context_id:
463+ * @publisher: A #HudActionPublisher object
464+ *
465+ * Gets the context ID for this publisher
466+ *
467+ * Return value: The context ID associtaed with this action publisher
468+ */
469+const gchar *
470+hud_action_publisher_get_context_id (HudActionPublisher *publisher)
471+{
472+ g_return_val_if_fail(HUD_IS_ACTION_PUBLISHER(publisher), 0);
473+ return publisher->context_id;
474+}
475+
476
477 /**
478 * hud_action_publisher_get_action_groups:
479@@ -606,7 +697,7 @@
480 * hud_action_description_set_attribute_value:
481 * @description: a #HudActionDescription
482 * @attribute_name: an attribute name
483- * @value: (allow none): the new value for the attribute
484+ * @value: (allow-none): the new value for the attribute
485 *
486 * Sets or unsets an attribute on @description.
487 *
488@@ -641,7 +732,7 @@
489 * hud_action_description_set_attribute:
490 * @description: a #HudActionDescription
491 * @attribute_name: an attribute name
492- * @format_string: (allow none): a #GVariant format string
493+ * @format_string: (allow-none): a #GVariant format string
494 * @...: arguments to @format_string
495 *
496 * Sets or unsets an attribute on @description.
497
498=== modified file 'libhud/action-publisher.h'
499--- libhud/action-publisher.h 2013-04-01 16:14:22 +0000
500+++ libhud/action-publisher.h 2013-04-15 19:11:56 +0000
501@@ -62,6 +62,21 @@
502 #define HUD_IS_ACTION_DESCRIPTION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
503 HUD_TYPE_ACTION_DESCRIPTION))
504
505+/**
506+ * HUD_ACTION_PUBLISHER_NO_CONTEXT:
507+ *
508+ * Can be passed to hud_action_publisher_new() to request that it build
509+ * it's own context.
510+ */
511+#define HUD_ACTION_PUBLISHER_NO_CONTEXT (NULL)
512+/**
513+ * HUD_ACTION_PUBLISHER_ALL_WINDOWS:
514+ *
515+ * Can be passed to hud_action_publisher_new() to request that these actions
516+ * apply to all windows for the application.
517+ */
518+#define HUD_ACTION_PUBLISHER_ALL_WINDOWS (0)
519+
520 typedef struct _HudActionDescription HudActionDescription;
521 typedef struct _HudActionPublisher HudActionPublisher;
522 typedef struct _HudActionPublisherActionGroupSet HudActionPublisherActionGroupSet;
523@@ -89,7 +104,8 @@
524
525 GType hud_action_publisher_get_type (void) G_GNUC_CONST;
526
527-HudActionPublisher * hud_action_publisher_new_for_id (GVariant *id);
528+HudActionPublisher * hud_action_publisher_new (guint window_id,
529+ const gchar * context_id);
530
531 HudActionPublisher * hud_action_publisher_new_for_application (GApplication *application);
532
533@@ -102,7 +118,8 @@
534 void hud_action_publisher_remove_action_group (HudActionPublisher *publisher,
535 const gchar *prefix,
536 GVariant *identifier);
537-GVariant * hud_action_publisher_get_id (HudActionPublisher *publisher);
538+guint hud_action_publisher_get_window_id (HudActionPublisher *publisher);
539+const gchar * hud_action_publisher_get_context_id (HudActionPublisher *publisher);
540 GList * hud_action_publisher_get_action_groups (HudActionPublisher *publisher);
541 const gchar * hud_action_publisher_get_description_path (HudActionPublisher *publisher);
542
543
544=== modified file 'libhud/manager.c'
545--- libhud/manager.c 2013-04-03 02:53:04 +0000
546+++ libhud/manager.c 2013-04-15 19:11:56 +0000
547@@ -121,7 +121,7 @@
548 HudManager * manager = HUD_MANAGER(object);
549
550 if (manager->priv->application) {
551- manager->priv->app_pub = hud_action_publisher_new_for_id(NULL);
552+ manager->priv->app_pub = hud_action_publisher_new(HUD_ACTION_PUBLISHER_ALL_WINDOWS, HUD_ACTION_PUBLISHER_NO_CONTEXT);
553
554 hud_action_publisher_add_action_group(manager->priv->app_pub, "app", g_application_get_dbus_object_path (manager->priv->application));
555 hud_manager_add_actions(manager, manager->priv->app_pub);
556@@ -290,7 +290,7 @@
557 g_variant_builder_unref(manager->priv->todo_add_acts);
558 manager->priv->todo_add_acts = NULL;
559 } else {
560- actions = g_variant_new_array(G_VARIANT_TYPE("(vso)"), NULL, 0);
561+ actions = g_variant_new_array(G_VARIANT_TYPE("(usso)"), NULL, 0);
562 }
563
564 /* Build a descriptions list */
565@@ -299,7 +299,7 @@
566 g_variant_builder_unref(manager->priv->todo_add_desc);
567 manager->priv->todo_add_desc = NULL;
568 } else {
569- descriptions = g_variant_new_array(G_VARIANT_TYPE("(vo)"), NULL, 0);
570+ descriptions = g_variant_new_array(G_VARIANT_TYPE("(uso)"), NULL, 0);
571 }
572
573 /* Should never happen, but let's get useful error messages if it does */
574@@ -535,8 +535,13 @@
575 /* Set up watching for new groups */
576 /* TODO */
577
578+ /* Grab the window and context IDs for each of them */
579+ GVariant * winid = g_variant_new_uint32(hud_action_publisher_get_window_id(pub));
580+ GVariant * conid = g_variant_new_string(hud_action_publisher_get_context_id(pub));
581+ g_variant_ref_sink(winid);
582+ g_variant_ref_sink(conid);
583+
584 /* Send the current groups out */
585- GVariant * id = hud_action_publisher_get_id(pub);
586 GList * ags_list = hud_action_publisher_get_action_groups(pub);
587
588 /* Build the variant builder if it doesn't exist */
589@@ -551,7 +556,8 @@
590
591 g_variant_builder_open(manager->priv->todo_add_acts, G_VARIANT_TYPE_TUPLE);
592
593- g_variant_builder_add_value(manager->priv->todo_add_acts, g_variant_new_variant(id));
594+ g_variant_builder_add_value(manager->priv->todo_add_acts, winid);
595+ g_variant_builder_add_value(manager->priv->todo_add_acts, conid);
596 g_variant_builder_add_value(manager->priv->todo_add_acts, g_variant_new_string(set->prefix));
597 g_variant_builder_add_value(manager->priv->todo_add_acts, g_variant_new_object_path(set->path));
598
599@@ -569,7 +575,8 @@
600 if (descpath != NULL) {
601 g_variant_builder_open(manager->priv->todo_add_desc, G_VARIANT_TYPE_TUPLE);
602
603- g_variant_builder_add_value(manager->priv->todo_add_desc, g_variant_new_variant(id));
604+ g_variant_builder_add_value(manager->priv->todo_add_desc, winid);
605+ g_variant_builder_add_value(manager->priv->todo_add_desc, conid);
606 g_variant_builder_add_value(manager->priv->todo_add_desc, g_variant_new_object_path(descpath));
607
608 g_variant_builder_close(manager->priv->todo_add_desc);
609@@ -580,6 +587,9 @@
610 manager->priv->todo_idle = g_idle_add(todo_handler, manager);
611 }
612
613+ g_variant_unref(winid); winid = NULL;
614+ g_variant_unref(conid); conid = NULL;
615+
616 return;
617 }
618
619@@ -601,3 +611,52 @@
620
621 return;
622 }
623+
624+/* Callback from setting the window context. Not much we can do, just
625+ reporting errors */
626+static void
627+set_window_context_cb (GObject * obj, GAsyncResult *res, gpointer user_data)
628+{
629+ GError * error = NULL;
630+
631+ _hud_app_iface_com_canonical_hud_application_call_set_window_context_finish((_HudAppIfaceComCanonicalHudApplication *)obj, res, &error);
632+ if (error != NULL) {
633+ g_warning("Unable to set context for window: %s", error->message);
634+ g_error_free(error);
635+ }
636+
637+ return;
638+}
639+
640+/**
641+ * hud_manager_switch_window_context:
642+ * @manager: A #HudManager object
643+ * @pub: Action publisher object tracking the descriptions and action groups
644+ *
645+ * Tells the HUD service that a window should use a different context of
646+ * actions with the current window. This allows the application to export
647+ * sets of actions and switch them easily with a single dbus message.
648+ */
649+void
650+hud_manager_switch_window_context (HudManager * manager, HudActionPublisher * pub)
651+{
652+ g_return_if_fail(HUD_IS_MANAGER(manager));
653+ g_return_if_fail(HUD_IS_ACTION_PUBLISHER(pub));
654+
655+ /* TODO: Need to cache contexts for reconnection case */
656+
657+ if (manager->priv->app_proxy == NULL) {
658+ g_debug("Unable to send context change now, caching for reconnection");
659+ return;
660+ }
661+
662+
663+ _hud_app_iface_com_canonical_hud_application_call_set_window_context(manager->priv->app_proxy,
664+ hud_action_publisher_get_window_id(pub),
665+ hud_action_publisher_get_context_id(pub),
666+ NULL, /* cancellable */
667+ set_window_context_cb,
668+ NULL);
669+
670+ return;
671+}
672
673=== modified file 'libhud/manager.h'
674--- libhud/manager.h 2013-04-01 16:14:22 +0000
675+++ libhud/manager.h 2013-04-15 19:11:56 +0000
676@@ -93,6 +93,9 @@
677 void hud_manager_remove_actions (HudManager * manager,
678 HudActionPublisher * pub);
679
680+void hud_manager_switch_window_context (HudManager * manager,
681+ HudActionPublisher * pub);
682+
683 /**
684 * SECTION:manager
685 * @short_description: Manage data exported to HUD for the application
686
687=== modified file 'src/CMakeLists.txt'
688--- src/CMakeLists.txt 2013-04-12 15:31:34 +0000
689+++ src/CMakeLists.txt 2013-04-15 19:11:56 +0000
690@@ -12,6 +12,10 @@
691 include_directories(${HUD_SERVICE_INCLUDE_DIRS})
692 include_directories(${HUD_CLIENT_INCLUDE_DIRS})
693
694+if(${FULL_WARNINGS})
695+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
696+endif()
697+
698 ###########################
699 # Generated Lib Hud Service
700 ###########################
701
702=== modified file 'src/application-source.c'
703--- src/application-source.c 2013-02-22 11:34:56 +0000
704+++ src/application-source.c 2013-04-15 19:11:56 +0000
705@@ -88,6 +88,11 @@
706 GVariant * actions,
707 GVariant * descs,
708 gpointer user_data);
709+static gboolean dbus_set_context (AppIfaceComCanonicalHudApplication * skel,
710+ GDBusMethodInvocation * invocation,
711+ guint window_id,
712+ const gchar * context,
713+ gpointer user_data);
714 static GList * source_get_items (HudSource * object);
715
716 G_DEFINE_TYPE_WITH_CODE (HudApplicationSource, hud_application_source, G_TYPE_OBJECT,
717@@ -442,6 +447,7 @@
718 }
719
720 g_signal_connect(G_OBJECT(source->priv->skel), "handle-add-sources", G_CALLBACK(dbus_add_sources), source);
721+ g_signal_connect(G_OBJECT(source->priv->skel), "handle-set-window-context", G_CALLBACK(dbus_set_context), source);
722
723 g_debug("Application ('%s') path: %s", id, source->priv->path);
724 g_free(app_id_clean);
725@@ -558,7 +564,8 @@
726 GVariantIter action_iter;
727 g_variant_iter_init(&action_iter, actions);
728
729- GVariant * id = NULL;
730+ guint32 idn = 0;
731+ gchar * context = NULL;
732 gchar * prefix = NULL;
733 gchar * object = NULL;
734
735@@ -566,13 +573,11 @@
736 the models need the actions, but it'd be hard to update them
737 if we add the actions second. This order is the best. Don't
738 change it. */
739- while (g_variant_iter_loop(&action_iter, "(vso)", &id, &prefix, &object)) {
740+ while (g_variant_iter_loop(&action_iter, "(usso)", &idn, &context, &prefix, &object)) {
741 g_debug("Adding prefix '%s' at path: %s", prefix, object);
742
743 #ifdef HAVE_HYBRIS
744- guint32 idn = WINDOW_ID_CONSTANT;
745-#else
746- guint32 idn = g_variant_get_int32(id);
747+ idn = WINDOW_ID_CONSTANT;
748 #endif
749
750 HudMenuModelCollector * collector = NULL;
751@@ -590,13 +595,11 @@
752 GVariantIter desc_iter;
753 g_variant_iter_init(&desc_iter, descs);
754
755- while (g_variant_iter_loop(&desc_iter, "(vo)", &id, &object)) {
756+ while (g_variant_iter_loop(&desc_iter, "(uso)", &idn, &context, &object)) {
757 g_debug("Adding descriptions: %s", object);
758
759 #ifdef HAVE_HYBRIS
760- guint32 idn = WINDOW_ID_CONSTANT;
761-#else
762- guint32 idn = g_variant_get_int32(id);
763+ idn = WINDOW_ID_CONSTANT;
764 #endif
765
766 HudMenuModelCollector * collector = NULL;
767@@ -614,6 +617,16 @@
768 return TRUE;
769 }
770
771+/* Application changing the context for a window */
772+static gboolean
773+dbus_set_context (AppIfaceComCanonicalHudApplication * skel, GDBusMethodInvocation * invocation, guint window_id, const gchar * context, gpointer user_data)
774+{
775+ /* TODO: Use the data for something useful */
776+
777+ g_dbus_method_invocation_return_value(invocation, NULL);
778+ return TRUE;
779+}
780+
781 /**
782 * hud_application_source_bamf_app_id:
783 * @app: A #BamfApplication object
784
785=== modified file 'tests/CMakeLists.txt'
786--- tests/CMakeLists.txt 2013-04-12 16:05:14 +0000
787+++ tests/CMakeLists.txt 2013-04-15 19:11:56 +0000
788@@ -2,6 +2,10 @@
789 include_directories(${HUD_CLIENT_INCLUDE_DIRS})
790 include_directories(${HUD_INCLUDE_DIRS})
791
792+if(${FULL_WARNINGS})
793+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
794+endif()
795+
796 #######################
797 # Dbus JSON Loader
798 #######################
799
800=== modified file 'tests/hudtestutils.c'
801--- tests/hudtestutils.c 2013-04-03 02:49:55 +0000
802+++ tests/hudtestutils.c 2013-04-15 19:11:56 +0000
803@@ -496,10 +496,7 @@
804 columns[7] = g_variant_new_boolean(parameterized);
805 columns[8] = NULL;
806
807- DeeModelIter *iter = dee_model_append_row (results_model,
808- columns);
809-
810-//dee_model_set_tag(query->results_model, iter, query->results_tag, result);
811+ dee_model_append_row (results_model, columns);
812 }
813
814 void
815
816=== modified file 'tests/test-hud-action-publisher.c'
817--- tests/test-hud-action-publisher.c 2013-04-04 17:09:26 +0000
818+++ tests/test-hud-action-publisher.c 2013-04-15 19:11:56 +0000
819@@ -17,21 +17,21 @@
820 &appstack_model);
821
822 {
823- HudActionPublisher *publisher = hud_action_publisher_new_for_id(NULL);
824+ HudActionPublisher *publisher = hud_action_publisher_new(HUD_ACTION_PUBLISHER_ALL_WINDOWS, HUD_ACTION_PUBLISHER_NO_CONTEXT);
825 g_assert(publisher);
826
827- g_assert_cmpint(g_variant_get_int32(hud_action_publisher_get_id(publisher)),
828- ==, -1);
829+ g_assert_cmpint(hud_action_publisher_get_window_id(publisher),
830+ ==, HUD_ACTION_PUBLISHER_ALL_WINDOWS);
831+ g_assert(hud_action_publisher_get_context_id(publisher) != NULL);
832
833 g_object_unref (publisher);
834 }
835
836 {
837- HudActionPublisher *publisher = hud_action_publisher_new_for_id (
838- g_variant_new_int32 (123));
839+ HudActionPublisher *publisher = hud_action_publisher_new(123, HUD_ACTION_PUBLISHER_NO_CONTEXT);
840 g_assert(publisher);
841
842- g_assert_cmpint(g_variant_get_int32(hud_action_publisher_get_id(publisher)),
843+ g_assert_cmpint(hud_action_publisher_get_window_id(publisher),
844 ==, 123);
845
846 g_object_unref (publisher);
847@@ -62,8 +62,6 @@
848 HudActionPublisher *publisher = hud_action_publisher_new_for_application(application);
849 g_assert(publisher);
850
851- g_assert(!hud_action_publisher_get_id(publisher));
852-
853 g_object_unref (application);
854 g_object_unref (publisher);
855
856
857=== modified file 'tests/test-hud-client-query.c'
858--- tests/test-hud-client-query.c 2013-04-09 16:13:32 +0000
859+++ tests/test-hud-client-query.c 2013-04-15 19:11:56 +0000
860@@ -51,6 +51,8 @@
861 g_main_loop_run(loop);
862 g_main_loop_unref(loop);
863
864+ g_source_remove(sig);
865+
866 /* Check the models */
867 g_assert(DEE_IS_MODEL(hud_client_query_get_results_model(query)));
868 g_assert(DEE_IS_MODEL(hud_client_query_get_appstack_model(query)));
869@@ -106,6 +108,8 @@
870 g_main_loop_run(loop);
871 g_main_loop_unref(loop);
872
873+ g_source_remove(sig);
874+
875 /* Make sure it has models */
876 g_assert(DEE_IS_MODEL(hud_client_query_get_results_model(query)));
877 g_assert(DEE_IS_MODEL(hud_client_query_get_appstack_model(query)));
878@@ -155,6 +159,8 @@
879 g_main_loop_run(loop);
880 g_main_loop_unref(loop);
881
882+ g_source_remove(sig);
883+
884 hud_client_query_set_query(query, "test2");
885 g_assert_cmpstr(hud_client_query_get_query(query), ==, "test2");
886
887@@ -202,6 +208,8 @@
888 g_main_loop_run(loop);
889 g_main_loop_unref(loop);
890
891+ g_source_remove(sig);
892+
893 /* Call the voice query */
894 gboolean called = FALSE;
895 g_signal_connect(G_OBJECT(query), "voice-query-finished",
896@@ -247,6 +255,8 @@
897 g_main_loop_run(loop);
898 g_main_loop_unref(loop);
899
900+ g_source_remove(sig);
901+
902 /* Set App ID */
903 hud_client_query_set_appstack_app(query, "application-id");
904
905@@ -285,6 +295,8 @@
906 g_main_loop_run(loop);
907 g_main_loop_unref(loop);
908
909+ g_source_remove(sig);
910+
911 /* Execute a command */
912 hud_client_query_execute_command (query,
913 g_variant_new_variant (g_variant_new_uint64 (4321)), 1234);
914@@ -324,6 +336,8 @@
915 g_main_loop_run(loop);
916 g_main_loop_unref(loop);
917
918+ g_source_remove(sig);
919+
920 /* Execute a parameterized command */
921 HudClientParam *param = hud_client_query_execute_param_command (query,
922 g_variant_new_variant (g_variant_new_uint64 (4321)), 1234);
923@@ -361,6 +375,8 @@
924
925 g_signal_connect(G_OBJECT(query), HUD_CLIENT_QUERY_SIGNAL_MODELS_CHANGED, G_CALLBACK(test_query_create_models_ready), loop);
926
927+ g_source_remove(sig);
928+
929 g_main_loop_run(loop);
930 g_main_loop_unref(loop);
931
932@@ -416,7 +432,7 @@
933 g_test_add_func ("/hud/client/query/update_app", test_query_update_app);
934 g_test_add_func ("/hud/client/query/execute_command", test_query_execute_command);
935 g_test_add_func ("/hud/client/query/execute_command_parameterized", test_query_execute_parameterized);
936-// g_test_add_func ("/hud/client/query/execute_command_toolbar", test_query_execute_toolbar);
937+ g_test_add_func ("/hud/client/query/execute_command_toolbar", test_query_execute_toolbar);
938 }
939
940 int
941
942=== modified file 'tests/test-hud-manager.c'
943--- tests/test-hud-manager.c 2013-04-03 16:01:16 +0000
944+++ tests/test-hud-manager.c 2013-04-15 19:11:56 +0000
945@@ -43,7 +43,7 @@
946 {
947 DBusMockProperties* properties = dbus_mock_new_properties ();
948 DBusMockMethods* methods = dbus_mock_new_methods ();
949- dbus_mock_methods_append (methods, "AddSources", "a(vso)a(vo)", "", "");
950+ dbus_mock_methods_append (methods, "AddSources", "a(usso)a(uso)", "", "");
951 dbus_mock_add_object (connection, DBUS_NAME, DBUS_PATH, "/app/object",
952 "com.canonical.hud.Application", properties, methods);
953 }
954@@ -65,7 +65,7 @@
955
956 dbus_mock_assert_method_call_results (connection, DBUS_NAME, "/app/object",
957 "AddSources",
958- "\\(\\[\\(\\d+, \\[<\\[\\(<-1>, 'app', objectpath '\\/app\\/id'\\)\\]>, <\\[\\(<-1>, objectpath '\\/com\\/canonical\\/hud\\/publisher0'\\)\\]>\\]\\)\\],\\)");
959+ "\\(\\[\\(\\d+, \\[<\\[\\(uint32 0, 'action-publisher-context-0', 'app', objectpath '\\/app\\/id'\\)\\]>, <\\[\\(uint32 0, 'action-publisher-context-0', objectpath '\\/com\\/canonical\\/hud\\/publisher0'\\)\\]>\\]\\)\\],\\)");
960
961 g_object_unref (application);
962
963@@ -87,7 +87,7 @@
964 {
965 DBusMockProperties* properties = dbus_mock_new_properties ();
966 DBusMockMethods* methods = dbus_mock_new_methods ();
967- dbus_mock_methods_append (methods, "AddSources", "a(vso)a(vo)", "", "");
968+ dbus_mock_methods_append (methods, "AddSources", "a(usso)a(uso)", "", "");
969 dbus_mock_add_object (connection, DBUS_NAME, DBUS_PATH, "/app/object",
970 "com.canonical.hud.Application", properties, methods);
971 }
972@@ -95,14 +95,14 @@
973 HudManager *manager = hud_manager_new ("test.app");
974 hud_test_utils_process_mainloop (100);
975
976- HudActionPublisher *publisher = hud_action_publisher_new_for_id(NULL);
977+ HudActionPublisher *publisher = hud_action_publisher_new(HUD_ACTION_PUBLISHER_ALL_WINDOWS, "test-add-context");
978 hud_action_publisher_add_action_group(publisher, "app", "/app/object");
979 hud_manager_add_actions(manager, publisher);
980 hud_test_utils_process_mainloop (100);
981
982 dbus_mock_assert_method_call_results (connection, DBUS_NAME, "/app/object",
983 "AddSources",
984- "\\(\\[\\(\\d+, \\[<\\[\\(<-1>, 'app', objectpath '\\/app\\/object'\\)\\]>, <\\[\\(<-1>, objectpath '\\/com\\/canonical\\/hud\\/publisher'\\)\\]>\\]\\)\\],\\)");
985+ "\\(\\[\\(\\d+, \\[<\\[\\(uint32 0, 'test-add-context', 'app', objectpath '\\/app\\/object'\\)\\]>, <\\[\\(uint32 0, 'test-add-context', objectpath '\\/com\\/canonical\\/hud\\/publisher'\\)\\]>\\]\\)\\],\\)");
986
987 g_object_unref (publisher);
988 g_object_unref (manager);
989@@ -129,22 +129,22 @@
990 {
991 DBusMockProperties* properties = dbus_mock_new_properties ();
992 DBusMockMethods* methods = dbus_mock_new_methods ();
993- dbus_mock_methods_append (methods, "AddSources", "a(vso)a(vo)", "", "");
994+ dbus_mock_methods_append (methods, "AddSources", "a(usso)a(uso)", "", "");
995 dbus_mock_add_object (connection, DBUS_NAME, DBUS_PATH, "/app/object",
996 "com.canonical.hud.Application", properties, methods);
997 }
998
999- HudManager *manager = hud_manager_new ("app.id");
1000+ HudManager *manager = hud_manager_new ("app-id");
1001 hud_test_utils_process_mainloop (100);
1002
1003- HudActionPublisher *publisher = hud_action_publisher_new_for_id(NULL);
1004+ HudActionPublisher *publisher = hud_action_publisher_new(HUD_ACTION_PUBLISHER_ALL_WINDOWS, "test-context");
1005 hud_action_publisher_add_action_group(publisher, "app", "/app/object");
1006 hud_manager_add_actions(manager, publisher);
1007 hud_test_utils_process_mainloop (100);
1008
1009 dbus_mock_assert_method_call_results (connection, DBUS_NAME, "/app/object",
1010 "AddSources",
1011- "\\(\\[\\(\\d+, \\[<\\[\\(<-1>, 'app', objectpath '\\/app\\/object'\\)\\]>, <\\[\\(<-1>, objectpath '\\/com\\/canonical\\/hud\\/publisher'\\)\\]>\\]\\)\\],\\)");
1012+ "\\(\\[\\(\\d+, \\[<\\[\\(uint32 0, 'test-context', 'app', objectpath '\\/app\\/object'\\)\\]>, <\\[\\(uint32 0, 'test-context', objectpath '\\/com\\/canonical\\/hud\\/publisher'\\)\\]>\\]\\)\\],\\)");
1013 dbus_mock_clear_method_calls(connection, DBUS_NAME, "/app/object");
1014
1015 hud_manager_remove_actions(manager, publisher);

Subscribers

People subscribed via source and target branches