Merge lp:~dbusmenu-team/libdbusmenu/ubuntu into lp:~ubuntu-desktop/libdbusmenu/ubuntu

Proposed by Ted Gould
Status: Merged
Merged at revision: not available
Proposed branch: lp:~dbusmenu-team/libdbusmenu/ubuntu
Merge into: lp:~ubuntu-desktop/libdbusmenu/ubuntu
Diff against target: 2790 lines (+1346/-406)
26 files modified
.bzrignore (+1/-0)
configure.ac (+6/-5)
debian/changelog (+12/-0)
debian/libdbusmenu-tools.install (+1/-1)
libdbusmenu-glib/Doxyfile (+257/-0)
libdbusmenu-glib/Makefile.am (+2/-0)
libdbusmenu-glib/client-menuitem.c (+106/-0)
libdbusmenu-glib/client-menuitem.h (+61/-0)
libdbusmenu-glib/client.c (+28/-59)
libdbusmenu-glib/client.h (+7/-2)
libdbusmenu-glib/dbus-menu.xml (+231/-119)
libdbusmenu-glib/menuitem-marshal.list (+1/-0)
libdbusmenu-glib/menuitem-private.h (+1/-1)
libdbusmenu-glib/menuitem.c (+55/-26)
libdbusmenu-glib/menuitem.h (+16/-12)
libdbusmenu-glib/server-marshal.list (+1/-1)
libdbusmenu-glib/server.c (+30/-30)
libdbusmenu-glib/server.h (+6/-5)
libdbusmenu-gtk/client.c (+36/-21)
tests/test-gtk-label-server.c (+6/-3)
tests/test-gtk-label.json (+121/-121)
tools/Makefile.am (+5/-0)
tools/dbusmenu-bench (+157/-0)
tools/testapp/CMakeLists.txt (+29/-0)
tools/testapp/Makefile.am (+17/-0)
tools/testapp/main.c (+153/-0)
To merge this branch: bzr merge lp:~dbusmenu-team/libdbusmenu/ubuntu
Reviewer Review Type Date Requested Status
Sebastien Bacher Pending
Review via email: mp+18630@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote :

0.2.2

lp:~dbusmenu-team/libdbusmenu/ubuntu updated
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
=== modified file '.bzrignore'
--- .bzrignore 2009-12-21 22:17:02 +0000
+++ .bzrignore 2010-02-04 20:30:33 +0000
@@ -58,3 +58,4 @@
58tests/test-glib-objects58tests/test-glib-objects
59tests/test-glib-objects-test59tests/test-glib-objects-test
60tests/test-glib-objects.xml60tests/test-glib-objects.xml
61tools/testapp/dbusmenu-testapp
6162
=== modified file 'configure.ac'
--- configure.ac 2010-01-20 02:07:35 +0000
+++ configure.ac 2010-02-04 20:30:33 +0000
@@ -1,11 +1,11 @@
11
2AC_INIT(libdbusmenu, 0.2.1, ted@canonical.com)2AC_INIT(libdbusmenu, 0.2.2, ted@canonical.com)
3AC_COPYRIGHT([Copyright 2009 Canonical])3AC_COPYRIGHT([Copyright 2009,2010 Canonical])
44
5AC_PREREQ(2.53)5AC_PREREQ(2.53)
66
7AM_CONFIG_HEADER(config.h)7AM_CONFIG_HEADER(config.h)
8AM_INIT_AUTOMAKE(libdbusmenu, 0.2.1)8AM_INIT_AUTOMAKE(libdbusmenu, 0.2.2)
99
10AM_MAINTAINER_MODE10AM_MAINTAINER_MODE
1111
@@ -65,8 +65,8 @@
65# Lib versioning 65# Lib versioning
66###########################66###########################
6767
68LIBDBUSMENU_CURRENT=068LIBDBUSMENU_CURRENT=1
69LIBDBUSMENU_REVISION=1169LIBDBUSMENU_REVISION=0
70LIBDBUSMENU_AGE=070LIBDBUSMENU_AGE=0
7171
72AC_SUBST(LIBDBUSMENU_CURRENT)72AC_SUBST(LIBDBUSMENU_CURRENT)
@@ -105,6 +105,7 @@
105libdbusmenu-gtk/Makefile105libdbusmenu-gtk/Makefile
106libdbusmenu-gtk/dbusmenu-gtk.pc106libdbusmenu-gtk/dbusmenu-gtk.pc
107tools/Makefile107tools/Makefile
108tools/testapp/Makefile
108tests/Makefile109tests/Makefile
109])110])
110111
111112
=== modified file 'debian/changelog'
--- debian/changelog 2010-01-20 02:07:35 +0000
+++ debian/changelog 2010-02-04 20:30:33 +0000
@@ -1,3 +1,15 @@
1libdbusmenu (0.2.2-0ubuntu1~ppa1) lucid; urgency=low
2
3 * Upstream Release 0.2.2
4 * Interoperability fixes
5 * Adding timestamps to events
6 * Better handling of XML
7 * Adding tools for timing dbusmenu
8 * debian/libdbusmenu-tools.install: Adding a wildcard to get
9 all of the tools in libexec
10
11 -- Ted Gould <ted@ubuntu.com> Thu, 04 Feb 2010 12:18:26 -0800
12
1libdbusmenu (0.2.1-0ubuntu1) lucid; urgency=low13libdbusmenu (0.2.1-0ubuntu1) lucid; urgency=low
214
3 * Upstream release 0.2.115 * Upstream release 0.2.1
416
=== modified file 'debian/libdbusmenu-tools.install'
--- debian/libdbusmenu-tools.install 2010-01-09 14:09:31 +0000
+++ debian/libdbusmenu-tools.install 2010-02-04 20:30:33 +0000
@@ -1,1 +1,1 @@
1debian/tmp/usr/lib/libdbusmenu/dbusmenu-dumper 1debian/tmp/usr/lib/libdbusmenu/dbusmenu-*
22
=== added file 'libdbusmenu-glib/Doxyfile'
--- libdbusmenu-glib/Doxyfile 1970-01-01 00:00:00 +0000
+++ libdbusmenu-glib/Doxyfile 2010-02-04 20:30:33 +0000
@@ -0,0 +1,257 @@
1# Doxyfile 1.6.1
2
3#---------------------------------------------------------------------------
4# Project related configuration options
5#---------------------------------------------------------------------------
6DOXYFILE_ENCODING = UTF-8
7PROJECT_NAME = DBusMenu
8PROJECT_NUMBER =
9OUTPUT_DIRECTORY =
10CREATE_SUBDIRS = NO
11OUTPUT_LANGUAGE = English
12BRIEF_MEMBER_DESC = YES
13REPEAT_BRIEF = YES
14ABBREVIATE_BRIEF =
15ALWAYS_DETAILED_SEC = NO
16INLINE_INHERITED_MEMB = NO
17FULL_PATH_NAMES = YES
18STRIP_FROM_PATH =
19STRIP_FROM_INC_PATH =
20SHORT_NAMES = NO
21JAVADOC_AUTOBRIEF = NO
22QT_AUTOBRIEF = NO
23MULTILINE_CPP_IS_BRIEF = NO
24INHERIT_DOCS = YES
25SEPARATE_MEMBER_PAGES = NO
26TAB_SIZE = 8
27ALIASES =
28OPTIMIZE_OUTPUT_FOR_C = NO
29OPTIMIZE_OUTPUT_JAVA = NO
30OPTIMIZE_FOR_FORTRAN = NO
31OPTIMIZE_OUTPUT_VHDL = NO
32EXTENSION_MAPPING =
33BUILTIN_STL_SUPPORT = NO
34CPP_CLI_SUPPORT = NO
35SIP_SUPPORT = NO
36IDL_PROPERTY_SUPPORT = YES
37DISTRIBUTE_GROUP_DOC = NO
38SUBGROUPING = YES
39TYPEDEF_HIDES_STRUCT = NO
40SYMBOL_CACHE_SIZE = 0
41#---------------------------------------------------------------------------
42# Build related configuration options
43#---------------------------------------------------------------------------
44EXTRACT_ALL = NO
45EXTRACT_PRIVATE = NO
46EXTRACT_STATIC = NO
47EXTRACT_LOCAL_CLASSES = YES
48EXTRACT_LOCAL_METHODS = NO
49EXTRACT_ANON_NSPACES = NO
50HIDE_UNDOC_MEMBERS = NO
51HIDE_UNDOC_CLASSES = NO
52HIDE_FRIEND_COMPOUNDS = NO
53HIDE_IN_BODY_DOCS = NO
54INTERNAL_DOCS = NO
55CASE_SENSE_NAMES = YES
56HIDE_SCOPE_NAMES = NO
57SHOW_INCLUDE_FILES = YES
58INLINE_INFO = YES
59SORT_MEMBER_DOCS = YES
60SORT_BRIEF_DOCS = NO
61SORT_MEMBERS_CTORS_1ST = NO
62SORT_GROUP_NAMES = NO
63SORT_BY_SCOPE_NAME = NO
64GENERATE_TODOLIST = YES
65GENERATE_TESTLIST = YES
66GENERATE_BUGLIST = YES
67GENERATE_DEPRECATEDLIST= YES
68ENABLED_SECTIONS =
69MAX_INITIALIZER_LINES = 30
70SHOW_USED_FILES = YES
71SHOW_DIRECTORIES = NO
72SHOW_FILES = YES
73SHOW_NAMESPACES = YES
74FILE_VERSION_FILTER =
75LAYOUT_FILE =
76#---------------------------------------------------------------------------
77# configuration options related to warning and progress messages
78#---------------------------------------------------------------------------
79QUIET = NO
80WARNINGS = YES
81WARN_IF_UNDOCUMENTED = YES
82WARN_IF_DOC_ERROR = YES
83WARN_NO_PARAMDOC = NO
84WARN_FORMAT = "$file:$line: $text"
85WARN_LOGFILE =
86#---------------------------------------------------------------------------
87# configuration options related to the input files
88#---------------------------------------------------------------------------
89INPUT = .
90INPUT_ENCODING = UTF-8
91FILE_PATTERNS = *.xml
92RECURSIVE = NO
93EXCLUDE =
94EXCLUDE_SYMLINKS = NO
95EXCLUDE_PATTERNS =
96EXCLUDE_SYMBOLS =
97EXAMPLE_PATH =
98EXAMPLE_PATTERNS =
99EXAMPLE_RECURSIVE = NO
100IMAGE_PATH =
101INPUT_FILTER = doxymel
102FILTER_PATTERNS = *.xml=doxymel
103FILTER_SOURCE_FILES = NO
104#---------------------------------------------------------------------------
105# configuration options related to source browsing
106#---------------------------------------------------------------------------
107SOURCE_BROWSER = NO
108INLINE_SOURCES = NO
109STRIP_CODE_COMMENTS = YES
110REFERENCED_BY_RELATION = NO
111REFERENCES_RELATION = NO
112REFERENCES_LINK_SOURCE = YES
113USE_HTAGS = NO
114VERBATIM_HEADERS = YES
115#---------------------------------------------------------------------------
116# configuration options related to the alphabetical class index
117#---------------------------------------------------------------------------
118ALPHABETICAL_INDEX = NO
119COLS_IN_ALPHA_INDEX = 5
120IGNORE_PREFIX =
121#---------------------------------------------------------------------------
122# configuration options related to the HTML output
123#---------------------------------------------------------------------------
124GENERATE_HTML = YES
125HTML_OUTPUT = html
126HTML_FILE_EXTENSION = .html
127HTML_HEADER =
128HTML_FOOTER =
129HTML_STYLESHEET =
130HTML_ALIGN_MEMBERS = YES
131HTML_DYNAMIC_SECTIONS = NO
132GENERATE_DOCSET = NO
133DOCSET_FEEDNAME = "Doxygen generated docs"
134DOCSET_BUNDLE_ID = org.doxygen.Project
135GENERATE_HTMLHELP = NO
136CHM_FILE =
137HHC_LOCATION =
138GENERATE_CHI = NO
139CHM_INDEX_ENCODING =
140BINARY_TOC = NO
141TOC_EXPAND = NO
142GENERATE_QHP = NO
143QCH_FILE =
144QHP_NAMESPACE =
145QHP_VIRTUAL_FOLDER = doc
146QHP_CUST_FILTER_NAME =
147QHP_CUST_FILTER_ATTRS =
148QHP_SECT_FILTER_ATTRS =
149QHG_LOCATION =
150DISABLE_INDEX = NO
151ENUM_VALUES_PER_LINE = 4
152GENERATE_TREEVIEW = NO
153USE_INLINE_TREES = NO
154TREEVIEW_WIDTH = 250
155FORMULA_FONTSIZE = 10
156SEARCHENGINE = YES
157#---------------------------------------------------------------------------
158# configuration options related to the LaTeX output
159#---------------------------------------------------------------------------
160GENERATE_LATEX = NO
161LATEX_OUTPUT = latex
162LATEX_CMD_NAME = latex
163MAKEINDEX_CMD_NAME = makeindex
164COMPACT_LATEX = NO
165PAPER_TYPE = a4wide
166EXTRA_PACKAGES =
167LATEX_HEADER =
168PDF_HYPERLINKS = YES
169USE_PDFLATEX = YES
170LATEX_BATCHMODE = NO
171LATEX_HIDE_INDICES = NO
172LATEX_SOURCE_CODE = NO
173#---------------------------------------------------------------------------
174# configuration options related to the RTF output
175#---------------------------------------------------------------------------
176GENERATE_RTF = NO
177RTF_OUTPUT = rtf
178COMPACT_RTF = NO
179RTF_HYPERLINKS = NO
180RTF_STYLESHEET_FILE =
181RTF_EXTENSIONS_FILE =
182#---------------------------------------------------------------------------
183# configuration options related to the man page output
184#---------------------------------------------------------------------------
185GENERATE_MAN = NO
186MAN_OUTPUT = man
187MAN_EXTENSION = .3
188MAN_LINKS = NO
189#---------------------------------------------------------------------------
190# configuration options related to the XML output
191#---------------------------------------------------------------------------
192GENERATE_XML = NO
193XML_OUTPUT = xml
194XML_SCHEMA =
195XML_DTD =
196XML_PROGRAMLISTING = YES
197#---------------------------------------------------------------------------
198# configuration options for the AutoGen Definitions output
199#---------------------------------------------------------------------------
200GENERATE_AUTOGEN_DEF = NO
201#---------------------------------------------------------------------------
202# configuration options related to the Perl module output
203#---------------------------------------------------------------------------
204GENERATE_PERLMOD = NO
205PERLMOD_LATEX = NO
206PERLMOD_PRETTY = YES
207PERLMOD_MAKEVAR_PREFIX =
208#---------------------------------------------------------------------------
209# Configuration options related to the preprocessor
210#---------------------------------------------------------------------------
211ENABLE_PREPROCESSING = YES
212MACRO_EXPANSION = NO
213EXPAND_ONLY_PREDEF = NO
214SEARCH_INCLUDES = YES
215INCLUDE_PATH =
216INCLUDE_FILE_PATTERNS =
217PREDEFINED =
218EXPAND_AS_DEFINED =
219SKIP_FUNCTION_MACROS = YES
220#---------------------------------------------------------------------------
221# Configuration::additions related to external references
222#---------------------------------------------------------------------------
223TAGFILES =
224GENERATE_TAGFILE =
225ALLEXTERNALS = NO
226EXTERNAL_GROUPS = YES
227PERL_PATH = /usr/bin/perl
228#---------------------------------------------------------------------------
229# Configuration options related to the dot tool
230#---------------------------------------------------------------------------
231CLASS_DIAGRAMS = YES
232MSCGEN_PATH =
233HIDE_UNDOC_RELATIONS = YES
234HAVE_DOT = NO
235DOT_FONTNAME = FreeSans
236DOT_FONTSIZE = 10
237DOT_FONTPATH =
238CLASS_GRAPH = YES
239COLLABORATION_GRAPH = YES
240GROUP_GRAPHS = YES
241UML_LOOK = NO
242TEMPLATE_RELATIONS = NO
243INCLUDE_GRAPH = YES
244INCLUDED_BY_GRAPH = YES
245CALL_GRAPH = NO
246CALLER_GRAPH = NO
247GRAPHICAL_HIERARCHY = YES
248DIRECTORY_GRAPH = YES
249DOT_IMAGE_FORMAT = png
250DOT_PATH =
251DOTFILE_DIRS =
252DOT_GRAPH_MAX_NODES = 50
253MAX_DOT_GRAPH_DEPTH = 0
254DOT_TRANSPARENT = NO
255DOT_MULTI_TARGETS = YES
256GENERATE_LEGEND = YES
257DOT_CLEANUP = YES
0258
=== modified file 'libdbusmenu-glib/Makefile.am'
--- libdbusmenu-glib/Makefile.am 2009-11-13 18:02:08 +0000
+++ libdbusmenu-glib/Makefile.am 2010-02-04 20:30:33 +0000
@@ -27,6 +27,8 @@
27 server.c \27 server.c \
28 server-marshal.h \28 server-marshal.h \
29 server-marshal.c \29 server-marshal.c \
30 client-menuitem.h \
31 client-menuitem.c \
30 client.h \32 client.h \
31 client.c33 client.c
3234
3335
=== added file 'libdbusmenu-glib/client-menuitem.c'
--- libdbusmenu-glib/client-menuitem.c 1970-01-01 00:00:00 +0000
+++ libdbusmenu-glib/client-menuitem.c 2010-02-04 20:30:33 +0000
@@ -0,0 +1,106 @@
1/*
2A small subclass of the menuitem for using clients.
3
4Copyright 2010 Canonical Ltd.
5
6Authors:
7 Ted Gould <ted@canonical.com>
8
9This program is free software: you can redistribute it and/or modify it
10under the terms of either or both of the following licenses:
11
121) the GNU Lesser General Public License version 3, as published by the
13Free Software Foundation; and/or
142) the GNU Lesser General Public License version 2.1, as published by
15the Free Software Foundation.
16
17This program is distributed in the hope that it will be useful, but
18WITHOUT ANY WARRANTY; without even the implied warranties of
19MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
20PURPOSE. See the applicable version of the GNU Lesser General Public
21License for more details.
22
23You should have received a copy of both the GNU Lesser General Public
24License version 3 and version 2.1 along with this program. If not, see
25<http://www.gnu.org/licenses/>
26*/
27
28#ifdef HAVE_CONFIG_H
29#include "config.h"
30#endif
31
32#include "client-menuitem.h"
33
34typedef struct _DbusmenuClientMenuitemPrivate DbusmenuClientMenuitemPrivate;
35
36struct _DbusmenuClientMenuitemPrivate
37{
38 DbusmenuClient * client;
39};
40
41#define DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(o) \
42(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemPrivate))
43
44static void dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass);
45static void dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self);
46static void dbusmenu_client_menuitem_dispose (GObject *object);
47static void dbusmenu_client_menuitem_finalize (GObject *object);
48static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp);
49
50G_DEFINE_TYPE (DbusmenuClientMenuitem, dbusmenu_client_menuitem, DBUSMENU_TYPE_MENUITEM);
51
52static void
53dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass)
54{
55 GObjectClass *object_class = G_OBJECT_CLASS (klass);
56
57 g_type_class_add_private (klass, sizeof (DbusmenuClientMenuitemPrivate));
58
59 object_class->dispose = dbusmenu_client_menuitem_dispose;
60 object_class->finalize = dbusmenu_client_menuitem_finalize;
61
62 DbusmenuMenuitemClass * mclass = DBUSMENU_MENUITEM_CLASS(klass);
63 mclass->handle_event = handle_event;
64
65 return;
66}
67
68static void
69dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self)
70{
71
72 return;
73}
74
75static void
76dbusmenu_client_menuitem_dispose (GObject *object)
77{
78
79 G_OBJECT_CLASS (dbusmenu_client_menuitem_parent_class)->dispose (object);
80 return;
81}
82
83static void
84dbusmenu_client_menuitem_finalize (GObject *object)
85{
86
87 G_OBJECT_CLASS (dbusmenu_client_menuitem_parent_class)->finalize (object);
88 return;
89}
90
91DbusmenuClientMenuitem *
92dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client)
93{
94 DbusmenuClientMenuitem * mi = g_object_new(DBUSMENU_CLIENT_MENUITEM_TYPE, "id", id, NULL);
95 DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi);
96 priv->client = client;
97 return mi;
98}
99
100static void
101handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp)
102{
103 DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi);
104 dbusmenu_client_send_event(priv->client, dbusmenu_menuitem_get_id(mi), name, value, timestamp);
105 return;
106}
0107
=== added file 'libdbusmenu-glib/client-menuitem.h'
--- libdbusmenu-glib/client-menuitem.h 1970-01-01 00:00:00 +0000
+++ libdbusmenu-glib/client-menuitem.h 2010-02-04 20:30:33 +0000
@@ -0,0 +1,61 @@
1/*
2A small subclass of the menuitem for using clients.
3
4Copyright 2010 Canonical Ltd.
5
6Authors:
7 Ted Gould <ted@canonical.com>
8
9This program is free software: you can redistribute it and/or modify it
10under the terms of either or both of the following licenses:
11
121) the GNU Lesser General Public License version 3, as published by the
13Free Software Foundation; and/or
142) the GNU Lesser General Public License version 2.1, as published by
15the Free Software Foundation.
16
17This program is distributed in the hope that it will be useful, but
18WITHOUT ANY WARRANTY; without even the implied warranties of
19MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
20PURPOSE. See the applicable version of the GNU Lesser General Public
21License for more details.
22
23You should have received a copy of both the GNU Lesser General Public
24License version 3 and version 2.1 along with this program. If not, see
25<http://www.gnu.org/licenses/>
26*/
27
28#ifndef __DBUSMENU_CLIENT_MENUITEM_H__
29#define __DBUSMENU_CLIENT_MENUITEM_H__
30
31#include <glib.h>
32#include <glib-object.h>
33#include "menuitem.h"
34#include "client.h"
35
36G_BEGIN_DECLS
37
38#define DBUSMENU_CLIENT_MENUITEM_TYPE (dbusmenu_client_menuitem_get_type ())
39#define DBUSMENU_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitem))
40#define DBUSMENU_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemClass))
41#define DBUSMENU_IS_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE))
42#define DBUSMENU_IS_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_CLIENT_MENUITEM_TYPE))
43#define DBUSMENU_CLIENT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemClass))
44
45typedef struct _DbusmenuClientMenuitem DbusmenuClientMenuitem;
46typedef struct _DbusmenuClientMenuitemClass DbusmenuClientMenuitemClass;
47
48struct _DbusmenuClientMenuitemClass {
49 DbusmenuMenuitemClass parent_class;
50};
51
52struct _DbusmenuClientMenuitem {
53 DbusmenuMenuitem parent;
54};
55
56GType dbusmenu_client_menuitem_get_type (void);
57DbusmenuClientMenuitem * dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client);
58
59G_END_DECLS
60
61#endif
062
=== modified file 'libdbusmenu-glib/client.c'
--- libdbusmenu-glib/client.c 2010-01-07 05:27:49 +0000
+++ libdbusmenu-glib/client.c 2010-02-04 20:30:33 +0000
@@ -35,6 +35,7 @@
3535
36#include "client.h"36#include "client.h"
37#include "menuitem.h"37#include "menuitem.h"
38#include "client-menuitem.h"
38#include "dbusmenu-client.h"39#include "dbusmenu-client.h"
39#include "server-marshal.h"40#include "server-marshal.h"
4041
@@ -96,10 +97,10 @@
96static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);97static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
97/* Private Funcs */98/* Private Funcs */
98static void layout_update (DBusGProxy * proxy, gint revision, guint parent, DbusmenuClient * client);99static void layout_update (DBusGProxy * proxy, gint revision, guint parent, DbusmenuClient * client);
99static void id_prop_update (DBusGProxy * proxy, guint id, gchar * property, GValue * value, DbusmenuClient * client);100static void id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client);
100static void id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client);101static void id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client);
101static void build_proxies (DbusmenuClient * client);102static void build_proxies (DbusmenuClient * client);
102static guint parse_node_get_id (xmlNodePtr node);103static gint parse_node_get_id (xmlNodePtr node);
103static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy);104static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy);
104static gint parse_layout (DbusmenuClient * client, const gchar * layout);105static gint parse_layout (DbusmenuClient * client, const gchar * layout);
105static void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data);106static void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data);
@@ -321,7 +322,7 @@
321/* Signal from the server that a property has changed322/* Signal from the server that a property has changed
322 on one of our menuitems */323 on one of our menuitems */
323static void324static void
324id_prop_update (DBusGProxy * proxy, guint id, gchar * property, GValue * value, DbusmenuClient * client)325id_prop_update (DBusGProxy * proxy, gint id, gchar * property, GValue * value, DbusmenuClient * client)
325{326{
326 #ifdef MASSIVEDEBUGGING327 #ifdef MASSIVEDEBUGGING
327 GValue valstr = {0};328 GValue valstr = {0};
@@ -344,7 +345,7 @@
344/* Oh, lots of updates now. That silly server, they want345/* Oh, lots of updates now. That silly server, they want
345 to change all kinds of stuff! */346 to change all kinds of stuff! */
346static void347static void
347id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client)348id_update (DBusGProxy * proxy, gint id, DbusmenuClient * client)
348{349{
349 #ifdef MASSIVEDEBUGGING350 #ifdef MASSIVEDEBUGGING
350 g_debug("Client side ID update: %d", id);351 g_debug("Client side ID update: %d", id);
@@ -498,15 +499,15 @@
498 priv->dbusproxy = NULL;499 priv->dbusproxy = NULL;
499 }500 }
500501
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);
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);
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);
504505
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);
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);
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);
508509
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);
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);
511512
512 update_layout(client);513 update_layout(client);
@@ -514,51 +515,23 @@
514 return;515 return;
515}516}
516517
517/* Get the "revision" attribute of the node, parse it and
518 return it. Also we're checking to ensure the node
519 is a 'menu' here. */
520static gint
521parse_node_get_revision (xmlNodePtr node)
522{
523 if (g_strcmp0((gchar *)node->name, "menu") != 0) {
524 /* This kills some nodes early */
525 g_warning("XML Node is not 'menu' it is '%s'", node->name);
526 return 0;
527 }
528
529 xmlAttrPtr attrib;
530 for (attrib = node->properties; attrib != NULL; attrib = attrib->next) {
531 if (g_strcmp0((gchar *)attrib->name, "revision") == 0) {
532 if (attrib->children != NULL) {
533 guint revision = (guint)g_ascii_strtoull((gchar *)attrib->children->content, NULL, 10);
534 /* g_debug ("Found ID: %d", id); */
535 return revision;
536 }
537 break;
538 }
539 }
540
541 g_warning("Unable to find a revision on the node");
542 return 0;
543}
544
545/* Get the ID attribute of the node, parse it and518/* Get the ID attribute of the node, parse it and
546 return it. Also we're checking to ensure the node519 return it. Also we're checking to ensure the node
547 is a 'menu' here. */520 is a 'menu' here. */
548static guint521static gint
549parse_node_get_id (xmlNodePtr node)522parse_node_get_id (xmlNodePtr node)
550{523{
551 if (g_strcmp0((gchar *)node->name, "menu") != 0) {524 if (g_strcmp0((gchar *)node->name, "menu") != 0) {
552 /* This kills some nodes early */525 /* This kills some nodes early */
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);
554 return 0;527 return -1;
555 }528 }
556529
557 xmlAttrPtr attrib;530 xmlAttrPtr attrib;
558 for (attrib = node->properties; attrib != NULL; attrib = attrib->next) {531 for (attrib = node->properties; attrib != NULL; attrib = attrib->next) {
559 if (g_strcmp0((gchar *)attrib->name, "id") == 0) {532 if (g_strcmp0((gchar *)attrib->name, "id") == 0) {
560 if (attrib->children != NULL) {533 if (attrib->children != NULL) {
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);
562 /* g_debug ("Found ID: %d", id); */535 /* g_debug ("Found ID: %d", id); */
563 return id;536 return id;
564 }537 }
@@ -567,7 +540,7 @@
567 }540 }
568541
569 g_warning("Unable to find an ID on the node");542 g_warning("Unable to find an ID on the node");
570 return 0;543 return -1;
571}544}
572545
573/* A small helper that calls _property_set on each hash table546/* A small helper that calls _property_set on each hash table
@@ -654,14 +627,11 @@
654 return;627 return;
655}628}
656629
657static void630void
658menuitem_activate (DbusmenuMenuitem * mi, DbusmenuClient * client)631dbusmenu_client_send_event (DbusmenuClient * client, gint id, const gchar * name, const GValue * value, guint timestamp)
659{632{
660 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);633 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
661 GValue value = {0};634 org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, GINT_TO_POINTER(id));
662 g_value_init(&value, G_TYPE_INT);
663 g_value_set_int(&value, 0);
664 org_ayatana_dbusmenu_event_async (priv->menuproxy, dbusmenu_menuitem_get_id(mi), "clicked", &value, menuitem_call_cb, mi);
665 return;635 return;
666}636}
667637
@@ -670,11 +640,14 @@
670static DbusmenuMenuitem *640static DbusmenuMenuitem *
671parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy)641parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy)
672{642{
673 guint id = parse_node_get_id(node);643 gint id = parse_node_get_id(node);
644 if (id < 0) {
645 return NULL;
646 }
674 #ifdef MASSIVEDEBUGGING647 #ifdef MASSIVEDEBUGGING
675 g_debug("Client looking at node with id: %d", id);648 g_debug("Client looking at node with id: %d", id);
676 #endif649 #endif
677 if (item == NULL || dbusmenu_menuitem_get_id(item) != id || id == 0) {650 if (item == NULL || dbusmenu_menuitem_get_id(item) != id) {
678 if (item != NULL) {651 if (item != NULL) {
679 if (parent != NULL) {652 if (parent != NULL) {
680 dbusmenu_menuitem_child_delete(parent, item);653 dbusmenu_menuitem_child_delete(parent, item);
@@ -683,17 +656,11 @@
683 item = NULL;656 item = NULL;
684 }657 }
685658
686 if (id == 0) {
687 g_warning("ID from XML file is zero");
688 return NULL;
689 }
690
691 /* Build a new item */659 /* Build a new item */
692 item = dbusmenu_menuitem_new_with_id(id);660 item = DBUSMENU_MENUITEM(dbusmenu_client_menuitem_new(id, client));
693 if (parent == NULL) {661 if (parent == NULL) {
694 dbusmenu_menuitem_set_root(item, TRUE);662 dbusmenu_menuitem_set_root(item, TRUE);
695 }663 }
696 g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activate), client);
697664
698 /* Get the properties queued up for this item */665 /* Get the properties queued up for this item */
699 /* Not happy about this, but I need these :( */666 /* Not happy about this, but I need these :( */
@@ -717,7 +684,10 @@
717684
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++) {
719 /* g_debug("Looking at child: %d", position); */686 /* g_debug("Looking at child: %d", position); */
720 guint childid = parse_node_get_id(children);687 gint childid = parse_node_get_id(children);
688 if (childid < 0) {
689 continue;
690 }
721 DbusmenuMenuitem * childmi = NULL;691 DbusmenuMenuitem * childmi = NULL;
722692
723 GList * childsearch = NULL;693 GList * childsearch = NULL;
@@ -764,7 +734,6 @@
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);
765735
766 xmlNodePtr root = xmlDocGetRootElement(xmldoc);736 xmlNodePtr root = xmlDocGetRootElement(xmldoc);
767 gint revision = parse_node_get_revision(root);
768737
769 DbusmenuMenuitem * oldroot = priv->root;738 DbusmenuMenuitem * oldroot = priv->root;
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);
@@ -781,7 +750,7 @@
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);
782 }751 }
783752
784 return revision;753 return 1;
785}754}
786755
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. */
788757
=== modified file 'libdbusmenu-glib/client.h'
--- libdbusmenu-glib/client.h 2009-12-10 04:57:31 +0000
+++ libdbusmenu-glib/client.h 2010-02-04 20:30:33 +0000
@@ -50,9 +50,9 @@
50#define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name"50#define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name"
51#define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object"51#define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object"
5252
53#define DBUSMENU_CLIENT_TYPES_DEFAULT "menuitem"53#define DBUSMENU_CLIENT_TYPES_DEFAULT "standard"
54#define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator"54#define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator"
55#define DBUSMENU_CLIENT_TYPES_IMAGE "menuitem"55#define DBUSMENU_CLIENT_TYPES_IMAGE "standard"
5656
57/**57/**
58 DbusmenuClientClass:58 DbusmenuClientClass:
@@ -104,6 +104,11 @@
104gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client,104gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client,
105 const gchar * type,105 const gchar * type,
106 DbusmenuClientTypeHandler newfunc);106 DbusmenuClientTypeHandler newfunc);
107void dbusmenu_client_send_event (DbusmenuClient * client,
108 gint id,
109 const gchar * name,
110 const GValue * value,
111 guint timestamp);
107112
108/**113/**
109 SECTION:client114 SECTION:client
110115
=== modified file 'libdbusmenu-glib/dbus-menu.xml'
--- libdbusmenu-glib/dbus-menu.xml 2009-12-24 10:31:16 +0000
+++ libdbusmenu-glib/dbus-menu.xml 2010-02-04 20:30:33 +0000
@@ -8,6 +8,7 @@
88
9Authors:9Authors:
10 Ted Gould <ted@canonical.com>10 Ted Gould <ted@canonical.com>
11 Aurelien Gateau <ted@canonical.com>
1112
12This program is free software: you can redistribute it and/or modify it 13This program is free software: you can redistribute it and/or modify it
13under the terms of either or both of the following licenses:14under the terms of either or both of the following licenses:
@@ -27,164 +28,275 @@
27License version 3 and version 2.1 along with this program. If not, see 28License version 3 and version 2.1 along with this program. If not, see
28<http://www.gnu.org/licenses/>29<http://www.gnu.org/licenses/>
29-->30-->
30<node name="/">31<node name="/" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
31 <interface name="org.ayatana.dbusmenu">32 <interface name="org.ayatana.dbusmenu">
33 <dox:d><![CDATA[
34 The goal of this DBus interface is to be able to pass menu items
35 through DBus.
36
37 Items are represented with a unique numeric id and a dictionary of
38 properties.
39
40 Available properties are:
41
42 <table>
43 <tr>
44 <th>Name</th>
45 <th>Type</th>
46 <th>Description</th>
47 <th>Default Value</th>
48 </tr>
49 <tr>
50 <td>type</td>
51 <td>String</td>
52 <td>Can be one of:
53 - "standard": an item which can be clicked to trigger an action or
54 show another menu
55 - "separator": a separator
56
57 Vendor specific types can be added by prefixing them with
58 "x-<vendor>-".
59 </td>
60 <td>"standard"</td>
61 </tr>
62 <tr>
63 <td>label</td>
64 <td>string</td>
65 <td>Text of the item, except that:
66 -# two consecutive underscore characters "__" are displayed as a
67 single underscore,
68 -# any remaining underscore characters are not displayed at all,
69 -# the first of those remaining underscore characters (unless it is
70 the last character in the string) indicates that the following
71 character is the access key.
72 </td>
73 <td>""</td>
74 </tr>
75 <tr>
76 <td>enabled</td>
77 <td>boolean</td>
78 <td>Whether the item can be activated or not.</td>
79 <td>true</td>
80 </tr>
81 <tr>
82 <td>icon-name</td>
83 <td>string</td>
84 <td>Icon name of the item, following the freedesktop.org icon spec.</td>
85 <td>""</td>
86 </tr>
87 <tr>
88 <td>icon-data</td>
89 <td>binary</td>
90 <td>PNG data of the icon.</td>
91 <td>Empty</td>
92 </tr>
93 <tr>
94 <td>toggle-type</td>
95 <td>string</td>
96 <td>
97 If the item can be toggled, this property should be set to:
98 - "checkmark": Item is an independent togglable item
99 - "radio": Item is part of a group where only one item can be
100 toggled at a time
101 - "": Item cannot be toggled
102 </td>
103 <td>""</td>
104 </tr>
105 <tr>
106 <td>toggle-state</td>
107 <td>int</td>
108 <td>
109 Describe the current state of a "togglable" item. Can be one of:
110 - 0 = off
111 - 1 = on
112 - anything else = indeterminate
113
114 Note:
115 The implementation does not itself handle ensuring that only one
116 item in a radio group is set to "on", or that a group does not have
117 "on" and "indeterminate" items simultaneously; maintaining this
118 policy is up to the toolkit wrappers.
119 </td>
120 <td>0</td>
121 </tr>
122 <tr>
123 <td>children-display</td>
124 <td>string</td>
125 <td>
126 If the menu item has children this property should be set to
127 "submenu".
128 </td>
129 <td>""</td>
130 </tr>
131 </table>
132
133 Vendor specific properties can be added by prefixing them with
134 "x-<vendor>-".
135 ]]></dox:d>
32136
33<!-- Properties -->137<!-- Properties -->
34<!--138 <property name="version" type="u" access="read">
35Provides the version of the DBusmenu API that this API is139 <dox:d>
36implementing.140 Provides the version of the DBusmenu API that this API is
37-->141 implementing.
38 <property name="version" type="u" access="read"/>142 </dox:d>
143 </property>
39144
40<!-- Functions -->145<!-- Functions -->
41146
42<!--147 <method name="GetLayout">
43Provides an XML representation of the menu hierarchy148 <dox:d><![CDATA[
44149 Provides an XML representation of the menu hierarchy
45@param parentId The ID of the parent node for the layout. For150
46 grabbing the layout from the root node use zero.151 XML syntax:
47@param revision The revision number of the layout. For matching152
48 with layoutUpdated signals.153 @verbatim
49@param layout The layout as an XML string of IDs.
50
51XML syntax:
52
53<menu id="1" revision="2"> # Root container154<menu id="1" revision="2"> # Root container
54 <menu id="2" revision="2"> # First level menu, for example "File"155 <menu id="2" revision="2"> # First level menu, for example "File"
55 <menu id="3" revision="2"/> ~ Second level menu, for example "Open"156 <menu id="3" revision="2"/> ~ Second level menu, for example "Open"
56 <menu id="4" revision="3"/>157 <menu id="4" revision="3"/>
57 ...158 ...
58 </menu>159 </menu>
59 <menu id="5" revision="2"> # Another first level menu, say "Edit"160 <menu id="5" revision="2"> # Another first level menu, say "Edit"
60 ...161 ...
61 </menu>162 </menu>
62 ...163 ...
63</menu>164</menu>
64-->165 @endverbatim
65 <method name="GetLayout">166 ]]></dox:d>
66 <arg type="u" name="parentId" direction="in" />167 <arg type="i" name="parentId" direction="in">
67 <arg type="u" name="revision" direction="out" />168 <dox:d>The ID of the parent node for the layout. For
68 <arg type="s" name="layout" direction="out" />169 grabbing the layout from the root node use zero.</dox:d>
170 </arg>
171 <arg type="u" name="revision" direction="out">
172 <dox:d>The revision number of the layout. For matching
173 with layoutUpdated signals.</dox:d>
174 </arg>
175 <arg type="s" name="layout" direction="out">
176 <dox:d>The layout as an XML string of IDs.</dox:d>
177 </arg>
69 </method>178 </method>
70179
71<!--
72Returns the list of items which are children of @a parentId.
73
74@param Ids A list of ids that we should be finding the properties
75 on. If the list is empty, all menu items should be sent.
76@param propertyNames list of string the list of item properties we
77 are interested in. If there are no entries in the list all of
78 the properties will be sent.
79
80An item is represented as a struct following this format:
81@li id unsigned the item id
82@li properties map(string => variant) the requested item properties
83
84-->
85 <method name="GetGroupProperties">180 <method name="GetGroupProperties">
86 <arg type="au" name="Ids" direction="in" />181 <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantList"/>
87 <arg type="as" name="propertyNames" direction="in" />182 <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="DBusMenuItemList"/>
88 <arg type="a(ua{sv})" name="properties" direction="out" />183 <dox:d>
184 Returns the list of items which are children of @a parentId.
185 </dox:d>
186 <arg type="ai" name="ids" direction="in" >
187 <dox:d>
188 A list of ids that we should be finding the properties
189 on. If the list is empty, all menu items should be sent.
190 </dox:d>
191 </arg>
192 <arg type="as" name="propertyNames" direction="in" >
193 <dox:d>
194 The list of item properties we are
195 interested in. If there are no entries in the list all of
196 the properties will be sent.
197 </dox:d>
198 </arg>
199 <arg type="a(ia{sv})" name="properties" direction="out" >
200 <dox:d>
201 An array of property values.
202 An item in this area is represented as a struct following
203 this format:
204 @li id unsigned the item id
205 @li properties map(string => variant) the requested item properties
206 </dox:d>
207 </arg>
89 </method>208 </method>
90209
91 <method name="GetChildren">210 <method name="GetChildren">
92 <arg type="u" name="id" direction="in" />211 <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="DBusMenuItemList"/>
212 <arg type="i" name="id" direction="in" />
93 <arg type="as" name="propertyNames" direction="in" />213 <arg type="as" name="propertyNames" direction="in" />
94 <arg type="a(ua{sv})" name="properties" direction="out" />214 <arg type="a(ia{sv})" name="properties" direction="out" />
95 </method>215 </method>
96216
97<!--
98Each menu item has a set of properties. Property keys are in menuitem.h:
99
100@li type string Type of the item (see below)
101@li label string Text of the item
102@li icon-data binary Raw data of the icon (TODO: define format)
103@li icon string Icon name of the item, following icon spec
104@li sensitive boolean Whether the item can be activated or not
105@li visible boolean Whether the item is visible or not (XXX: Is this necessary?)
106@li checked boolean Whether a checkbox or radio item is checked
107@li shortcut string The keyboard shortcut
108
109@c type property is an enum which can take the following values (client.h):
110
111@li action An item which can be clicked to trigger an action
112@li checkbox An item which can be checked or unchecked
113@li radio An item which can be checked or unchecked as part of a group
114@li separator A separator
115@li menu An item which contains more items
116-->
117 <method name="GetProperty">217 <method name="GetProperty">
118 <arg type="u" name="id" direction="in" />218 <arg type="i" name="id" direction="in" />
119 <arg type="s" name="name" direction="in" />219 <arg type="s" name="name" direction="in" />
120 <arg type="v" name="value" direction="out" />220 <arg type="v" name="value" direction="out" />
121 </method>221 </method>
122222
123<!--
124Returns multiple properties in one call. This is more efficient than
125GetProperty.
126
127@param id unsigned the item whose properties we want to retrieve.
128@param propertyNames list of string name of the properties we want. If the list contains no entries, all properties are sent.
129-->
130 <method name="GetProperties">223 <method name="GetProperties">
224 <dox:d>
225 Returns multiple properties in one call. This is more efficient than
226 GetProperty.
227
228 </dox:d>
131 <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>229 <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
132 <arg type="u" name="id" direction="in" />230 <arg type="i" name="id" direction="in" >
133 <arg type="as" name="propertyNames" direction="in" />231 <dox:d>The item whose properties we want to retrieve.</dox:d>
232 </arg>
233 <arg type="as" name="propertyNames" direction="in" >
234 <dox:d>List of string name of the properties we want. If the list contains no entries, all properties are sent.</dox:d>
235 </arg>
134 <arg type="a{sv}" name="properties" direction="out" />236 <arg type="a{sv}" name="properties" direction="out" />
135 </method>237 </method>
136238
137<!--
138This is called by the applet to notify the application an event happened on a
139menu item.
140
141@param id the id of the item which received the event
142@param type the type of event
143@param data event-specific data
144
145@a type can be one of the following:
146
147@li "clicked"
148@li "hovered"
149
150Vendor specific events can be added by prefixing them with "x-<vendor>-"
151-->
152 <method name="Event">239 <method name="Event">
153 <arg type="u" name="id" direction="in" />240 <dox:d><![CDATA[
154 <arg type="s" name="eventId" direction="in" />241 This is called by the applet to notify the application an event happened on a
155 <arg type="v" name="data" direction="in" />242 menu item.
243
244 @a type can be one of the following:
245
246 @li "clicked"
247 @li "hovered"
248
249 Vendor specific events can be added by prefixing them with "x-<vendor>-"
250 ]]></dox:d>
251 <arg type="i" name="id" direction="in" >
252 <dox:d>the id of the item which received the event</dox:d>
253 </arg>
254 <arg type="s" name="eventId" direction="in" >
255 <dox:d>the type of event</dox:d>
256 </arg>
257 <arg type="v" name="data" direction="in" >
258 <dox:d>event-specific data</dox:d>
259 </arg>
260 <arg type="u" name="timestamp" direction="in" >
261 <dox:d>The time that the event occured if available or the time the message was sent if not</dox:d>
262 </arg>
156 </method>263 </method>
157264
158<!-- Signals -->265<!-- Signals -->
159<!--
160Triggered by the application to notify the applet that the property @a property
161from item @a id has changed to @a value.
162-->
163 <signal name="ItemPropertyUpdated">266 <signal name="ItemPropertyUpdated">
164 <arg type="u" name="id" direction="out" />267 <dox:d>
268 Triggered by the application to notify the applet that the property @a property
269 from item @a id has changed to @a value.
270 </dox:d>
271 <arg type="i" name="id" direction="out" />
165 <arg type="s" name="prop" direction="out" />272 <arg type="s" name="prop" direction="out" />
166 <arg type="v" name="value" direction="out" />273 <arg type="v" name="value" direction="out" />
167 </signal>274 </signal>
168275
169<!--
170Triggered by the application to notify the applet that all properties of item
171@a id should be considered outdated
172-->
173 <signal name="ItemUpdated">276 <signal name="ItemUpdated">
174 <arg type="u" name="id" direction="out" />277 <dox:d>
278 Triggered by the application to notify the applet that all properties of item
279 </dox:d>
280 <arg type="i" name="id" direction="out" >
281 <dox:d>id which should be considered outdated</dox:d>
282 </arg>
175 </signal>283 </signal>
176284
177<!--285 <signal name="LayoutUpdated">
178Triggered by the application to notify display of a layout update, up to286 <dox:d>
179revision287 Triggered by the application to notify display of a layout update, up to
180@param revsion The revision of the layout that we're currently on288 revision
181@param parent If the layout update is only of a subtree, this is the parent289 </dox:d>
182 item for the entries that have changed. It is zero if the290 <arg type="u" name="revision" direction="out" >
183 whole layout should be considered invalid.291 <dox:d>The revision of the layout that we're currently on</dox:d>
184-->292 </arg>
185 <signal name="LayoutUpdate">293 <arg type="i" name="parent" direction="out" >
186 <arg type="i" name="revision" direction="out" />294 <dox:d>
187 <arg type="u" name="parent" direction="out" />295 If the layout update is only of a subtree, this is the
296 parent item for the entries that have changed. It is zero if
297 the whole layout should be considered invalid.
298 </dox:d>
299 </arg>
188 </signal>300 </signal>
189301
190<!-- End of interesting stuff -->302<!-- End of interesting stuff -->
191303
=== modified file 'libdbusmenu-glib/menuitem-marshal.list'
--- libdbusmenu-glib/menuitem-marshal.list 2009-12-19 03:58:26 +0000
+++ libdbusmenu-glib/menuitem-marshal.list 2010-02-04 20:30:33 +0000
@@ -3,3 +3,4 @@
3VOID: OBJECT, UINT3VOID: OBJECT, UINT
4VOID: OBJECT4VOID: OBJECT
5VOID: VOID5VOID: VOID
6VOID: UINT
67
=== modified file 'libdbusmenu-glib/menuitem-private.h'
--- libdbusmenu-glib/menuitem-private.h 2009-11-13 18:02:08 +0000
+++ libdbusmenu-glib/menuitem-private.h 2010-02-04 20:30:33 +0000
@@ -33,7 +33,7 @@
3333
34G_BEGIN_DECLS34G_BEGIN_DECLS
3535
36void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array, gint revision);36void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array);
3737
38G_END_DECLS38G_END_DECLS
3939
4040
=== modified file 'libdbusmenu-glib/menuitem.c'
--- libdbusmenu-glib/menuitem.c 2009-12-21 22:15:45 +0000
+++ libdbusmenu-glib/menuitem.c 2010-02-04 20:30:33 +0000
@@ -55,7 +55,7 @@
55typedef struct _DbusmenuMenuitemPrivate DbusmenuMenuitemPrivate;55typedef struct _DbusmenuMenuitemPrivate DbusmenuMenuitemPrivate;
56struct _DbusmenuMenuitemPrivate56struct _DbusmenuMenuitemPrivate
57{57{
58 guint id;58 gint id;
59 GList * children;59 GList * children;
60 GHashTable * properties;60 GHashTable * properties;
61 gboolean root;61 gboolean root;
@@ -92,6 +92,7 @@
92static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);92static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec);
93static void g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out);93static void g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out);
94static void g_value_transform_STRING_INT (const GValue * in, GValue * out);94static void g_value_transform_STRING_INT (const GValue * in, GValue * out);
95static void handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp);
9596
96/* GObject stuff */97/* GObject stuff */
97G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT);98G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT);
@@ -108,6 +109,8 @@
108 object_class->set_property = set_property;109 object_class->set_property = set_property;
109 object_class->get_property = get_property;110 object_class->get_property = get_property;
110111
112 klass->handle_event = handle_event;
113
111 /**114 /**
112 DbusmenuMenuitem::property-changed:115 DbusmenuMenuitem::property-changed:
113 @arg0: The #DbusmenuMenuitem object.116 @arg0: The #DbusmenuMenuitem object.
@@ -127,6 +130,7 @@
127 /**130 /**
128 DbusmenuMenuitem::item-activated:131 DbusmenuMenuitem::item-activated:
129 @arg0: The #DbusmenuMenuitem object.132 @arg0: The #DbusmenuMenuitem object.
133 @arg1: The timestamp of when it was activated
130134
131 Emitted on the objects on the server side when135 Emitted on the objects on the server side when
132 they are signaled on the client side.136 they are signaled on the client side.
@@ -136,8 +140,8 @@
136 G_SIGNAL_RUN_LAST,140 G_SIGNAL_RUN_LAST,
137 G_STRUCT_OFFSET(DbusmenuMenuitemClass, item_activated),141 G_STRUCT_OFFSET(DbusmenuMenuitemClass, item_activated),
138 NULL, NULL,142 NULL, NULL,
139 _dbusmenu_menuitem_marshal_VOID__VOID,143 _dbusmenu_menuitem_marshal_VOID__UINT,
140 G_TYPE_NONE, 0, G_TYPE_NONE);144 G_TYPE_NONE, 1, G_TYPE_UINT, G_TYPE_NONE);
141 /**145 /**
142 DbusmenuMenuitem::child-added:146 DbusmenuMenuitem::child-added:
143 @arg0: The #DbusmenuMenuitem which is the parent.147 @arg0: The #DbusmenuMenuitem which is the parent.
@@ -206,7 +210,7 @@
206 G_TYPE_NONE, 0, G_TYPE_NONE);210 G_TYPE_NONE, 0, G_TYPE_NONE);
207211
208 g_object_class_install_property (object_class, PROP_ID,212 g_object_class_install_property (object_class, PROP_ID,
209 g_param_spec_uint("id", "ID for the menu item",213 g_param_spec_int("id", "ID for the menu item",
210 "This is a unique indentifier for the menu item.",214 "This is a unique indentifier for the menu item.",
211 0, 30000, 0,215 0, 30000, 0,
212 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));216 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
@@ -245,7 +249,7 @@
245 return;249 return;
246}250}
247251
248static guint menuitem_next_id = 1;252static gint menuitem_next_id = 0;
249253
250/* A small little function to both clear the insides of a 254/* A small little function to both clear the insides of a
251 value as well as the memory it itself uses. */255 value as well as the memory it itself uses. */
@@ -314,9 +318,9 @@
314318
315 switch (id) {319 switch (id) {
316 case PROP_ID:320 case PROP_ID:
317 priv->id = g_value_get_uint(value);321 priv->id = g_value_get_int(value);
318 if (priv->id > menuitem_next_id) {322 if (priv->id > menuitem_next_id) {
319 menuitem_next_id = priv->id;323 menuitem_next_id = priv->id + 1;
320 }324 }
321 break;325 break;
322 }326 }
@@ -331,16 +335,23 @@
331335
332 switch (id) {336 switch (id) {
333 case PROP_ID:337 case PROP_ID:
334 if (priv->id == 0) {338 g_value_set_int(value, priv->id);
335 priv->id = menuitem_next_id++;
336 }
337 g_value_set_uint(value, priv->id);
338 break;339 break;
339 }340 }
340341
341 return;342 return;
342}343}
343344
345/* Handles the activate event if it is sent. */
346static void
347handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp)
348{
349 if (g_strcmp0(name, "clicked") == 0) {
350 g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, timestamp, TRUE);
351 }
352
353 return;
354}
344355
345/* Public interface */356/* Public interface */
346357
@@ -354,7 +365,7 @@
354DbusmenuMenuitem *365DbusmenuMenuitem *
355dbusmenu_menuitem_new (void)366dbusmenu_menuitem_new (void)
356{367{
357 return g_object_new(DBUSMENU_TYPE_MENUITEM, NULL);368 return g_object_new(DBUSMENU_TYPE_MENUITEM, "id", menuitem_next_id++, NULL);
358}369}
359370
360/**371/**
@@ -366,7 +377,7 @@
366 Return value: A newly allocated #DbusmenuMenuitem.377 Return value: A newly allocated #DbusmenuMenuitem.
367*/378*/
368DbusmenuMenuitem *379DbusmenuMenuitem *
369dbusmenu_menuitem_new_with_id (guint id)380dbusmenu_menuitem_new_with_id (gint id)
370{381{
371 DbusmenuMenuitem * mi = g_object_new(DBUSMENU_TYPE_MENUITEM, "id", id, NULL);382 DbusmenuMenuitem * mi = g_object_new(DBUSMENU_TYPE_MENUITEM, "id", id, NULL);
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); */
@@ -641,7 +652,7 @@
641 can't be found.652 can't be found.
642*/653*/
643DbusmenuMenuitem *654DbusmenuMenuitem *
644dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, guint id)655dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, gint id)
645{656{
646 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL);657 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL);
647658
@@ -660,7 +671,7 @@
660671
661typedef struct {672typedef struct {
662 DbusmenuMenuitem * mi;673 DbusmenuMenuitem * mi;
663 guint id;674 gint id;
664} find_id_t;675} find_id_t;
665676
666/* Basically the heart of the find_id that matches the677/* Basically the heart of the find_id that matches the
@@ -696,7 +707,7 @@
696 represented by @mi.707 represented by @mi.
697*/708*/
698DbusmenuMenuitem *709DbusmenuMenuitem *
699dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id)710dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id)
700{711{
701 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL);712 g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL);
702 find_id_t find_id = {mi: NULL, id: id};713 find_id_t find_id = {mi: NULL, id: id};
@@ -1047,7 +1058,6 @@
1047 dbusmenu_menuitem_buildxml:1058 dbusmenu_menuitem_buildxml:
1048 @mi: #DbusmenuMenuitem to represent in XML1059 @mi: #DbusmenuMenuitem to represent in XML
1049 @array: A list of string that will be turned into an XML file1060 @array: A list of string that will be turned into an XML file
1050 @revision: The revision of the layout to embed in the XML
10511061
1052 This function will add strings to the array @array. It will put1062 This function will add strings to the array @array. It will put
1053 at least one entry if this menu item has no children. If it has1063 at least one entry if this menu item has no children. If it has
@@ -1056,18 +1066,22 @@
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.
1057*/1067*/
1058void1068void
1059dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array, gint revision)1069dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array)
1060{1070{
1061 g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));1071 g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));
10621072
1073 gint id = 0;
1074 if (!dbusmenu_menuitem_get_root(mi)) {
1075 id = dbusmenu_menuitem_get_id(mi);
1076 }
1077
1063 GList * children = dbusmenu_menuitem_get_children(mi);1078 GList * children = dbusmenu_menuitem_get_children(mi);
1064 /* TODO: Only put revision info in the root node. Save some bandwidth. */
1065 if (children == NULL) {1079 if (children == NULL) {
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));
1067 } else {1081 } else {
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));
1069 for ( ; children != NULL; children = children->next) {1083 for ( ; children != NULL; children = children->next) {
1070 dbusmenu_menuitem_buildxml(DBUSMENU_MENUITEM(children->data), array, revision);1084 dbusmenu_menuitem_buildxml(DBUSMENU_MENUITEM(children->data), array);
1071 }1085 }
1072 g_ptr_array_add(array, g_strdup("</menu>"));1086 g_ptr_array_add(array, g_strdup("</menu>"));
1073 }1087 }
@@ -1112,20 +1126,35 @@
1112}1126}
11131127
1114/**1128/**
1115 dbusmenu_menuitem_activate:1129 dbusmenu_menuitem_handle_event:
1116 @mi: The #DbusmenuMenuitem to send the signal on.1130 @mi: The #DbusmenuMenuitem to send the signal on.
1131 @name: The name of the signal
1132 @value: A value that could be set for the event
1133 @timestamp: The timestamp of when the event happened
1134
1135 This function is called to create an event. It is likely
1136 to be overrided by subclasses. The default menu item
1137 will respond to the activate signal and do:
11171138
1118 Emits the #DbusmenuMenuitem::item-activate signal on this1139 Emits the #DbusmenuMenuitem::item-activate signal on this
1119 menu item. Called by server objects when they get the1140 menu item. Called by server objects when they get the
1120 appropriate DBus signals from the client.1141 appropriate DBus signals from the client.
1142
1143 If you subclass this function you should really think
1144 about calling the parent function unless you have a good
1145 reason not to.
1121*/1146*/
1122void1147void
1123dbusmenu_menuitem_activate (DbusmenuMenuitem * mi)1148dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp)
1124{1149{
1125 g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));1150 g_return_if_fail(DBUSMENU_IS_MENUITEM(mi));
1126 #ifdef MASSIVEDEBUGGING1151 #ifdef MASSIVEDEBUGGING
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);
1128 #endif1153 #endif
1129 g_signal_emit(G_OBJECT(mi), signals[ITEM_ACTIVATED], 0, TRUE);1154 DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi);
1155
1156 if (class->handle_event != NULL) {
1157 return class->handle_event(mi, name, value, timestamp);
1158 }
1130 return;1159 return;
1131}1160}
11321161
=== modified file 'libdbusmenu-glib/menuitem.h'
--- libdbusmenu-glib/menuitem.h 2010-01-07 16:49:35 +0000
+++ libdbusmenu-glib/menuitem.h 2010-02-04 20:30:33 +0000
@@ -52,19 +52,19 @@
5252
53#define DBUSMENU_MENUITEM_PROP_TYPE "type"53#define DBUSMENU_MENUITEM_PROP_TYPE "type"
54#define DBUSMENU_MENUITEM_PROP_VISIBLE "visible"54#define DBUSMENU_MENUITEM_PROP_VISIBLE "visible"
55#define DBUSMENU_MENUITEM_PROP_SENSITIVE "sensitive"55#define DBUSMENU_MENUITEM_PROP_ENABLED "enabled"
56#define DBUSMENU_MENUITEM_PROP_LABEL "label"56#define DBUSMENU_MENUITEM_PROP_LABEL "label"
57#define DBUSMENU_MENUITEM_PROP_ICON "icon"57#define DBUSMENU_MENUITEM_PROP_ICON_NAME "icon-name"
58#define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data"58#define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data"
59#define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type"59#define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type"
60#define DBUSMENU_MENUITEM_PROP_TOGGLE_CHECKED "toggle-checked"60#define DBUSMENU_MENUITEM_PROP_TOGGLE_STATE "toggle-state"
6161
62#define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark"62#define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark"
63#define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio"63#define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio"
6464
65#define DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED "unchecked"65#define DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED 0
66#define DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED "checked"66#define DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED 1
67#define DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN "indeterminate"67#define DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN -1
6868
69/**69/**
70 DbusmenuMenuitem:70 DbusmenuMenuitem:
@@ -92,6 +92,9 @@
92 @realized: Slot for #DbusmenuMenuitem::realized.92 @realized: Slot for #DbusmenuMenuitem::realized.
93 @buildxml: Virtual function that appends the strings required93 @buildxml: Virtual function that appends the strings required
94 to represent this menu item in the menu XML file.94 to represent this menu item in the menu XML file.
95 @handle_event: This function is to override how events are handled
96 by subclasses. Look at #dbusmenu_menuitem_handle_event for
97 lots of good information.
95 @reserved1: Reserved for future use.98 @reserved1: Reserved for future use.
96 @reserved2: Reserved for future use.99 @reserved2: Reserved for future use.
97 @reserved3: Reserved for future use.100 @reserved3: Reserved for future use.
@@ -104,7 +107,7 @@
104107
105 /* Signals */108 /* Signals */
106 void (*property_changed) (gchar * property, GValue * value);109 void (*property_changed) (gchar * property, GValue * value);
107 void (*item_activated) (void);110 void (*item_activated) (guint timestamp);
108 void (*child_added) (DbusmenuMenuitem * child, guint position);111 void (*child_added) (DbusmenuMenuitem * child, guint position);
109 void (*child_removed) (DbusmenuMenuitem * child);112 void (*child_removed) (DbusmenuMenuitem * child);
110 void (*child_moved) (DbusmenuMenuitem * child, guint newpos, guint oldpos);113 void (*child_moved) (DbusmenuMenuitem * child, guint newpos, guint oldpos);
@@ -112,17 +115,18 @@
112115
113 /* Virtual functions */116 /* Virtual functions */
114 void (*buildxml) (GPtrArray * stringarray);117 void (*buildxml) (GPtrArray * stringarray);
118 void (*handle_event) (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp);
115119
116 void (*reserved1) (void);120 void (*reserved1) (void);
117 void (*reserved2) (void);121 void (*reserved2) (void);
118 void (*reserved3) (void);122 /* void (*reserved3) (void); */
119 /* void (*reserved4) (void); -- realized, realloc when bumping lib version */123 /* void (*reserved4) (void); -- realized, realloc when bumping lib version */
120};124};
121125
122GType dbusmenu_menuitem_get_type (void);126GType dbusmenu_menuitem_get_type (void);
123127
124DbusmenuMenuitem * dbusmenu_menuitem_new (void) G_GNUC_WARN_UNUSED_RESULT;128DbusmenuMenuitem * dbusmenu_menuitem_new (void) G_GNUC_WARN_UNUSED_RESULT;
125DbusmenuMenuitem * dbusmenu_menuitem_new_with_id (guint id) G_GNUC_WARN_UNUSED_RESULT;129DbusmenuMenuitem * dbusmenu_menuitem_new_with_id (gint id) G_GNUC_WARN_UNUSED_RESULT;
126guint dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi);130guint dbusmenu_menuitem_get_id (DbusmenuMenuitem * mi);
127131
128GList * dbusmenu_menuitem_get_children (DbusmenuMenuitem * mi);132GList * dbusmenu_menuitem_get_children (DbusmenuMenuitem * mi);
@@ -134,8 +138,8 @@
134gboolean dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child);138gboolean dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child);
135gboolean dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position);139gboolean dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position);
136gboolean dbusmenu_menuitem_child_reorder (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position);140gboolean dbusmenu_menuitem_child_reorder (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position);
137DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, guint id);141DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, gint id);
138DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id);142DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id);
139143
140gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value);144gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value);
141gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value);145gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value);
@@ -153,7 +157,7 @@
153gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi);157gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi);
154158
155void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data);159void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data);
156void dbusmenu_menuitem_activate (DbusmenuMenuitem * mi);160void dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, guint timestamp);
157161
158/**162/**
159 SECTION:menuitem163 SECTION:menuitem
160164
=== modified file 'libdbusmenu-glib/server-marshal.list'
--- libdbusmenu-glib/server-marshal.list 2009-12-09 17:17:32 +0000
+++ libdbusmenu-glib/server-marshal.list 2010-02-04 20:30:33 +0000
@@ -1,2 +1,2 @@
1VOID: UINT, STRING, POINTER1VOID: UINT, STRING, POINTER
2VOID: INT, UINT2VOID: UINT, INT
33
=== modified file 'libdbusmenu-glib/server.c'
--- libdbusmenu-glib/server.c 2009-12-24 10:31:16 +0000
+++ libdbusmenu-glib/server.c 2010-02-04 20:30:33 +0000
@@ -35,16 +35,16 @@
35#include "server-marshal.h"35#include "server-marshal.h"
3636
37/* DBus Prototypes */37/* DBus Prototypes */
38static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, guint parent, guint * revision, gchar ** layout, GError ** error);38static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, gint parent, guint * revision, gchar ** layout, GError ** error);
39static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * property, gchar ** value, GError ** error);39static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, gint id, gchar * property, gchar ** value, GError ** error);
40static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * properties, GHashTable ** dict, GError ** error);40static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, gint id, GPtrArray * properties, GHashTable ** dict, GError ** error);
41static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error);41static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error);
42static gboolean _dbusmenu_server_event (DbusmenuServer * server, guint id, gchar * eventid, GValue * data, GError ** error);42static gboolean _dbusmenu_server_event (DbusmenuServer * server, gint id, gchar * eventid, GValue * data, guint timestamp, GError ** error);
43static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, guint id, GPtrArray * properties, GPtrArray ** output, GError ** error);43static gboolean _dbusmenu_server_get_children (DbusmenuServer * server, gint id, GPtrArray * properties, GPtrArray ** output, GError ** error);
4444
45#include "dbusmenu-server.h"45#include "dbusmenu-server.h"
4646
47#define DBUSMENU_VERSION_NUMBER 147#define DBUSMENU_VERSION_NUMBER 2
4848
49/* Privates, I'll show you mine... */49/* Privates, I'll show you mine... */
50typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate;50typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate;
@@ -63,7 +63,7 @@
63enum {63enum {
64 ID_PROP_UPDATE,64 ID_PROP_UPDATE,
65 ID_UPDATE,65 ID_UPDATE,
66 LAYOUT_UPDATE,66 LAYOUT_UPDATED,
67 LAST_SIGNAL67 LAST_SIGNAL
68};68};
6969
@@ -148,7 +148,7 @@
148 g_cclosure_marshal_VOID__UINT,148 g_cclosure_marshal_VOID__UINT,
149 G_TYPE_NONE, 1, G_TYPE_UINT);149 G_TYPE_NONE, 1, G_TYPE_UINT);
150 /**150 /**
151 DbusmenuServer::layout-update:151 DbusmenuServer::layout-updated:
152 @arg0: The #DbusmenuServer emitting the signal.152 @arg0: The #DbusmenuServer emitting the signal.
153 @arg1: A revision number representing which revision the update153 @arg1: A revision number representing which revision the update
154 represents itself as.154 represents itself as.
@@ -157,13 +157,13 @@
157 This signal is emitted any time the layout of the157 This signal is emitted any time the layout of the
158 menuitems under this server is changed.158 menuitems under this server is changed.
159 */159 */
160 signals[LAYOUT_UPDATE] = g_signal_new(DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE,160 signals[LAYOUT_UPDATED] = g_signal_new(DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED,
161 G_TYPE_FROM_CLASS(class),161 G_TYPE_FROM_CLASS(class),
162 G_SIGNAL_RUN_LAST,162 G_SIGNAL_RUN_LAST,
163 G_STRUCT_OFFSET(DbusmenuServerClass, layout_update),163 G_STRUCT_OFFSET(DbusmenuServerClass, layout_updated),
164 NULL, NULL,164 NULL, NULL,
165 _dbusmenu_server_marshal_VOID__INT_UINT,165 _dbusmenu_server_marshal_VOID__UINT_INT,
166 G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_UINT);166 G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_INT);
167167
168168
169 g_object_class_install_property (object_class, PROP_DBUS_OBJECT,169 g_object_class_install_property (object_class, PROP_DBUS_OBJECT,
@@ -248,7 +248,7 @@
248 g_debug("Setting root node to NULL");248 g_debug("Setting root node to NULL");
249 }249 }
250 priv->layout_revision++;250 priv->layout_revision++;
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);
252 break;252 break;
253 default:253 default:
254 g_return_if_reached();254 g_return_if_reached();
@@ -306,7 +306,7 @@
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. */
307 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);307 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
308 priv->layout_revision++;308 priv->layout_revision++;
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);
310 return;310 return;
311}311}
312312
@@ -317,7 +317,7 @@
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. */
318 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);318 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
319 priv->layout_revision++;319 priv->layout_revision++;
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);
321 return;321 return;
322}322}
323323
@@ -326,7 +326,7 @@
326{326{
327 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);327 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
328 priv->layout_revision++;328 priv->layout_revision++;
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);
330 return;330 return;
331}331}
332332
@@ -366,7 +366,7 @@
366366
367/* DBus interface */367/* DBus interface */
368static gboolean368static gboolean
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)
370{370{
371 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);371 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
372372
@@ -376,13 +376,13 @@
376 if (parent == 0) {376 if (parent == 0) {
377 if (priv->root == NULL) {377 if (priv->root == NULL) {
378 /* g_debug("Getting layout without root node!"); */378 /* g_debug("Getting layout without root node!"); */
379 g_ptr_array_add(xmlarray, g_strdup_printf("<menu revision=\"%d\" />", priv->layout_revision));379 g_ptr_array_add(xmlarray, g_strdup("<menu/>"));
380 } else {380 } else {
381 dbusmenu_menuitem_buildxml(priv->root, xmlarray, priv->layout_revision);381 dbusmenu_menuitem_buildxml(priv->root, xmlarray);
382 }382 }
383 } else {383 } else {
384 DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent);384 DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent);
385 dbusmenu_menuitem_buildxml(item, xmlarray, priv->layout_revision);385 dbusmenu_menuitem_buildxml(item, xmlarray);
386 }386 }
387 g_ptr_array_add(xmlarray, NULL);387 g_ptr_array_add(xmlarray, NULL);
388388
@@ -396,7 +396,7 @@
396}396}
397397
398static gboolean 398static gboolean
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)
400{400{
401 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);401 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
402 DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);402 DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);
@@ -441,7 +441,7 @@
441}441}
442442
443static gboolean443static gboolean
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)
445{445{
446 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);446 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
447 DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);447 DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);
@@ -475,12 +475,12 @@
475}475}
476476
477static void477static void
478_gvalue_array_append_uint(GValueArray *array, guint i)478_gvalue_array_append_int(GValueArray *array, gint i)
479{479{
480 GValue value = {0};480 GValue value = {0};
481481
482 g_value_init(&value, G_TYPE_UINT);482 g_value_init(&value, G_TYPE_INT);
483 g_value_set_uint(&value, i);483 g_value_set_int(&value, i);
484 g_value_array_append(array, &value);484 g_value_array_append(array, &value);
485 g_value_unset(&value);485 g_value_unset(&value);
486}486}
@@ -502,18 +502,18 @@
502 DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data);502 DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(data);
503 GPtrArray * output = (GPtrArray *)(user_data);503 GPtrArray * output = (GPtrArray *)(user_data);
504504
505 guint id = dbusmenu_menuitem_get_id(mi);505 gint id = dbusmenu_menuitem_get_id(mi);
506 GHashTable * dict = dbusmenu_menuitem_properties_copy(mi);506 GHashTable * dict = dbusmenu_menuitem_properties_copy(mi);
507507
508 GValueArray * item = g_value_array_new(1);508 GValueArray * item = g_value_array_new(1);
509 _gvalue_array_append_uint(item, id);509 _gvalue_array_append_int(item, id);
510 _gvalue_array_append_hashtable(item, dict);510 _gvalue_array_append_hashtable(item, dict);
511511
512 g_ptr_array_add(output, item);512 g_ptr_array_add(output, item);
513}513}
514514
515static gboolean515static gboolean
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)
517{517{
518 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);518 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
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);
@@ -537,7 +537,7 @@
537}537}
538538
539static gboolean539static gboolean
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)
541{541{
542 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);542 DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server);
543 DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);543 DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);
@@ -553,7 +553,7 @@
553 return FALSE;553 return FALSE;
554 }554 }
555555
556 dbusmenu_menuitem_activate(mi);556 dbusmenu_menuitem_handle_event(mi, eventid, data, timestamp);
557 return TRUE;557 return TRUE;
558}558}
559559
560560
=== modified file 'libdbusmenu-glib/server.h'
--- libdbusmenu-glib/server.h 2009-12-09 19:58:32 +0000
+++ libdbusmenu-glib/server.h 2010-02-04 20:30:33 +0000
@@ -45,7 +45,8 @@
4545
46#define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "item-property-updated"46#define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "item-property-updated"
47#define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "item-updated"47#define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "item-updated"
48#define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE "layout-update"48#define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED "layout-updated"
49#define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED
4950
50#define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object"51#define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object"
51#define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node"52#define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node"
@@ -56,7 +57,7 @@
56 @parent_class: #GObjectClass57 @parent_class: #GObjectClass
57 @id_prop_update: Slot for #DbusmenuServer::id-prop-update.58 @id_prop_update: Slot for #DbusmenuServer::id-prop-update.
58 @id_update: Slot for #DbusmenuServer::id-update.59 @id_update: Slot for #DbusmenuServer::id-update.
59 @layout_update: Slot for #DbusmenuServer::layout-update.60 @layout_updated: Slot for #DbusmenuServer::layout-update.
60 @dbusmenu_server_reserved1: Reserved for future use.61 @dbusmenu_server_reserved1: Reserved for future use.
61 @dbusmenu_server_reserved2: Reserved for future use.62 @dbusmenu_server_reserved2: Reserved for future use.
62 @dbusmenu_server_reserved3: Reserved for future use.63 @dbusmenu_server_reserved3: Reserved for future use.
@@ -69,9 +70,9 @@
69 GObjectClass parent_class;70 GObjectClass parent_class;
7071
71 /* Signals */72 /* Signals */
72 void (*id_prop_update)(guint id, gchar * property, gchar * value);73 void (*id_prop_update)(gint id, gchar * property, gchar * value);
73 void (*id_update)(guint id);74 void (*id_update)(gint id);
74 void (*layout_update)(gint revision);75 void (*layout_updated)(gint revision);
7576
76 /* Reserved */77 /* Reserved */
77 void (*dbusmenu_server_reserved1)(void);78 void (*dbusmenu_server_reserved1)(void);
7879
=== modified file 'libdbusmenu-gtk/client.c'
--- libdbusmenu-gtk/client.c 2010-01-11 18:42:55 +0000
+++ libdbusmenu-gtk/client.c 2010-02-04 20:30:33 +0000
@@ -109,7 +109,10 @@
109static gboolean109static gboolean
110menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi)110menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi)
111{111{
112 dbusmenu_menuitem_activate(mi);112 GValue value = {0};
113 g_value_init(&value, G_TYPE_INT);
114 g_value_set_int(&value, 0);
115 dbusmenu_menuitem_handle_event(mi, "clicked", &value, gtk_get_current_event_time());
113 return TRUE;116 return TRUE;
114}117}
115118
@@ -136,7 +139,7 @@
136{139{
137 gboolean val = TRUE;140 gboolean val = TRUE;
138 if (value != NULL) {141 if (value != NULL) {
139 val = dbusmenu_menuitem_property_get_bool(mi, DBUSMENU_MENUITEM_PROP_SENSITIVE);142 val = dbusmenu_menuitem_property_get_bool(mi, DBUSMENU_MENUITEM_PROP_ENABLED);
140 }143 }
141 gtk_widget_set_sensitive(GTK_WIDGET(gmi), val);144 gtk_widget_set_sensitive(GTK_WIDGET(gmi), val);
142 return;145 return;
@@ -147,17 +150,23 @@
147process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value)150process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value)
148{151{
149 if (!IS_GENERICMENUITEM(gmi)) return;152 if (!IS_GENERICMENUITEM(gmi)) return;
153 if (value == NULL) return;
150154
151 GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE;155 GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE;
152156
153 if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) {157 GValue strvalue = {0};
154 const gchar * strval = g_value_get_string(value);158 g_value_init(&strvalue, G_TYPE_STRING);
159
160 if (value != NULL && g_value_transform(value, &strvalue)) {
161 const gchar * strval = g_value_get_string(&strvalue);
155162
156 if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_CHECK)) {163 if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_CHECK)) {
157 type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX;164 type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX;
158 } else if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_RADIO)) {165 } else if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_RADIO)) {
159 type = GENERICMENUITEM_CHECK_TYPE_RADIO;166 type = GENERICMENUITEM_CHECK_TYPE_RADIO;
160 }167 }
168
169 g_value_unset(&strvalue);
161 }170 }
162171
163 genericmenuitem_set_check_type(GENERICMENUITEM(gmi), type);172 genericmenuitem_set_check_type(GENERICMENUITEM(gmi), type);
@@ -167,18 +176,21 @@
167176
168/* Process the sensitive property */177/* Process the sensitive property */
169static void178static void
170process_toggle_checked (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value)179process_toggle_state (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value)
171{180{
172 if (!IS_GENERICMENUITEM(gmi)) return;181 if (!IS_GENERICMENUITEM(gmi)) return;
173182
174 GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED;183 GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED;
175184
176 if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) {185 GValue intvalue = {0};
177 const gchar * strval = g_value_get_string(value);186 g_value_init(&intvalue, G_TYPE_INT);
178187
179 if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED)) {188 if (value != NULL && g_value_transform(value, &intvalue)) {
189 int val = g_value_get_int(&intvalue);
190
191 if (val == DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED) {
180 state = GENERICMENUITEM_STATE_CHECKED;192 state = GENERICMENUITEM_STATE_CHECKED;
181 } else if (!g_strcmp0(strval, DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN)) {193 } else if (val == DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN) {
182 state = GENERICMENUITEM_STATE_INDETERMINATE;194 state = GENERICMENUITEM_STATE_INDETERMINATE;
183 }195 }
184 }196 }
@@ -196,12 +208,12 @@
196 gtk_menu_item_set_label(gmi, g_value_get_string(value));208 gtk_menu_item_set_label(gmi, g_value_get_string(value));
197 } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) {209 } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) {
198 process_visible(mi, gmi, value);210 process_visible(mi, gmi, value);
199 } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SENSITIVE)) {211 } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_ENABLED)) {
200 process_sensitive(mi, gmi, value);212 process_sensitive(mi, gmi, value);
201 } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)) {213 } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)) {
202 process_toggle_type(mi, gmi, value);214 process_toggle_type(mi, gmi, value);
203 } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_CHECKED)) {215 } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_STATE)) {
204 process_toggle_checked(mi, gmi, value);216 process_toggle_state(mi, gmi, value);
205 }217 }
206218
207 return;219 return;
@@ -284,9 +296,9 @@
284296
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 */
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));
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));
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));
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));
290302
291 /* Oh, we're a child, let's deal with that */303 /* Oh, we're a child, let's deal with that */
292 if (parent != NULL) {304 if (parent != NULL) {
@@ -426,8 +438,8 @@
426 }438 }
427439
428 image_property_handle(newitem,440 image_property_handle(newitem,
429 DBUSMENU_MENUITEM_PROP_ICON,441 DBUSMENU_MENUITEM_PROP_ICON_NAME,
430 dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON),442 dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON_NAME),
431 client);443 client);
432 image_property_handle(newitem,444 image_property_handle(newitem,
433 DBUSMENU_MENUITEM_PROP_ICON_DATA,445 DBUSMENU_MENUITEM_PROP_ICON_DATA,
@@ -468,7 +480,10 @@
468image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata)480image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata)
469{481{
470 /* We're only looking at these two properties here */482 /* We're only looking at these two properties here */
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 &&
484 g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_DATA) != 0) {
485 return;
486 }
472487
473 const gchar * value = NULL;488 const gchar * value = NULL;
474 489
@@ -479,10 +494,10 @@
479 if (value == NULL || value[0] == '\0') {494 if (value == NULL || value[0] == '\0') {
480 /* This means that we're unsetting a value. */495 /* This means that we're unsetting a value. */
481 /* Try to use the other one */496 /* Try to use the other one */
482 if (g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON)) {497 if (g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_NAME)) {
483 property = DBUSMENU_MENUITEM_PROP_ICON_DATA;498 property = DBUSMENU_MENUITEM_PROP_ICON_DATA;
484 } else {499 } else {
485 property = DBUSMENU_MENUITEM_PROP_ICON;500 property = DBUSMENU_MENUITEM_PROP_ICON_NAME;
486 }501 }
487 }502 }
488503
@@ -504,7 +519,7 @@
504 }519 }
505520
506 /* Now figure out what to change */521 /* Now figure out what to change */
507 if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON)) {522 if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_NAME)) {
508 const gchar * iconname = dbusmenu_menuitem_property_get(item, property);523 const gchar * iconname = dbusmenu_menuitem_property_get(item, property);
509 if (iconname == NULL) {524 if (iconname == NULL) {
510 /* If there is no name, by golly we want no525 /* If there is no name, by golly we want no
511526
=== modified file 'tests/test-gtk-label-server.c'
--- tests/test-gtk-label-server.c 2009-09-02 20:13:15 +0000
+++ tests/test-gtk-label-server.c 2010-02-04 20:30:33 +0000
@@ -32,9 +32,9 @@
32#include <json-glib/json-glib.h>32#include <json-glib/json-glib.h>
3333
34static void34static void
35menuitem_click(DbusmenuMenuitem * mi, gpointer user_data)35menuitem_click(DbusmenuMenuitem * mi, guint32 time, gpointer user_data)
36{36{
37 g_debug("Clicked on: %d", dbusmenu_menuitem_get_id(mi));37 g_debug("Clicked on: %d @ %d", dbusmenu_menuitem_get_id(mi), time);
38 return;38 return;
39}39}
4040
@@ -53,7 +53,10 @@
53 JsonNode * lnode = json_object_get_member(node, member);53 JsonNode * lnode = json_object_get_member(node, member);
54 if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; }54 if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; }
5555
56 dbusmenu_menuitem_property_set(mi, member, json_node_get_string(lnode));56 GValue value = {0};
57 json_node_get_value(lnode, &value);
58 dbusmenu_menuitem_property_set_value(mi, member, &value);
59 g_value_unset(&value);
57 }60 }
5861
59 return;62 return;
6063
=== modified file 'tests/test-gtk-label.json'
--- tests/test-gtk-label.json 2010-01-07 16:40:45 +0000
+++ tests/test-gtk-label.json 2010-02-04 20:30:33 +0000
@@ -1,256 +1,256 @@
1[1[
2 {"id": 1, "type": "menuitem",2 {"id": 1, "type": "standard",
3 "label": "value1",3 "label": "value1",
4 "submenu": [4 "submenu": [
5 {"id": 30, "type": "menuitem",5 {"id": 30, "type": "standard",
6 "label": "value30"},6 "label": "value30"},
7 {"id": 31, "type": "menuitem",7 {"id": 31, "type": "standard",
8 "label": "value31"},8 "label": "value31"},
9 {"id": 32, "type": "menuitem",9 {"id": 32, "type": "standard",
10 "label": "value32"},10 "label": "value32"},
11 {"id": 33, "type": "menuitem",11 {"id": 33, "type": "standard",
12 "label": "value33"},12 "label": "value33"},
13 {"id": 34, "type": "menuitem",13 {"id": 34, "type": "standard",
14 "label": "value34"},14 "label": "value34"},
15 {"id": 35, "type": "menuitem",15 {"id": 35, "type": "standard",
16 "label": "value35"},16 "label": "value35"},
17 {"id": 36, "type": "menuitem",17 {"id": 36, "type": "standard",
18 "label": "value36"},18 "label": "value36"},
19 {"id": 37, "type": "menuitem",19 {"id": 37, "type": "standard",
20 "label": "value37"},20 "label": "value37"},
21 {"id": 38, "type": "menuitem",21 {"id": 38, "type": "standard",
22 "label": "value38"},22 "label": "value38"},
23 {"id": 39, "type": "menuitem",23 {"id": 39, "type": "standard",
24 "label": "value39"}24 "label": "value39"}
25 ]25 ]
26 },26 },
27 {"id": 2, "type": "menuitem",27 {"id": 2, "type": "standard",
28 "label": "value2",28 "label": "value2",
29 "submenu": [29 "submenu": [
30 {"id": 20, "type": "menuitem",30 {"id": 20, "type": "standard",
31 "label": "value20"},31 "label": "value20"},
32 {"id": 21, "type": "separator",32 {"id": 21, "type": "separator",
33 "label": "value21"},33 "label": "value21"},
34 {"id": 22, "type": "menuitem",34 {"id": 22, "type": "standard",
35 "label": "value22"},35 "label": "value22"},
36 {"id": 23, "type": "separator",36 {"id": 23, "type": "separator",
37 "label": "value23"},37 "label": "value23"},
38 {"id": 24, "type": "menuitem",38 {"id": 24, "type": "standard",
39 "label": "value24"},39 "label": "value24"},
40 {"id": 25, "type": "separator",40 {"id": 25, "type": "separator",
41 "label": "value25"},41 "label": "value25"},
42 {"id": 26, "type": "menuitem",42 {"id": 26, "type": "standard",
43 "label": "value26"},43 "label": "value26"},
44 {"id": 27, "type": "separator",44 {"id": 27, "type": "separator",
45 "label": "value27"},45 "label": "value27"},
46 {"id": 28, "type": "menuitem",46 {"id": 28, "type": "standard",
47 "label": "value28"},47 "label": "value28"},
48 {"id": 29, "type": "menuitem", "visible": "false",48 {"id": 29, "type": "standard", "visible": "false",
49 "label": "value29"}49 "label": "value29"}
50 ]50 ]
51 },51 },
52 {"id": 4, "type": "menuitem",52 {"id": 4, "type": "standard",
53 "label": "value4",53 "label": "value4",
54 "submenu": [54 "submenu": [
55 {"id": 40,55 {"id": 40,
56 "type": "menuitem",56 "type": "standard",
57 "sensitive": "true",57 "enabled": "true",
58 "label": "value40"},58 "label": "value40"},
59 {"id": 41,59 {"id": 41,
60 "type": "menuitem",60 "type": "standard",
61 "sensitive": "false",61 "enabled": "false",
62 "label": "value41"},62 "label": "value41"},
63 {"id": 42,63 {"id": 42,
64 "type": "menuitem",64 "type": "standard",
65 "sensitive": "true",65 "enabled": "true",
66 "label": "value42"},66 "label": "value42"},
67 {"id": 43,67 {"id": 43,
68 "type": "menuitem",68 "type": "standard",
69 "sensitive": "false",69 "enabled": "false",
70 "label": "value43"},70 "label": "value43"},
71 {"id": 44,71 {"id": 44,
72 "type": "menuitem",72 "type": "standard",
73 "sensitive": "true",73 "enabled": "true",
74 "label": "value44"},74 "label": "value44"},
75 {"id": 45,75 {"id": 45,
76 "type": "menuitem",76 "type": "standard",
77 "sensitive": "false",77 "enabled": "false",
78 "label": "value45"},78 "label": "value45"},
79 {"id": 46,79 {"id": 46,
80 "type": "menuitem",80 "type": "standard",
81 "sensitive": "true",81 "enabled": "true",
82 "label": "value46"},82 "label": "value46"},
83 {"id": 47,83 {"id": 47,
84 "type": "menuitem",84 "type": "standard",
85 "sensitive": "false",85 "enabled": "false",
86 "label": "value47"},86 "label": "value47"},
87 {"id": 48,87 {"id": 48,
88 "type": "menuitem",88 "type": "standard",
89 "sensitive": "true",89 "enabled": "true",
90 "label": "value48"},90 "label": "value48"},
91 {"id": 49,91 {"id": 49,
92 "type": "menuitem",92 "type": "standard",
93 "visible": "false",93 "visible": "false",
94 "sensitive": "false",94 "enabled": "false",
95 "label": "value49"}95 "label": "value49"}
96 ]96 ]
97 },97 },
98 {"id": 3, "type": "menuitem",98 {"id": 3, "type": "standard",
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",
100 "not.a.value": "A useless value",100 "not.a.value": "A useless value",
101 "submenu": [101 "submenu": [
102 {"id": 10, "type": "menuitem",102 {"id": 10, "type": "standard",
103 "label": "value10"},103 "label": "value10"},
104 {"id": 11, "type": "menuitem",104 {"id": 11, "type": "standard",
105 "label": "value11"},105 "label": "value11"},
106 {"id": 12, "type": "menuitem",106 {"id": 12, "type": "standard",
107 "label": "value12"},107 "label": "value12"},
108 {"id": 13, "type": "menuitem",108 {"id": 13, "type": "standard",
109 "label": "value13"},109 "label": "value13"},
110 {"id": 14, "type": "menuitem",110 {"id": 14, "type": "standard",
111 "label": "value14"},111 "label": "value14"},
112 {"id": 15, "type": "menuitem",112 {"id": 15, "type": "standard",
113 "label": "value15"},113 "label": "value15"},
114 {"id": 16, "type": "menuitem",114 {"id": 16, "type": "standard",
115 "label": "value16"},115 "label": "value16"},
116 {"id": 17, "type": "menuitem",116 {"id": 17, "type": "standard",
117 "label": "value17"},117 "label": "value17"},
118 {"id": 18, "type": "menuitem",118 {"id": 18, "type": "standard",
119 "label": "value18"},119 "label": "value18"},
120 {"id": 19, "type": "menuitem",120 {"id": 19, "type": "standard",
121 "label": "value19"}121 "label": "value19"}
122 ]122 ]
123 },123 },
124 {"id": 4, "type": "menuitem",124 {"id": 4, "type": "standard",
125 "label": "value2",125 "label": "value2",
126 "submenu": [126 "submenu": [
127 {"id": 5, "type": "menuitem",127 {"id": 5, "type": "standard",
128 "label": "value5",128 "label": "value5",
129 "submenu": [129 "submenu": [
130 {"id": 10, "type": "menuitem",130 {"id": 10, "type": "standard",
131 "label": "value10"},131 "label": "value10"},
132 {"id": 11, "type": "menuitem",132 {"id": 11, "type": "standard",
133 "label": "value11"},133 "label": "value11"},
134 {"id": 12, "type": "menuitem",134 {"id": 12, "type": "standard",
135 "label": "value12"},135 "label": "value12"},
136 {"id": 13, "type": "menuitem",136 {"id": 13, "type": "standard",
137 "label": "value13"},137 "label": "value13"},
138 {"id": 14, "type": "menuitem",138 {"id": 14, "type": "standard",
139 "label": "value14"},139 "label": "value14"},
140 {"id": 15, "type": "menuitem",140 {"id": 15, "type": "standard",
141 "label": "value15"},141 "label": "value15"},
142 {"id": 16, "type": "menuitem",142 {"id": 16, "type": "standard",
143 "label": "value16"},143 "label": "value16"},
144 {"id": 17, "type": "menuitem",144 {"id": 17, "type": "standard",
145 "label": "value17"},145 "label": "value17"},
146 {"id": 18, "type": "menuitem",146 {"id": 18, "type": "standard",
147 "label": "value18"},147 "label": "value18"},
148 {"id": 19, "type": "menuitem",148 {"id": 19, "type": "standard",
149 "label": "value19"}149 "label": "value19"}
150 ]150 ]
151 },151 },
152 {"id": 6, "type": "menuitem",152 {"id": 6, "type": "standard",
153 "label": "value6",153 "label": "value6",
154 "submenu": [154 "submenu": [
155 {"id": 20, "type": "menuitem",155 {"id": 20, "type": "standard",
156 "label": "value20"},156 "label": "value20"},
157 {"id": 21, "type": "menuitem",157 {"id": 21, "type": "standard",
158 "label": "value21"},158 "label": "value21"},
159 {"id": 22, "type": "menuitem",159 {"id": 22, "type": "standard",
160 "label": "value22"},160 "label": "value22"},
161 {"id": 23, "type": "menuitem",161 {"id": 23, "type": "standard",
162 "label": "value23"},162 "label": "value23"},
163 {"id": 24, "type": "menuitem",163 {"id": 24, "type": "standard",
164 "label": "value24"},164 "label": "value24"},
165 {"id": 25, "type": "menuitem",165 {"id": 25, "type": "standard",
166 "label": "value25"},166 "label": "value25"},
167 {"id": 26, "type": "menuitem",167 {"id": 26, "type": "standard",
168 "label": "value26"},168 "label": "value26"},
169 {"id": 27, "type": "menuitem",169 {"id": 27, "type": "standard",
170 "label": "value27"},170 "label": "value27"},
171 {"id": 28, "type": "menuitem",171 {"id": 28, "type": "standard",
172 "label": "value28"},172 "label": "value28"},
173 {"id": 29, "type": "menuitem",173 {"id": 29, "type": "standard",
174 "label": "value29"}174 "label": "value29"}
175 ]175 ]
176 },176 },
177 {"id": 7, "type": "menuitem",177 {"id": 7, "type": "standard",
178 "label": "value7",178 "label": "value7",
179 "submenu": [179 "submenu": [
180 {"id": 30, "type": "menuitem",180 {"id": 30, "type": "standard",
181 "label": "value30"},181 "label": "value30"},
182 {"id": 31, "type": "menuitem",182 {"id": 31, "type": "standard",
183 "label": "value31"},183 "label": "value31"},
184 {"id": 32, "type": "menuitem",184 {"id": 32, "type": "standard",
185 "label": "value32"},185 "label": "value32"},
186 {"id": 33, "type": "menuitem",186 {"id": 33, "type": "standard",
187 "label": "value33"},187 "label": "value33"},
188 {"id": 34, "type": "menuitem",188 {"id": 34, "type": "standard",
189 "label": "value34"},189 "label": "value34"},
190 {"id": 35, "type": "menuitem",190 {"id": 35, "type": "standard",
191 "label": "value35"},191 "label": "value35"},
192 {"id": 36, "type": "menuitem",192 {"id": 36, "type": "standard",
193 "label": "value36"},193 "label": "value36"},
194 {"id": 37, "type": "menuitem",194 {"id": 37, "type": "standard",
195 "label": "value37"},195 "label": "value37"},
196 {"id": 38, "type": "menuitem",196 {"id": 38, "type": "standard",
197 "label": "value38"},197 "label": "value38"},
198 {"id": 39, "type": "menuitem",198 {"id": 39, "type": "standard",
199 "label": "value39"}199 "label": "value39"}
200 ]200 ]
201 },201 },
202 ]202 ]
203 },203 },
204 {"id": 8, "type": "menuitem",204 {"id": 8, "type": "standard",
205 "label": "value1",205 "label": "value1",
206 "submenu": [206 "submenu": [
207 {"id": 80,207 {"id": 80,
208 "type": "menuitem",208 "type": "standard",
209 "icon": "face-angel",209 "icon-name": "face-angel",
210 "label": "angel"},210 "label": "angel"},
211 {"id": 81,211 {"id": 81,
212 "type": "menuitem",212 "type": "standard",
213 "icon": "face-angry",213 "icon-name": "face-angry",
214 "label": "angry"},214 "label": "angry"},
215 {"id": 82,215 {"id": 82,
216 "type": "menuitem",216 "type": "standard",
217 "icon": "face-cool",217 "icon-name": "face-cool",
218 "label": "cool"},218 "label": "cool"},
219 {"id": 83,219 {"id": 83,
220 "type":"menuitem",220 "type":"standard",
221 "icon": "face-devilish",221 "icon-name": "face-devilish",
222 "label": "devilish"},222 "label": "devilish"},
223 {"id": 84,223 {"id": 84,
224 "type": "menuitem",224 "type": "standard",
225 "icon": "face-embarrassed",225 "icon-name": "face-embarrassed",
226 "label": "embarrassed"},226 "label": "embarrassed"},
227 {"id": 85,227 {"id": 85,
228 "type": "menuitem",228 "type": "standard",
229 "icon": "face-kiss",229 "icon-name": "face-kiss",
230 "label": "kiss"},230 "label": "kiss"},
231 {"id": 86,231 {"id": 86,
232 "type": "menuitem",232 "type": "standard",
233 "icon": "face-laugh",233 "icon-name": "face-laugh",
234 "label": "laugh"},234 "label": "laugh"},
235 {"id": 87,235 {"id": 87,
236 "type": "menuitem",236 "type": "standard",
237 "icon": "face-monkey",237 "icon-name": "face-monkey",
238 "label": "monkey"},238 "label": "monkey"},
239 {"id": 88,239 {"id": 88,
240 "type": "menuitem",240 "type": "standard",
241 "icon": "face-sad",241 "icon-name": "face-sad",
242 "label": "sad"},242 "label": "sad"},
243 {"id": 89,243 {"id": 89,
244 "type": "menuitem",244 "type": "standard",
245 "icon": "face-sick",245 "icon-name": "face-sick",
246 "label": "sick"}246 "label": "sick"}
247 ]247 ]
248 },248 },
249 {"id": 9, "type": "menuitem",249 {"id": 9, "type": "standard",
250 "label": "value1",250 "label": "value1",
251 "submenu": [251 "submenu": [
252 {"id": 90,252 {"id": 90,
253 "type": "menuitem",253 "type": "standard",
254 "icon-data":254 "icon-data":
255"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW255"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW
256BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8256BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8
@@ -266,7 +266,7 @@
266QmCC",266QmCC",
267 "label": "up"},267 "label": "up"},
268 {"id": 91,268 {"id": 91,
269 "type": "menuitem",269 "type": "standard",
270 "icon-data":270 "icon-data":
271"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG271"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG
272sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD272sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD
@@ -283,8 +283,8 @@
283+ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC",283+ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC",
284 "label": "down"},284 "label": "down"},
285 {"id": 92,285 {"id": 92,
286 "type": "menuitem",286 "type": "standard",
287 "icon": "up",287 "icon-name": "up",
288 "icon-data":288 "icon-data":
289"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG289"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG
290sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD290sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD
@@ -301,8 +301,8 @@
301+ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC",301+ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC",
302 "label": "up"},302 "label": "up"},
303 {"id": 93,303 {"id": 93,
304 "type": "menuitem",304 "type": "standard",
305 "icon": "down",305 "icon-name": "down",
306 "icon-data":306 "icon-data":
307"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW307"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW
308BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8308BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8
@@ -319,7 +319,7 @@
319 "label": "down"}319 "label": "down"}
320 ]320 ]
321 },321 },
322 {"id": 1, "type": "menuitem",322 {"id": 1, "type": "standard",
323 "label": "value1",323 "label": "value1",
324 "submenu": [324 "submenu": [
325 {"id": 30,325 {"id": 30,
@@ -329,42 +329,42 @@
329 {"id": 31,329 {"id": 31,
330 "label": "No check (checked)",330 "label": "No check (checked)",
331 "toggle-type": "none",331 "toggle-type": "none",
332 "toggle-checked": "checked"332 "toggle-state": 1
333 },333 },
334 {"id": 32,334 {"id": 32,
335 "label": "No check (????)",335 "label": "No check (????)",
336 "toggle-type": "none",336 "toggle-type": "none",
337 "toggle-checked": "indeterminate"337 "toggle-state": -1
338 },338 },
339 {"id": 33,339 {"id": 33,
340 "label": "Check (empty)",340 "label": "Check (empty)",
341 "toggle-type": "checkmark",341 "toggle-type": "checkmark",
342 "toggle-checked": "unchecked"342 "toggle-state": 0
343 },343 },
344 {"id": 34,344 {"id": 34,
345 "label": "Check (checked)",345 "label": "Check (checked)",
346 "toggle-type": "checkmark",346 "toggle-type": "checkmark",
347 "toggle-checked": "checked"347 "toggle-state": 1
348 },348 },
349 {"id": 35,349 {"id": 35,
350 "label": "Check (?????)",350 "label": "Check (?????)",
351 "toggle-type": "checkmark",351 "toggle-type": "checkmark",
352 "toggle-checked": "indeterminate"352 "toggle-state": -1
353 },353 },
354 {"id": 36,354 {"id": 36,
355 "label": "Radio (empty)",355 "label": "Radio (empty)",
356 "toggle-type": "radio",356 "toggle-type": "radio",
357 "toggle-checked": "unchecked"357 "toggle-state": 0
358 },358 },
359 {"id": 37,359 {"id": 37,
360 "label": "Radio (checked)",360 "label": "Radio (checked)",
361 "toggle-type": "radio",361 "toggle-type": "radio",
362 "toggle-checked": "checked"362 "toggle-state": 1
363 },363 },
364 {"id": 38,364 {"id": 38,
365 "label": "Radio (?????)",365 "label": "Radio (?????)",
366 "toggle-type": "radio",366 "toggle-type": "radio",
367 "toggle-checked": "indeterminate"367 "toggle-state": -1
368 }368 }
369 ]369 ]
370 },370 },
371371
=== modified file 'tools/Makefile.am'
--- tools/Makefile.am 2009-10-05 14:12:45 +0000
+++ tools/Makefile.am 2010-02-04 20:30:33 +0000
@@ -1,6 +1,10 @@
11
2SUBDIRS = testapp
3
2libexec_PROGRAMS = dbusmenu-dumper4libexec_PROGRAMS = dbusmenu-dumper
35
6libexec_SCRIPTS = dbusmenu-bench
7
4dbusmenu_dumper_SOURCES = \8dbusmenu_dumper_SOURCES = \
5 dbusmenu-dumper.c9 dbusmenu-dumper.c
610
@@ -12,3 +16,4 @@
12 ../libdbusmenu-glib/libdbusmenu-glib.la \16 ../libdbusmenu-glib/libdbusmenu-glib.la \
13 $(DBUSMENUGLIB_LIBS)17 $(DBUSMENUGLIB_LIBS)
1418
19EXTRA_DIST = dbusmenu-bench
1520
=== added file 'tools/dbusmenu-bench'
--- tools/dbusmenu-bench 1970-01-01 00:00:00 +0000
+++ tools/dbusmenu-bench 2010-02-04 20:30:33 +0000
@@ -0,0 +1,157 @@
1#!/usr/bin/env python
2# encoding: utf-8
3"""
4A library to communicate a menu object set accross DBus and
5track updates and maintain consistency.
6
7Copyright 2010 Canonical Ltd.
8
9Authors:
10 Aurélien Gâteau <aurelien.gateau@canonical.com>
11
12This program is free software: you can redistribute it and/or modify it
13under the terms of either or both of the following licenses:
14
151) the GNU Lesser General Public License version 3, as published by the
16Free Software Foundation; and/or
172) the GNU Lesser General Public License version 2.1, as published by
18the Free Software Foundation.
19
20This program is distributed in the hope that it will be useful, but
21WITHOUT ANY WARRANTY; without even the implied warranties of
22MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
23PURPOSE. See the applicable version of the GNU Lesser General Public
24License for more details.
25
26You should have received a copy of both the GNU Lesser General Public
27License version 3 and version 2.1 along with this program. If not, see
28<http://www.gnu.org/licenses/>
29"""
30import itertools
31import time
32import sys
33from optparse import OptionParser
34from xml.etree import ElementTree as ET
35
36import dbus
37
38DBUS_INTERFACE = "org.ayatana.dbusmenu"
39DBUS_SERVICE = "org.dbusmenu.test"
40DBUS_PATH = "/MenuBar"
41
42PROBE_GET_LAYOUT = "GetLayout"
43PROBE_GET_PROPERTIES = "GetProperties"
44PROBE_GET_CHILDREN = "GetChildren"
45PROBES = PROBE_GET_LAYOUT, PROBE_GET_PROPERTIES, PROBE_GET_CHILDREN
46
47class Chrono(object):
48 def __init__(self):
49 self._time = 0
50 self.restart()
51
52 def restart(self):
53 new_time = time.time()
54 delta = new_time - self._time
55 self._time = new_time
56 return delta
57
58 def elapsed(self):
59 return time.time() - self._time
60
61
62def dump_properties(properties, prepend=""):
63 for key, value in properties.items():
64 print "%s- %s: %s" % (prepend, key, value)
65
66
67def run_test_sequence(menu, dump=False):
68 """
69 Runs the test sequence and returns a dict of method_name: seconds
70 """
71 property_names = ["type", "label", "enabled", "icon-name"]
72 times = dict()
73 chrono = Chrono()
74 revision, layout = menu.GetLayout(dbus.Int32(0))
75 times["GetLayout"] = chrono.elapsed()
76 if dump:
77 print "revision:", revision
78 print "layout:"
79 print layout
80
81 # Get ids
82 tree = ET.fromstring(layout)
83 root_id = int(tree.attrib["id"])
84 child_element = tree.find("menu")
85 assert child_element is not None
86 child_id = int(child_element.attrib["id"])
87
88 chrono.restart()
89 children = menu.GetChildren(dbus.Int32(root_id), property_names)
90 times["GetChildren"] = chrono.elapsed()
91 if dump:
92 print "children:"
93 for child in children:
94 id, properties = child
95 print "- %d:" % id
96 dump_properties(properties, prepend=" ")
97
98 chrono.restart()
99 properties = menu.GetProperties(dbus.Int32(child_id), property_names)
100 times["GetProperties"] = chrono.elapsed()
101 if dump:
102 print "properties:"
103 dump_properties(properties)
104
105 return times
106
107def create_timing_dict():
108 return dict(zip(PROBES, itertools.repeat(0)))
109
110def print_probe(prefix, name, value, timestamp):
111 value = int(value * 1000000)
112 print "%(prefix)s.%(name)s:%(value)d@%(timestamp)d" % locals()
113
114def main():
115 parser = OptionParser(usage = "%prog [options]")
116
117 parser.add_option("-c", "--count", dest="count", type=int, default=1,
118 help="repeat calls COUNT times", metavar="COUNT")
119 parser.add_option("-d", "--dump", dest="dump", action="store_true", default=False,
120 help="dump call output to stdout")
121
122 (options, args) = parser.parse_args()
123
124 bus = dbus.SessionBus()
125 proxy = bus.get_object(DBUS_SERVICE, DBUS_PATH)
126 menu = dbus.Interface(proxy, dbus_interface=DBUS_INTERFACE)
127
128 if options.dump:
129 run_test_sequence(menu, dump=True)
130 return
131
132 cumulated_timings = create_timing_dict()
133 min_timings = create_timing_dict()
134 max_timings = create_timing_dict()
135 for x in range(options.count):
136 timings = run_test_sequence(menu)
137 for name, timing in timings.items():
138 cumulated_timings[name] += timing
139 if min_timings[name] == 0 or min_timings[name] > timing:
140 min_timings[name] = timing
141 if max_timings[name] < timing:
142 max_timings[name] = timing
143
144 timestamp = int(time.time())
145 for name, timing in cumulated_timings.items():
146 print_probe("average", name, timing / options.count, timestamp)
147 for name, timing in min_timings.items():
148 print_probe("min", name, timing, timestamp)
149 for name, timing in max_timings.items():
150 print_probe("max", name, timing, timestamp)
151
152 return 0
153
154
155if __name__=="__main__":
156 sys.exit(main())
157# vi: ts=4 sw=4 et tw=0
0158
=== added directory 'tools/testapp'
=== added file 'tools/testapp/CMakeLists.txt'
--- tools/testapp/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tools/testapp/CMakeLists.txt 2010-02-04 20:30:33 +0000
@@ -0,0 +1,29 @@
1find_package(PkgConfig REQUIRED)
2
3pkg_check_modules(DBUSMENUGLIB REQUIRED dbusmenu-glib)
4pkg_check_modules(GLIB REQUIRED glib-2.0)
5pkg_check_modules(JSONGLIB REQUIRED json-glib-1.0)
6
7set(glibapp_SRCS
8 main.c
9 )
10
11include_directories(
12 ${DBUSMENUGLIB_INCLUDE_DIRS}
13 ${GLIB_INCLUDE_DIRS}
14 ${JSONGLIB_INCLUDE_DIRS}
15 )
16
17link_directories(
18 ${DBUSMENUGLIB_LIBRARY_DIRS}
19 ${GLIB_LIBRARY_DIRS}
20 ${JSONGLIB_LIBRARY_DIRS}
21 )
22
23add_executable(dbusmenubench-glibapp ${glibapp_SRCS})
24
25target_link_libraries(dbusmenubench-glibapp
26 ${DBUSMENUGLIB_LIBRARIES}
27 ${GLIB_LIBARIES}
28 ${JSONGLIB_LIBRARIES}
29 )
030
=== added file 'tools/testapp/Makefile.am'
--- tools/testapp/Makefile.am 1970-01-01 00:00:00 +0000
+++ tools/testapp/Makefile.am 2010-02-04 20:30:33 +0000
@@ -0,0 +1,17 @@
1
2libexec_PROGRAMS = dbusmenu-testapp
3
4dbusmenu_testapp_SOURCES = \
5 main.c
6
7dbusmenu_testapp_CFLAGS = \
8 -I $(srcdir)/../.. \
9 $(DBUSMENUTESTS_CFLAGS) \
10 $(DBUSMENUGLIB_CFLAGS) \
11 -Wall -Werror
12
13dbusmenu_testapp_LDADD = \
14 $(builddir)/../../libdbusmenu-glib/libdbusmenu-glib.la \
15 $(builddir)/../../libdbusmenu-gtk/libdbusmenu-gtk.la \
16 $(DBUSMENUGTK_LIBS) \
17 $(DBUSMENUTESTS_LIBS)
018
=== added file 'tools/testapp/main.c'
--- tools/testapp/main.c 1970-01-01 00:00:00 +0000
+++ tools/testapp/main.c 2010-02-04 20:30:33 +0000
@@ -0,0 +1,153 @@
1/*
2A library to communicate a menu object set accross DBus and
3track updates and maintain consistency.
4
5Copyright 2010 Canonical Ltd.
6
7Authors:
8 Aurélien Gâteau <aurelien.gateau@canonical.com>
9
10This program is free software: you can redistribute it and/or modify it
11under the terms of either or both of the following licenses:
12
131) the GNU Lesser General Public License version 3, as published by the
14Free Software Foundation; and/or
152) the GNU Lesser General Public License version 2.1, as published by
16the Free Software Foundation.
17
18This program is distributed in the hope that it will be useful, but
19WITHOUT ANY WARRANTY; without even the implied warranties of
20MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
21PURPOSE. See the applicable version of the GNU Lesser General Public
22License for more details.
23
24You should have received a copy of both the GNU Lesser General Public
25License version 3 and version 2.1 along with this program. If not, see
26<http://www.gnu.org/licenses/>
27*/
28#include <glib.h>
29
30#include <dbus/dbus-glib.h>
31#include <dbus/dbus-glib-bindings.h>
32
33#include <json-glib/json-glib.h>
34
35#include <libdbusmenu-glib/server.h>
36#include <libdbusmenu-glib/menuitem.h>
37
38#define USAGE "dbusmenubench-glibapp <path/to/menu.json>"
39
40static void
41set_props (DbusmenuMenuitem * mi, JsonObject * node)
42{
43 if (node == NULL) return;
44
45 GList * members = NULL;
46 for (members = json_object_get_members(node); members != NULL; members = g_list_next(members)) {
47 const gchar * member = members->data;
48
49 if (!g_strcmp0(member, "id")) { continue; }
50 if (!g_strcmp0(member, "submenu")) { continue; }
51
52 JsonNode * lnode = json_object_get_member(node, member);
53 if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; }
54
55 dbusmenu_menuitem_property_set(mi, member, json_node_get_string(lnode));
56 }
57
58 return;
59}
60
61static DbusmenuMenuitem *
62layout2menuitem (JsonNode * inlayout)
63{
64 if (inlayout == NULL) return NULL;
65 if (JSON_NODE_TYPE(inlayout) != JSON_NODE_OBJECT) return NULL;
66
67 JsonObject * layout = json_node_get_object(inlayout);
68
69 DbusmenuMenuitem * local = NULL;
70 if (json_object_has_member(layout, "id")) {
71 JsonNode * node = json_object_get_member(layout, "id");
72 g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_VALUE, NULL);
73 local = dbusmenu_menuitem_new_with_id(json_node_get_int(node));
74 } else {
75 local = dbusmenu_menuitem_new();
76 }
77
78 set_props(local, layout);
79
80 if (json_object_has_member(layout, "submenu")) {
81 JsonNode * node = json_object_get_member(layout, "submenu");
82 g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_ARRAY, local);
83 JsonArray * array = json_node_get_array(node);
84 guint count;
85 for (count = 0; count < json_array_get_length(array); count++) {
86 DbusmenuMenuitem * child = layout2menuitem(json_array_get_element(array, count));
87 if (child != NULL) {
88 dbusmenu_menuitem_child_append(local, child);
89 }
90 }
91 }
92
93 /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */
94 return local;
95}
96
97void init_menu(DbusmenuMenuitem *root, const char *filename)
98{
99 JsonParser * parser = json_parser_new();
100 GError * error = NULL;
101 if (!json_parser_load_from_file(parser, filename, &error)) {
102 g_debug("Failed parsing file %s because: %s", filename, error->message);
103 return;
104 }
105 JsonNode * root_node = json_parser_get_root(parser);
106 if (JSON_NODE_TYPE(root_node) != JSON_NODE_ARRAY) {
107 g_debug("Root node is not an array, fail. It's an: %s", json_node_type_name(root_node));
108 return;
109 }
110
111 JsonArray * root_array = json_node_get_array(root_node);
112 int pos;
113 int count = json_array_get_length(root_array);
114 for (pos=0; pos < count; ++pos) {
115 DbusmenuMenuitem *child = layout2menuitem(json_array_get_element(root_array, pos));
116 dbusmenu_menuitem_child_append(root, child);
117 }
118}
119
120int main (int argc, char ** argv)
121{
122 g_type_init();
123
124 if (argc != 2) {
125 g_warning(USAGE);
126 return 1;
127 }
128 const char *filename = argv[1];
129
130 GError * error = NULL;
131 DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
132 DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
133 guint nameret = 0;
134
135 if (!org_freedesktop_DBus_request_name(bus_proxy, "org.dbusmenu.test", 0, &nameret, &error)) {
136 g_error("Unable to call to request name");
137 return 1;
138 }
139
140 if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
141 g_error("Unable to get name");
142 return 1;
143 }
144
145 DbusmenuServer *server = dbusmenu_server_new("/MenuBar");
146 DbusmenuMenuitem *root = dbusmenu_menuitem_new_with_id(0);
147 init_menu(root, filename);
148 dbusmenu_server_set_root(server, root);
149
150 g_main_loop_run(g_main_loop_new(NULL, FALSE));
151
152 return 0;
153}

Subscribers

People subscribed via source and target branches

to all changes: