Merge lp:~ted/libindicator/window-id into lp:libindicator/0.5
- window-id
- Merge into trunk.0.5
Proposed by
Ted Gould
Status: | Merged |
---|---|
Merged at revision: | 440 |
Proposed branch: | lp:~ted/libindicator/window-id |
Merge into: | lp:libindicator/0.5 |
Diff against target: |
421 lines (+323/-2) 7 files modified
.bzrignore (+2/-0) libindicator/indicator-object.c (+35/-0) libindicator/indicator-object.h (+2/-0) tests/Makefile.am (+24/-2) tests/dummy-indicator-entry-func.c (+130/-0) tests/dummy-indicator-entry-func.h (+56/-0) tests/test-loader.c (+74/-0) |
To merge this branch: | bzr merge lp:~ted/libindicator/window-id |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Neil J. Patel (community) | Approve | ||
Review via email: mp+88638@code.launchpad.net |
Commit message
Description of the change
Adding an additional function to send the window ID to IndicatorObjects that support it.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2012-01-13 12:04:25 +0000 |
3 | +++ .bzrignore 2012-01-16 03:12:23 +0000 |
4 | @@ -179,3 +179,5 @@ |
5 | tools/indicator-loader3 |
6 | libindicator-[0-9]*.[0-9]*.[0-9]* |
7 | build-aux |
8 | +libdummy_indicator_entry_func_la-dummy-indicator-entry-func.lo |
9 | +libdummy-indicator-entry-func.la |
10 | |
11 | === modified file 'libindicator/indicator-object.c' |
12 | --- libindicator/indicator-object.c 2011-07-21 14:18:42 +0000 |
13 | +++ libindicator/indicator-object.c 2012-01-16 03:12:23 +0000 |
14 | @@ -99,6 +99,10 @@ |
15 | klass->get_entries = get_entries_default; |
16 | klass->get_location = NULL; |
17 | |
18 | + klass->entry_activate = NULL; |
19 | + klass->entry_activate_window = NULL; |
20 | + klass->entry_close = NULL; |
21 | + |
22 | /** |
23 | IndicatorObject::entry-added: |
24 | @arg0: The #IndicatorObject object |
25 | @@ -539,6 +543,37 @@ |
26 | } |
27 | |
28 | /** |
29 | + indicator_object_entry_activate_window: |
30 | + @io: #IndicatorObject to query |
31 | + @entry: The #IndicatorObjectEntry whose entry was shown |
32 | + @windowid: ID of the window that is currently focused (or will |
33 | + be very shortly) |
34 | + @timestamp: The X11 timestamp of the event |
35 | + |
36 | + Used to signal to the indicator that the menu on an entry has |
37 | + been clicked on. This can either be an activate or a showing |
38 | + of the menu. Also includes a window ID so that we can know what |
39 | + application is going to be getting focused soon. If there is |
40 | + no override of this function, it is the same as calling |
41 | + indicator_object_entry_activate and in general is preferable |
42 | + if you have that information available. |
43 | +*/ |
44 | +void |
45 | +indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) |
46 | +{ |
47 | + g_return_if_fail(INDICATOR_IS_OBJECT(io)); |
48 | + IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io); |
49 | + |
50 | + if (class->entry_activate_window != NULL) { |
51 | + return class->entry_activate_window(io, entry, windowid, timestamp); |
52 | + } else { |
53 | + indicator_object_entry_activate(io, entry, timestamp); |
54 | + } |
55 | + |
56 | + return; |
57 | +} |
58 | + |
59 | +/** |
60 | indicator_object_entry_activate: |
61 | @io: #IndicatorObject to query |
62 | @entry: The #IndicatorObjectEntry whose entry was shown |
63 | |
64 | === modified file 'libindicator/indicator-object.h' |
65 | --- libindicator/indicator-object.h 2011-07-21 14:17:41 +0000 |
66 | +++ libindicator/indicator-object.h 2012-01-16 03:12:23 +0000 |
67 | @@ -118,6 +118,7 @@ |
68 | gboolean (*get_show_now) (IndicatorObject * io, IndicatorObjectEntry * entry); |
69 | |
70 | void (*entry_activate) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); |
71 | + void (*entry_activate_window) (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp); |
72 | void (*entry_close) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); |
73 | |
74 | /* Signals */ |
75 | @@ -184,6 +185,7 @@ |
76 | guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry); |
77 | guint indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntry * entry); |
78 | void indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); |
79 | +void indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp); |
80 | void indicator_object_entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); |
81 | |
82 | void indicator_object_set_environment (IndicatorObject * io, const GStrv env); |
83 | |
84 | === modified file 'tests/Makefile.am' |
85 | --- tests/Makefile.am 2011-07-11 22:01:12 +0000 |
86 | +++ tests/Makefile.am 2012-01-16 03:12:23 +0000 |
87 | @@ -14,7 +14,8 @@ |
88 | libdummy-indicator-blank.la \ |
89 | libdummy-indicator-null.la \ |
90 | libdummy-indicator-signaler.la \ |
91 | - libdummy-indicator-simple.la |
92 | + libdummy-indicator-simple.la \ |
93 | + libdummy-indicator-entry-func.la |
94 | |
95 | DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf |
96 | XVFB_RUN=". $(srcdir)/run-xvfb.sh" |
97 | @@ -162,6 +163,27 @@ |
98 | -avoid-version |
99 | |
100 | ############################# |
101 | +# Dummy Indicator Entry Func |
102 | +############################# |
103 | + |
104 | +libdummy_indicator_entry_func_la_SOURCES = \ |
105 | + dummy-indicator-entry-func.c \ |
106 | + dummy-indicator-entry-func.h |
107 | + |
108 | +libdummy_indicator_entry_func_la_CFLAGS = \ |
109 | + -Wall -Werror \ |
110 | + $(LIBINDICATOR_CFLAGS) -I$(top_srcdir) |
111 | + |
112 | +libdummy_indicator_entry_func_la_LIBADD = \ |
113 | + $(LIBINDICATOR_LIBS) \ |
114 | + -L$(top_builddir)/libindicator/.libs \ |
115 | + $(INDICATOR_LIB) |
116 | + |
117 | +libdummy_indicator_entry_func_la_LDFLAGS = \ |
118 | + -module \ |
119 | + -avoid-version |
120 | + |
121 | +############################# |
122 | # Service Shutdown Timeout |
123 | ############################# |
124 | |
125 | @@ -412,7 +434,7 @@ |
126 | XML_REPORT = loader-check-results.xml |
127 | HTML_REPORT = loader-check-results.html |
128 | |
129 | -loader-tester: test-loader libdummy-indicator-null.la libdummy-indicator-simple.la Makefile |
130 | +loader-tester: test-loader libdummy-indicator-null.la libdummy-indicator-simple.la libdummy-indicator-entry-func.la Makefile |
131 | @echo "#!/bin/bash" > loader-tester |
132 | @echo $(XVFB_RUN) >> $@ |
133 | @echo gtester -k --verbose -o=$(XML_REPORT) ./test-loader >> loader-tester |
134 | |
135 | === added file 'tests/dummy-indicator-entry-func.c' |
136 | --- tests/dummy-indicator-entry-func.c 1970-01-01 00:00:00 +0000 |
137 | +++ tests/dummy-indicator-entry-func.c 2012-01-16 03:12:23 +0000 |
138 | @@ -0,0 +1,130 @@ |
139 | +/* |
140 | +Test for libindicator |
141 | + |
142 | +Copyright 2012 Canonical Ltd. |
143 | + |
144 | +Authors: |
145 | + Ted Gould <ted@canonical.com> |
146 | + |
147 | +This library is free software; you can redistribute it and/or |
148 | +modify it under the terms of the GNU General Public License |
149 | +version 3.0 as published by the Free Software Foundation. |
150 | + |
151 | +This library is distributed in the hope that it will be useful, |
152 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
153 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
154 | +GNU General Public License version 3.0 for more details. |
155 | + |
156 | +You should have received a copy of the GNU General Public |
157 | +License along with this library. If not, see |
158 | +<http://www.gnu.org/licenses/>. |
159 | +*/ |
160 | + |
161 | +#include "dummy-indicator-entry-func.h" |
162 | + |
163 | + |
164 | +GType dummy_indicator_entry_func_get_type (void); |
165 | + |
166 | +INDICATOR_SET_VERSION |
167 | +INDICATOR_SET_TYPE(DUMMY_INDICATOR_ENTRY_FUNC_TYPE) |
168 | + |
169 | + |
170 | +GtkLabel * |
171 | +get_label (IndicatorObject * io) |
172 | +{ |
173 | + return NULL; |
174 | +} |
175 | + |
176 | +GtkImage * |
177 | +get_icon (IndicatorObject * io) |
178 | +{ |
179 | + return NULL; |
180 | +} |
181 | + |
182 | +GtkMenu * |
183 | +get_menu (IndicatorObject * io) |
184 | +{ |
185 | + return NULL; |
186 | +} |
187 | +const gchar * |
188 | +get_accessible_desc (IndicatorObject * io) |
189 | +{ |
190 | + return NULL; |
191 | +} |
192 | + |
193 | +static void |
194 | +entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp) |
195 | +{ |
196 | + DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io); |
197 | + self->entry_activate_called = TRUE; |
198 | + return; |
199 | +} |
200 | + |
201 | +static void |
202 | +entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) |
203 | +{ |
204 | + DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io); |
205 | + self->entry_activate_window_called = TRUE; |
206 | + return; |
207 | +} |
208 | + |
209 | +static void |
210 | +entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp) |
211 | +{ |
212 | + DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io); |
213 | + self->entry_close_called = TRUE; |
214 | + return; |
215 | +} |
216 | + |
217 | + |
218 | +static void dummy_indicator_entry_func_class_init (DummyIndicatorEntryFuncClass *klass); |
219 | +static void dummy_indicator_entry_func_init (DummyIndicatorEntryFunc *self); |
220 | +static void dummy_indicator_entry_func_dispose (GObject *object); |
221 | +static void dummy_indicator_entry_func_finalize (GObject *object); |
222 | + |
223 | +G_DEFINE_TYPE (DummyIndicatorEntryFunc, dummy_indicator_entry_func, INDICATOR_OBJECT_TYPE); |
224 | + |
225 | +static void |
226 | +dummy_indicator_entry_func_class_init (DummyIndicatorEntryFuncClass *klass) |
227 | +{ |
228 | + GObjectClass *object_class = G_OBJECT_CLASS (klass); |
229 | + |
230 | + object_class->dispose = dummy_indicator_entry_func_dispose; |
231 | + object_class->finalize = dummy_indicator_entry_func_finalize; |
232 | + |
233 | + IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass); |
234 | + |
235 | + io_class->get_label = get_label; |
236 | + io_class->get_image = get_icon; |
237 | + io_class->get_menu = get_menu; |
238 | + io_class->get_accessible_desc = get_accessible_desc; |
239 | + |
240 | + io_class->entry_activate = entry_activate; |
241 | + io_class->entry_activate_window = entry_activate_window; |
242 | + io_class->entry_close = entry_close; |
243 | + |
244 | + return; |
245 | +} |
246 | + |
247 | +static void |
248 | +dummy_indicator_entry_func_init (DummyIndicatorEntryFunc *self) |
249 | +{ |
250 | + |
251 | + return; |
252 | +} |
253 | + |
254 | +static void |
255 | +dummy_indicator_entry_func_dispose (GObject *object) |
256 | +{ |
257 | + |
258 | + G_OBJECT_CLASS (dummy_indicator_entry_func_parent_class)->dispose (object); |
259 | + return; |
260 | +} |
261 | + |
262 | +static void |
263 | +dummy_indicator_entry_func_finalize (GObject *object) |
264 | +{ |
265 | + |
266 | + G_OBJECT_CLASS (dummy_indicator_entry_func_parent_class)->finalize (object); |
267 | + return; |
268 | +} |
269 | |
270 | === added file 'tests/dummy-indicator-entry-func.h' |
271 | --- tests/dummy-indicator-entry-func.h 1970-01-01 00:00:00 +0000 |
272 | +++ tests/dummy-indicator-entry-func.h 2012-01-16 03:12:23 +0000 |
273 | @@ -0,0 +1,56 @@ |
274 | +/* |
275 | +Test for libindicator |
276 | + |
277 | +Copyright 2012 Canonical Ltd. |
278 | + |
279 | +Authors: |
280 | + Ted Gould <ted@canonical.com> |
281 | + |
282 | +This library is free software; you can redistribute it and/or |
283 | +modify it under the terms of the GNU General Public License |
284 | +version 3.0 as published by the Free Software Foundation. |
285 | + |
286 | +This library is distributed in the hope that it will be useful, |
287 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
288 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
289 | +GNU General Public License version 3.0 for more details. |
290 | + |
291 | +You should have received a copy of the GNU General Public |
292 | +License along with this library. If not, see |
293 | +<http://www.gnu.org/licenses/>. |
294 | +*/ |
295 | + |
296 | +#ifndef __DUMMY_INDICATOR_ENTRY_FUNC__ |
297 | +#define __DUMMY_INDICATOR_ENTRY_FUNC__ |
298 | + |
299 | +#include <glib.h> |
300 | +#include <glib-object.h> |
301 | + |
302 | +#include "libindicator/indicator.h" |
303 | +#include "libindicator/indicator-object.h" |
304 | + |
305 | +G_BEGIN_DECLS |
306 | + |
307 | +#define DUMMY_INDICATOR_ENTRY_FUNC_TYPE (dummy_indicator_entry_func_get_type ()) |
308 | +#define DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFunc)) |
309 | +#define DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass)) |
310 | +#define IS_DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE)) |
311 | +#define IS_DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE)) |
312 | +#define DUMMY_INDICATOR_ENTRY_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass)) |
313 | + |
314 | +typedef struct _DummyIndicatorEntryFunc DummyIndicatorEntryFunc; |
315 | +typedef struct _DummyIndicatorEntryFuncClass DummyIndicatorEntryFuncClass; |
316 | + |
317 | +struct _DummyIndicatorEntryFuncClass { |
318 | + IndicatorObjectClass parent_class; |
319 | +}; |
320 | + |
321 | +struct _DummyIndicatorEntryFunc { |
322 | + IndicatorObject parent; |
323 | + |
324 | + gboolean entry_activate_called; |
325 | + gboolean entry_activate_window_called; |
326 | + gboolean entry_close_called; |
327 | +}; |
328 | + |
329 | +#endif /* __DUMMY_INDICATOR_ENTRY_FUNC__ */ |
330 | |
331 | === modified file 'tests/test-loader.c' |
332 | --- tests/test-loader.c 2011-07-06 21:11:29 +0000 |
333 | +++ tests/test-loader.c 2012-01-16 03:12:23 +0000 |
334 | @@ -23,6 +23,78 @@ |
335 | #include <gtk/gtk.h> |
336 | #include "libindicator/indicator-object.h" |
337 | |
338 | +#include "dummy-indicator-entry-func.h" |
339 | + |
340 | +void |
341 | +entry_func_swap (IndicatorObject * io) |
342 | +{ |
343 | + static void (*saved_func) (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) = NULL; |
344 | + IndicatorObjectClass * klass = INDICATOR_OBJECT_GET_CLASS(io); |
345 | + |
346 | + if (saved_func == NULL) { |
347 | + saved_func = klass->entry_activate_window; |
348 | + } |
349 | + |
350 | + if (klass->entry_activate_window == NULL) { |
351 | + klass->entry_activate_window = saved_func; |
352 | + } else { |
353 | + klass->entry_activate_window = NULL; |
354 | + } |
355 | + |
356 | + return; |
357 | +} |
358 | + |
359 | +void |
360 | +test_loader_entry_func_window (void) |
361 | +{ |
362 | + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-entry-func.so"); |
363 | + g_assert(object != NULL); |
364 | + |
365 | + DummyIndicatorEntryFunc * entryfunc = (DummyIndicatorEntryFunc *)(object); |
366 | + |
367 | + entryfunc->entry_activate_called = FALSE; |
368 | + entryfunc->entry_activate_window_called = FALSE; |
369 | + entryfunc->entry_close_called = FALSE; |
370 | + |
371 | + entry_func_swap(object); |
372 | + indicator_object_entry_activate_window(object, NULL, 0, 0); |
373 | + g_assert(entryfunc->entry_activate_called); |
374 | + |
375 | + entry_func_swap(object); |
376 | + indicator_object_entry_activate_window(object, NULL, 0, 0); |
377 | + g_assert(entryfunc->entry_activate_window_called); |
378 | + |
379 | + g_object_unref(object); |
380 | + |
381 | + return; |
382 | +} |
383 | + |
384 | +void |
385 | +test_loader_entry_funcs (void) |
386 | +{ |
387 | + IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-entry-func.so"); |
388 | + g_assert(object != NULL); |
389 | + |
390 | + DummyIndicatorEntryFunc * entryfunc = (DummyIndicatorEntryFunc *)(object); |
391 | + |
392 | + entryfunc->entry_activate_called = FALSE; |
393 | + entryfunc->entry_activate_window_called = FALSE; |
394 | + entryfunc->entry_close_called = FALSE; |
395 | + |
396 | + indicator_object_entry_activate(object, NULL, 0); |
397 | + g_assert(entryfunc->entry_activate_called); |
398 | + |
399 | + indicator_object_entry_activate_window(object, NULL, 0, 0); |
400 | + g_assert(entryfunc->entry_activate_window_called); |
401 | + |
402 | + indicator_object_entry_close(object, NULL, 0); |
403 | + g_assert(entryfunc->entry_close_called); |
404 | + |
405 | + g_object_unref(object); |
406 | + |
407 | + return; |
408 | +} |
409 | + |
410 | void destroy_cb (gpointer data, GObject * object); |
411 | |
412 | void |
413 | @@ -174,6 +246,8 @@ |
414 | g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors); |
415 | g_test_add_func ("/libindicator/loader/dummy/simple_location", test_loader_filename_dummy_simple_location); |
416 | g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler); |
417 | + g_test_add_func ("/libindicator/loader/dummy/entry_funcs", test_loader_entry_funcs); |
418 | + g_test_add_func ("/libindicator/loader/dummy/entry_func_window", test_loader_entry_func_window); |
419 | |
420 | return; |
421 | } |
Looks good, approved.