Merge lp:~dbusmenu-team/libdbusmenu/ubuntu into lp:~ubuntu-desktop/libdbusmenu/ubuntu
- ubuntu
- Merge into ubuntu
Proposed by
Ted Gould
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sebastien Bacher | Pending | ||
Review via email: mp+18630@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote : | # |
- 60. By Sebastien Bacher
-
releasing version 0.2.2-0ubuntu1
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2009-12-21 22:17:02 +0000 | |||
3 | +++ .bzrignore 2010-02-04 20:30:33 +0000 | |||
4 | @@ -58,3 +58,4 @@ | |||
5 | 58 | tests/test-glib-objects | 58 | tests/test-glib-objects |
6 | 59 | tests/test-glib-objects-test | 59 | tests/test-glib-objects-test |
7 | 60 | tests/test-glib-objects.xml | 60 | tests/test-glib-objects.xml |
8 | 61 | tools/testapp/dbusmenu-testapp | ||
9 | 61 | 62 | ||
10 | === modified file 'configure.ac' | |||
11 | --- configure.ac 2010-01-20 02:07:35 +0000 | |||
12 | +++ configure.ac 2010-02-04 20:30:33 +0000 | |||
13 | @@ -1,11 +1,11 @@ | |||
14 | 1 | 1 | ||
17 | 2 | AC_INIT(libdbusmenu, 0.2.1, ted@canonical.com) | 2 | AC_INIT(libdbusmenu, 0.2.2, ted@canonical.com) |
18 | 3 | AC_COPYRIGHT([Copyright 2009 Canonical]) | 3 | AC_COPYRIGHT([Copyright 2009,2010 Canonical]) |
19 | 4 | 4 | ||
20 | 5 | AC_PREREQ(2.53) | 5 | AC_PREREQ(2.53) |
21 | 6 | 6 | ||
22 | 7 | AM_CONFIG_HEADER(config.h) | 7 | AM_CONFIG_HEADER(config.h) |
24 | 8 | AM_INIT_AUTOMAKE(libdbusmenu, 0.2.1) | 8 | AM_INIT_AUTOMAKE(libdbusmenu, 0.2.2) |
25 | 9 | 9 | ||
26 | 10 | AM_MAINTAINER_MODE | 10 | AM_MAINTAINER_MODE |
27 | 11 | 11 | ||
28 | @@ -65,8 +65,8 @@ | |||
29 | 65 | # Lib versioning | 65 | # Lib versioning |
30 | 66 | ########################### | 66 | ########################### |
31 | 67 | 67 | ||
34 | 68 | LIBDBUSMENU_CURRENT=0 | 68 | LIBDBUSMENU_CURRENT=1 |
35 | 69 | LIBDBUSMENU_REVISION=11 | 69 | LIBDBUSMENU_REVISION=0 |
36 | 70 | LIBDBUSMENU_AGE=0 | 70 | LIBDBUSMENU_AGE=0 |
37 | 71 | 71 | ||
38 | 72 | AC_SUBST(LIBDBUSMENU_CURRENT) | 72 | AC_SUBST(LIBDBUSMENU_CURRENT) |
39 | @@ -105,6 +105,7 @@ | |||
40 | 105 | libdbusmenu-gtk/Makefile | 105 | libdbusmenu-gtk/Makefile |
41 | 106 | libdbusmenu-gtk/dbusmenu-gtk.pc | 106 | libdbusmenu-gtk/dbusmenu-gtk.pc |
42 | 107 | tools/Makefile | 107 | tools/Makefile |
43 | 108 | tools/testapp/Makefile | ||
44 | 108 | tests/Makefile | 109 | tests/Makefile |
45 | 109 | ]) | 110 | ]) |
46 | 110 | 111 | ||
47 | 111 | 112 | ||
48 | === modified file 'debian/changelog' | |||
49 | --- debian/changelog 2010-01-20 02:07:35 +0000 | |||
50 | +++ debian/changelog 2010-02-04 20:30:33 +0000 | |||
51 | @@ -1,3 +1,15 @@ | |||
52 | 1 | libdbusmenu (0.2.2-0ubuntu1~ppa1) lucid; urgency=low | ||
53 | 2 | |||
54 | 3 | * Upstream Release 0.2.2 | ||
55 | 4 | * Interoperability fixes | ||
56 | 5 | * Adding timestamps to events | ||
57 | 6 | * Better handling of XML | ||
58 | 7 | * Adding tools for timing dbusmenu | ||
59 | 8 | * debian/libdbusmenu-tools.install: Adding a wildcard to get | ||
60 | 9 | all of the tools in libexec | ||
61 | 10 | |||
62 | 11 | -- Ted Gould <ted@ubuntu.com> Thu, 04 Feb 2010 12:18:26 -0800 | ||
63 | 12 | |||
64 | 1 | libdbusmenu (0.2.1-0ubuntu1) lucid; urgency=low | 13 | libdbusmenu (0.2.1-0ubuntu1) lucid; urgency=low |
65 | 2 | 14 | ||
66 | 3 | * Upstream release 0.2.1 | 15 | * Upstream release 0.2.1 |
67 | 4 | 16 | ||
68 | === modified file 'debian/libdbusmenu-tools.install' | |||
69 | --- debian/libdbusmenu-tools.install 2010-01-09 14:09:31 +0000 | |||
70 | +++ debian/libdbusmenu-tools.install 2010-02-04 20:30:33 +0000 | |||
71 | @@ -1,1 +1,1 @@ | |||
73 | 1 | debian/tmp/usr/lib/libdbusmenu/dbusmenu-dumper | 1 | debian/tmp/usr/lib/libdbusmenu/dbusmenu-* |
74 | 2 | 2 | ||
75 | === added file 'libdbusmenu-glib/Doxyfile' | |||
76 | --- libdbusmenu-glib/Doxyfile 1970-01-01 00:00:00 +0000 | |||
77 | +++ libdbusmenu-glib/Doxyfile 2010-02-04 20:30:33 +0000 | |||
78 | @@ -0,0 +1,257 @@ | |||
79 | 1 | # Doxyfile 1.6.1 | ||
80 | 2 | |||
81 | 3 | #--------------------------------------------------------------------------- | ||
82 | 4 | # Project related configuration options | ||
83 | 5 | #--------------------------------------------------------------------------- | ||
84 | 6 | DOXYFILE_ENCODING = UTF-8 | ||
85 | 7 | PROJECT_NAME = DBusMenu | ||
86 | 8 | PROJECT_NUMBER = | ||
87 | 9 | OUTPUT_DIRECTORY = | ||
88 | 10 | CREATE_SUBDIRS = NO | ||
89 | 11 | OUTPUT_LANGUAGE = English | ||
90 | 12 | BRIEF_MEMBER_DESC = YES | ||
91 | 13 | REPEAT_BRIEF = YES | ||
92 | 14 | ABBREVIATE_BRIEF = | ||
93 | 15 | ALWAYS_DETAILED_SEC = NO | ||
94 | 16 | INLINE_INHERITED_MEMB = NO | ||
95 | 17 | FULL_PATH_NAMES = YES | ||
96 | 18 | STRIP_FROM_PATH = | ||
97 | 19 | STRIP_FROM_INC_PATH = | ||
98 | 20 | SHORT_NAMES = NO | ||
99 | 21 | JAVADOC_AUTOBRIEF = NO | ||
100 | 22 | QT_AUTOBRIEF = NO | ||
101 | 23 | MULTILINE_CPP_IS_BRIEF = NO | ||
102 | 24 | INHERIT_DOCS = YES | ||
103 | 25 | SEPARATE_MEMBER_PAGES = NO | ||
104 | 26 | TAB_SIZE = 8 | ||
105 | 27 | ALIASES = | ||
106 | 28 | OPTIMIZE_OUTPUT_FOR_C = NO | ||
107 | 29 | OPTIMIZE_OUTPUT_JAVA = NO | ||
108 | 30 | OPTIMIZE_FOR_FORTRAN = NO | ||
109 | 31 | OPTIMIZE_OUTPUT_VHDL = NO | ||
110 | 32 | EXTENSION_MAPPING = | ||
111 | 33 | BUILTIN_STL_SUPPORT = NO | ||
112 | 34 | CPP_CLI_SUPPORT = NO | ||
113 | 35 | SIP_SUPPORT = NO | ||
114 | 36 | IDL_PROPERTY_SUPPORT = YES | ||
115 | 37 | DISTRIBUTE_GROUP_DOC = NO | ||
116 | 38 | SUBGROUPING = YES | ||
117 | 39 | TYPEDEF_HIDES_STRUCT = NO | ||
118 | 40 | SYMBOL_CACHE_SIZE = 0 | ||
119 | 41 | #--------------------------------------------------------------------------- | ||
120 | 42 | # Build related configuration options | ||
121 | 43 | #--------------------------------------------------------------------------- | ||
122 | 44 | EXTRACT_ALL = NO | ||
123 | 45 | EXTRACT_PRIVATE = NO | ||
124 | 46 | EXTRACT_STATIC = NO | ||
125 | 47 | EXTRACT_LOCAL_CLASSES = YES | ||
126 | 48 | EXTRACT_LOCAL_METHODS = NO | ||
127 | 49 | EXTRACT_ANON_NSPACES = NO | ||
128 | 50 | HIDE_UNDOC_MEMBERS = NO | ||
129 | 51 | HIDE_UNDOC_CLASSES = NO | ||
130 | 52 | HIDE_FRIEND_COMPOUNDS = NO | ||
131 | 53 | HIDE_IN_BODY_DOCS = NO | ||
132 | 54 | INTERNAL_DOCS = NO | ||
133 | 55 | CASE_SENSE_NAMES = YES | ||
134 | 56 | HIDE_SCOPE_NAMES = NO | ||
135 | 57 | SHOW_INCLUDE_FILES = YES | ||
136 | 58 | INLINE_INFO = YES | ||
137 | 59 | SORT_MEMBER_DOCS = YES | ||
138 | 60 | SORT_BRIEF_DOCS = NO | ||
139 | 61 | SORT_MEMBERS_CTORS_1ST = NO | ||
140 | 62 | SORT_GROUP_NAMES = NO | ||
141 | 63 | SORT_BY_SCOPE_NAME = NO | ||
142 | 64 | GENERATE_TODOLIST = YES | ||
143 | 65 | GENERATE_TESTLIST = YES | ||
144 | 66 | GENERATE_BUGLIST = YES | ||
145 | 67 | GENERATE_DEPRECATEDLIST= YES | ||
146 | 68 | ENABLED_SECTIONS = | ||
147 | 69 | MAX_INITIALIZER_LINES = 30 | ||
148 | 70 | SHOW_USED_FILES = YES | ||
149 | 71 | SHOW_DIRECTORIES = NO | ||
150 | 72 | SHOW_FILES = YES | ||
151 | 73 | SHOW_NAMESPACES = YES | ||
152 | 74 | FILE_VERSION_FILTER = | ||
153 | 75 | LAYOUT_FILE = | ||
154 | 76 | #--------------------------------------------------------------------------- | ||
155 | 77 | # configuration options related to warning and progress messages | ||
156 | 78 | #--------------------------------------------------------------------------- | ||
157 | 79 | QUIET = NO | ||
158 | 80 | WARNINGS = YES | ||
159 | 81 | WARN_IF_UNDOCUMENTED = YES | ||
160 | 82 | WARN_IF_DOC_ERROR = YES | ||
161 | 83 | WARN_NO_PARAMDOC = NO | ||
162 | 84 | WARN_FORMAT = "$file:$line: $text" | ||
163 | 85 | WARN_LOGFILE = | ||
164 | 86 | #--------------------------------------------------------------------------- | ||
165 | 87 | # configuration options related to the input files | ||
166 | 88 | #--------------------------------------------------------------------------- | ||
167 | 89 | INPUT = . | ||
168 | 90 | INPUT_ENCODING = UTF-8 | ||
169 | 91 | FILE_PATTERNS = *.xml | ||
170 | 92 | RECURSIVE = NO | ||
171 | 93 | EXCLUDE = | ||
172 | 94 | EXCLUDE_SYMLINKS = NO | ||
173 | 95 | EXCLUDE_PATTERNS = | ||
174 | 96 | EXCLUDE_SYMBOLS = | ||
175 | 97 | EXAMPLE_PATH = | ||
176 | 98 | EXAMPLE_PATTERNS = | ||
177 | 99 | EXAMPLE_RECURSIVE = NO | ||
178 | 100 | IMAGE_PATH = | ||
179 | 101 | INPUT_FILTER = doxymel | ||
180 | 102 | FILTER_PATTERNS = *.xml=doxymel | ||
181 | 103 | FILTER_SOURCE_FILES = NO | ||
182 | 104 | #--------------------------------------------------------------------------- | ||
183 | 105 | # configuration options related to source browsing | ||
184 | 106 | #--------------------------------------------------------------------------- | ||
185 | 107 | SOURCE_BROWSER = NO | ||
186 | 108 | INLINE_SOURCES = NO | ||
187 | 109 | STRIP_CODE_COMMENTS = YES | ||
188 | 110 | REFERENCED_BY_RELATION = NO | ||
189 | 111 | REFERENCES_RELATION = NO | ||
190 | 112 | REFERENCES_LINK_SOURCE = YES | ||
191 | 113 | USE_HTAGS = NO | ||
192 | 114 | VERBATIM_HEADERS = YES | ||
193 | 115 | #--------------------------------------------------------------------------- | ||
194 | 116 | # configuration options related to the alphabetical class index | ||
195 | 117 | #--------------------------------------------------------------------------- | ||
196 | 118 | ALPHABETICAL_INDEX = NO | ||
197 | 119 | COLS_IN_ALPHA_INDEX = 5 | ||
198 | 120 | IGNORE_PREFIX = | ||
199 | 121 | #--------------------------------------------------------------------------- | ||
200 | 122 | # configuration options related to the HTML output | ||
201 | 123 | #--------------------------------------------------------------------------- | ||
202 | 124 | GENERATE_HTML = YES | ||
203 | 125 | HTML_OUTPUT = html | ||
204 | 126 | HTML_FILE_EXTENSION = .html | ||
205 | 127 | HTML_HEADER = | ||
206 | 128 | HTML_FOOTER = | ||
207 | 129 | HTML_STYLESHEET = | ||
208 | 130 | HTML_ALIGN_MEMBERS = YES | ||
209 | 131 | HTML_DYNAMIC_SECTIONS = NO | ||
210 | 132 | GENERATE_DOCSET = NO | ||
211 | 133 | DOCSET_FEEDNAME = "Doxygen generated docs" | ||
212 | 134 | DOCSET_BUNDLE_ID = org.doxygen.Project | ||
213 | 135 | GENERATE_HTMLHELP = NO | ||
214 | 136 | CHM_FILE = | ||
215 | 137 | HHC_LOCATION = | ||
216 | 138 | GENERATE_CHI = NO | ||
217 | 139 | CHM_INDEX_ENCODING = | ||
218 | 140 | BINARY_TOC = NO | ||
219 | 141 | TOC_EXPAND = NO | ||
220 | 142 | GENERATE_QHP = NO | ||
221 | 143 | QCH_FILE = | ||
222 | 144 | QHP_NAMESPACE = | ||
223 | 145 | QHP_VIRTUAL_FOLDER = doc | ||
224 | 146 | QHP_CUST_FILTER_NAME = | ||
225 | 147 | QHP_CUST_FILTER_ATTRS = | ||
226 | 148 | QHP_SECT_FILTER_ATTRS = | ||
227 | 149 | QHG_LOCATION = | ||
228 | 150 | DISABLE_INDEX = NO | ||
229 | 151 | ENUM_VALUES_PER_LINE = 4 | ||
230 | 152 | GENERATE_TREEVIEW = NO | ||
231 | 153 | USE_INLINE_TREES = NO | ||
232 | 154 | TREEVIEW_WIDTH = 250 | ||
233 | 155 | FORMULA_FONTSIZE = 10 | ||
234 | 156 | SEARCHENGINE = YES | ||
235 | 157 | #--------------------------------------------------------------------------- | ||
236 | 158 | # configuration options related to the LaTeX output | ||
237 | 159 | #--------------------------------------------------------------------------- | ||
238 | 160 | GENERATE_LATEX = NO | ||
239 | 161 | LATEX_OUTPUT = latex | ||
240 | 162 | LATEX_CMD_NAME = latex | ||
241 | 163 | MAKEINDEX_CMD_NAME = makeindex | ||
242 | 164 | COMPACT_LATEX = NO | ||
243 | 165 | PAPER_TYPE = a4wide | ||
244 | 166 | EXTRA_PACKAGES = | ||
245 | 167 | LATEX_HEADER = | ||
246 | 168 | PDF_HYPERLINKS = YES | ||
247 | 169 | USE_PDFLATEX = YES | ||
248 | 170 | LATEX_BATCHMODE = NO | ||
249 | 171 | LATEX_HIDE_INDICES = NO | ||
250 | 172 | LATEX_SOURCE_CODE = NO | ||
251 | 173 | #--------------------------------------------------------------------------- | ||
252 | 174 | # configuration options related to the RTF output | ||
253 | 175 | #--------------------------------------------------------------------------- | ||
254 | 176 | GENERATE_RTF = NO | ||
255 | 177 | RTF_OUTPUT = rtf | ||
256 | 178 | COMPACT_RTF = NO | ||
257 | 179 | RTF_HYPERLINKS = NO | ||
258 | 180 | RTF_STYLESHEET_FILE = | ||
259 | 181 | RTF_EXTENSIONS_FILE = | ||
260 | 182 | #--------------------------------------------------------------------------- | ||
261 | 183 | # configuration options related to the man page output | ||
262 | 184 | #--------------------------------------------------------------------------- | ||
263 | 185 | GENERATE_MAN = NO | ||
264 | 186 | MAN_OUTPUT = man | ||
265 | 187 | MAN_EXTENSION = .3 | ||
266 | 188 | MAN_LINKS = NO | ||
267 | 189 | #--------------------------------------------------------------------------- | ||
268 | 190 | # configuration options related to the XML output | ||
269 | 191 | #--------------------------------------------------------------------------- | ||
270 | 192 | GENERATE_XML = NO | ||
271 | 193 | XML_OUTPUT = xml | ||
272 | 194 | XML_SCHEMA = | ||
273 | 195 | XML_DTD = | ||
274 | 196 | XML_PROGRAMLISTING = YES | ||
275 | 197 | #--------------------------------------------------------------------------- | ||
276 | 198 | # configuration options for the AutoGen Definitions output | ||
277 | 199 | #--------------------------------------------------------------------------- | ||
278 | 200 | GENERATE_AUTOGEN_DEF = NO | ||
279 | 201 | #--------------------------------------------------------------------------- | ||
280 | 202 | # configuration options related to the Perl module output | ||
281 | 203 | #--------------------------------------------------------------------------- | ||
282 | 204 | GENERATE_PERLMOD = NO | ||
283 | 205 | PERLMOD_LATEX = NO | ||
284 | 206 | PERLMOD_PRETTY = YES | ||
285 | 207 | PERLMOD_MAKEVAR_PREFIX = | ||
286 | 208 | #--------------------------------------------------------------------------- | ||
287 | 209 | # Configuration options related to the preprocessor | ||
288 | 210 | #--------------------------------------------------------------------------- | ||
289 | 211 | ENABLE_PREPROCESSING = YES | ||
290 | 212 | MACRO_EXPANSION = NO | ||
291 | 213 | EXPAND_ONLY_PREDEF = NO | ||
292 | 214 | SEARCH_INCLUDES = YES | ||
293 | 215 | INCLUDE_PATH = | ||
294 | 216 | INCLUDE_FILE_PATTERNS = | ||
295 | 217 | PREDEFINED = | ||
296 | 218 | EXPAND_AS_DEFINED = | ||
297 | 219 | SKIP_FUNCTION_MACROS = YES | ||
298 | 220 | #--------------------------------------------------------------------------- | ||
299 | 221 | # Configuration::additions related to external references | ||
300 | 222 | #--------------------------------------------------------------------------- | ||
301 | 223 | TAGFILES = | ||
302 | 224 | GENERATE_TAGFILE = | ||
303 | 225 | ALLEXTERNALS = NO | ||
304 | 226 | EXTERNAL_GROUPS = YES | ||
305 | 227 | PERL_PATH = /usr/bin/perl | ||
306 | 228 | #--------------------------------------------------------------------------- | ||
307 | 229 | # Configuration options related to the dot tool | ||
308 | 230 | #--------------------------------------------------------------------------- | ||
309 | 231 | CLASS_DIAGRAMS = YES | ||
310 | 232 | MSCGEN_PATH = | ||
311 | 233 | HIDE_UNDOC_RELATIONS = YES | ||
312 | 234 | HAVE_DOT = NO | ||
313 | 235 | DOT_FONTNAME = FreeSans | ||
314 | 236 | DOT_FONTSIZE = 10 | ||
315 | 237 | DOT_FONTPATH = | ||
316 | 238 | CLASS_GRAPH = YES | ||
317 | 239 | COLLABORATION_GRAPH = YES | ||
318 | 240 | GROUP_GRAPHS = YES | ||
319 | 241 | UML_LOOK = NO | ||
320 | 242 | TEMPLATE_RELATIONS = NO | ||
321 | 243 | INCLUDE_GRAPH = YES | ||
322 | 244 | INCLUDED_BY_GRAPH = YES | ||
323 | 245 | CALL_GRAPH = NO | ||
324 | 246 | CALLER_GRAPH = NO | ||
325 | 247 | GRAPHICAL_HIERARCHY = YES | ||
326 | 248 | DIRECTORY_GRAPH = YES | ||
327 | 249 | DOT_IMAGE_FORMAT = png | ||
328 | 250 | DOT_PATH = | ||
329 | 251 | DOTFILE_DIRS = | ||
330 | 252 | DOT_GRAPH_MAX_NODES = 50 | ||
331 | 253 | MAX_DOT_GRAPH_DEPTH = 0 | ||
332 | 254 | DOT_TRANSPARENT = NO | ||
333 | 255 | DOT_MULTI_TARGETS = YES | ||
334 | 256 | GENERATE_LEGEND = YES | ||
335 | 257 | DOT_CLEANUP = YES | ||
336 | 0 | 258 | ||
337 | === modified file 'libdbusmenu-glib/Makefile.am' | |||
338 | --- libdbusmenu-glib/Makefile.am 2009-11-13 18:02:08 +0000 | |||
339 | +++ libdbusmenu-glib/Makefile.am 2010-02-04 20:30:33 +0000 | |||
340 | @@ -27,6 +27,8 @@ | |||
341 | 27 | server.c \ | 27 | server.c \ |
342 | 28 | server-marshal.h \ | 28 | server-marshal.h \ |
343 | 29 | server-marshal.c \ | 29 | server-marshal.c \ |
344 | 30 | client-menuitem.h \ | ||
345 | 31 | client-menuitem.c \ | ||
346 | 30 | client.h \ | 32 | client.h \ |
347 | 31 | client.c | 33 | client.c |
348 | 32 | 34 | ||
349 | 33 | 35 | ||
350 | === added file 'libdbusmenu-glib/client-menuitem.c' | |||
351 | --- libdbusmenu-glib/client-menuitem.c 1970-01-01 00:00:00 +0000 | |||
352 | +++ libdbusmenu-glib/client-menuitem.c 2010-02-04 20:30:33 +0000 | |||
353 | @@ -0,0 +1,106 @@ | |||
354 | 1 | /* | ||
355 | 2 | A small subclass of the menuitem for using clients. | ||
356 | 3 | |||
357 | 4 | Copyright 2010 Canonical Ltd. | ||
358 | 5 | |||
359 | 6 | Authors: | ||
360 | 7 | Ted Gould <ted@canonical.com> | ||
361 | 8 | |||
362 | 9 | This program is free software: you can redistribute it and/or modify it | ||
363 | 10 | under the terms of either or both of the following licenses: | ||
364 | 11 | |||
365 | 12 | 1) the GNU Lesser General Public License version 3, as published by the | ||
366 | 13 | Free Software Foundation; and/or | ||
367 | 14 | 2) the GNU Lesser General Public License version 2.1, as published by | ||
368 | 15 | the Free Software Foundation. | ||
369 | 16 | |||
370 | 17 | This program is distributed in the hope that it will be useful, but | ||
371 | 18 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
372 | 19 | MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
373 | 20 | PURPOSE. See the applicable version of the GNU Lesser General Public | ||
374 | 21 | License for more details. | ||
375 | 22 | |||
376 | 23 | You should have received a copy of both the GNU Lesser General Public | ||
377 | 24 | License version 3 and version 2.1 along with this program. If not, see | ||
378 | 25 | <http://www.gnu.org/licenses/> | ||
379 | 26 | */ | ||
380 | 27 | |||
381 | 28 | #ifdef HAVE_CONFIG_H | ||
382 | 29 | #include "config.h" | ||
383 | 30 | #endif | ||
384 | 31 | |||
385 | 32 | #include "client-menuitem.h" | ||
386 | 33 | |||
387 | 34 | typedef struct _DbusmenuClientMenuitemPrivate DbusmenuClientMenuitemPrivate; | ||
388 | 35 | |||
389 | 36 | struct _DbusmenuClientMenuitemPrivate | ||
390 | 37 | { | ||
391 | 38 | DbusmenuClient * client; | ||
392 | 39 | }; | ||
393 | 40 | |||
394 | 41 | #define DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(o) \ | ||
395 | 42 | (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemPrivate)) | ||
396 | 43 | |||
397 | 44 | static void dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass); | ||
398 | 45 | static void dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self); | ||
399 | 46 | static void dbusmenu_client_menuitem_dispose (GObject *object); | ||
400 | 47 | static void dbusmenu_client_menuitem_finalize (GObject *object); | ||
401 | 48 | static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); | ||
402 | 49 | |||
403 | 50 | G_DEFINE_TYPE (DbusmenuClientMenuitem, dbusmenu_client_menuitem, DBUSMENU_TYPE_MENUITEM); | ||
404 | 51 | |||
405 | 52 | static void | ||
406 | 53 | dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass) | ||
407 | 54 | { | ||
408 | 55 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
409 | 56 | |||
410 | 57 | g_type_class_add_private (klass, sizeof (DbusmenuClientMenuitemPrivate)); | ||
411 | 58 | |||
412 | 59 | object_class->dispose = dbusmenu_client_menuitem_dispose; | ||
413 | 60 | object_class->finalize = dbusmenu_client_menuitem_finalize; | ||
414 | 61 | |||
415 | 62 | DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass); | ||
416 | 63 | mclass->handle_event = handle_event; | ||
417 | 64 | |||
418 | 65 | return; | ||
419 | 66 | } | ||
420 | 67 | |||
421 | 68 | static void | ||
422 | 69 | dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self) | ||
423 | 70 | { | ||
424 | 71 | |||
425 | 72 | return; | ||
426 | 73 | } | ||
427 | 74 | |||
428 | 75 | static void | ||
429 | 76 | dbusmenu_client_menuitem_dispose (GObject *object) | ||
430 | 77 | { | ||
431 | 78 | |||
432 | 79 | G_OBJECT_CLASS (dbusmenu_client_menuitem_parent_class)->dispose (object); | ||
433 | 80 | return; | ||
434 | 81 | } | ||
435 | 82 | |||
436 | 83 | static void | ||
437 | 84 | dbusmenu_client_menuitem_finalize (GObject *object) | ||
438 | 85 | { | ||
439 | 86 | |||
440 | 87 | G_OBJECT_CLASS (dbusmenu_client_menuitem_parent_class)->finalize (object); | ||
441 | 88 | return; | ||
442 | 89 | } | ||
443 | 90 | |||
444 | 91 | DbusmenuClientMenuitem * | ||
445 | 92 | dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client) | ||
446 | 93 | { | ||
447 | 94 | DbusmenuClientMenuitem * mi = g_object_new(DBUSMENU_CLIENT_MENUITEM_TYPE, "id", id, NULL); | ||
448 | 95 | DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi); | ||
449 | 96 | priv->client = client; | ||
450 | 97 | return mi; | ||
451 | 98 | } | ||
452 | 99 | |||
453 | 100 | static void | ||
454 | 101 | handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) | ||
455 | 102 | { | ||
456 | 103 | DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi); | ||
457 | 104 | dbusmenu_client_send_event(priv->client, dbusmenu_menuitem_get_id(mi), name, value, timestamp); | ||
458 | 105 | return; | ||
459 | 106 | } | ||
460 | 0 | 107 | ||
461 | === added file 'libdbusmenu-glib/client-menuitem.h' | |||
462 | --- libdbusmenu-glib/client-menuitem.h 1970-01-01 00:00:00 +0000 | |||
463 | +++ libdbusmenu-glib/client-menuitem.h 2010-02-04 20:30:33 +0000 | |||
464 | @@ -0,0 +1,61 @@ | |||
465 | 1 | /* | ||
466 | 2 | A small subclass of the menuitem for using clients. | ||
467 | 3 | |||
468 | 4 | Copyright 2010 Canonical Ltd. | ||
469 | 5 | |||
470 | 6 | Authors: | ||
471 | 7 | Ted Gould <ted@canonical.com> | ||
472 | 8 | |||
473 | 9 | This program is free software: you can redistribute it and/or modify it | ||
474 | 10 | under the terms of either or both of the following licenses: | ||
475 | 11 | |||
476 | 12 | 1) the GNU Lesser General Public License version 3, as published by the | ||
477 | 13 | Free Software Foundation; and/or | ||
478 | 14 | 2) the GNU Lesser General Public License version 2.1, as published by | ||
479 | 15 | the Free Software Foundation. | ||
480 | 16 | |||
481 | 17 | This program is distributed in the hope that it will be useful, but | ||
482 | 18 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
483 | 19 | MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
484 | 20 | PURPOSE. See the applicable version of the GNU Lesser General Public | ||
485 | 21 | License for more details. | ||
486 | 22 | |||
487 | 23 | You should have received a copy of both the GNU Lesser General Public | ||
488 | 24 | License version 3 and version 2.1 along with this program. If not, see | ||
489 | 25 | <http://www.gnu.org/licenses/> | ||
490 | 26 | */ | ||
491 | 27 | |||
492 | 28 | #ifndef __DBUSMENU_CLIENT_MENUITEM_H__ | ||
493 | 29 | #define __DBUSMENU_CLIENT_MENUITEM_H__ | ||
494 | 30 | |||
495 | 31 | #include <glib.h> | ||
496 | 32 | #include <glib-object.h> | ||
497 | 33 | #include "menuitem.h" | ||
498 | 34 | #include "client.h" | ||
499 | 35 | |||
500 | 36 | G_BEGIN_DECLS | ||
501 | 37 | |||
502 | 38 | #define DBUSMENU_CLIENT_MENUITEM_TYPE (dbusmenu_client_menuitem_get_type ()) | ||
503 | 39 | #define DBUSMENU_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitem)) | ||
504 | 40 | #define DBUSMENU_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemClass)) | ||
505 | 41 | #define DBUSMENU_IS_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE)) | ||
506 | 42 | #define DBUSMENU_IS_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_CLIENT_MENUITEM_TYPE)) | ||
507 | 43 | #define DBUSMENU_CLIENT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemClass)) | ||
508 | 44 | |||
509 | 45 | typedef struct _DbusmenuClientMenuitem DbusmenuClientMenuitem; | ||
510 | 46 | typedef struct _DbusmenuClientMenuitemClass DbusmenuClientMenuitemClass; | ||
511 | 47 | |||
512 | 48 | struct _DbusmenuClientMenuitemClass { | ||
513 | 49 | DbusmenuMenuitemClass parent_class; | ||
514 | 50 | }; | ||
515 | 51 | |||
516 | 52 | struct _DbusmenuClientMenuitem { | ||
517 | 53 | DbusmenuMenuitem parent; | ||
518 | 54 | }; | ||
519 | 55 | |||
520 | 56 | GType dbusmenu_client_menuitem_get_type (void); | ||
521 | 57 | DbusmenuClientMenuitem * dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client); | ||
522 | 58 | |||
523 | 59 | G_END_DECLS | ||
524 | 60 | |||
525 | 61 | #endif | ||
526 | 0 | 62 | ||
527 | === modified file 'libdbusmenu-glib/client.c' | |||
528 | --- libdbusmenu-glib/client.c 2010-01-07 05:27:49 +0000 | |||
529 | +++ libdbusmenu-glib/client.c 2010-02-04 20:30:33 +0000 | |||
530 | @@ -35,6 +35,7 @@ | |||
531 | 35 | 35 | ||
532 | 36 | #include "client.h" | 36 | #include "client.h" |
533 | 37 | #include "menuitem.h" | 37 | #include "menuitem.h" |
534 | 38 | #include "client-menuitem.h" | ||
535 | 38 | #include "dbusmenu-client.h" | 39 | #include "dbusmenu-client.h" |
536 | 39 | #include "server-marshal.h" | 40 | #include "server-marshal.h" |
537 | 40 | 41 | ||
538 | @@ -96,10 +97,10 @@ | |||
539 | 96 | static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); | 97 | static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); |
540 | 97 | /* Private Funcs */ | 98 | /* Private Funcs */ |
541 | 98 | static void layout_update (DBusGProxy * proxy, gint revision, guint parent, DbusmenuClient * client); | 99 | static void layout_update (DBusGProxy * proxy, gint revision, guint parent, DbusmenuClient * client); |
544 | 99 | static void id_prop_update (DBusGProxy * proxy, guint id, gchar * property, GValue * value, DbusmenuClient * client); | 100 | static void id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client); |
545 | 100 | static void id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client); | 101 | static void id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client); |
546 | 101 | static void build_proxies (DbusmenuClient * client); | 102 | static void build_proxies (DbusmenuClient * client); |
548 | 102 | static guint parse_node_get_id (xmlNodePtr node); | 103 | static gint parse_node_get_id (xmlNodePtr node); |
549 | 103 | static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy); | 104 | static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy); |
550 | 104 | static gint parse_layout (DbusmenuClient * client, const gchar * layout); | 105 | static gint parse_layout (DbusmenuClient * client, const gchar * layout); |
551 | 105 | static void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); | 106 | static void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); |
552 | @@ -321,7 +322,7 @@ | |||
553 | 321 | /* Signal from the server that a property has changed | 322 | /* Signal from the server that a property has changed |
554 | 322 | on one of our menuitems */ | 323 | on one of our menuitems */ |
555 | 323 | static void | 324 | static void |
557 | 324 | id_prop_update (DBusGProxy * proxy, guint id, gchar * property, GValue * value, DbusmenuClient * client) | 325 | id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client) |
558 | 325 | { | 326 | { |
559 | 326 | #ifdef MASSIVEDEBUGGING | 327 | #ifdef MASSIVEDEBUGGING |
560 | 327 | GValue valstr = {0}; | 328 | GValue valstr = {0}; |
561 | @@ -344,7 +345,7 @@ | |||
562 | 344 | /* Oh, lots of updates now. That silly server, they want | 345 | /* Oh, lots of updates now. That silly server, they want |
563 | 345 | to change all kinds of stuff! */ | 346 | to change all kinds of stuff! */ |
564 | 346 | static void | 347 | static void |
566 | 347 | id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client) | 348 | id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client) |
567 | 348 | { | 349 | { |
568 | 349 | #ifdef MASSIVEDEBUGGING | 350 | #ifdef MASSIVEDEBUGGING |
569 | 350 | g_debug("Client side ID update: %d", id); | 351 | g_debug("Client side ID update: %d", id); |
570 | @@ -498,15 +499,15 @@ | |||
571 | 498 | priv->dbusproxy = NULL; | 499 | priv->dbusproxy = NULL; |
572 | 499 | } | 500 | } |
573 | 500 | 501 | ||
577 | 501 | dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__INT_UINT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); | 502 | dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_INT, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); |
578 | 502 | dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdate", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); | 503 | dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdated", G_TYPE_UINT, G_TYPE_INT, G_TYPE_INVALID); |
579 | 503 | dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdate", G_CALLBACK(layout_update), client, NULL); | 504 | dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdated", G_CALLBACK(layout_update), client, NULL); |
580 | 504 | 505 | ||
581 | 505 | dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); | 506 | dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); |
582 | 506 | dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); | 507 | dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); |
583 | 507 | dbus_g_proxy_connect_signal(priv->menuproxy, "ItemPropertyUpdated", G_CALLBACK(id_prop_update), client, NULL); | 508 | dbus_g_proxy_connect_signal(priv->menuproxy, "ItemPropertyUpdated", G_CALLBACK(id_prop_update), client, NULL); |
584 | 508 | 509 | ||
586 | 509 | dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_UINT, G_TYPE_INVALID); | 510 | dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_INT, G_TYPE_INVALID); |
587 | 510 | dbus_g_proxy_connect_signal(priv->menuproxy, "ItemUpdated", G_CALLBACK(id_update), client, NULL); | 511 | dbus_g_proxy_connect_signal(priv->menuproxy, "ItemUpdated", G_CALLBACK(id_update), client, NULL); |
588 | 511 | 512 | ||
589 | 512 | update_layout(client); | 513 | update_layout(client); |
590 | @@ -514,51 +515,23 @@ | |||
591 | 514 | return; | 515 | return; |
592 | 515 | } | 516 | } |
593 | 516 | 517 | ||
594 | 517 | /* Get the "revision" attribute of the node, parse it and | ||
595 | 518 | return it. Also we're checking to ensure the node | ||
596 | 519 | is a 'menu' here. */ | ||
597 | 520 | static gint | ||
598 | 521 | parse_node_get_revision (xmlNodePtr node) | ||
599 | 522 | { | ||
600 | 523 | if (g_strcmp0((gchar *)node->name, "menu") != 0) { | ||
601 | 524 | /* This kills some nodes early */ | ||
602 | 525 | g_warning("XML Node is not 'menu' it is '%s'", node->name); | ||
603 | 526 | return 0; | ||
604 | 527 | } | ||
605 | 528 | |||
606 | 529 | xmlAttrPtr attrib; | ||
607 | 530 | for (attrib = node->properties; attrib != NULL; attrib = attrib->next) { | ||
608 | 531 | if (g_strcmp0((gchar *)attrib->name, "revision") == 0) { | ||
609 | 532 | if (attrib->children != NULL) { | ||
610 | 533 | guint revision = (guint)g_ascii_strtoull((gchar *)attrib->children->content, NULL, 10); | ||
611 | 534 | /* g_debug ("Found ID: %d", id); */ | ||
612 | 535 | return revision; | ||
613 | 536 | } | ||
614 | 537 | break; | ||
615 | 538 | } | ||
616 | 539 | } | ||
617 | 540 | |||
618 | 541 | g_warning("Unable to find a revision on the node"); | ||
619 | 542 | return 0; | ||
620 | 543 | } | ||
621 | 544 | |||
622 | 545 | /* Get the ID attribute of the node, parse it and | 518 | /* Get the ID attribute of the node, parse it and |
623 | 546 | return it. Also we're checking to ensure the node | 519 | return it. Also we're checking to ensure the node |
624 | 547 | is a 'menu' here. */ | 520 | is a 'menu' here. */ |
626 | 548 | static guint | 521 | static gint |
627 | 549 | parse_node_get_id (xmlNodePtr node) | 522 | parse_node_get_id (xmlNodePtr node) |
628 | 550 | { | 523 | { |
629 | 551 | if (g_strcmp0((gchar *)node->name, "menu") != 0) { | 524 | if (g_strcmp0((gchar *)node->name, "menu") != 0) { |
630 | 552 | /* This kills some nodes early */ | 525 | /* This kills some nodes early */ |
631 | 553 | g_warning("XML Node is not 'menu' it is '%s'", node->name); | 526 | g_warning("XML Node is not 'menu' it is '%s'", node->name); |
633 | 554 | return 0; | 527 | return -1; |
634 | 555 | } | 528 | } |
635 | 556 | 529 | ||
636 | 557 | xmlAttrPtr attrib; | 530 | xmlAttrPtr attrib; |
637 | 558 | for (attrib = node->properties; attrib != NULL; attrib = attrib->next) { | 531 | for (attrib = node->properties; attrib != NULL; attrib = attrib->next) { |
638 | 559 | if (g_strcmp0((gchar *)attrib->name, "id") == 0) { | 532 | if (g_strcmp0((gchar *)attrib->name, "id") == 0) { |
639 | 560 | if (attrib->children != NULL) { | 533 | if (attrib->children != NULL) { |
641 | 561 | guint id = (guint)g_ascii_strtoull((gchar *)attrib->children->content, NULL, 10); | 534 | gint id = (guint)g_ascii_strtoll((gchar *)attrib->children->content, NULL, 10); |
642 | 562 | /* g_debug ("Found ID: %d", id); */ | 535 | /* g_debug ("Found ID: %d", id); */ |
643 | 563 | return id; | 536 | return id; |
644 | 564 | } | 537 | } |
645 | @@ -567,7 +540,7 @@ | |||
646 | 567 | } | 540 | } |
647 | 568 | 541 | ||
648 | 569 | g_warning("Unable to find an ID on the node"); | 542 | g_warning("Unable to find an ID on the node"); |
650 | 570 | return 0; | 543 | return -1; |
651 | 571 | } | 544 | } |
652 | 572 | 545 | ||
653 | 573 | /* A small helper that calls _property_set on each hash table | 546 | /* A small helper that calls _property_set on each hash table |
654 | @@ -654,14 +627,11 @@ | |||
655 | 654 | return; | 627 | return; |
656 | 655 | } | 628 | } |
657 | 656 | 629 | ||
660 | 657 | static void | 630 | void |
661 | 658 | menuitem_activate (DbusmenuMenuitem * mi, DbusmenuClient * client) | 631 | dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, const GValue * value, guint timestamp) |
662 | 659 | { | 632 | { |
663 | 660 | DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); | 633 | DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); |
668 | 661 | GValue value = {0}; | 634 | org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, GINT_TO_POINTER(id)); |
665 | 662 | g_value_init(&value, G_TYPE_INT); | ||
666 | 663 | g_value_set_int(&value, 0); | ||
667 | 664 | org_ayatana_dbusmenu_event_async (priv->menuproxy, dbusmenu_menuitem_get_id(mi), "clicked", &value, menuitem_call_cb, mi); | ||
669 | 665 | return; | 635 | return; |
670 | 666 | } | 636 | } |
671 | 667 | 637 | ||
672 | @@ -670,11 +640,14 @@ | |||
673 | 670 | static DbusmenuMenuitem * | 640 | static DbusmenuMenuitem * |
674 | 671 | parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy) | 641 | parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy) |
675 | 672 | { | 642 | { |
677 | 673 | guint id = parse_node_get_id(node); | 643 | gint id = parse_node_get_id(node); |
678 | 644 | if (id < 0) { | ||
679 | 645 | return NULL; | ||
680 | 646 | } | ||
681 | 674 | #ifdef MASSIVEDEBUGGING | 647 | #ifdef MASSIVEDEBUGGING |
682 | 675 | g_debug("Client looking at node with id: %d", id); | 648 | g_debug("Client looking at node with id: %d", id); |
683 | 676 | #endif | 649 | #endif |
685 | 677 | if (item == NULL || dbusmenu_menuitem_get_id(item) != id || id == 0) { | 650 | if (item == NULL || dbusmenu_menuitem_get_id(item) != id) { |
686 | 678 | if (item != NULL) { | 651 | if (item != NULL) { |
687 | 679 | if (parent != NULL) { | 652 | if (parent != NULL) { |
688 | 680 | dbusmenu_menuitem_child_delete(parent, item); | 653 | dbusmenu_menuitem_child_delete(parent, item); |
689 | @@ -683,17 +656,11 @@ | |||
690 | 683 | item = NULL; | 656 | item = NULL; |
691 | 684 | } | 657 | } |
692 | 685 | 658 | ||
693 | 686 | if (id == 0) { | ||
694 | 687 | g_warning("ID from XML file is zero"); | ||
695 | 688 | return NULL; | ||
696 | 689 | } | ||
697 | 690 | |||
698 | 691 | /* Build a new item */ | 659 | /* Build a new item */ |
700 | 692 | item = dbusmenu_menuitem_new_with_id(id); | 660 | item = DBUSMENU_MENUITEM(dbusmenu_client_menuitem_new(id, client)); |
701 | 693 | if (parent == NULL) { | 661 | if (parent == NULL) { |
702 | 694 | dbusmenu_menuitem_set_root(item, TRUE); | 662 | dbusmenu_menuitem_set_root(item, TRUE); |
703 | 695 | } | 663 | } |
704 | 696 | g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activate), client); | ||
705 | 697 | 664 | ||
706 | 698 | /* Get the properties queued up for this item */ | 665 | /* Get the properties queued up for this item */ |
707 | 699 | /* Not happy about this, but I need these :( */ | 666 | /* Not happy about this, but I need these :( */ |
708 | @@ -717,7 +684,10 @@ | |||
709 | 717 | 684 | ||
710 | 718 | for (children = node->children, position = 0; children != NULL; children = children->next, position++) { | 685 | for (children = node->children, position = 0; children != NULL; children = children->next, position++) { |
711 | 719 | /* g_debug("Looking at child: %d", position); */ | 686 | /* g_debug("Looking at child: %d", position); */ |
713 | 720 | guint childid = parse_node_get_id(children); | 687 | gint childid = parse_node_get_id(children); |
714 | 688 | if (childid < 0) { | ||
715 | 689 | continue; | ||
716 | 690 | } | ||
717 | 721 | DbusmenuMenuitem * childmi = NULL; | 691 | DbusmenuMenuitem * childmi = NULL; |
718 | 722 | 692 | ||
719 | 723 | GList * childsearch = NULL; | 693 | GList * childsearch = NULL; |
720 | @@ -764,7 +734,6 @@ | |||
721 | 764 | xmldoc = xmlReadMemory(layout, g_utf8_strlen(layout, 16*1024), "dbusmenu.xml", NULL, 0); | 734 | xmldoc = xmlReadMemory(layout, g_utf8_strlen(layout, 16*1024), "dbusmenu.xml", NULL, 0); |
722 | 765 | 735 | ||
723 | 766 | xmlNodePtr root = xmlDocGetRootElement(xmldoc); | 736 | xmlNodePtr root = xmlDocGetRootElement(xmldoc); |
724 | 767 | gint revision = parse_node_get_revision(root); | ||
725 | 768 | 737 | ||
726 | 769 | DbusmenuMenuitem * oldroot = priv->root; | 738 | DbusmenuMenuitem * oldroot = priv->root; |
727 | 770 | priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); | 739 | priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); |
728 | @@ -781,7 +750,7 @@ | |||
729 | 781 | g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE); | 750 | g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE); |
730 | 782 | } | 751 | } |
731 | 783 | 752 | ||
733 | 784 | return revision; | 753 | return 1; |
734 | 785 | } | 754 | } |
735 | 786 | 755 | ||
736 | 787 | /* When the layout property returns, here's where we take care of that. */ | 756 | /* When the layout property returns, here's where we take care of that. */ |
737 | 788 | 757 | ||
738 | === modified file 'libdbusmenu-glib/client.h' | |||
739 | --- libdbusmenu-glib/client.h 2009-12-10 04:57:31 +0000 | |||
740 | +++ libdbusmenu-glib/client.h 2010-02-04 20:30:33 +0000 | |||
741 | @@ -50,9 +50,9 @@ | |||
742 | 50 | #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" | 50 | #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" |
743 | 51 | #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" | 51 | #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" |
744 | 52 | 52 | ||
746 | 53 | #define DBUSMENU_CLIENT_TYPES_DEFAULT "menuitem" | 53 | #define DBUSMENU_CLIENT_TYPES_DEFAULT "standard" |
747 | 54 | #define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator" | 54 | #define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator" |
749 | 55 | #define DBUSMENU_CLIENT_TYPES_IMAGE "menuitem" | 55 | #define DBUSMENU_CLIENT_TYPES_IMAGE "standard" |
750 | 56 | 56 | ||
751 | 57 | /** | 57 | /** |
752 | 58 | DbusmenuClientClass: | 58 | DbusmenuClientClass: |
753 | @@ -104,6 +104,11 @@ | |||
754 | 104 | gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, | 104 | gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, |
755 | 105 | const gchar * type, | 105 | const gchar * type, |
756 | 106 | DbusmenuClientTypeHandler newfunc); | 106 | DbusmenuClientTypeHandler newfunc); |
757 | 107 | void dbusmenu_client_send_event (DbusmenuClient * client, | ||
758 | 108 | gint id, | ||
759 | 109 | const gchar * name, | ||
760 | 110 | const GValue * value, | ||
761 | 111 | guint timestamp); | ||
762 | 107 | 112 | ||
763 | 108 | /** | 113 | /** |
764 | 109 | SECTION:client | 114 | SECTION:client |
765 | 110 | 115 | ||
766 | === modified file 'libdbusmenu-glib/dbus-menu.xml' | |||
767 | --- libdbusmenu-glib/dbus-menu.xml 2009-12-24 10:31:16 +0000 | |||
768 | +++ libdbusmenu-glib/dbus-menu.xml 2010-02-04 20:30:33 +0000 | |||
769 | @@ -8,6 +8,7 @@ | |||
770 | 8 | 8 | ||
771 | 9 | Authors: | 9 | Authors: |
772 | 10 | Ted Gould <ted@canonical.com> | 10 | Ted Gould <ted@canonical.com> |
773 | 11 | Aurelien Gateau <ted@canonical.com> | ||
774 | 11 | 12 | ||
775 | 12 | This program is free software: you can redistribute it and/or modify it | 13 | This program is free software: you can redistribute it and/or modify it |
776 | 13 | under the terms of either or both of the following licenses: | 14 | under the terms of either or both of the following licenses: |
777 | @@ -27,164 +28,275 @@ | |||
778 | 27 | License version 3 and version 2.1 along with this program. If not, see | 28 | License version 3 and version 2.1 along with this program. If not, see |
779 | 28 | <http://www.gnu.org/licenses/> | 29 | <http://www.gnu.org/licenses/> |
780 | 29 | --> | 30 | --> |
782 | 30 | <node name="/"> | 31 | <node name="/" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd"> |
783 | 31 | <interface name="org.ayatana.dbusmenu"> | 32 | <interface name="org.ayatana.dbusmenu"> |
784 | 33 | <dox:d><![CDATA[ | ||
785 | 34 | The goal of this DBus interface is to be able to pass menu items | ||
786 | 35 | through DBus. | ||
787 | 36 | |||
788 | 37 | Items are represented with a unique numeric id and a dictionary of | ||
789 | 38 | properties. | ||
790 | 39 | |||
791 | 40 | Available properties are: | ||
792 | 41 | |||
793 | 42 | <table> | ||
794 | 43 | <tr> | ||
795 | 44 | <th>Name</th> | ||
796 | 45 | <th>Type</th> | ||
797 | 46 | <th>Description</th> | ||
798 | 47 | <th>Default Value</th> | ||
799 | 48 | </tr> | ||
800 | 49 | <tr> | ||
801 | 50 | <td>type</td> | ||
802 | 51 | <td>String</td> | ||
803 | 52 | <td>Can be one of: | ||
804 | 53 | - "standard": an item which can be clicked to trigger an action or | ||
805 | 54 | show another menu | ||
806 | 55 | - "separator": a separator | ||
807 | 56 | |||
808 | 57 | Vendor specific types can be added by prefixing them with | ||
809 | 58 | "x-<vendor>-". | ||
810 | 59 | </td> | ||
811 | 60 | <td>"standard"</td> | ||
812 | 61 | </tr> | ||
813 | 62 | <tr> | ||
814 | 63 | <td>label</td> | ||
815 | 64 | <td>string</td> | ||
816 | 65 | <td>Text of the item, except that: | ||
817 | 66 | -# two consecutive underscore characters "__" are displayed as a | ||
818 | 67 | single underscore, | ||
819 | 68 | -# any remaining underscore characters are not displayed at all, | ||
820 | 69 | -# the first of those remaining underscore characters (unless it is | ||
821 | 70 | the last character in the string) indicates that the following | ||
822 | 71 | character is the access key. | ||
823 | 72 | </td> | ||
824 | 73 | <td>""</td> | ||
825 | 74 | </tr> | ||
826 | 75 | <tr> | ||
827 | 76 | <td>enabled</td> | ||
828 | 77 | <td>boolean</td> | ||
829 | 78 | <td>Whether the item can be activated or not.</td> | ||
830 | 79 | <td>true</td> | ||
831 | 80 | </tr> | ||
832 | 81 | <tr> | ||
833 | 82 | <td>icon-name</td> | ||
834 | 83 | <td>string</td> | ||
835 | 84 | <td>Icon name of the item, following the freedesktop.org icon spec.</td> | ||
836 | 85 | <td>""</td> | ||
837 | 86 | </tr> | ||
838 | 87 | <tr> | ||
839 | 88 | <td>icon-data</td> | ||
840 | 89 | <td>binary</td> | ||
841 | 90 | <td>PNG data of the icon.</td> | ||
842 | 91 | <td>Empty</td> | ||
843 | 92 | </tr> | ||
844 | 93 | <tr> | ||
845 | 94 | <td>toggle-type</td> | ||
846 | 95 | <td>string</td> | ||
847 | 96 | <td> | ||
848 | 97 | If the item can be toggled, this property should be set to: | ||
849 | 98 | - "checkmark": Item is an independent togglable item | ||
850 | 99 | - "radio": Item is part of a group where only one item can be | ||
851 | 100 | toggled at a time | ||
852 | 101 | - "": Item cannot be toggled | ||
853 | 102 | </td> | ||
854 | 103 | <td>""</td> | ||
855 | 104 | </tr> | ||
856 | 105 | <tr> | ||
857 | 106 | <td>toggle-state</td> | ||
858 | 107 | <td>int</td> | ||
859 | 108 | <td> | ||
860 | 109 | Describe the current state of a "togglable" item. Can be one of: | ||
861 | 110 | - 0 = off | ||
862 | 111 | - 1 = on | ||
863 | 112 | - anything else = indeterminate | ||
864 | 113 | |||
865 | 114 | Note: | ||
866 | 115 | The implementation does not itself handle ensuring that only one | ||
867 | 116 | item in a radio group is set to "on", or that a group does not have | ||
868 | 117 | "on" and "indeterminate" items simultaneously; maintaining this | ||
869 | 118 | policy is up to the toolkit wrappers. | ||
870 | 119 | </td> | ||
871 | 120 | <td>0</td> | ||
872 | 121 | </tr> | ||
873 | 122 | <tr> | ||
874 | 123 | <td>children-display</td> | ||
875 | 124 | <td>string</td> | ||
876 | 125 | <td> | ||
877 | 126 | If the menu item has children this property should be set to | ||
878 | 127 | "submenu". | ||
879 | 128 | </td> | ||
880 | 129 | <td>""</td> | ||
881 | 130 | </tr> | ||
882 | 131 | </table> | ||
883 | 132 | |||
884 | 133 | Vendor specific properties can be added by prefixing them with | ||
885 | 134 | "x-<vendor>-". | ||
886 | 135 | ]]></dox:d> | ||
887 | 32 | 136 | ||
888 | 33 | <!-- Properties --> | 137 | <!-- Properties --> |
894 | 34 | <!-- | 138 | <property name="version" type="u" access="read"> |
895 | 35 | Provides the version of the DBusmenu API that this API is | 139 | <dox:d> |
896 | 36 | implementing. | 140 | Provides the version of the DBusmenu API that this API is |
897 | 37 | --> | 141 | implementing. |
898 | 38 | <property name="version" type="u" access="read"/> | 142 | </dox:d> |
899 | 143 | </property> | ||
900 | 39 | 144 | ||
901 | 40 | <!-- Functions --> | 145 | <!-- Functions --> |
902 | 41 | 146 | ||
914 | 42 | <!-- | 147 | <method name="GetLayout"> |
915 | 43 | Provides an XML representation of the menu hierarchy | 148 | <dox:d><![CDATA[ |
916 | 44 | 149 | Provides an XML representation of the menu hierarchy | |
917 | 45 | @param parentId The ID of the parent node for the layout. For | 150 | |
918 | 46 | grabbing the layout from the root node use zero. | 151 | XML syntax: |
919 | 47 | @param revision The revision number of the layout. For matching | 152 | |
920 | 48 | with layoutUpdated signals. | 153 | @verbatim |
910 | 49 | @param layout The layout as an XML string of IDs. | ||
911 | 50 | |||
912 | 51 | XML syntax: | ||
913 | 52 | |||
921 | 53 | <menu id="1" revision="2"> # Root container | 154 | <menu id="1" revision="2"> # Root container |
931 | 54 | <menu id="2" revision="2"> # First level menu, for example "File" | 155 | <menu id="2" revision="2"> # First level menu, for example "File" |
932 | 55 | <menu id="3" revision="2"/> ~ Second level menu, for example "Open" | 156 | <menu id="3" revision="2"/> ~ Second level menu, for example "Open" |
933 | 56 | <menu id="4" revision="3"/> | 157 | <menu id="4" revision="3"/> |
934 | 57 | ... | 158 | ... |
935 | 58 | </menu> | 159 | </menu> |
936 | 59 | <menu id="5" revision="2"> # Another first level menu, say "Edit" | 160 | <menu id="5" revision="2"> # Another first level menu, say "Edit" |
937 | 60 | ... | 161 | ... |
938 | 61 | </menu> | 162 | </menu> |
939 | 62 | ... | 163 | ... |
940 | 63 | </menu> | 164 | </menu> |
946 | 64 | --> | 165 | @endverbatim |
947 | 65 | <method name="GetLayout"> | 166 | ]]></dox:d> |
948 | 66 | <arg type="u" name="parentId" direction="in" /> | 167 | <arg type="i" name="parentId" direction="in"> |
949 | 67 | <arg type="u" name="revision" direction="out" /> | 168 | <dox:d>The ID of the parent node for the layout. For |
950 | 68 | <arg type="s" name="layout" direction="out" /> | 169 | grabbing the layout from the root node use zero.</dox:d> |
951 | 170 | </arg> | ||
952 | 171 | <arg type="u" name="revision" direction="out"> | ||
953 | 172 | <dox:d>The revision number of the layout. For matching | ||
954 | 173 | with layoutUpdated signals.</dox:d> | ||
955 | 174 | </arg> | ||
956 | 175 | <arg type="s" name="layout" direction="out"> | ||
957 | 176 | <dox:d>The layout as an XML string of IDs.</dox:d> | ||
958 | 177 | </arg> | ||
959 | 69 | </method> | 178 | </method> |
960 | 70 | 179 | ||
961 | 71 | <!-- | ||
962 | 72 | Returns the list of items which are children of @a parentId. | ||
963 | 73 | |||
964 | 74 | @param Ids A list of ids that we should be finding the properties | ||
965 | 75 | on. If the list is empty, all menu items should be sent. | ||
966 | 76 | @param propertyNames list of string the list of item properties we | ||
967 | 77 | are interested in. If there are no entries in the list all of | ||
968 | 78 | the properties will be sent. | ||
969 | 79 | |||
970 | 80 | An item is represented as a struct following this format: | ||
971 | 81 | @li id unsigned the item id | ||
972 | 82 | @li properties map(string => variant) the requested item properties | ||
973 | 83 | |||
974 | 84 | --> | ||
975 | 85 | <method name="GetGroupProperties"> | 180 | <method name="GetGroupProperties"> |
979 | 86 | <arg type="au" name="Ids" direction="in" /> | 181 | <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantList"/> |
980 | 87 | <arg type="as" name="propertyNames" direction="in" /> | 182 | <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="DBusMenuItemList"/> |
981 | 88 | <arg type="a(ua{sv})" name="properties" direction="out" /> | 183 | <dox:d> |
982 | 184 | Returns the list of items which are children of @a parentId. | ||
983 | 185 | </dox:d> | ||
984 | 186 | <arg type="ai" name="ids" direction="in" > | ||
985 | 187 | <dox:d> | ||
986 | 188 | A list of ids that we should be finding the properties | ||
987 | 189 | on. If the list is empty, all menu items should be sent. | ||
988 | 190 | </dox:d> | ||
989 | 191 | </arg> | ||
990 | 192 | <arg type="as" name="propertyNames" direction="in" > | ||
991 | 193 | <dox:d> | ||
992 | 194 | The list of item properties we are | ||
993 | 195 | interested in. If there are no entries in the list all of | ||
994 | 196 | the properties will be sent. | ||
995 | 197 | </dox:d> | ||
996 | 198 | </arg> | ||
997 | 199 | <arg type="a(ia{sv})" name="properties" direction="out" > | ||
998 | 200 | <dox:d> | ||
999 | 201 | An array of property values. | ||
1000 | 202 | An item in this area is represented as a struct following | ||
1001 | 203 | this format: | ||
1002 | 204 | @li id unsigned the item id | ||
1003 | 205 | @li properties map(string => variant) the requested item properties | ||
1004 | 206 | </dox:d> | ||
1005 | 207 | </arg> | ||
1006 | 89 | </method> | 208 | </method> |
1007 | 90 | 209 | ||
1008 | 91 | <method name="GetChildren"> | 210 | <method name="GetChildren"> |
1010 | 92 | <arg type="u" name="id" direction="in" /> | 211 | <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="DBusMenuItemList"/> |
1011 | 212 | <arg type="i" name="id" direction="in" /> | ||
1012 | 93 | <arg type="as" name="propertyNames" direction="in" /> | 213 | <arg type="as" name="propertyNames" direction="in" /> |
1014 | 94 | <arg type="a(ua{sv})" name="properties" direction="out" /> | 214 | <arg type="a(ia{sv})" name="properties" direction="out" /> |
1015 | 95 | </method> | 215 | </method> |
1016 | 96 | 216 | ||
1017 | 97 | <!-- | ||
1018 | 98 | Each menu item has a set of properties. Property keys are in menuitem.h: | ||
1019 | 99 | |||
1020 | 100 | @li type string Type of the item (see below) | ||
1021 | 101 | @li label string Text of the item | ||
1022 | 102 | @li icon-data binary Raw data of the icon (TODO: define format) | ||
1023 | 103 | @li icon string Icon name of the item, following icon spec | ||
1024 | 104 | @li sensitive boolean Whether the item can be activated or not | ||
1025 | 105 | @li visible boolean Whether the item is visible or not (XXX: Is this necessary?) | ||
1026 | 106 | @li checked boolean Whether a checkbox or radio item is checked | ||
1027 | 107 | @li shortcut string The keyboard shortcut | ||
1028 | 108 | |||
1029 | 109 | @c type property is an enum which can take the following values (client.h): | ||
1030 | 110 | |||
1031 | 111 | @li action An item which can be clicked to trigger an action | ||
1032 | 112 | @li checkbox An item which can be checked or unchecked | ||
1033 | 113 | @li radio An item which can be checked or unchecked as part of a group | ||
1034 | 114 | @li separator A separator | ||
1035 | 115 | @li menu An item which contains more items | ||
1036 | 116 | --> | ||
1037 | 117 | <method name="GetProperty"> | 217 | <method name="GetProperty"> |
1039 | 118 | <arg type="u" name="id" direction="in" /> | 218 | <arg type="i" name="id" direction="in" /> |
1040 | 119 | <arg type="s" name="name" direction="in" /> | 219 | <arg type="s" name="name" direction="in" /> |
1041 | 120 | <arg type="v" name="value" direction="out" /> | 220 | <arg type="v" name="value" direction="out" /> |
1042 | 121 | </method> | 221 | </method> |
1043 | 122 | 222 | ||
1044 | 123 | <!-- | ||
1045 | 124 | Returns multiple properties in one call. This is more efficient than | ||
1046 | 125 | GetProperty. | ||
1047 | 126 | |||
1048 | 127 | @param id unsigned the item whose properties we want to retrieve. | ||
1049 | 128 | @param propertyNames list of string name of the properties we want. If the list contains no entries, all properties are sent. | ||
1050 | 129 | --> | ||
1051 | 130 | <method name="GetProperties"> | 223 | <method name="GetProperties"> |
1052 | 224 | <dox:d> | ||
1053 | 225 | Returns multiple properties in one call. This is more efficient than | ||
1054 | 226 | GetProperty. | ||
1055 | 227 | |||
1056 | 228 | </dox:d> | ||
1057 | 131 | <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> | 229 | <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/> |
1060 | 132 | <arg type="u" name="id" direction="in" /> | 230 | <arg type="i" name="id" direction="in" > |
1061 | 133 | <arg type="as" name="propertyNames" direction="in" /> | 231 | <dox:d>The item whose properties we want to retrieve.</dox:d> |
1062 | 232 | </arg> | ||
1063 | 233 | <arg type="as" name="propertyNames" direction="in" > | ||
1064 | 234 | <dox:d>List of string name of the properties we want. If the list contains no entries, all properties are sent.</dox:d> | ||
1065 | 235 | </arg> | ||
1066 | 134 | <arg type="a{sv}" name="properties" direction="out" /> | 236 | <arg type="a{sv}" name="properties" direction="out" /> |
1067 | 135 | </method> | 237 | </method> |
1068 | 136 | 238 | ||
1069 | 137 | <!-- | ||
1070 | 138 | This is called by the applet to notify the application an event happened on a | ||
1071 | 139 | menu item. | ||
1072 | 140 | |||
1073 | 141 | @param id the id of the item which received the event | ||
1074 | 142 | @param type the type of event | ||
1075 | 143 | @param data event-specific data | ||
1076 | 144 | |||
1077 | 145 | @a type can be one of the following: | ||
1078 | 146 | |||
1079 | 147 | @li "clicked" | ||
1080 | 148 | @li "hovered" | ||
1081 | 149 | |||
1082 | 150 | Vendor specific events can be added by prefixing them with "x-<vendor>-" | ||
1083 | 151 | --> | ||
1084 | 152 | <method name="Event"> | 239 | <method name="Event"> |
1088 | 153 | <arg type="u" name="id" direction="in" /> | 240 | <dox:d><![CDATA[ |
1089 | 154 | <arg type="s" name="eventId" direction="in" /> | 241 | This is called by the applet to notify the application an event happened on a |
1090 | 155 | <arg type="v" name="data" direction="in" /> | 242 | menu item. |
1091 | 243 | |||
1092 | 244 | @a type can be one of the following: | ||
1093 | 245 | |||
1094 | 246 | @li "clicked" | ||
1095 | 247 | @li "hovered" | ||
1096 | 248 | |||
1097 | 249 | Vendor specific events can be added by prefixing them with "x-<vendor>-" | ||
1098 | 250 | ]]></dox:d> | ||
1099 | 251 | <arg type="i" name="id" direction="in" > | ||
1100 | 252 | <dox:d>the id of the item which received the event</dox:d> | ||
1101 | 253 | </arg> | ||
1102 | 254 | <arg type="s" name="eventId" direction="in" > | ||
1103 | 255 | <dox:d>the type of event</dox:d> | ||
1104 | 256 | </arg> | ||
1105 | 257 | <arg type="v" name="data" direction="in" > | ||
1106 | 258 | <dox:d>event-specific data</dox:d> | ||
1107 | 259 | </arg> | ||
1108 | 260 | <arg type="u" name="timestamp" direction="in" > | ||
1109 | 261 | <dox:d>The time that the event occured if available or the time the message was sent if not</dox:d> | ||
1110 | 262 | </arg> | ||
1111 | 156 | </method> | 263 | </method> |
1112 | 157 | 264 | ||
1113 | 158 | <!-- Signals --> | 265 | <!-- Signals --> |
1114 | 159 | <!-- | ||
1115 | 160 | Triggered by the application to notify the applet that the property @a property | ||
1116 | 161 | from item @a id has changed to @a value. | ||
1117 | 162 | --> | ||
1118 | 163 | <signal name="ItemPropertyUpdated"> | 266 | <signal name="ItemPropertyUpdated"> |
1120 | 164 | <arg type="u" name="id" direction="out" /> | 267 | <dox:d> |
1121 | 268 | Triggered by the application to notify the applet that the property @a property | ||
1122 | 269 | from item @a id has changed to @a value. | ||
1123 | 270 | </dox:d> | ||
1124 | 271 | <arg type="i" name="id" direction="out" /> | ||
1125 | 165 | <arg type="s" name="prop" direction="out" /> | 272 | <arg type="s" name="prop" direction="out" /> |
1126 | 166 | <arg type="v" name="value" direction="out" /> | 273 | <arg type="v" name="value" direction="out" /> |
1127 | 167 | </signal> | 274 | </signal> |
1128 | 168 | 275 | ||
1129 | 169 | <!-- | ||
1130 | 170 | Triggered by the application to notify the applet that all properties of item | ||
1131 | 171 | @a id should be considered outdated | ||
1132 | 172 | --> | ||
1133 | 173 | <signal name="ItemUpdated"> | 276 | <signal name="ItemUpdated"> |
1135 | 174 | <arg type="u" name="id" direction="out" /> | 277 | <dox:d> |
1136 | 278 | Triggered by the application to notify the applet that all properties of item | ||
1137 | 279 | </dox:d> | ||
1138 | 280 | <arg type="i" name="id" direction="out" > | ||
1139 | 281 | <dox:d>id which should be considered outdated</dox:d> | ||
1140 | 282 | </arg> | ||
1141 | 175 | </signal> | 283 | </signal> |
1142 | 176 | 284 | ||
1154 | 177 | <!-- | 285 | <signal name="LayoutUpdated"> |
1155 | 178 | Triggered by the application to notify display of a layout update, up to | 286 | <dox:d> |
1156 | 179 | revision | 287 | Triggered by the application to notify display of a layout update, up to |
1157 | 180 | @param revsion The revision of the layout that we're currently on | 288 | revision |
1158 | 181 | @param parent If the layout update is only of a subtree, this is the parent | 289 | </dox:d> |
1159 | 182 | item for the entries that have changed. It is zero if the | 290 | <arg type="u" name="revision" direction="out" > |
1160 | 183 | whole layout should be considered invalid. | 291 | <dox:d>The revision of the layout that we're currently on</dox:d> |
1161 | 184 | --> | 292 | </arg> |
1162 | 185 | <signal name="LayoutUpdate"> | 293 | <arg type="i" name="parent" direction="out" > |
1163 | 186 | <arg type="i" name="revision" direction="out" /> | 294 | <dox:d> |
1164 | 187 | <arg type="u" name="parent" direction="out" /> | 295 | If the layout update is only of a subtree, this is the |
1165 | 296 | parent item for the entries that have changed. It is zero if | ||
1166 | 297 | the whole layout should be considered invalid. | ||
1167 | 298 | </dox:d> | ||
1168 | 299 | </arg> | ||
1169 | 188 | </signal> | 300 | </signal> |
1170 | 189 | 301 | ||
1171 | 190 | <!-- End of interesting stuff --> | 302 | <!-- End of interesting stuff --> |
1172 | 191 | 303 | ||
1173 | === modified file 'libdbusmenu-glib/menuitem-marshal.list' | |||
1174 | --- libdbusmenu-glib/menuitem-marshal.list 2009-12-19 03:58:26 +0000 | |||
1175 | +++ libdbusmenu-glib/menuitem-marshal.list 2010-02-04 20:30:33 +0000 | |||
1176 | @@ -3,3 +3,4 @@ | |||
1177 | 3 | VOID: OBJECT, UINT | 3 | VOID: OBJECT, UINT |
1178 | 4 | VOID: OBJECT | 4 | VOID: OBJECT |
1179 | 5 | VOID: VOID | 5 | VOID: VOID |
1180 | 6 | VOID: UINT | ||
1181 | 6 | 7 | ||
1182 | === modified file 'libdbusmenu-glib/menuitem-private.h' | |||
1183 | --- libdbusmenu-glib/menuitem-private.h 2009-11-13 18:02:08 +0000 | |||
1184 | +++ libdbusmenu-glib/menuitem-private.h 2010-02-04 20:30:33 +0000 | |||
1185 | @@ -33,7 +33,7 @@ | |||
1186 | 33 | 33 | ||
1187 | 34 | G_BEGIN_DECLS | 34 | G_BEGIN_DECLS |
1188 | 35 | 35 | ||
1190 | 36 | void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array, gint revision); | 36 | void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array); |
1191 | 37 | 37 | ||
1192 | 38 | G_END_DECLS | 38 | G_END_DECLS |
1193 | 39 | 39 | ||
1194 | 40 | 40 | ||
1195 | === modified file 'libdbusmenu-glib/menuitem.c' | |||
1196 | --- libdbusmenu-glib/menuitem.c 2009-12-21 22:15:45 +0000 | |||
1197 | +++ libdbusmenu-glib/menuitem.c 2010-02-04 20:30:33 +0000 | |||
1198 | @@ -55,7 +55,7 @@ | |||
1199 | 55 | typedef struct _DbusmenuMenuitemPrivate DbusmenuMenuitemPrivate; | 55 | typedef struct _DbusmenuMenuitemPrivate DbusmenuMenuitemPrivate; |
1200 | 56 | struct _DbusmenuMenuitemPrivate | 56 | struct _DbusmenuMenuitemPrivate |
1201 | 57 | { | 57 | { |
1203 | 58 | guint id; | 58 | gint id; |
1204 | 59 | GList * children; | 59 | GList * children; |
1205 | 60 | GHashTable * properties; | 60 | GHashTable * properties; |
1206 | 61 | gboolean root; | 61 | gboolean root; |
1207 | @@ -92,6 +92,7 @@ | |||
1208 | 92 | static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); | 92 | static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); |
1209 | 93 | static void g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out); | 93 | static void g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out); |
1210 | 94 | static void g_value_transform_STRING_INT (const GValue * in, GValue * out); | 94 | static void g_value_transform_STRING_INT (const GValue * in, GValue * out); |
1211 | 95 | static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); | ||
1212 | 95 | 96 | ||
1213 | 96 | /* GObject stuff */ | 97 | /* GObject stuff */ |
1214 | 97 | G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT); | 98 | G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT); |
1215 | @@ -108,6 +109,8 @@ | |||
1216 | 108 | object_class->set_property = set_property; | 109 | object_class->set_property = set_property; |
1217 | 109 | object_class->get_property = get_property; | 110 | object_class->get_property = get_property; |
1218 | 110 | 111 | ||
1219 | 112 | klass->handle_event = handle_event; | ||
1220 | 113 | |||
1221 | 111 | /** | 114 | /** |
1222 | 112 | DbusmenuMenuitem::property-changed: | 115 | DbusmenuMenuitem::property-changed: |
1223 | 113 | @arg0: The #DbusmenuMenuitem object. | 116 | @arg0: The #DbusmenuMenuitem object. |
1224 | @@ -127,6 +130,7 @@ | |||
1225 | 127 | /** | 130 | /** |
1226 | 128 | DbusmenuMenuitem::item-activated: | 131 | DbusmenuMenuitem::item-activated: |
1227 | 129 | @arg0: The #DbusmenuMenuitem object. | 132 | @arg0: The #DbusmenuMenuitem object. |
1228 | 133 | @arg1: The timestamp of when it was activated | ||
1229 | 130 | 134 | ||
1230 | 131 | Emitted on the objects on the server side when | 135 | Emitted on the objects on the server side when |
1231 | 132 | they are signaled on the client side. | 136 | they are signaled on the client side. |
1232 | @@ -136,8 +140,8 @@ | |||
1233 | 136 | G_SIGNAL_RUN_LAST, | 140 | G_SIGNAL_RUN_LAST, |
1234 | 137 | G_STRUCT_OFFSET(DbusmenuMenuitemClass, item_activated), | 141 | G_STRUCT_OFFSET(DbusmenuMenuitemClass, item_activated), |
1235 | 138 | NULL, NULL, | 142 | NULL, NULL, |
1238 | 139 | _dbusmenu_menuitem_marshal_VOID__VOID, | 143 | _dbusmenu_menuitem_marshal_VOID__UINT, |
1239 | 140 | G_TYPE_NONE, 0, G_TYPE_NONE); | 144 | G_TYPE_NONE, 1, G_TYPE_UINT, G_TYPE_NONE); |
1240 | 141 | /** | 145 | /** |
1241 | 142 | DbusmenuMenuitem::child-added: | 146 | DbusmenuMenuitem::child-added: |
1242 | 143 | @arg0: The #DbusmenuMenuitem which is the parent. | 147 | @arg0: The #DbusmenuMenuitem which is the parent. |
1243 | @@ -206,7 +210,7 @@ | |||
1244 | 206 | G_TYPE_NONE, 0, G_TYPE_NONE); | 210 | G_TYPE_NONE, 0, G_TYPE_NONE); |
1245 | 207 | 211 | ||
1246 | 208 | g_object_class_install_property (object_class, PROP_ID, | 212 | g_object_class_install_property (object_class, PROP_ID, |
1248 | 209 | g_param_spec_uint("id", "ID for the menu item", | 213 | g_param_spec_int("id", "ID for the menu item", |
1249 | 210 | "This is a unique indentifier for the menu item.", | 214 | "This is a unique indentifier for the menu item.", |
1250 | 211 | 0, 30000, 0, | 215 | 0, 30000, 0, |
1251 | 212 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); | 216 | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); |
1252 | @@ -245,7 +249,7 @@ | |||
1253 | 245 | return; | 249 | return; |
1254 | 246 | } | 250 | } |
1255 | 247 | 251 | ||
1257 | 248 | static guint menuitem_next_id = 1; | 252 | static gint menuitem_next_id = 0; |
1258 | 249 | 253 | ||
1259 | 250 | /* A small little function to both clear the insides of a | 254 | /* A small little function to both clear the insides of a |
1260 | 251 | value as well as the memory it itself uses. */ | 255 | value as well as the memory it itself uses. */ |
1261 | @@ -314,9 +318,9 @@ | |||
1262 | 314 | 318 | ||
1263 | 315 | switch (id) { | 319 | switch (id) { |
1264 | 316 | case PROP_ID: | 320 | case PROP_ID: |
1266 | 317 | priv->id = g_value_get_uint(value); | 321 | priv->id = g_value_get_int(value); |
1267 | 318 | if (priv->id > menuitem_next_id) { | 322 | if (priv->id > menuitem_next_id) { |
1269 | 319 | menuitem_next_id = priv->id; | 323 | menuitem_next_id = priv->id + 1; |
1270 | 320 | } | 324 | } |
1271 | 321 | break; | 325 | break; |
1272 | 322 | } | 326 | } |
1273 | @@ -331,16 +335,23 @@ | |||
1274 | 331 | 335 | ||
1275 | 332 | switch (id) { | 336 | switch (id) { |
1276 | 333 | case PROP_ID: | 337 | case PROP_ID: |
1281 | 334 | if (priv->id == 0) { | 338 | g_value_set_int(value, priv->id); |
1278 | 335 | priv->id = menuitem_next_id++; | ||
1279 | 336 | } | ||
1280 | 337 | g_value_set_uint(value, priv->id); | ||
1282 | 338 | break; | 339 | break; |
1283 | 339 | } | 340 | } |
1284 | 340 | 341 | ||
1285 | 341 | return; | 342 | return; |
1286 | 342 | } | 343 | } |
1287 | 343 | 344 | ||
1288 | 345 | /* Handles the activate event if it is sent. */ | ||
1289 | 346 | static void | ||
1290 | 347 | handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) | ||
1291 | 348 | { | ||
1292 | 349 | if (g_strcmp0(name, "clicked") == 0) { | ||
1293 | 350 | g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, timestamp, TRUE); | ||
1294 | 351 | } | ||
1295 | 352 | |||
1296 | 353 | return; | ||
1297 | 354 | } | ||
1298 | 344 | 355 | ||
1299 | 345 | /* Public interface */ | 356 | /* Public interface */ |
1300 | 346 | 357 | ||
1301 | @@ -354,7 +365,7 @@ | |||
1302 | 354 | DbusmenuMenuitem * | 365 | DbusmenuMenuitem * |
1303 | 355 | dbusmenu_menuitem_new (void) | 366 | dbusmenu_menuitem_new (void) |
1304 | 356 | { | 367 | { |
1306 | 357 | return g_object_new(DBUSMENU_TYPE_MENUITEM, NULL); | 368 | return g_object_new(DBUSMENU_TYPE_MENUITEM, "id", menuitem_next_id++, NULL); |
1307 | 358 | } | 369 | } |
1308 | 359 | 370 | ||
1309 | 360 | /** | 371 | /** |
1310 | @@ -366,7 +377,7 @@ | |||
1311 | 366 | Return value: A newly allocated #DbusmenuMenuitem. | 377 | Return value: A newly allocated #DbusmenuMenuitem. |
1312 | 367 | */ | 378 | */ |
1313 | 368 | DbusmenuMenuitem * | 379 | DbusmenuMenuitem * |
1315 | 369 | dbusmenu_menuitem_new_with_id (guint id) | 380 | dbusmenu_menuitem_new_with_id (gint id) |
1316 | 370 | { | 381 | { |
1317 | 371 | DbusmenuMenuitem * mi = g_object_new(DBUSMENU_TYPE_MENUITEM, "id", id, NULL); | 382 | DbusmenuMenuitem * mi = g_object_new(DBUSMENU_TYPE_MENUITEM, "id", id, NULL); |
1318 | 372 | /* g_debug("New Menuitem id %d goal id %d", dbusmenu_menuitem_get_id(mi), id); */ | 383 | /* g_debug("New Menuitem id %d goal id %d", dbusmenu_menuitem_get_id(mi), id); */ |
1319 | @@ -641,7 +652,7 @@ | |||
1320 | 641 | can't be found. | 652 | can't be found. |
1321 | 642 | */ | 653 | */ |
1322 | 643 | DbusmenuMenuitem * | 654 | DbusmenuMenuitem * |
1324 | 644 | dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, guint id) | 655 | dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, gint id) |
1325 | 645 | { | 656 | { |
1326 | 646 | g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); | 657 | g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); |
1327 | 647 | 658 | ||
1328 | @@ -660,7 +671,7 @@ | |||
1329 | 660 | 671 | ||
1330 | 661 | typedef struct { | 672 | typedef struct { |
1331 | 662 | DbusmenuMenuitem * mi; | 673 | DbusmenuMenuitem * mi; |
1333 | 663 | guint id; | 674 | gint id; |
1334 | 664 | } find_id_t; | 675 | } find_id_t; |
1335 | 665 | 676 | ||
1336 | 666 | /* Basically the heart of the find_id that matches the | 677 | /* Basically the heart of the find_id that matches the |
1337 | @@ -696,7 +707,7 @@ | |||
1338 | 696 | represented by @mi. | 707 | represented by @mi. |
1339 | 697 | */ | 708 | */ |
1340 | 698 | DbusmenuMenuitem * | 709 | DbusmenuMenuitem * |
1342 | 699 | dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id) | 710 | dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id) |
1343 | 700 | { | 711 | { |
1344 | 701 | g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); | 712 | g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); |
1345 | 702 | find_id_t find_id = {mi: NULL, id: id}; | 713 | find_id_t find_id = {mi: NULL, id: id}; |
1346 | @@ -1047,7 +1058,6 @@ | |||
1347 | 1047 | dbusmenu_menuitem_buildxml: | 1058 | dbusmenu_menuitem_buildxml: |
1348 | 1048 | @mi: #DbusmenuMenuitem to represent in XML | 1059 | @mi: #DbusmenuMenuitem to represent in XML |
1349 | 1049 | @array: A list of string that will be turned into an XML file | 1060 | @array: A list of string that will be turned into an XML file |
1350 | 1050 | @revision: The revision of the layout to embed in the XML | ||
1351 | 1051 | 1061 | ||
1352 | 1052 | This function will add strings to the array @array. It will put | 1062 | This function will add strings to the array @array. It will put |
1353 | 1053 | at least one entry if this menu item has no children. If it has | 1063 | at least one entry if this menu item has no children. If it has |
1354 | @@ -1056,18 +1066,22 @@ | |||
1355 | 1056 | children to place their own tags in the array in between those two. | 1066 | children to place their own tags in the array in between those two. |
1356 | 1057 | */ | 1067 | */ |
1357 | 1058 | void | 1068 | void |
1359 | 1059 | dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array, gint revision) | 1069 | dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array) |
1360 | 1060 | { | 1070 | { |
1361 | 1061 | g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); | 1071 | g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); |
1362 | 1062 | 1072 | ||
1363 | 1073 | gint id = 0; | ||
1364 | 1074 | if (!dbusmenu_menuitem_get_root(mi)) { | ||
1365 | 1075 | id = dbusmenu_menuitem_get_id(mi); | ||
1366 | 1076 | } | ||
1367 | 1077 | |||
1368 | 1063 | GList * children = dbusmenu_menuitem_get_children(mi); | 1078 | GList * children = dbusmenu_menuitem_get_children(mi); |
1369 | 1064 | /* TODO: Only put revision info in the root node. Save some bandwidth. */ | ||
1370 | 1065 | if (children == NULL) { | 1079 | if (children == NULL) { |
1372 | 1066 | g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\" revision=\"%d\" />", dbusmenu_menuitem_get_id(mi), revision)); | 1080 | g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\"/>", id)); |
1373 | 1067 | } else { | 1081 | } else { |
1375 | 1068 | g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\" revision=\"%d\">", dbusmenu_menuitem_get_id(mi), revision)); | 1082 | g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\">", id)); |
1376 | 1069 | for ( ; children != NULL; children = children->next) { | 1083 | for ( ; children != NULL; children = children->next) { |
1378 | 1070 | dbusmenu_menuitem_buildxml(DBUSMENU_MENUITEM(children->data), array, revision); | 1084 | dbusmenu_menuitem_buildxml(DBUSMENU_MENUITEM(children->data), array); |
1379 | 1071 | } | 1085 | } |
1380 | 1072 | g_ptr_array_add(array, g_strdup("</menu>")); | 1086 | g_ptr_array_add(array, g_strdup("</menu>")); |
1381 | 1073 | } | 1087 | } |
1382 | @@ -1112,20 +1126,35 @@ | |||
1383 | 1112 | } | 1126 | } |
1384 | 1113 | 1127 | ||
1385 | 1114 | /** | 1128 | /** |
1387 | 1115 | dbusmenu_menuitem_activate: | 1129 | dbusmenu_menuitem_handle_event: |
1388 | 1116 | @mi: The #DbusmenuMenuitem to send the signal on. | 1130 | @mi: The #DbusmenuMenuitem to send the signal on. |
1389 | 1131 | @name: The name of the signal | ||
1390 | 1132 | @value: A value that could be set for the event | ||
1391 | 1133 | @timestamp: The timestamp of when the event happened | ||
1392 | 1134 | |||
1393 | 1135 | This function is called to create an event. It is likely | ||
1394 | 1136 | to be overrided by subclasses. The default menu item | ||
1395 | 1137 | will respond to the activate signal and do: | ||
1396 | 1117 | 1138 | ||
1397 | 1118 | Emits the #DbusmenuMenuitem::item-activate signal on this | 1139 | Emits the #DbusmenuMenuitem::item-activate signal on this |
1398 | 1119 | menu item. Called by server objects when they get the | 1140 | menu item. Called by server objects when they get the |
1399 | 1120 | appropriate DBus signals from the client. | 1141 | appropriate DBus signals from the client. |
1400 | 1142 | |||
1401 | 1143 | If you subclass this function you should really think | ||
1402 | 1144 | about calling the parent function unless you have a good | ||
1403 | 1145 | reason not to. | ||
1404 | 1121 | */ | 1146 | */ |
1405 | 1122 | void | 1147 | void |
1407 | 1123 | dbusmenu_menuitem_activate (DbusmenuMenuitem * mi) | 1148 | dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp) |
1408 | 1124 | { | 1149 | { |
1409 | 1125 | g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); | 1150 | g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); |
1410 | 1126 | #ifdef MASSIVEDEBUGGING | 1151 | #ifdef MASSIVEDEBUGGING |
1412 | 1127 | g_debug("Menuitem %d (%s) activated", ID(mi), LABEL(mi)); | 1152 | g_debug("Menuitem %d (%s) is getting event '%s'", ID(mi), LABEL(mi), name); |
1413 | 1128 | #endif | 1153 | #endif |
1415 | 1129 | g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, TRUE); | 1154 | DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi); |
1416 | 1155 | |||
1417 | 1156 | if (class->handle_event != NULL) { | ||
1418 | 1157 | return class->handle_event(mi, name, value, timestamp); | ||
1419 | 1158 | } | ||
1420 | 1130 | return; | 1159 | return; |
1421 | 1131 | } | 1160 | } |
1422 | 1132 | 1161 | ||
1423 | === modified file 'libdbusmenu-glib/menuitem.h' | |||
1424 | --- libdbusmenu-glib/menuitem.h 2010-01-07 16:49:35 +0000 | |||
1425 | +++ libdbusmenu-glib/menuitem.h 2010-02-04 20:30:33 +0000 | |||
1426 | @@ -52,19 +52,19 @@ | |||
1427 | 52 | 52 | ||
1428 | 53 | #define DBUSMENU_MENUITEM_PROP_TYPE "type" | 53 | #define DBUSMENU_MENUITEM_PROP_TYPE "type" |
1429 | 54 | #define DBUSMENU_MENUITEM_PROP_VISIBLE "visible" | 54 | #define DBUSMENU_MENUITEM_PROP_VISIBLE "visible" |
1431 | 55 | #define DBUSMENU_MENUITEM_PROP_SENSITIVE "sensitive" | 55 | #define DBUSMENU_MENUITEM_PROP_ENABLED "enabled" |
1432 | 56 | #define DBUSMENU_MENUITEM_PROP_LABEL "label" | 56 | #define DBUSMENU_MENUITEM_PROP_LABEL "label" |
1434 | 57 | #define DBUSMENU_MENUITEM_PROP_ICON "icon" | 57 | #define DBUSMENU_MENUITEM_PROP_ICON_NAME "icon-name" |
1435 | 58 | #define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data" | 58 | #define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data" |
1436 | 59 | #define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type" | 59 | #define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type" |
1438 | 60 | #define DBUSMENU_MENUITEM_PROP_TOGGLE_CHECKED "toggle-checked" | 60 | #define DBUSMENU_MENUITEM_PROP_TOGGLE_STATE "toggle-state" |
1439 | 61 | 61 | ||
1440 | 62 | #define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark" | 62 | #define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark" |
1441 | 63 | #define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio" | 63 | #define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio" |
1442 | 64 | 64 | ||
1446 | 65 | #define DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED "unchecked" | 65 | #define DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED 0 |
1447 | 66 | #define DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED "checked" | 66 | #define DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED 1 |
1448 | 67 | #define DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN "indeterminate" | 67 | #define DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN -1 |
1449 | 68 | 68 | ||
1450 | 69 | /** | 69 | /** |
1451 | 70 | DbusmenuMenuitem: | 70 | DbusmenuMenuitem: |
1452 | @@ -92,6 +92,9 @@ | |||
1453 | 92 | @realized: Slot for #DbusmenuMenuitem::realized. | 92 | @realized: Slot for #DbusmenuMenuitem::realized. |
1454 | 93 | @buildxml: Virtual function that appends the strings required | 93 | @buildxml: Virtual function that appends the strings required |
1455 | 94 | to represent this menu item in the menu XML file. | 94 | to represent this menu item in the menu XML file. |
1456 | 95 | @handle_event: This function is to override how events are handled | ||
1457 | 96 | by subclasses. Look at #dbusmenu_menuitem_handle_event for | ||
1458 | 97 | lots of good information. | ||
1459 | 95 | @reserved1: Reserved for future use. | 98 | @reserved1: Reserved for future use. |
1460 | 96 | @reserved2: Reserved for future use. | 99 | @reserved2: Reserved for future use. |
1461 | 97 | @reserved3: Reserved for future use. | 100 | @reserved3: Reserved for future use. |
1462 | @@ -104,7 +107,7 @@ | |||
1463 | 104 | 107 | ||
1464 | 105 | /* Signals */ | 108 | /* Signals */ |
1465 | 106 | void (*property_changed) (gchar * property, GValue * value); | 109 | void (*property_changed) (gchar * property, GValue * value); |
1467 | 107 | void (*item_activated) (void); | 110 | void (*item_activated) (guint timestamp); |
1468 | 108 | void (*child_added) (DbusmenuMenuitem * child, guint position); | 111 | void (*child_added) (DbusmenuMenuitem * child, guint position); |
1469 | 109 | void (*child_removed) (DbusmenuMenuitem * child); | 112 | void (*child_removed) (DbusmenuMenuitem * child); |
1470 | 110 | void (*child_moved) (DbusmenuMenuitem * child, guint newpos, guint oldpos); | 113 | void (*child_moved) (DbusmenuMenuitem * child, guint newpos, guint oldpos); |
1471 | @@ -112,17 +115,18 @@ | |||
1472 | 112 | 115 | ||
1473 | 113 | /* Virtual functions */ | 116 | /* Virtual functions */ |
1474 | 114 | void (*buildxml) (GPtrArray * stringarray); | 117 | void (*buildxml) (GPtrArray * stringarray); |
1475 | 118 | void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); | ||
1476 | 115 | 119 | ||
1477 | 116 | void (*reserved1) (void); | 120 | void (*reserved1) (void); |
1478 | 117 | void (*reserved2) (void); | 121 | void (*reserved2) (void); |
1480 | 118 | void (*reserved3) (void); | 122 | /* void (*reserved3) (void); */ |
1481 | 119 | /* void (*reserved4) (void); -- realized, realloc when bumping lib version */ | 123 | /* void (*reserved4) (void); -- realized, realloc when bumping lib version */ |
1482 | 120 | }; | 124 | }; |
1483 | 121 | 125 | ||
1484 | 122 | GType dbusmenu_menuitem_get_type (void); | 126 | GType dbusmenu_menuitem_get_type (void); |
1485 | 123 | 127 | ||
1486 | 124 | DbusmenuMenuitem * dbusmenu_menuitem_new (void) G_GNUC_WARN_UNUSED_RESULT; | 128 | DbusmenuMenuitem * dbusmenu_menuitem_new (void) G_GNUC_WARN_UNUSED_RESULT; |
1488 | 125 | DbusmenuMenuitem * dbusmenu_menuitem_new_with_id (guint id) G_GNUC_WARN_UNUSED_RESULT; | 129 | DbusmenuMenuitem * dbusmenu_menuitem_new_with_id (gint id) G_GNUC_WARN_UNUSED_RESULT; |
1489 | 126 | guint dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi); | 130 | guint dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi); |
1490 | 127 | 131 | ||
1491 | 128 | GList * dbusmenu_menuitem_get_children (DbusmenuMenuitem * mi); | 132 | GList * dbusmenu_menuitem_get_children (DbusmenuMenuitem * mi); |
1492 | @@ -134,8 +138,8 @@ | |||
1493 | 134 | gboolean dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child); | 138 | gboolean dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child); |
1494 | 135 | gboolean dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position); | 139 | gboolean dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position); |
1495 | 136 | gboolean dbusmenu_menuitem_child_reorder (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position); | 140 | gboolean dbusmenu_menuitem_child_reorder (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position); |
1498 | 137 | DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, guint id); | 141 | DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, gint id); |
1499 | 138 | DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id); | 142 | DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id); |
1500 | 139 | 143 | ||
1501 | 140 | gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); | 144 | gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); |
1502 | 141 | gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); | 145 | gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); |
1503 | @@ -153,7 +157,7 @@ | |||
1504 | 153 | gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi); | 157 | gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi); |
1505 | 154 | 158 | ||
1506 | 155 | void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data); | 159 | void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data); |
1508 | 156 | void dbusmenu_menuitem_activate (DbusmenuMenuitem * mi); | 160 | void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp); |
1509 | 157 | 161 | ||
1510 | 158 | /** | 162 | /** |
1511 | 159 | SECTION:menuitem | 163 | SECTION:menuitem |
1512 | 160 | 164 | ||
1513 | === modified file 'libdbusmenu-glib/server-marshal.list' | |||
1514 | --- libdbusmenu-glib/server-marshal.list 2009-12-09 17:17:32 +0000 | |||
1515 | +++ libdbusmenu-glib/server-marshal.list 2010-02-04 20:30:33 +0000 | |||
1516 | @@ -1,2 +1,2 @@ | |||
1517 | 1 | VOID: UINT, STRING, POINTER | 1 | VOID: UINT, STRING, POINTER |
1519 | 2 | VOID: INT, UINT | 2 | VOID: UINT, INT |
1520 | 3 | 3 | ||
1521 | === modified file 'libdbusmenu-glib/server.c' | |||
1522 | --- libdbusmenu-glib/server.c 2009-12-24 10:31:16 +0000 | |||
1523 | +++ libdbusmenu-glib/server.c 2010-02-04 20:30:33 +0000 | |||
1524 | @@ -35,16 +35,16 @@ | |||
1525 | 35 | #include "server-marshal.h" | 35 | #include "server-marshal.h" |
1526 | 36 | 36 | ||
1527 | 37 | /* DBus Prototypes */ | 37 | /* DBus Prototypes */ |
1531 | 38 | static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, guint parent, guint * revision, gchar ** layout, GError ** error); | 38 | static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error); |
1532 | 39 | static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * property, gchar ** value, GError ** error); | 39 | static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error); |
1533 | 40 | static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * properties, GHashTable ** dict, GError ** error); | 40 | static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, GPtrArray * properties, GHashTable ** dict, GError ** error); |
1534 | 41 | static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error); | 41 | static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error); |
1537 | 42 | static gboolean _dbusmenu_server_event (DbusmenuServer * server, guint id, gchar * eventid, GValue * data, GError ** error); | 42 | static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error); |
1538 | 43 | static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, guint id, GPtrArray * properties, GPtrArray ** output, GError ** error); | 43 | static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error); |
1539 | 44 | 44 | ||
1540 | 45 | #include "dbusmenu-server.h" | 45 | #include "dbusmenu-server.h" |
1541 | 46 | 46 | ||
1543 | 47 | #define DBUSMENU_VERSION_NUMBER 1 | 47 | #define DBUSMENU_VERSION_NUMBER 2 |
1544 | 48 | 48 | ||
1545 | 49 | /* Privates, I'll show you mine... */ | 49 | /* Privates, I'll show you mine... */ |
1546 | 50 | typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; | 50 | typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; |
1547 | @@ -63,7 +63,7 @@ | |||
1548 | 63 | enum { | 63 | enum { |
1549 | 64 | ID_PROP_UPDATE, | 64 | ID_PROP_UPDATE, |
1550 | 65 | ID_UPDATE, | 65 | ID_UPDATE, |
1552 | 66 | LAYOUT_UPDATE, | 66 | LAYOUT_UPDATED, |
1553 | 67 | LAST_SIGNAL | 67 | LAST_SIGNAL |
1554 | 68 | }; | 68 | }; |
1555 | 69 | 69 | ||
1556 | @@ -148,7 +148,7 @@ | |||
1557 | 148 | g_cclosure_marshal_VOID__UINT, | 148 | g_cclosure_marshal_VOID__UINT, |
1558 | 149 | G_TYPE_NONE, 1, G_TYPE_UINT); | 149 | G_TYPE_NONE, 1, G_TYPE_UINT); |
1559 | 150 | /** | 150 | /** |
1561 | 151 | DbusmenuServer::layout-update: | 151 | DbusmenuServer::layout-updated: |
1562 | 152 | @arg0: The #DbusmenuServer emitting the signal. | 152 | @arg0: The #DbusmenuServer emitting the signal. |
1563 | 153 | @arg1: A revision number representing which revision the update | 153 | @arg1: A revision number representing which revision the update |
1564 | 154 | represents itself as. | 154 | represents itself as. |
1565 | @@ -157,13 +157,13 @@ | |||
1566 | 157 | This signal is emitted any time the layout of the | 157 | This signal is emitted any time the layout of the |
1567 | 158 | menuitems under this server is changed. | 158 | menuitems under this server is changed. |
1568 | 159 | */ | 159 | */ |
1570 | 160 | signals[LAYOUT_UPDATE] = g_signal_new(DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE, | 160 | signals[LAYOUT_UPDATED] = g_signal_new(DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED, |
1571 | 161 | G_TYPE_FROM_CLASS(class), | 161 | G_TYPE_FROM_CLASS(class), |
1572 | 162 | G_SIGNAL_RUN_LAST, | 162 | G_SIGNAL_RUN_LAST, |
1574 | 163 | G_STRUCT_OFFSET(DbusmenuServerClass, layout_update), | 163 | G_STRUCT_OFFSET(DbusmenuServerClass, layout_updated), |
1575 | 164 | NULL, NULL, | 164 | NULL, NULL, |
1578 | 165 | _dbusmenu_server_marshal_VOID__INT_UINT, | 165 | _dbusmenu_server_marshal_VOID__UINT_INT, |
1579 | 166 | G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_UINT); | 166 | G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_INT); |
1580 | 167 | 167 | ||
1581 | 168 | 168 | ||
1582 | 169 | g_object_class_install_property (object_class, PROP_DBUS_OBJECT, | 169 | g_object_class_install_property (object_class, PROP_DBUS_OBJECT, |
1583 | @@ -248,7 +248,7 @@ | |||
1584 | 248 | g_debug("Setting root node to NULL"); | 248 | g_debug("Setting root node to NULL"); |
1585 | 249 | } | 249 | } |
1586 | 250 | priv->layout_revision++; | 250 | priv->layout_revision++; |
1588 | 251 | g_signal_emit(obj, signals[LAYOUT_UPDATE], 0, priv->layout_revision, 0, TRUE); | 251 | g_signal_emit(obj, signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); |
1589 | 252 | break; | 252 | break; |
1590 | 253 | default: | 253 | default: |
1591 | 254 | g_return_if_reached(); | 254 | g_return_if_reached(); |
1592 | @@ -306,7 +306,7 @@ | |||
1593 | 306 | /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ | 306 | /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ |
1594 | 307 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); | 307 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); |
1595 | 308 | priv->layout_revision++; | 308 | priv->layout_revision++; |
1597 | 309 | g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, 0, TRUE); | 309 | g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); |
1598 | 310 | return; | 310 | return; |
1599 | 311 | } | 311 | } |
1600 | 312 | 312 | ||
1601 | @@ -317,7 +317,7 @@ | |||
1602 | 317 | /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ | 317 | /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ |
1603 | 318 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); | 318 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); |
1604 | 319 | priv->layout_revision++; | 319 | priv->layout_revision++; |
1606 | 320 | g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, 0, TRUE); | 320 | g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); |
1607 | 321 | return; | 321 | return; |
1608 | 322 | } | 322 | } |
1609 | 323 | 323 | ||
1610 | @@ -326,7 +326,7 @@ | |||
1611 | 326 | { | 326 | { |
1612 | 327 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); | 327 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); |
1613 | 328 | priv->layout_revision++; | 328 | priv->layout_revision++; |
1615 | 329 | g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, 0, TRUE); | 329 | g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE); |
1616 | 330 | return; | 330 | return; |
1617 | 331 | } | 331 | } |
1618 | 332 | 332 | ||
1619 | @@ -366,7 +366,7 @@ | |||
1620 | 366 | 366 | ||
1621 | 367 | /* DBus interface */ | 367 | /* DBus interface */ |
1622 | 368 | static gboolean | 368 | static gboolean |
1624 | 369 | _dbusmenu_server_get_layout (DbusmenuServer * server, guint parent, guint * revision, gchar ** layout, GError ** error) | 369 | _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error) |
1625 | 370 | { | 370 | { |
1626 | 371 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); | 371 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); |
1627 | 372 | 372 | ||
1628 | @@ -376,13 +376,13 @@ | |||
1629 | 376 | if (parent == 0) { | 376 | if (parent == 0) { |
1630 | 377 | if (priv->root == NULL) { | 377 | if (priv->root == NULL) { |
1631 | 378 | /* g_debug("Getting layout without root node!"); */ | 378 | /* g_debug("Getting layout without root node!"); */ |
1633 | 379 | g_ptr_array_add(xmlarray, g_strdup_printf("<menu revision=\"%d\" />", priv->layout_revision)); | 379 | g_ptr_array_add(xmlarray, g_strdup("<menu/>")); |
1634 | 380 | } else { | 380 | } else { |
1636 | 381 | dbusmenu_menuitem_buildxml(priv->root, xmlarray, priv->layout_revision); | 381 | dbusmenu_menuitem_buildxml(priv->root, xmlarray); |
1637 | 382 | } | 382 | } |
1638 | 383 | } else { | 383 | } else { |
1639 | 384 | DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent); | 384 | DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent); |
1641 | 385 | dbusmenu_menuitem_buildxml(item, xmlarray, priv->layout_revision); | 385 | dbusmenu_menuitem_buildxml(item, xmlarray); |
1642 | 386 | } | 386 | } |
1643 | 387 | g_ptr_array_add(xmlarray, NULL); | 387 | g_ptr_array_add(xmlarray, NULL); |
1644 | 388 | 388 | ||
1645 | @@ -396,7 +396,7 @@ | |||
1646 | 396 | } | 396 | } |
1647 | 397 | 397 | ||
1648 | 398 | static gboolean | 398 | static gboolean |
1650 | 399 | _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * property, gchar ** value, GError ** error) | 399 | _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error) |
1651 | 400 | { | 400 | { |
1652 | 401 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); | 401 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); |
1653 | 402 | DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); | 402 | DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); |
1654 | @@ -441,7 +441,7 @@ | |||
1655 | 441 | } | 441 | } |
1656 | 442 | 442 | ||
1657 | 443 | static gboolean | 443 | static gboolean |
1659 | 444 | _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * properties, GHashTable ** dict, GError ** error) | 444 | _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, GPtrArray * properties, GHashTable ** dict, GError ** error) |
1660 | 445 | { | 445 | { |
1661 | 446 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); | 446 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); |
1662 | 447 | DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); | 447 | DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); |
1663 | @@ -475,12 +475,12 @@ | |||
1664 | 475 | } | 475 | } |
1665 | 476 | 476 | ||
1666 | 477 | static void | 477 | static void |
1668 | 478 | _gvalue_array_append_uint(GValueArray *array, guint i) | 478 | _gvalue_array_append_int(GValueArray *array, gint i) |
1669 | 479 | { | 479 | { |
1670 | 480 | GValue value = {0}; | 480 | GValue value = {0}; |
1671 | 481 | 481 | ||
1674 | 482 | g_value_init(&value, G_TYPE_UINT); | 482 | g_value_init(&value, G_TYPE_INT); |
1675 | 483 | g_value_set_uint(&value, i); | 483 | g_value_set_int(&value, i); |
1676 | 484 | g_value_array_append(array, &value); | 484 | g_value_array_append(array, &value); |
1677 | 485 | g_value_unset(&value); | 485 | g_value_unset(&value); |
1678 | 486 | } | 486 | } |
1679 | @@ -502,18 +502,18 @@ | |||
1680 | 502 | DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); | 502 | DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data); |
1681 | 503 | GPtrArray * output = (GPtrArray *)(user_data); | 503 | GPtrArray * output = (GPtrArray *)(user_data); |
1682 | 504 | 504 | ||
1684 | 505 | guint id = dbusmenu_menuitem_get_id(mi); | 505 | gint id = dbusmenu_menuitem_get_id(mi); |
1685 | 506 | GHashTable * dict = dbusmenu_menuitem_properties_copy(mi); | 506 | GHashTable * dict = dbusmenu_menuitem_properties_copy(mi); |
1686 | 507 | 507 | ||
1687 | 508 | GValueArray * item = g_value_array_new(1); | 508 | GValueArray * item = g_value_array_new(1); |
1689 | 509 | _gvalue_array_append_uint(item, id); | 509 | _gvalue_array_append_int(item, id); |
1690 | 510 | _gvalue_array_append_hashtable(item, dict); | 510 | _gvalue_array_append_hashtable(item, dict); |
1691 | 511 | 511 | ||
1692 | 512 | g_ptr_array_add(output, item); | 512 | g_ptr_array_add(output, item); |
1693 | 513 | } | 513 | } |
1694 | 514 | 514 | ||
1695 | 515 | static gboolean | 515 | static gboolean |
1697 | 516 | _dbusmenu_server_get_children (DbusmenuServer * server, guint id, GPtrArray * properties, GPtrArray ** output, GError ** error) | 516 | _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error) |
1698 | 517 | { | 517 | { |
1699 | 518 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); | 518 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); |
1700 | 519 | DbusmenuMenuitem * mi = id == 0 ? priv->root : dbusmenu_menuitem_find_id(priv->root, id); | 519 | DbusmenuMenuitem * mi = id == 0 ? priv->root : dbusmenu_menuitem_find_id(priv->root, id); |
1701 | @@ -537,7 +537,7 @@ | |||
1702 | 537 | } | 537 | } |
1703 | 538 | 538 | ||
1704 | 539 | static gboolean | 539 | static gboolean |
1706 | 540 | _dbusmenu_server_event (DbusmenuServer * server, guint id, gchar * eventid, GValue * data, GError ** error) | 540 | _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error) |
1707 | 541 | { | 541 | { |
1708 | 542 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); | 542 | DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); |
1709 | 543 | DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); | 543 | DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); |
1710 | @@ -553,7 +553,7 @@ | |||
1711 | 553 | return FALSE; | 553 | return FALSE; |
1712 | 554 | } | 554 | } |
1713 | 555 | 555 | ||
1715 | 556 | dbusmenu_menuitem_activate(mi); | 556 | dbusmenu_menuitem_handle_event(mi, eventid, data, timestamp); |
1716 | 557 | return TRUE; | 557 | return TRUE; |
1717 | 558 | } | 558 | } |
1718 | 559 | 559 | ||
1719 | 560 | 560 | ||
1720 | === modified file 'libdbusmenu-glib/server.h' | |||
1721 | --- libdbusmenu-glib/server.h 2009-12-09 19:58:32 +0000 | |||
1722 | +++ libdbusmenu-glib/server.h 2010-02-04 20:30:33 +0000 | |||
1723 | @@ -45,7 +45,8 @@ | |||
1724 | 45 | 45 | ||
1725 | 46 | #define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "item-property-updated" | 46 | #define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "item-property-updated" |
1726 | 47 | #define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "item-updated" | 47 | #define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "item-updated" |
1728 | 48 | #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE "layout-update" | 48 | #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED "layout-updated" |
1729 | 49 | #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED | ||
1730 | 49 | 50 | ||
1731 | 50 | #define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object" | 51 | #define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object" |
1732 | 51 | #define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node" | 52 | #define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node" |
1733 | @@ -56,7 +57,7 @@ | |||
1734 | 56 | @parent_class: #GObjectClass | 57 | @parent_class: #GObjectClass |
1735 | 57 | @id_prop_update: Slot for #DbusmenuServer::id-prop-update. | 58 | @id_prop_update: Slot for #DbusmenuServer::id-prop-update. |
1736 | 58 | @id_update: Slot for #DbusmenuServer::id-update. | 59 | @id_update: Slot for #DbusmenuServer::id-update. |
1738 | 59 | @layout_update: Slot for #DbusmenuServer::layout-update. | 60 | @layout_updated: Slot for #DbusmenuServer::layout-update. |
1739 | 60 | @dbusmenu_server_reserved1: Reserved for future use. | 61 | @dbusmenu_server_reserved1: Reserved for future use. |
1740 | 61 | @dbusmenu_server_reserved2: Reserved for future use. | 62 | @dbusmenu_server_reserved2: Reserved for future use. |
1741 | 62 | @dbusmenu_server_reserved3: Reserved for future use. | 63 | @dbusmenu_server_reserved3: Reserved for future use. |
1742 | @@ -69,9 +70,9 @@ | |||
1743 | 69 | GObjectClass parent_class; | 70 | GObjectClass parent_class; |
1744 | 70 | 71 | ||
1745 | 71 | /* Signals */ | 72 | /* Signals */ |
1749 | 72 | void (*id_prop_update)(guint id, gchar * property, gchar * value); | 73 | void (*id_prop_update)(gint id, gchar * property, gchar * value); |
1750 | 73 | void (*id_update)(guint id); | 74 | void (*id_update)(gint id); |
1751 | 74 | void (*layout_update)(gint revision); | 75 | void (*layout_updated)(gint revision); |
1752 | 75 | 76 | ||
1753 | 76 | /* Reserved */ | 77 | /* Reserved */ |
1754 | 77 | void (*dbusmenu_server_reserved1)(void); | 78 | void (*dbusmenu_server_reserved1)(void); |
1755 | 78 | 79 | ||
1756 | === modified file 'libdbusmenu-gtk/client.c' | |||
1757 | --- libdbusmenu-gtk/client.c 2010-01-11 18:42:55 +0000 | |||
1758 | +++ libdbusmenu-gtk/client.c 2010-02-04 20:30:33 +0000 | |||
1759 | @@ -109,7 +109,10 @@ | |||
1760 | 109 | static gboolean | 109 | static gboolean |
1761 | 110 | menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) | 110 | menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) |
1762 | 111 | { | 111 | { |
1764 | 112 | dbusmenu_menuitem_activate(mi); | 112 | GValue value = {0}; |
1765 | 113 | g_value_init(&value, G_TYPE_INT); | ||
1766 | 114 | g_value_set_int(&value, 0); | ||
1767 | 115 | dbusmenu_menuitem_handle_event(mi, "clicked", &value, gtk_get_current_event_time()); | ||
1768 | 113 | return TRUE; | 116 | return TRUE; |
1769 | 114 | } | 117 | } |
1770 | 115 | 118 | ||
1771 | @@ -136,7 +139,7 @@ | |||
1772 | 136 | { | 139 | { |
1773 | 137 | gboolean val = TRUE; | 140 | gboolean val = TRUE; |
1774 | 138 | if (value != NULL) { | 141 | if (value != NULL) { |
1776 | 139 | val = dbusmenu_menuitem_property_get_bool(mi, DBUSMENU_MENUITEM_PROP_SENSITIVE); | 142 | val = dbusmenu_menuitem_property_get_bool(mi, DBUSMENU_MENUITEM_PROP_ENABLED); |
1777 | 140 | } | 143 | } |
1778 | 141 | gtk_widget_set_sensitive(GTK_WIDGET(gmi), val); | 144 | gtk_widget_set_sensitive(GTK_WIDGET(gmi), val); |
1779 | 142 | return; | 145 | return; |
1780 | @@ -147,17 +150,23 @@ | |||
1781 | 147 | process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) | 150 | process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) |
1782 | 148 | { | 151 | { |
1783 | 149 | if (!IS_GENERICMENUITEM(gmi)) return; | 152 | if (!IS_GENERICMENUITEM(gmi)) return; |
1784 | 153 | if (value == NULL) return; | ||
1785 | 150 | 154 | ||
1786 | 151 | GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE; | 155 | GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE; |
1787 | 152 | 156 | ||
1790 | 153 | if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) { | 157 | GValue strvalue = {0}; |
1791 | 154 | const gchar * strval = g_value_get_string(value); | 158 | g_value_init(&strvalue, G_TYPE_STRING); |
1792 | 159 | |||
1793 | 160 | if (value != NULL && g_value_transform(value, &strvalue)) { | ||
1794 | 161 | const gchar * strval = g_value_get_string(&strvalue); | ||
1795 | 155 | 162 | ||
1796 | 156 | if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_CHECK)) { | 163 | if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_CHECK)) { |
1797 | 157 | type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX; | 164 | type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX; |
1798 | 158 | } else if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_RADIO)) { | 165 | } else if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_RADIO)) { |
1799 | 159 | type = GENERICMENUITEM_CHECK_TYPE_RADIO; | 166 | type = GENERICMENUITEM_CHECK_TYPE_RADIO; |
1800 | 160 | } | 167 | } |
1801 | 168 | |||
1802 | 169 | g_value_unset(&strvalue); | ||
1803 | 161 | } | 170 | } |
1804 | 162 | 171 | ||
1805 | 163 | genericmenuitem_set_check_type(GENERICMENUITEM(gmi), type); | 172 | genericmenuitem_set_check_type(GENERICMENUITEM(gmi), type); |
1806 | @@ -167,18 +176,21 @@ | |||
1807 | 167 | 176 | ||
1808 | 168 | /* Process the sensitive property */ | 177 | /* Process the sensitive property */ |
1809 | 169 | static void | 178 | static void |
1811 | 170 | process_toggle_checked (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) | 179 | process_toggle_state (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) |
1812 | 171 | { | 180 | { |
1813 | 172 | if (!IS_GENERICMENUITEM(gmi)) return; | 181 | if (!IS_GENERICMENUITEM(gmi)) return; |
1814 | 173 | 182 | ||
1815 | 174 | GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED; | 183 | GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED; |
1816 | 175 | 184 | ||
1821 | 176 | if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) { | 185 | GValue intvalue = {0}; |
1822 | 177 | const gchar * strval = g_value_get_string(value); | 186 | g_value_init(&intvalue, G_TYPE_INT); |
1823 | 178 | 187 | ||
1824 | 179 | if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED)) { | 188 | if (value != NULL && g_value_transform(value, &intvalue)) { |
1825 | 189 | int val = g_value_get_int(&intvalue); | ||
1826 | 190 | |||
1827 | 191 | if (val == DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED) { | ||
1828 | 180 | state = GENERICMENUITEM_STATE_CHECKED; | 192 | state = GENERICMENUITEM_STATE_CHECKED; |
1830 | 181 | } else if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN)) { | 193 | } else if (val == DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN) { |
1831 | 182 | state = GENERICMENUITEM_STATE_INDETERMINATE; | 194 | state = GENERICMENUITEM_STATE_INDETERMINATE; |
1832 | 183 | } | 195 | } |
1833 | 184 | } | 196 | } |
1834 | @@ -196,12 +208,12 @@ | |||
1835 | 196 | gtk_menu_item_set_label(gmi, g_value_get_string(value)); | 208 | gtk_menu_item_set_label(gmi, g_value_get_string(value)); |
1836 | 197 | } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) { | 209 | } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) { |
1837 | 198 | process_visible(mi, gmi, value); | 210 | process_visible(mi, gmi, value); |
1839 | 199 | } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SENSITIVE)) { | 211 | } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_ENABLED)) { |
1840 | 200 | process_sensitive(mi, gmi, value); | 212 | process_sensitive(mi, gmi, value); |
1841 | 201 | } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)) { | 213 | } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)) { |
1842 | 202 | process_toggle_type(mi, gmi, value); | 214 | process_toggle_type(mi, gmi, value); |
1845 | 203 | } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_CHECKED)) { | 215 | } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE)) { |
1846 | 204 | process_toggle_checked(mi, gmi, value); | 216 | process_toggle_state(mi, gmi, value); |
1847 | 205 | } | 217 | } |
1848 | 206 | 218 | ||
1849 | 207 | return; | 219 | return; |
1850 | @@ -284,9 +296,9 @@ | |||
1851 | 284 | 296 | ||
1852 | 285 | /* Check our set of props to see if any are set already */ | 297 | /* Check our set of props to see if any are set already */ |
1853 | 286 | process_visible(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); | 298 | process_visible(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); |
1855 | 287 | process_sensitive(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_SENSITIVE)); | 299 | process_sensitive(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_ENABLED)); |
1856 | 288 | process_toggle_type(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)); | 300 | process_toggle_type(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)); |
1858 | 289 | process_toggle_checked(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_CHECKED)); | 301 | process_toggle_state(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE)); |
1859 | 290 | 302 | ||
1860 | 291 | /* Oh, we're a child, let's deal with that */ | 303 | /* Oh, we're a child, let's deal with that */ |
1861 | 292 | if (parent != NULL) { | 304 | if (parent != NULL) { |
1862 | @@ -426,8 +438,8 @@ | |||
1863 | 426 | } | 438 | } |
1864 | 427 | 439 | ||
1865 | 428 | image_property_handle(newitem, | 440 | image_property_handle(newitem, |
1868 | 429 | DBUSMENU_MENUITEM_PROP_ICON, | 441 | DBUSMENU_MENUITEM_PROP_ICON_NAME, |
1869 | 430 | dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON), | 442 | dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON_NAME), |
1870 | 431 | client); | 443 | client); |
1871 | 432 | image_property_handle(newitem, | 444 | image_property_handle(newitem, |
1872 | 433 | DBUSMENU_MENUITEM_PROP_ICON_DATA, | 445 | DBUSMENU_MENUITEM_PROP_ICON_DATA, |
1873 | @@ -468,7 +480,10 @@ | |||
1874 | 468 | image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata) | 480 | image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata) |
1875 | 469 | { | 481 | { |
1876 | 470 | /* We're only looking at these two properties here */ | 482 | /* We're only looking at these two properties here */ |
1878 | 471 | g_return_if_fail(!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON) || !g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_DATA)); | 483 | if (g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_NAME) != 0 && |
1879 | 484 | g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_DATA) != 0) { | ||
1880 | 485 | return; | ||
1881 | 486 | } | ||
1882 | 472 | 487 | ||
1883 | 473 | const gchar * value = NULL; | 488 | const gchar * value = NULL; |
1884 | 474 | 489 | ||
1885 | @@ -479,10 +494,10 @@ | |||
1886 | 479 | if (value == NULL || value[0] == '\0') { | 494 | if (value == NULL || value[0] == '\0') { |
1887 | 480 | /* This means that we're unsetting a value. */ | 495 | /* This means that we're unsetting a value. */ |
1888 | 481 | /* Try to use the other one */ | 496 | /* Try to use the other one */ |
1890 | 482 | if (g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON)) { | 497 | if (g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_NAME)) { |
1891 | 483 | property = DBUSMENU_MENUITEM_PROP_ICON_DATA; | 498 | property = DBUSMENU_MENUITEM_PROP_ICON_DATA; |
1892 | 484 | } else { | 499 | } else { |
1894 | 485 | property = DBUSMENU_MENUITEM_PROP_ICON; | 500 | property = DBUSMENU_MENUITEM_PROP_ICON_NAME; |
1895 | 486 | } | 501 | } |
1896 | 487 | } | 502 | } |
1897 | 488 | 503 | ||
1898 | @@ -504,7 +519,7 @@ | |||
1899 | 504 | } | 519 | } |
1900 | 505 | 520 | ||
1901 | 506 | /* Now figure out what to change */ | 521 | /* Now figure out what to change */ |
1903 | 507 | if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON)) { | 522 | if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_NAME)) { |
1904 | 508 | const gchar * iconname = dbusmenu_menuitem_property_get(item, property); | 523 | const gchar * iconname = dbusmenu_menuitem_property_get(item, property); |
1905 | 509 | if (iconname == NULL) { | 524 | if (iconname == NULL) { |
1906 | 510 | /* If there is no name, by golly we want no | 525 | /* If there is no name, by golly we want no |
1907 | 511 | 526 | ||
1908 | === modified file 'tests/test-gtk-label-server.c' | |||
1909 | --- tests/test-gtk-label-server.c 2009-09-02 20:13:15 +0000 | |||
1910 | +++ tests/test-gtk-label-server.c 2010-02-04 20:30:33 +0000 | |||
1911 | @@ -32,9 +32,9 @@ | |||
1912 | 32 | #include <json-glib/json-glib.h> | 32 | #include <json-glib/json-glib.h> |
1913 | 33 | 33 | ||
1914 | 34 | static void | 34 | static void |
1916 | 35 | menuitem_click(DbusmenuMenuitem * mi, gpointer user_data) | 35 | menuitem_click(DbusmenuMenuitem * mi, guint32 time, gpointer user_data) |
1917 | 36 | { | 36 | { |
1919 | 37 | g_debug("Clicked on: %d", dbusmenu_menuitem_get_id(mi)); | 37 | g_debug("Clicked on: %d @ %d", dbusmenu_menuitem_get_id(mi), time); |
1920 | 38 | return; | 38 | return; |
1921 | 39 | } | 39 | } |
1922 | 40 | 40 | ||
1923 | @@ -53,7 +53,10 @@ | |||
1924 | 53 | JsonNode * lnode = json_object_get_member(node, member); | 53 | JsonNode * lnode = json_object_get_member(node, member); |
1925 | 54 | if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; } | 54 | if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; } |
1926 | 55 | 55 | ||
1928 | 56 | dbusmenu_menuitem_property_set(mi, member, json_node_get_string(lnode)); | 56 | GValue value = {0}; |
1929 | 57 | json_node_get_value(lnode, &value); | ||
1930 | 58 | dbusmenu_menuitem_property_set_value(mi, member, &value); | ||
1931 | 59 | g_value_unset(&value); | ||
1932 | 57 | } | 60 | } |
1933 | 58 | 61 | ||
1934 | 59 | return; | 62 | return; |
1935 | 60 | 63 | ||
1936 | === modified file 'tests/test-gtk-label.json' | |||
1937 | --- tests/test-gtk-label.json 2010-01-07 16:40:45 +0000 | |||
1938 | +++ tests/test-gtk-label.json 2010-02-04 20:30:33 +0000 | |||
1939 | @@ -1,256 +1,256 @@ | |||
1940 | 1 | [ | 1 | [ |
1942 | 2 | {"id": 1, "type": "menuitem", | 2 | {"id": 1, "type": "standard", |
1943 | 3 | "label": "value1", | 3 | "label": "value1", |
1944 | 4 | "submenu": [ | 4 | "submenu": [ |
1946 | 5 | {"id": 30, "type": "menuitem", | 5 | {"id": 30, "type": "standard", |
1947 | 6 | "label": "value30"}, | 6 | "label": "value30"}, |
1949 | 7 | {"id": 31, "type": "menuitem", | 7 | {"id": 31, "type": "standard", |
1950 | 8 | "label": "value31"}, | 8 | "label": "value31"}, |
1952 | 9 | {"id": 32, "type": "menuitem", | 9 | {"id": 32, "type": "standard", |
1953 | 10 | "label": "value32"}, | 10 | "label": "value32"}, |
1955 | 11 | {"id": 33, "type": "menuitem", | 11 | {"id": 33, "type": "standard", |
1956 | 12 | "label": "value33"}, | 12 | "label": "value33"}, |
1958 | 13 | {"id": 34, "type": "menuitem", | 13 | {"id": 34, "type": "standard", |
1959 | 14 | "label": "value34"}, | 14 | "label": "value34"}, |
1961 | 15 | {"id": 35, "type": "menuitem", | 15 | {"id": 35, "type": "standard", |
1962 | 16 | "label": "value35"}, | 16 | "label": "value35"}, |
1964 | 17 | {"id": 36, "type": "menuitem", | 17 | {"id": 36, "type": "standard", |
1965 | 18 | "label": "value36"}, | 18 | "label": "value36"}, |
1967 | 19 | {"id": 37, "type": "menuitem", | 19 | {"id": 37, "type": "standard", |
1968 | 20 | "label": "value37"}, | 20 | "label": "value37"}, |
1970 | 21 | {"id": 38, "type": "menuitem", | 21 | {"id": 38, "type": "standard", |
1971 | 22 | "label": "value38"}, | 22 | "label": "value38"}, |
1973 | 23 | {"id": 39, "type": "menuitem", | 23 | {"id": 39, "type": "standard", |
1974 | 24 | "label": "value39"} | 24 | "label": "value39"} |
1975 | 25 | ] | 25 | ] |
1976 | 26 | }, | 26 | }, |
1978 | 27 | {"id": 2, "type": "menuitem", | 27 | {"id": 2, "type": "standard", |
1979 | 28 | "label": "value2", | 28 | "label": "value2", |
1980 | 29 | "submenu": [ | 29 | "submenu": [ |
1982 | 30 | {"id": 20, "type": "menuitem", | 30 | {"id": 20, "type": "standard", |
1983 | 31 | "label": "value20"}, | 31 | "label": "value20"}, |
1984 | 32 | {"id": 21, "type": "separator", | 32 | {"id": 21, "type": "separator", |
1985 | 33 | "label": "value21"}, | 33 | "label": "value21"}, |
1987 | 34 | {"id": 22, "type": "menuitem", | 34 | {"id": 22, "type": "standard", |
1988 | 35 | "label": "value22"}, | 35 | "label": "value22"}, |
1989 | 36 | {"id": 23, "type": "separator", | 36 | {"id": 23, "type": "separator", |
1990 | 37 | "label": "value23"}, | 37 | "label": "value23"}, |
1992 | 38 | {"id": 24, "type": "menuitem", | 38 | {"id": 24, "type": "standard", |
1993 | 39 | "label": "value24"}, | 39 | "label": "value24"}, |
1994 | 40 | {"id": 25, "type": "separator", | 40 | {"id": 25, "type": "separator", |
1995 | 41 | "label": "value25"}, | 41 | "label": "value25"}, |
1997 | 42 | {"id": 26, "type": "menuitem", | 42 | {"id": 26, "type": "standard", |
1998 | 43 | "label": "value26"}, | 43 | "label": "value26"}, |
1999 | 44 | {"id": 27, "type": "separator", | 44 | {"id": 27, "type": "separator", |
2000 | 45 | "label": "value27"}, | 45 | "label": "value27"}, |
2002 | 46 | {"id": 28, "type": "menuitem", | 46 | {"id": 28, "type": "standard", |
2003 | 47 | "label": "value28"}, | 47 | "label": "value28"}, |
2005 | 48 | {"id": 29, "type": "menuitem", "visible": "false", | 48 | {"id": 29, "type": "standard", "visible": "false", |
2006 | 49 | "label": "value29"} | 49 | "label": "value29"} |
2007 | 50 | ] | 50 | ] |
2008 | 51 | }, | 51 | }, |
2010 | 52 | {"id": 4, "type": "menuitem", | 52 | {"id": 4, "type": "standard", |
2011 | 53 | "label": "value4", | 53 | "label": "value4", |
2012 | 54 | "submenu": [ | 54 | "submenu": [ |
2013 | 55 | {"id": 40, | 55 | {"id": 40, |
2016 | 56 | "type": "menuitem", | 56 | "type": "standard", |
2017 | 57 | "sensitive": "true", | 57 | "enabled": "true", |
2018 | 58 | "label": "value40"}, | 58 | "label": "value40"}, |
2019 | 59 | {"id": 41, | 59 | {"id": 41, |
2022 | 60 | "type": "menuitem", | 60 | "type": "standard", |
2023 | 61 | "sensitive": "false", | 61 | "enabled": "false", |
2024 | 62 | "label": "value41"}, | 62 | "label": "value41"}, |
2025 | 63 | {"id": 42, | 63 | {"id": 42, |
2028 | 64 | "type": "menuitem", | 64 | "type": "standard", |
2029 | 65 | "sensitive": "true", | 65 | "enabled": "true", |
2030 | 66 | "label": "value42"}, | 66 | "label": "value42"}, |
2031 | 67 | {"id": 43, | 67 | {"id": 43, |
2034 | 68 | "type": "menuitem", | 68 | "type": "standard", |
2035 | 69 | "sensitive": "false", | 69 | "enabled": "false", |
2036 | 70 | "label": "value43"}, | 70 | "label": "value43"}, |
2037 | 71 | {"id": 44, | 71 | {"id": 44, |
2040 | 72 | "type": "menuitem", | 72 | "type": "standard", |
2041 | 73 | "sensitive": "true", | 73 | "enabled": "true", |
2042 | 74 | "label": "value44"}, | 74 | "label": "value44"}, |
2043 | 75 | {"id": 45, | 75 | {"id": 45, |
2046 | 76 | "type": "menuitem", | 76 | "type": "standard", |
2047 | 77 | "sensitive": "false", | 77 | "enabled": "false", |
2048 | 78 | "label": "value45"}, | 78 | "label": "value45"}, |
2049 | 79 | {"id": 46, | 79 | {"id": 46, |
2052 | 80 | "type": "menuitem", | 80 | "type": "standard", |
2053 | 81 | "sensitive": "true", | 81 | "enabled": "true", |
2054 | 82 | "label": "value46"}, | 82 | "label": "value46"}, |
2055 | 83 | {"id": 47, | 83 | {"id": 47, |
2058 | 84 | "type": "menuitem", | 84 | "type": "standard", |
2059 | 85 | "sensitive": "false", | 85 | "enabled": "false", |
2060 | 86 | "label": "value47"}, | 86 | "label": "value47"}, |
2061 | 87 | {"id": 48, | 87 | {"id": 48, |
2064 | 88 | "type": "menuitem", | 88 | "type": "standard", |
2065 | 89 | "sensitive": "true", | 89 | "enabled": "true", |
2066 | 90 | "label": "value48"}, | 90 | "label": "value48"}, |
2067 | 91 | {"id": 49, | 91 | {"id": 49, |
2069 | 92 | "type": "menuitem", | 92 | "type": "standard", |
2070 | 93 | "visible": "false", | 93 | "visible": "false", |
2072 | 94 | "sensitive": "false", | 94 | "enabled": "false", |
2073 | 95 | "label": "value49"} | 95 | "label": "value49"} |
2074 | 96 | ] | 96 | ] |
2075 | 97 | }, | 97 | }, |
2077 | 98 | {"id": 3, "type": "menuitem", | 98 | {"id": 3, "type": "standard", |
2078 | 99 | "label": "a super long label that is really of unreasonable length but we should make sure it makes it across the bus", | 99 | "label": "a super long label that is really of unreasonable length but we should make sure it makes it across the bus", |
2079 | 100 | "not.a.value": "A useless value", | 100 | "not.a.value": "A useless value", |
2080 | 101 | "submenu": [ | 101 | "submenu": [ |
2082 | 102 | {"id": 10, "type": "menuitem", | 102 | {"id": 10, "type": "standard", |
2083 | 103 | "label": "value10"}, | 103 | "label": "value10"}, |
2085 | 104 | {"id": 11, "type": "menuitem", | 104 | {"id": 11, "type": "standard", |
2086 | 105 | "label": "value11"}, | 105 | "label": "value11"}, |
2088 | 106 | {"id": 12, "type": "menuitem", | 106 | {"id": 12, "type": "standard", |
2089 | 107 | "label": "value12"}, | 107 | "label": "value12"}, |
2091 | 108 | {"id": 13, "type": "menuitem", | 108 | {"id": 13, "type": "standard", |
2092 | 109 | "label": "value13"}, | 109 | "label": "value13"}, |
2094 | 110 | {"id": 14, "type": "menuitem", | 110 | {"id": 14, "type": "standard", |
2095 | 111 | "label": "value14"}, | 111 | "label": "value14"}, |
2097 | 112 | {"id": 15, "type": "menuitem", | 112 | {"id": 15, "type": "standard", |
2098 | 113 | "label": "value15"}, | 113 | "label": "value15"}, |
2100 | 114 | {"id": 16, "type": "menuitem", | 114 | {"id": 16, "type": "standard", |
2101 | 115 | "label": "value16"}, | 115 | "label": "value16"}, |
2103 | 116 | {"id": 17, "type": "menuitem", | 116 | {"id": 17, "type": "standard", |
2104 | 117 | "label": "value17"}, | 117 | "label": "value17"}, |
2106 | 118 | {"id": 18, "type": "menuitem", | 118 | {"id": 18, "type": "standard", |
2107 | 119 | "label": "value18"}, | 119 | "label": "value18"}, |
2109 | 120 | {"id": 19, "type": "menuitem", | 120 | {"id": 19, "type": "standard", |
2110 | 121 | "label": "value19"} | 121 | "label": "value19"} |
2111 | 122 | ] | 122 | ] |
2112 | 123 | }, | 123 | }, |
2114 | 124 | {"id": 4, "type": "menuitem", | 124 | {"id": 4, "type": "standard", |
2115 | 125 | "label": "value2", | 125 | "label": "value2", |
2116 | 126 | "submenu": [ | 126 | "submenu": [ |
2118 | 127 | {"id": 5, "type": "menuitem", | 127 | {"id": 5, "type": "standard", |
2119 | 128 | "label": "value5", | 128 | "label": "value5", |
2120 | 129 | "submenu": [ | 129 | "submenu": [ |
2122 | 130 | {"id": 10, "type": "menuitem", | 130 | {"id": 10, "type": "standard", |
2123 | 131 | "label": "value10"}, | 131 | "label": "value10"}, |
2125 | 132 | {"id": 11, "type": "menuitem", | 132 | {"id": 11, "type": "standard", |
2126 | 133 | "label": "value11"}, | 133 | "label": "value11"}, |
2128 | 134 | {"id": 12, "type": "menuitem", | 134 | {"id": 12, "type": "standard", |
2129 | 135 | "label": "value12"}, | 135 | "label": "value12"}, |
2131 | 136 | {"id": 13, "type": "menuitem", | 136 | {"id": 13, "type": "standard", |
2132 | 137 | "label": "value13"}, | 137 | "label": "value13"}, |
2134 | 138 | {"id": 14, "type": "menuitem", | 138 | {"id": 14, "type": "standard", |
2135 | 139 | "label": "value14"}, | 139 | "label": "value14"}, |
2137 | 140 | {"id": 15, "type": "menuitem", | 140 | {"id": 15, "type": "standard", |
2138 | 141 | "label": "value15"}, | 141 | "label": "value15"}, |
2140 | 142 | {"id": 16, "type": "menuitem", | 142 | {"id": 16, "type": "standard", |
2141 | 143 | "label": "value16"}, | 143 | "label": "value16"}, |
2143 | 144 | {"id": 17, "type": "menuitem", | 144 | {"id": 17, "type": "standard", |
2144 | 145 | "label": "value17"}, | 145 | "label": "value17"}, |
2146 | 146 | {"id": 18, "type": "menuitem", | 146 | {"id": 18, "type": "standard", |
2147 | 147 | "label": "value18"}, | 147 | "label": "value18"}, |
2149 | 148 | {"id": 19, "type": "menuitem", | 148 | {"id": 19, "type": "standard", |
2150 | 149 | "label": "value19"} | 149 | "label": "value19"} |
2151 | 150 | ] | 150 | ] |
2152 | 151 | }, | 151 | }, |
2154 | 152 | {"id": 6, "type": "menuitem", | 152 | {"id": 6, "type": "standard", |
2155 | 153 | "label": "value6", | 153 | "label": "value6", |
2156 | 154 | "submenu": [ | 154 | "submenu": [ |
2158 | 155 | {"id": 20, "type": "menuitem", | 155 | {"id": 20, "type": "standard", |
2159 | 156 | "label": "value20"}, | 156 | "label": "value20"}, |
2161 | 157 | {"id": 21, "type": "menuitem", | 157 | {"id": 21, "type": "standard", |
2162 | 158 | "label": "value21"}, | 158 | "label": "value21"}, |
2164 | 159 | {"id": 22, "type": "menuitem", | 159 | {"id": 22, "type": "standard", |
2165 | 160 | "label": "value22"}, | 160 | "label": "value22"}, |
2167 | 161 | {"id": 23, "type": "menuitem", | 161 | {"id": 23, "type": "standard", |
2168 | 162 | "label": "value23"}, | 162 | "label": "value23"}, |
2170 | 163 | {"id": 24, "type": "menuitem", | 163 | {"id": 24, "type": "standard", |
2171 | 164 | "label": "value24"}, | 164 | "label": "value24"}, |
2173 | 165 | {"id": 25, "type": "menuitem", | 165 | {"id": 25, "type": "standard", |
2174 | 166 | "label": "value25"}, | 166 | "label": "value25"}, |
2176 | 167 | {"id": 26, "type": "menuitem", | 167 | {"id": 26, "type": "standard", |
2177 | 168 | "label": "value26"}, | 168 | "label": "value26"}, |
2179 | 169 | {"id": 27, "type": "menuitem", | 169 | {"id": 27, "type": "standard", |
2180 | 170 | "label": "value27"}, | 170 | "label": "value27"}, |
2182 | 171 | {"id": 28, "type": "menuitem", | 171 | {"id": 28, "type": "standard", |
2183 | 172 | "label": "value28"}, | 172 | "label": "value28"}, |
2185 | 173 | {"id": 29, "type": "menuitem", | 173 | {"id": 29, "type": "standard", |
2186 | 174 | "label": "value29"} | 174 | "label": "value29"} |
2187 | 175 | ] | 175 | ] |
2188 | 176 | }, | 176 | }, |
2190 | 177 | {"id": 7, "type": "menuitem", | 177 | {"id": 7, "type": "standard", |
2191 | 178 | "label": "value7", | 178 | "label": "value7", |
2192 | 179 | "submenu": [ | 179 | "submenu": [ |
2194 | 180 | {"id": 30, "type": "menuitem", | 180 | {"id": 30, "type": "standard", |
2195 | 181 | "label": "value30"}, | 181 | "label": "value30"}, |
2197 | 182 | {"id": 31, "type": "menuitem", | 182 | {"id": 31, "type": "standard", |
2198 | 183 | "label": "value31"}, | 183 | "label": "value31"}, |
2200 | 184 | {"id": 32, "type": "menuitem", | 184 | {"id": 32, "type": "standard", |
2201 | 185 | "label": "value32"}, | 185 | "label": "value32"}, |
2203 | 186 | {"id": 33, "type": "menuitem", | 186 | {"id": 33, "type": "standard", |
2204 | 187 | "label": "value33"}, | 187 | "label": "value33"}, |
2206 | 188 | {"id": 34, "type": "menuitem", | 188 | {"id": 34, "type": "standard", |
2207 | 189 | "label": "value34"}, | 189 | "label": "value34"}, |
2209 | 190 | {"id": 35, "type": "menuitem", | 190 | {"id": 35, "type": "standard", |
2210 | 191 | "label": "value35"}, | 191 | "label": "value35"}, |
2212 | 192 | {"id": 36, "type": "menuitem", | 192 | {"id": 36, "type": "standard", |
2213 | 193 | "label": "value36"}, | 193 | "label": "value36"}, |
2215 | 194 | {"id": 37, "type": "menuitem", | 194 | {"id": 37, "type": "standard", |
2216 | 195 | "label": "value37"}, | 195 | "label": "value37"}, |
2218 | 196 | {"id": 38, "type": "menuitem", | 196 | {"id": 38, "type": "standard", |
2219 | 197 | "label": "value38"}, | 197 | "label": "value38"}, |
2221 | 198 | {"id": 39, "type": "menuitem", | 198 | {"id": 39, "type": "standard", |
2222 | 199 | "label": "value39"} | 199 | "label": "value39"} |
2223 | 200 | ] | 200 | ] |
2224 | 201 | }, | 201 | }, |
2225 | 202 | ] | 202 | ] |
2226 | 203 | }, | 203 | }, |
2228 | 204 | {"id": 8, "type": "menuitem", | 204 | {"id": 8, "type": "standard", |
2229 | 205 | "label": "value1", | 205 | "label": "value1", |
2230 | 206 | "submenu": [ | 206 | "submenu": [ |
2231 | 207 | {"id": 80, | 207 | {"id": 80, |
2234 | 208 | "type": "menuitem", | 208 | "type": "standard", |
2235 | 209 | "icon": "face-angel", | 209 | "icon-name": "face-angel", |
2236 | 210 | "label": "angel"}, | 210 | "label": "angel"}, |
2237 | 211 | {"id": 81, | 211 | {"id": 81, |
2240 | 212 | "type": "menuitem", | 212 | "type": "standard", |
2241 | 213 | "icon": "face-angry", | 213 | "icon-name": "face-angry", |
2242 | 214 | "label": "angry"}, | 214 | "label": "angry"}, |
2243 | 215 | {"id": 82, | 215 | {"id": 82, |
2246 | 216 | "type": "menuitem", | 216 | "type": "standard", |
2247 | 217 | "icon": "face-cool", | 217 | "icon-name": "face-cool", |
2248 | 218 | "label": "cool"}, | 218 | "label": "cool"}, |
2249 | 219 | {"id": 83, | 219 | {"id": 83, |
2252 | 220 | "type":"menuitem", | 220 | "type":"standard", |
2253 | 221 | "icon": "face-devilish", | 221 | "icon-name": "face-devilish", |
2254 | 222 | "label": "devilish"}, | 222 | "label": "devilish"}, |
2255 | 223 | {"id": 84, | 223 | {"id": 84, |
2258 | 224 | "type": "menuitem", | 224 | "type": "standard", |
2259 | 225 | "icon": "face-embarrassed", | 225 | "icon-name": "face-embarrassed", |
2260 | 226 | "label": "embarrassed"}, | 226 | "label": "embarrassed"}, |
2261 | 227 | {"id": 85, | 227 | {"id": 85, |
2264 | 228 | "type": "menuitem", | 228 | "type": "standard", |
2265 | 229 | "icon": "face-kiss", | 229 | "icon-name": "face-kiss", |
2266 | 230 | "label": "kiss"}, | 230 | "label": "kiss"}, |
2267 | 231 | {"id": 86, | 231 | {"id": 86, |
2270 | 232 | "type": "menuitem", | 232 | "type": "standard", |
2271 | 233 | "icon": "face-laugh", | 233 | "icon-name": "face-laugh", |
2272 | 234 | "label": "laugh"}, | 234 | "label": "laugh"}, |
2273 | 235 | {"id": 87, | 235 | {"id": 87, |
2276 | 236 | "type": "menuitem", | 236 | "type": "standard", |
2277 | 237 | "icon": "face-monkey", | 237 | "icon-name": "face-monkey", |
2278 | 238 | "label": "monkey"}, | 238 | "label": "monkey"}, |
2279 | 239 | {"id": 88, | 239 | {"id": 88, |
2282 | 240 | "type": "menuitem", | 240 | "type": "standard", |
2283 | 241 | "icon": "face-sad", | 241 | "icon-name": "face-sad", |
2284 | 242 | "label": "sad"}, | 242 | "label": "sad"}, |
2285 | 243 | {"id": 89, | 243 | {"id": 89, |
2288 | 244 | "type": "menuitem", | 244 | "type": "standard", |
2289 | 245 | "icon": "face-sick", | 245 | "icon-name": "face-sick", |
2290 | 246 | "label": "sick"} | 246 | "label": "sick"} |
2291 | 247 | ] | 247 | ] |
2292 | 248 | }, | 248 | }, |
2294 | 249 | {"id": 9, "type": "menuitem", | 249 | {"id": 9, "type": "standard", |
2295 | 250 | "label": "value1", | 250 | "label": "value1", |
2296 | 251 | "submenu": [ | 251 | "submenu": [ |
2297 | 252 | {"id": 90, | 252 | {"id": 90, |
2299 | 253 | "type": "menuitem", | 253 | "type": "standard", |
2300 | 254 | "icon-data": | 254 | "icon-data": |
2301 | 255 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW | 255 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW |
2302 | 256 | BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8 | 256 | BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8 |
2303 | @@ -266,7 +266,7 @@ | |||
2304 | 266 | QmCC", | 266 | QmCC", |
2305 | 267 | "label": "up"}, | 267 | "label": "up"}, |
2306 | 268 | {"id": 91, | 268 | {"id": 91, |
2308 | 269 | "type": "menuitem", | 269 | "type": "standard", |
2309 | 270 | "icon-data": | 270 | "icon-data": |
2310 | 271 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG | 271 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG |
2311 | 272 | sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD | 272 | sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD |
2312 | @@ -283,8 +283,8 @@ | |||
2313 | 283 | +ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC", | 283 | +ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC", |
2314 | 284 | "label": "down"}, | 284 | "label": "down"}, |
2315 | 285 | {"id": 92, | 285 | {"id": 92, |
2318 | 286 | "type": "menuitem", | 286 | "type": "standard", |
2319 | 287 | "icon": "up", | 287 | "icon-name": "up", |
2320 | 288 | "icon-data": | 288 | "icon-data": |
2321 | 289 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG | 289 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG |
2322 | 290 | sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD | 290 | sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD |
2323 | @@ -301,8 +301,8 @@ | |||
2324 | 301 | +ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC", | 301 | +ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC", |
2325 | 302 | "label": "up"}, | 302 | "label": "up"}, |
2326 | 303 | {"id": 93, | 303 | {"id": 93, |
2329 | 304 | "type": "menuitem", | 304 | "type": "standard", |
2330 | 305 | "icon": "down", | 305 | "icon-name": "down", |
2331 | 306 | "icon-data": | 306 | "icon-data": |
2332 | 307 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW | 307 | "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW |
2333 | 308 | BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8 | 308 | BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8 |
2334 | @@ -319,7 +319,7 @@ | |||
2335 | 319 | "label": "down"} | 319 | "label": "down"} |
2336 | 320 | ] | 320 | ] |
2337 | 321 | }, | 321 | }, |
2339 | 322 | {"id": 1, "type": "menuitem", | 322 | {"id": 1, "type": "standard", |
2340 | 323 | "label": "value1", | 323 | "label": "value1", |
2341 | 324 | "submenu": [ | 324 | "submenu": [ |
2342 | 325 | {"id": 30, | 325 | {"id": 30, |
2343 | @@ -329,42 +329,42 @@ | |||
2344 | 329 | {"id": 31, | 329 | {"id": 31, |
2345 | 330 | "label": "No check (checked)", | 330 | "label": "No check (checked)", |
2346 | 331 | "toggle-type": "none", | 331 | "toggle-type": "none", |
2348 | 332 | "toggle-checked": "checked" | 332 | "toggle-state": 1 |
2349 | 333 | }, | 333 | }, |
2350 | 334 | {"id": 32, | 334 | {"id": 32, |
2351 | 335 | "label": "No check (????)", | 335 | "label": "No check (????)", |
2352 | 336 | "toggle-type": "none", | 336 | "toggle-type": "none", |
2354 | 337 | "toggle-checked": "indeterminate" | 337 | "toggle-state": -1 |
2355 | 338 | }, | 338 | }, |
2356 | 339 | {"id": 33, | 339 | {"id": 33, |
2357 | 340 | "label": "Check (empty)", | 340 | "label": "Check (empty)", |
2358 | 341 | "toggle-type": "checkmark", | 341 | "toggle-type": "checkmark", |
2360 | 342 | "toggle-checked": "unchecked" | 342 | "toggle-state": 0 |
2361 | 343 | }, | 343 | }, |
2362 | 344 | {"id": 34, | 344 | {"id": 34, |
2363 | 345 | "label": "Check (checked)", | 345 | "label": "Check (checked)", |
2364 | 346 | "toggle-type": "checkmark", | 346 | "toggle-type": "checkmark", |
2366 | 347 | "toggle-checked": "checked" | 347 | "toggle-state": 1 |
2367 | 348 | }, | 348 | }, |
2368 | 349 | {"id": 35, | 349 | {"id": 35, |
2369 | 350 | "label": "Check (?????)", | 350 | "label": "Check (?????)", |
2370 | 351 | "toggle-type": "checkmark", | 351 | "toggle-type": "checkmark", |
2372 | 352 | "toggle-checked": "indeterminate" | 352 | "toggle-state": -1 |
2373 | 353 | }, | 353 | }, |
2374 | 354 | {"id": 36, | 354 | {"id": 36, |
2375 | 355 | "label": "Radio (empty)", | 355 | "label": "Radio (empty)", |
2376 | 356 | "toggle-type": "radio", | 356 | "toggle-type": "radio", |
2378 | 357 | "toggle-checked": "unchecked" | 357 | "toggle-state": 0 |
2379 | 358 | }, | 358 | }, |
2380 | 359 | {"id": 37, | 359 | {"id": 37, |
2381 | 360 | "label": "Radio (checked)", | 360 | "label": "Radio (checked)", |
2382 | 361 | "toggle-type": "radio", | 361 | "toggle-type": "radio", |
2384 | 362 | "toggle-checked": "checked" | 362 | "toggle-state": 1 |
2385 | 363 | }, | 363 | }, |
2386 | 364 | {"id": 38, | 364 | {"id": 38, |
2387 | 365 | "label": "Radio (?????)", | 365 | "label": "Radio (?????)", |
2388 | 366 | "toggle-type": "radio", | 366 | "toggle-type": "radio", |
2390 | 367 | "toggle-checked": "indeterminate" | 367 | "toggle-state": -1 |
2391 | 368 | } | 368 | } |
2392 | 369 | ] | 369 | ] |
2393 | 370 | }, | 370 | }, |
2394 | 371 | 371 | ||
2395 | === modified file 'tools/Makefile.am' | |||
2396 | --- tools/Makefile.am 2009-10-05 14:12:45 +0000 | |||
2397 | +++ tools/Makefile.am 2010-02-04 20:30:33 +0000 | |||
2398 | @@ -1,6 +1,10 @@ | |||
2399 | 1 | 1 | ||
2400 | 2 | SUBDIRS = testapp | ||
2401 | 3 | |||
2402 | 2 | libexec_PROGRAMS = dbusmenu-dumper | 4 | libexec_PROGRAMS = dbusmenu-dumper |
2403 | 3 | 5 | ||
2404 | 6 | libexec_SCRIPTS = dbusmenu-bench | ||
2405 | 7 | |||
2406 | 4 | dbusmenu_dumper_SOURCES = \ | 8 | dbusmenu_dumper_SOURCES = \ |
2407 | 5 | dbusmenu-dumper.c | 9 | dbusmenu-dumper.c |
2408 | 6 | 10 | ||
2409 | @@ -12,3 +16,4 @@ | |||
2410 | 12 | ../libdbusmenu-glib/libdbusmenu-glib.la \ | 16 | ../libdbusmenu-glib/libdbusmenu-glib.la \ |
2411 | 13 | $(DBUSMENUGLIB_LIBS) | 17 | $(DBUSMENUGLIB_LIBS) |
2412 | 14 | 18 | ||
2413 | 19 | EXTRA_DIST = dbusmenu-bench | ||
2414 | 15 | 20 | ||
2415 | === added file 'tools/dbusmenu-bench' | |||
2416 | --- tools/dbusmenu-bench 1970-01-01 00:00:00 +0000 | |||
2417 | +++ tools/dbusmenu-bench 2010-02-04 20:30:33 +0000 | |||
2418 | @@ -0,0 +1,157 @@ | |||
2419 | 1 | #!/usr/bin/env python | ||
2420 | 2 | # encoding: utf-8 | ||
2421 | 3 | """ | ||
2422 | 4 | A library to communicate a menu object set accross DBus and | ||
2423 | 5 | track updates and maintain consistency. | ||
2424 | 6 | |||
2425 | 7 | Copyright 2010 Canonical Ltd. | ||
2426 | 8 | |||
2427 | 9 | Authors: | ||
2428 | 10 | Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
2429 | 11 | |||
2430 | 12 | This program is free software: you can redistribute it and/or modify it | ||
2431 | 13 | under the terms of either or both of the following licenses: | ||
2432 | 14 | |||
2433 | 15 | 1) the GNU Lesser General Public License version 3, as published by the | ||
2434 | 16 | Free Software Foundation; and/or | ||
2435 | 17 | 2) the GNU Lesser General Public License version 2.1, as published by | ||
2436 | 18 | the Free Software Foundation. | ||
2437 | 19 | |||
2438 | 20 | This program is distributed in the hope that it will be useful, but | ||
2439 | 21 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2440 | 22 | MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
2441 | 23 | PURPOSE. See the applicable version of the GNU Lesser General Public | ||
2442 | 24 | License for more details. | ||
2443 | 25 | |||
2444 | 26 | You should have received a copy of both the GNU Lesser General Public | ||
2445 | 27 | License version 3 and version 2.1 along with this program. If not, see | ||
2446 | 28 | <http://www.gnu.org/licenses/> | ||
2447 | 29 | """ | ||
2448 | 30 | import itertools | ||
2449 | 31 | import time | ||
2450 | 32 | import sys | ||
2451 | 33 | from optparse import OptionParser | ||
2452 | 34 | from xml.etree import ElementTree as ET | ||
2453 | 35 | |||
2454 | 36 | import dbus | ||
2455 | 37 | |||
2456 | 38 | DBUS_INTERFACE = "org.ayatana.dbusmenu" | ||
2457 | 39 | DBUS_SERVICE = "org.dbusmenu.test" | ||
2458 | 40 | DBUS_PATH = "/MenuBar" | ||
2459 | 41 | |||
2460 | 42 | PROBE_GET_LAYOUT = "GetLayout" | ||
2461 | 43 | PROBE_GET_PROPERTIES = "GetProperties" | ||
2462 | 44 | PROBE_GET_CHILDREN = "GetChildren" | ||
2463 | 45 | PROBES = PROBE_GET_LAYOUT, PROBE_GET_PROPERTIES, PROBE_GET_CHILDREN | ||
2464 | 46 | |||
2465 | 47 | class Chrono(object): | ||
2466 | 48 | def __init__(self): | ||
2467 | 49 | self._time = 0 | ||
2468 | 50 | self.restart() | ||
2469 | 51 | |||
2470 | 52 | def restart(self): | ||
2471 | 53 | new_time = time.time() | ||
2472 | 54 | delta = new_time - self._time | ||
2473 | 55 | self._time = new_time | ||
2474 | 56 | return delta | ||
2475 | 57 | |||
2476 | 58 | def elapsed(self): | ||
2477 | 59 | return time.time() - self._time | ||
2478 | 60 | |||
2479 | 61 | |||
2480 | 62 | def dump_properties(properties, prepend=""): | ||
2481 | 63 | for key, value in properties.items(): | ||
2482 | 64 | print "%s- %s: %s" % (prepend, key, value) | ||
2483 | 65 | |||
2484 | 66 | |||
2485 | 67 | def run_test_sequence(menu, dump=False): | ||
2486 | 68 | """ | ||
2487 | 69 | Runs the test sequence and returns a dict of method_name: seconds | ||
2488 | 70 | """ | ||
2489 | 71 | property_names = ["type", "label", "enabled", "icon-name"] | ||
2490 | 72 | times = dict() | ||
2491 | 73 | chrono = Chrono() | ||
2492 | 74 | revision, layout = menu.GetLayout(dbus.Int32(0)) | ||
2493 | 75 | times["GetLayout"] = chrono.elapsed() | ||
2494 | 76 | if dump: | ||
2495 | 77 | print "revision:", revision | ||
2496 | 78 | print "layout:" | ||
2497 | 79 | print layout | ||
2498 | 80 | |||
2499 | 81 | # Get ids | ||
2500 | 82 | tree = ET.fromstring(layout) | ||
2501 | 83 | root_id = int(tree.attrib["id"]) | ||
2502 | 84 | child_element = tree.find("menu") | ||
2503 | 85 | assert child_element is not None | ||
2504 | 86 | child_id = int(child_element.attrib["id"]) | ||
2505 | 87 | |||
2506 | 88 | chrono.restart() | ||
2507 | 89 | children = menu.GetChildren(dbus.Int32(root_id), property_names) | ||
2508 | 90 | times["GetChildren"] = chrono.elapsed() | ||
2509 | 91 | if dump: | ||
2510 | 92 | print "children:" | ||
2511 | 93 | for child in children: | ||
2512 | 94 | id, properties = child | ||
2513 | 95 | print "- %d:" % id | ||
2514 | 96 | dump_properties(properties, prepend=" ") | ||
2515 | 97 | |||
2516 | 98 | chrono.restart() | ||
2517 | 99 | properties = menu.GetProperties(dbus.Int32(child_id), property_names) | ||
2518 | 100 | times["GetProperties"] = chrono.elapsed() | ||
2519 | 101 | if dump: | ||
2520 | 102 | print "properties:" | ||
2521 | 103 | dump_properties(properties) | ||
2522 | 104 | |||
2523 | 105 | return times | ||
2524 | 106 | |||
2525 | 107 | def create_timing_dict(): | ||
2526 | 108 | return dict(zip(PROBES, itertools.repeat(0))) | ||
2527 | 109 | |||
2528 | 110 | def print_probe(prefix, name, value, timestamp): | ||
2529 | 111 | value = int(value * 1000000) | ||
2530 | 112 | print "%(prefix)s.%(name)s:%(value)d@%(timestamp)d" % locals() | ||
2531 | 113 | |||
2532 | 114 | def main(): | ||
2533 | 115 | parser = OptionParser(usage = "%prog [options]") | ||
2534 | 116 | |||
2535 | 117 | parser.add_option("-c", "--count", dest="count", type=int, default=1, | ||
2536 | 118 | help="repeat calls COUNT times", metavar="COUNT") | ||
2537 | 119 | parser.add_option("-d", "--dump", dest="dump", action="store_true", default=False, | ||
2538 | 120 | help="dump call output to stdout") | ||
2539 | 121 | |||
2540 | 122 | (options, args) = parser.parse_args() | ||
2541 | 123 | |||
2542 | 124 | bus = dbus.SessionBus() | ||
2543 | 125 | proxy = bus.get_object(DBUS_SERVICE, DBUS_PATH) | ||
2544 | 126 | menu = dbus.Interface(proxy, dbus_interface=DBUS_INTERFACE) | ||
2545 | 127 | |||
2546 | 128 | if options.dump: | ||
2547 | 129 | run_test_sequence(menu, dump=True) | ||
2548 | 130 | return | ||
2549 | 131 | |||
2550 | 132 | cumulated_timings = create_timing_dict() | ||
2551 | 133 | min_timings = create_timing_dict() | ||
2552 | 134 | max_timings = create_timing_dict() | ||
2553 | 135 | for x in range(options.count): | ||
2554 | 136 | timings = run_test_sequence(menu) | ||
2555 | 137 | for name, timing in timings.items(): | ||
2556 | 138 | cumulated_timings[name] += timing | ||
2557 | 139 | if min_timings[name] == 0 or min_timings[name] > timing: | ||
2558 | 140 | min_timings[name] = timing | ||
2559 | 141 | if max_timings[name] < timing: | ||
2560 | 142 | max_timings[name] = timing | ||
2561 | 143 | |||
2562 | 144 | timestamp = int(time.time()) | ||
2563 | 145 | for name, timing in cumulated_timings.items(): | ||
2564 | 146 | print_probe("average", name, timing / options.count, timestamp) | ||
2565 | 147 | for name, timing in min_timings.items(): | ||
2566 | 148 | print_probe("min", name, timing, timestamp) | ||
2567 | 149 | for name, timing in max_timings.items(): | ||
2568 | 150 | print_probe("max", name, timing, timestamp) | ||
2569 | 151 | |||
2570 | 152 | return 0 | ||
2571 | 153 | |||
2572 | 154 | |||
2573 | 155 | if __name__=="__main__": | ||
2574 | 156 | sys.exit(main()) | ||
2575 | 157 | # vi: ts=4 sw=4 et tw=0 | ||
2576 | 0 | 158 | ||
2577 | === added directory 'tools/testapp' | |||
2578 | === added file 'tools/testapp/CMakeLists.txt' | |||
2579 | --- tools/testapp/CMakeLists.txt 1970-01-01 00:00:00 +0000 | |||
2580 | +++ tools/testapp/CMakeLists.txt 2010-02-04 20:30:33 +0000 | |||
2581 | @@ -0,0 +1,29 @@ | |||
2582 | 1 | find_package(PkgConfig REQUIRED) | ||
2583 | 2 | |||
2584 | 3 | pkg_check_modules(DBUSMENUGLIB REQUIRED dbusmenu-glib) | ||
2585 | 4 | pkg_check_modules(GLIB REQUIRED glib-2.0) | ||
2586 | 5 | pkg_check_modules(JSONGLIB REQUIRED json-glib-1.0) | ||
2587 | 6 | |||
2588 | 7 | set(glibapp_SRCS | ||
2589 | 8 | main.c | ||
2590 | 9 | ) | ||
2591 | 10 | |||
2592 | 11 | include_directories( | ||
2593 | 12 | ${DBUSMENUGLIB_INCLUDE_DIRS} | ||
2594 | 13 | ${GLIB_INCLUDE_DIRS} | ||
2595 | 14 | ${JSONGLIB_INCLUDE_DIRS} | ||
2596 | 15 | ) | ||
2597 | 16 | |||
2598 | 17 | link_directories( | ||
2599 | 18 | ${DBUSMENUGLIB_LIBRARY_DIRS} | ||
2600 | 19 | ${GLIB_LIBRARY_DIRS} | ||
2601 | 20 | ${JSONGLIB_LIBRARY_DIRS} | ||
2602 | 21 | ) | ||
2603 | 22 | |||
2604 | 23 | add_executable(dbusmenubench-glibapp ${glibapp_SRCS}) | ||
2605 | 24 | |||
2606 | 25 | target_link_libraries(dbusmenubench-glibapp | ||
2607 | 26 | ${DBUSMENUGLIB_LIBRARIES} | ||
2608 | 27 | ${GLIB_LIBARIES} | ||
2609 | 28 | ${JSONGLIB_LIBRARIES} | ||
2610 | 29 | ) | ||
2611 | 0 | 30 | ||
2612 | === added file 'tools/testapp/Makefile.am' | |||
2613 | --- tools/testapp/Makefile.am 1970-01-01 00:00:00 +0000 | |||
2614 | +++ tools/testapp/Makefile.am 2010-02-04 20:30:33 +0000 | |||
2615 | @@ -0,0 +1,17 @@ | |||
2616 | 1 | |||
2617 | 2 | libexec_PROGRAMS = dbusmenu-testapp | ||
2618 | 3 | |||
2619 | 4 | dbusmenu_testapp_SOURCES = \ | ||
2620 | 5 | main.c | ||
2621 | 6 | |||
2622 | 7 | dbusmenu_testapp_CFLAGS = \ | ||
2623 | 8 | -I $(srcdir)/../.. \ | ||
2624 | 9 | $(DBUSMENUTESTS_CFLAGS) \ | ||
2625 | 10 | $(DBUSMENUGLIB_CFLAGS) \ | ||
2626 | 11 | -Wall -Werror | ||
2627 | 12 | |||
2628 | 13 | dbusmenu_testapp_LDADD = \ | ||
2629 | 14 | $(builddir)/../../libdbusmenu-glib/libdbusmenu-glib.la \ | ||
2630 | 15 | $(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk.la \ | ||
2631 | 16 | $(DBUSMENUGTK_LIBS) \ | ||
2632 | 17 | $(DBUSMENUTESTS_LIBS) | ||
2633 | 0 | 18 | ||
2634 | === added file 'tools/testapp/main.c' | |||
2635 | --- tools/testapp/main.c 1970-01-01 00:00:00 +0000 | |||
2636 | +++ tools/testapp/main.c 2010-02-04 20:30:33 +0000 | |||
2637 | @@ -0,0 +1,153 @@ | |||
2638 | 1 | /* | ||
2639 | 2 | A library to communicate a menu object set accross DBus and | ||
2640 | 3 | track updates and maintain consistency. | ||
2641 | 4 | |||
2642 | 5 | Copyright 2010 Canonical Ltd. | ||
2643 | 6 | |||
2644 | 7 | Authors: | ||
2645 | 8 | Aurélien Gâteau <aurelien.gateau@canonical.com> | ||
2646 | 9 | |||
2647 | 10 | This program is free software: you can redistribute it and/or modify it | ||
2648 | 11 | under the terms of either or both of the following licenses: | ||
2649 | 12 | |||
2650 | 13 | 1) the GNU Lesser General Public License version 3, as published by the | ||
2651 | 14 | Free Software Foundation; and/or | ||
2652 | 15 | 2) the GNU Lesser General Public License version 2.1, as published by | ||
2653 | 16 | the Free Software Foundation. | ||
2654 | 17 | |||
2655 | 18 | This program is distributed in the hope that it will be useful, but | ||
2656 | 19 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2657 | 20 | MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR | ||
2658 | 21 | PURPOSE. See the applicable version of the GNU Lesser General Public | ||
2659 | 22 | License for more details. | ||
2660 | 23 | |||
2661 | 24 | You should have received a copy of both the GNU Lesser General Public | ||
2662 | 25 | License version 3 and version 2.1 along with this program. If not, see | ||
2663 | 26 | <http://www.gnu.org/licenses/> | ||
2664 | 27 | */ | ||
2665 | 28 | #include <glib.h> | ||
2666 | 29 | |||
2667 | 30 | #include <dbus/dbus-glib.h> | ||
2668 | 31 | #include <dbus/dbus-glib-bindings.h> | ||
2669 | 32 | |||
2670 | 33 | #include <json-glib/json-glib.h> | ||
2671 | 34 | |||
2672 | 35 | #include <libdbusmenu-glib/server.h> | ||
2673 | 36 | #include <libdbusmenu-glib/menuitem.h> | ||
2674 | 37 | |||
2675 | 38 | #define USAGE "dbusmenubench-glibapp <path/to/menu.json>" | ||
2676 | 39 | |||
2677 | 40 | static void | ||
2678 | 41 | set_props (DbusmenuMenuitem * mi, JsonObject * node) | ||
2679 | 42 | { | ||
2680 | 43 | if (node == NULL) return; | ||
2681 | 44 | |||
2682 | 45 | GList * members = NULL; | ||
2683 | 46 | for (members = json_object_get_members(node); members != NULL; members = g_list_next(members)) { | ||
2684 | 47 | const gchar * member = members->data; | ||
2685 | 48 | |||
2686 | 49 | if (!g_strcmp0(member, "id")) { continue; } | ||
2687 | 50 | if (!g_strcmp0(member, "submenu")) { continue; } | ||
2688 | 51 | |||
2689 | 52 | JsonNode * lnode = json_object_get_member(node, member); | ||
2690 | 53 | if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; } | ||
2691 | 54 | |||
2692 | 55 | dbusmenu_menuitem_property_set(mi, member, json_node_get_string(lnode)); | ||
2693 | 56 | } | ||
2694 | 57 | |||
2695 | 58 | return; | ||
2696 | 59 | } | ||
2697 | 60 | |||
2698 | 61 | static DbusmenuMenuitem * | ||
2699 | 62 | layout2menuitem (JsonNode * inlayout) | ||
2700 | 63 | { | ||
2701 | 64 | if (inlayout == NULL) return NULL; | ||
2702 | 65 | if (JSON_NODE_TYPE(inlayout) != JSON_NODE_OBJECT) return NULL; | ||
2703 | 66 | |||
2704 | 67 | JsonObject * layout = json_node_get_object(inlayout); | ||
2705 | 68 | |||
2706 | 69 | DbusmenuMenuitem * local = NULL; | ||
2707 | 70 | if (json_object_has_member(layout, "id")) { | ||
2708 | 71 | JsonNode * node = json_object_get_member(layout, "id"); | ||
2709 | 72 | g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_VALUE, NULL); | ||
2710 | 73 | local = dbusmenu_menuitem_new_with_id(json_node_get_int(node)); | ||
2711 | 74 | } else { | ||
2712 | 75 | local = dbusmenu_menuitem_new(); | ||
2713 | 76 | } | ||
2714 | 77 | |||
2715 | 78 | set_props(local, layout); | ||
2716 | 79 | |||
2717 | 80 | if (json_object_has_member(layout, "submenu")) { | ||
2718 | 81 | JsonNode * node = json_object_get_member(layout, "submenu"); | ||
2719 | 82 | g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_ARRAY, local); | ||
2720 | 83 | JsonArray * array = json_node_get_array(node); | ||
2721 | 84 | guint count; | ||
2722 | 85 | for (count = 0; count < json_array_get_length(array); count++) { | ||
2723 | 86 | DbusmenuMenuitem * child = layout2menuitem(json_array_get_element(array, count)); | ||
2724 | 87 | if (child != NULL) { | ||
2725 | 88 | dbusmenu_menuitem_child_append(local, child); | ||
2726 | 89 | } | ||
2727 | 90 | } | ||
2728 | 91 | } | ||
2729 | 92 | |||
2730 | 93 | /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ | ||
2731 | 94 | return local; | ||
2732 | 95 | } | ||
2733 | 96 | |||
2734 | 97 | void init_menu(DbusmenuMenuitem *root, const char *filename) | ||
2735 | 98 | { | ||
2736 | 99 | JsonParser * parser = json_parser_new(); | ||
2737 | 100 | GError * error = NULL; | ||
2738 | 101 | if (!json_parser_load_from_file(parser, filename, &error)) { | ||
2739 | 102 | g_debug("Failed parsing file %s because: %s", filename, error->message); | ||
2740 | 103 | return; | ||
2741 | 104 | } | ||
2742 | 105 | JsonNode * root_node = json_parser_get_root(parser); | ||
2743 | 106 | if (JSON_NODE_TYPE(root_node) != JSON_NODE_ARRAY) { | ||
2744 | 107 | g_debug("Root node is not an array, fail. It's an: %s", json_node_type_name(root_node)); | ||
2745 | 108 | return; | ||
2746 | 109 | } | ||
2747 | 110 | |||
2748 | 111 | JsonArray * root_array = json_node_get_array(root_node); | ||
2749 | 112 | int pos; | ||
2750 | 113 | int count = json_array_get_length(root_array); | ||
2751 | 114 | for (pos=0; pos < count; ++pos) { | ||
2752 | 115 | DbusmenuMenuitem *child = layout2menuitem(json_array_get_element(root_array, pos)); | ||
2753 | 116 | dbusmenu_menuitem_child_append(root, child); | ||
2754 | 117 | } | ||
2755 | 118 | } | ||
2756 | 119 | |||
2757 | 120 | int main (int argc, char ** argv) | ||
2758 | 121 | { | ||
2759 | 122 | g_type_init(); | ||
2760 | 123 | |||
2761 | 124 | if (argc != 2) { | ||
2762 | 125 | g_warning(USAGE); | ||
2763 | 126 | return 1; | ||
2764 | 127 | } | ||
2765 | 128 | const char *filename = argv[1]; | ||
2766 | 129 | |||
2767 | 130 | GError * error = NULL; | ||
2768 | 131 | DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); | ||
2769 | 132 | DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); | ||
2770 | 133 | guint nameret = 0; | ||
2771 | 134 | |||
2772 | 135 | if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) { | ||
2773 | 136 | g_error("Unable to call to request name"); | ||
2774 | 137 | return 1; | ||
2775 | 138 | } | ||
2776 | 139 | |||
2777 | 140 | if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { | ||
2778 | 141 | g_error("Unable to get name"); | ||
2779 | 142 | return 1; | ||
2780 | 143 | } | ||
2781 | 144 | |||
2782 | 145 | DbusmenuServer *server = dbusmenu_server_new("/MenuBar"); | ||
2783 | 146 | DbusmenuMenuitem *root = dbusmenu_menuitem_new_with_id(0); | ||
2784 | 147 | init_menu(root, filename); | ||
2785 | 148 | dbusmenu_server_set_root(server, root); | ||
2786 | 149 | |||
2787 | 150 | g_main_loop_run(g_main_loop_new(NULL, FALSE)); | ||
2788 | 151 | |||
2789 | 152 | return 0; | ||
2790 | 153 | } |
0.2.2