From 36826dcea61c5bcf6be1fa50a80c205d58283e62 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 28 Jan 2011 14:14:13 -0600 Subject: Adding a signal for events --- libdbusmenu-glib/menuitem-marshal.list | 1 + libdbusmenu-glib/menuitem.c | 18 ++++++++++++++++++ libdbusmenu-glib/menuitem.h | 5 ++++- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem-marshal.list b/libdbusmenu-glib/menuitem-marshal.list index e3cb272..b2e02e5 100644 --- a/libdbusmenu-glib/menuitem-marshal.list +++ b/libdbusmenu-glib/menuitem-marshal.list @@ -4,3 +4,4 @@ VOID: OBJECT, UINT VOID: OBJECT VOID: VOID VOID: UINT +VOID: STRING, VARIANT, UINT diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index b40195c..83d98fa 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -71,6 +71,7 @@ enum { REALIZED, SHOW_TO_USER, ABOUT_TO_SHOW, + EVENT, LAST_SIGNAL }; @@ -244,6 +245,23 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) NULL, NULL, _dbusmenu_menuitem_marshal_VOID__VOID, G_TYPE_BOOLEAN, 0, G_TYPE_NONE); + /** + DbusmenuMenuitem::event: + @arg0: The #DbusmenuMenuitem object. + @arg1: Name of the event + @arg2: Information passed along with the event + @arg3: X11 timestamp of when the event happened + + Emitted when an event is passed through. The event is signalled + after handle_event is called. + */ + signals[EVENT] = g_signal_new(DBUSMENU_MENUITEM_SIGNAL_EVENT, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(DbusmenuMenuitemClass, event), + NULL, NULL, + _dbusmenu_menuitem_marshal_VOID__STRING_VARIANT_UINT, + G_TYPE_BOOLEAN, 3, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_UINT); g_object_class_install_property (object_class, PROP_ID, g_param_spec_int(PROP_ID_S, "ID for the menu item", diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index a4c7611..dee7ee1 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -51,6 +51,7 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID (g_signal_lookup(DBUSMENU_MENUITEM_SIGNAL_REALIZED, DBUSMENU_TYPE_MENUITEM)) #define DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER "show-to-user" #define DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW "about-to-show" +#define DBUSMENU_MENUITEM_SIGNAL_EVENT "event" #define DBUSMENU_MENUITEM_PROP_TYPE "type" #define DBUSMENU_MENUITEM_PROP_VISIBLE "visible" @@ -133,6 +134,7 @@ typedef void (*dbusmenu_menuitem_buildxml_slot_t) (DbusmenuMenuitem * mi, GPtrAr * @handle_event: This function is to override how events are handled by subclasses. Look at #dbusmenu_menuitem_handle_event for lots of good information. * @send_about_to_show: Virtual function that notifies server that the client is about to show a menu. * @show_to_user: Slot for #DbusmenuMenuitem::show-to-user. + * @event: Slot for #DbsumenuMenuitem::event. * * @reserved1: Reserved for future use. * @reserved2: Reserved for future use. @@ -162,13 +164,14 @@ struct _DbusmenuMenuitemClass void (*show_to_user) (DbusmenuMenuitem * mi, guint timestamp, gpointer cb_data); gboolean (*about_to_show) (void); + void (*event) (const gchar * name, GVariant * value, guint timestamp); + /*< Private >*/ void (*reserved1) (void); void (*reserved2) (void); void (*reserved3) (void); void (*reserved4) (void); void (*reserved5) (void); - void (*reserved6) (void); }; GType dbusmenu_menuitem_get_type (void); -- cgit v1.2.3 From d7e867eebbd24717dcf6886555eec6fe5c8ba450 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 28 Jan 2011 14:18:29 -0600 Subject: Now emit that signal appropriately --- libdbusmenu-glib/menuitem.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 83d98fa..7a279b1 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1441,6 +1441,9 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVari if (class->handle_event != NULL) { return class->handle_event(mi, name, variant, timestamp); } + + g_signal_emit(G_OBJECT(mi), EVENT, g_quark_from_string(name), name, variant, timestamp, TRUE); + return; } -- cgit v1.2.3 From 2a68cd1f7c8a9e77cf2a33953cc75f45fab44f91 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Feb 2011 17:07:56 -0600 Subject: Adding a property for text direction --- libdbusmenu-glib/dbus-menu.xml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 042a24c..4ba2f0e 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -171,6 +171,14 @@ License version 3 and version 2.1 along with this program. If not, see + + + Represents the way the text direction of the application. This + allows the server to handle mismatches intelligently. For left- + to-right the string is "ltr" for right-to-left it is "rtl". + + + -- cgit v1.2.3 From 999440cb9a577155258e31d625a0454ad7301952 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Feb 2011 22:06:49 -0600 Subject: Adding a type for the text direction, putting it in a generic header for all --- libdbusmenu-glib/Makefile.am | 3 ++- libdbusmenu-glib/server.h | 1 + libdbusmenu-glib/types.h | 55 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 libdbusmenu-glib/types.h (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index e6877b6..5f8bd35 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -19,7 +19,8 @@ libdbusmenu_glibinclude_HEADERS = \ menuitem.h \ menuitem-proxy.h \ server.h \ - client.h + client.h \ + types.h libdbusmenu_glib_la_SOURCES = \ dbus-menu-clean.xml.h \ diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 5668258..99216ea 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -33,6 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "menuitem.h" +#include "types.h" G_BEGIN_DECLS diff --git a/libdbusmenu-glib/types.h b/libdbusmenu-glib/types.h new file mode 100644 index 0000000..f8ec6a4 --- /dev/null +++ b/libdbusmenu-glib/types.h @@ -0,0 +1,55 @@ +/* +Types that are used in several objects. + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the +Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by +the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + +#ifndef __DBUSMENU_TYPES_H__ +#define __DBUSMENU_TYPES_H__ + +#include + +G_BEGIN_DECLS + +/** + DbusmenuTextDirection: + @DBUSMENU_TEXT_DIRECTION_NONE: Unspecified text direction + @DBUSMENU_TEXT_DIRECTION_LTR: Left-to-right text direction + @DBUSMENU_TEXT_DIRECTION_RTL: Right-to-left text direction + + The direction of text that the strings that this server + will be sending strings as. +*/ +typedef enum _DbusmenuTextDirection DbusmenuTextDirection; +enum _DbusmenuServerTextDirection { /*< prefix=DBUSMENU >*/ + DBUSMENU_TEXT_DIRECTION_NONE, /*< nick=none >*/ + DBUSMENU_TEXT_DIRECTION_LTR, /*< nick=ltr >*/ + DBUSMENU_TEXT_DIRECTION_RTL /*< nick=rtl >*/ +}; + + +G_END_DECLS + +#endif /* __DBUSMENU_TYPES_H__ */ + -- cgit v1.2.3 From edcd67e602c43de358839b9d277d25e049e9951b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Feb 2011 22:16:20 -0600 Subject: Some enum type templates --- libdbusmenu-glib/enum-types.c.in | 67 ++++++++++++++++++++++++++++++++++++++++ libdbusmenu-glib/enum-types.h.in | 53 +++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 libdbusmenu-glib/enum-types.c.in create mode 100644 libdbusmenu-glib/enum-types.h.in (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/enum-types.c.in b/libdbusmenu-glib/enum-types.c.in new file mode 100644 index 0000000..d572d44 --- /dev/null +++ b/libdbusmenu-glib/enum-types.c.in @@ -0,0 +1,67 @@ +/*** BEGIN file-header ***/ +/* +Enums from the dbusmenu headers + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the + Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by + the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + +#include "enum-types.h" + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +#include "@filename@" +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +/** + @enum_name@_get_type: + + Builds a GLib type for the #@EnumName@ enumeration. + + Return value: A unique #GType for the #@EnumName@ enum. +*/ +GType +@enum_name@_get_type (void) +{ + static GType etype = 0; + if (G_UNLIKELY(etype == 0)) { + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ + { @VALUENAME@, "@VALUENAME@", "@valuenick@" }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ + { 0, NULL, NULL} + }; + + etype = g_@type@_register_static (g_intern_static_string("@EnumName@"), values); + } + + return etype; +} + +/*** END value-tail ***/ diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in new file mode 100644 index 0000000..83b4bd2 --- /dev/null +++ b/libdbusmenu-glib/enum-types.h.in @@ -0,0 +1,53 @@ +/*** BEGIN file-header ***/ +/* +Enums from the dbusmenu headers + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the + Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by + the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + +#ifndef __DBUSMENU_ENUM_TYPES_H__ +#define __DBUSMENU_ENUM_TYPES_H__ + +#include + +G_BEGIN_DECLS + +/*** END file-header ***/ + +/*** BEGIN file-tail ***/ + +G_END_DECLS + +#endif /* __DBUSMENU_ENUM_TYPES_H__ */ +/*** END file-tail ***/ + +/*** BEGIN file-production ***/ +/* Enumerations from file: "@filename@" */ +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +GType @enum_name@_get_type (void) G_GNUC_CONST; +#define DBUSMENU_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) + +/*** END value-header ***/ -- cgit v1.2.3 From b7835fe50f382dccbab670033d2ce6e3ed4218c3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Feb 2011 22:43:07 -0600 Subject: Adding building the enums untilthe build system --- libdbusmenu-glib/Makefile.am | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 5f8bd35..cc4a6b0 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -1,6 +1,7 @@ -CLEANFILES = - +BUILT_SOURCES = +CLEANFILES = +DISTCLEANFILES = EXTRA_DIST = \ clean-namespaces.xslt \ dbusmenu-glib-0.4.pc.in \ @@ -9,6 +10,8 @@ EXTRA_DIST = \ menuitem-marshal.list \ server-marshal.list +include $(top_srcdir)/Makefile.am.enum + lib_LTLIBRARIES = \ libdbusmenu-glib.la @@ -25,6 +28,8 @@ libdbusmenu_glibinclude_HEADERS = \ libdbusmenu_glib_la_SOURCES = \ dbus-menu-clean.xml.h \ dbus-menu-clean.xml.c \ + enum-types.h \ + enum-types.c \ menuitem.h \ menuitem.c \ menuitem-marshal.h \ @@ -57,6 +62,14 @@ libdbusmenu_glib_la_LIBADD = \ pkgconfig_DATA = dbusmenu-glib-0.4.pc pkgconfigdir = $(libdir)/pkgconfig +glib_enum_h = enum-types.h +glib_enum_c = enum-types.c +glib_enum_headers = $(addprefix $(srcdir)/, $(libdbusmenu_glibinclude_HEADERS)) + +DISTCLEANFILES += \ + enum-types.c \ + enum-types.h + %.xml.h: %.xml echo "extern const char * $(subst -,_,$(subst .,_,$(basename $(notdir $@))));" > $@ @@ -70,7 +83,7 @@ dbus-menu-clean.xml: dbus-menu.xml CLEANFILES += dbus-menu-clean.xml -BUILT_SOURCES = \ +BUILT_SOURCES += \ dbus-menu-clean.xml.c \ dbus-menu-clean.xml.h \ client-marshal.h \ -- cgit v1.2.3 From 52a86fa21af7177cd4adb71a1d5d034d30f91eaa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Feb 2011 22:51:33 -0600 Subject: Make sure the text direction isn't in the server --- libdbusmenu-glib/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/types.h b/libdbusmenu-glib/types.h index f8ec6a4..aec8573 100644 --- a/libdbusmenu-glib/types.h +++ b/libdbusmenu-glib/types.h @@ -42,7 +42,7 @@ G_BEGIN_DECLS will be sending strings as. */ typedef enum _DbusmenuTextDirection DbusmenuTextDirection; -enum _DbusmenuServerTextDirection { /*< prefix=DBUSMENU >*/ +enum _DbusmenuTextDirection { /*< prefix=DBUSMENU >*/ DBUSMENU_TEXT_DIRECTION_NONE, /*< nick=none >*/ DBUSMENU_TEXT_DIRECTION_LTR, /*< nick=ltr >*/ DBUSMENU_TEXT_DIRECTION_RTL /*< nick=rtl >*/ -- cgit v1.2.3 From 093bb7435efaf19668a194d4fda5eae691e784eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Feb 2011 22:55:41 -0600 Subject: Changing the definition style to make mkenums happy. --- libdbusmenu-glib/types.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/types.h b/libdbusmenu-glib/types.h index aec8573..f6d8daf 100644 --- a/libdbusmenu-glib/types.h +++ b/libdbusmenu-glib/types.h @@ -41,12 +41,11 @@ G_BEGIN_DECLS The direction of text that the strings that this server will be sending strings as. */ -typedef enum _DbusmenuTextDirection DbusmenuTextDirection; -enum _DbusmenuTextDirection { /*< prefix=DBUSMENU >*/ +typedef enum { /*< prefix=DBUSMENU_TEXT_DIRECTION >*/ DBUSMENU_TEXT_DIRECTION_NONE, /*< nick=none >*/ DBUSMENU_TEXT_DIRECTION_LTR, /*< nick=ltr >*/ DBUSMENU_TEXT_DIRECTION_RTL /*< nick=rtl >*/ -}; +} DbusmenuTextDirection; G_END_DECLS -- cgit v1.2.3 From 15d2b9c0957d1ad2c45c6361866fbb5ea66ec0df Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Feb 2011 23:03:27 -0600 Subject: Adding a property for text direction --- libdbusmenu-glib/server.c | 9 ++++++++- libdbusmenu-glib/server.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 777e4ef..5946db1 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -35,6 +35,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "menuitem-private.h" #include "server.h" #include "server-marshal.h" +#include "enum-types.h" #include "dbus-menu-clean.xml.h" @@ -74,7 +75,8 @@ enum { PROP_0, PROP_DBUS_OBJECT, PROP_ROOT_NODE, - PROP_VERSION + PROP_VERSION, + PROP_TEXT_DIRECTION }; /* Errors */ @@ -285,6 +287,11 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) "The version of the DBusmenu API that we're implementing.", DBUSMENU_VERSION_NUMBER, DBUSMENU_VERSION_NUMBER, DBUSMENU_VERSION_NUMBER, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_TEXT_DIRECTION, + g_param_spec_enum(DBUSMENU_SERVER_PROP_TEXT_DIRECTION, "The default direction of text", + "The object that represents this set of menus on DBus", + DBUSMENU_TYPE_TEXT_DIRECTION, DBUSMENU_TEXT_DIRECTION_NONE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); if (dbusmenu_node_info == NULL) { GError * error = NULL; diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 99216ea..d7a0281 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -53,6 +53,7 @@ G_BEGIN_DECLS #define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object" #define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node" #define DBUSMENU_SERVER_PROP_VERSION "version" +#define DBUSMENU_SERVER_PROP_TEXT_DIRECTION "text-direction" typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; -- cgit v1.2.3 From de1f7af764f47b39e505adb996be4ec174b54825 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 20:46:56 -0600 Subject: Adding prototypes for the text direction --- libdbusmenu-glib/server.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index d7a0281..da76a49 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -111,6 +111,8 @@ struct _DbusmenuServer { GType dbusmenu_server_get_type (void); DbusmenuServer * dbusmenu_server_new (const gchar * object); void dbusmenu_server_set_root (DbusmenuServer * server, DbusmenuMenuitem * root); +DbusmenuTextDirection dbusmenu_server_get_text_direction (DbusmenuServer * server); +void dbusmenu_server_set_text_direction (DbusmenuServer * server, DbusmenuTextDirection dir); /** SECIONT:server -- cgit v1.2.3 From 02d6bd3f749237e4361845368eb96a0250212a93 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 20:48:38 -0600 Subject: Whitespace --- libdbusmenu-glib/server.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index da76a49..7923b45 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -108,11 +108,13 @@ struct _DbusmenuServer { DbusmenuServerPrivate * priv; }; -GType dbusmenu_server_get_type (void); -DbusmenuServer * dbusmenu_server_new (const gchar * object); -void dbusmenu_server_set_root (DbusmenuServer * server, DbusmenuMenuitem * root); -DbusmenuTextDirection dbusmenu_server_get_text_direction (DbusmenuServer * server); -void dbusmenu_server_set_text_direction (DbusmenuServer * server, DbusmenuTextDirection dir); +GType dbusmenu_server_get_type (void); +DbusmenuServer * dbusmenu_server_new (const gchar * object); +void dbusmenu_server_set_root (DbusmenuServer * server, + DbusmenuMenuitem * root); +DbusmenuTextDirection dbusmenu_server_get_text_direction (DbusmenuServer * server); +void dbusmenu_server_set_text_direction (DbusmenuServer * server, + DbusmenuTextDirection dir); /** SECIONT:server -- cgit v1.2.3 From 3d8b8738f8f8b757132d442cbca57aae0c871eb3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 21:09:13 -0600 Subject: Adding a the text direction stub functions in. --- libdbusmenu-glib/server.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 5946db1..a2a4557 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1204,5 +1204,39 @@ dbusmenu_server_set_root (DbusmenuServer * self, DbusmenuMenuitem * root) return; } +/** + dbusmenu_server_get_text_direction: + @server: The #DbusmenuServer object to get the text direction from + + Returns the value of the text direction that is being exported + over DBus for this server. It should relate to the direction + of the labels and other text fields that are being exported by + this server. + + Return value: Text direction exported for this server. +*/ +DbusmenuTextDirection +dbusmenu_server_get_text_direction (DbusmenuServer * server) +{ + return DBUSMENU_TEXT_DIRECTION_NONE; +} + +/** + dbusmenu_server_set_text_direction: + @server: The #DbusmenuServer object to set the text direction on + + Sets the text direction that should be exported over DBus for + this server. If the value is set to #DBUSMENU_TEXT_DIRECTION_NONE + the default detection will be used for setting the value and + exported over DBus. +*/ +void +dbusmenu_server_set_text_direction (DbusmenuServer * server, DbusmenuTextDirection dir) +{ + + + return; +} + -- cgit v1.2.3 From b30759981718e0806418a55c6ea128127d1343d4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 21:19:15 -0600 Subject: Fleshing out the accessors for the text direction --- libdbusmenu-glib/server.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index a2a4557..9784c1d 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1218,9 +1218,16 @@ dbusmenu_server_set_root (DbusmenuServer * self, DbusmenuMenuitem * root) DbusmenuTextDirection dbusmenu_server_get_text_direction (DbusmenuServer * server) { + g_return_val_if_fail(DBUSMENU_IS_SERVER(server), DBUSMENU_TEXT_DIRECTION_NONE); + GValue val = {0}; + g_value_init(&val, DBUSMENU_TYPE_TEXT_DIRECTION); + g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_TEXT_DIRECTION, &val); - return DBUSMENU_TEXT_DIRECTION_NONE; + DbusmenuTextDirection retval = g_value_get_enum(&val); + g_value_unset(&val); + + return retval; } /** @@ -1235,8 +1242,14 @@ dbusmenu_server_get_text_direction (DbusmenuServer * server) void dbusmenu_server_set_text_direction (DbusmenuServer * server, DbusmenuTextDirection dir) { - - + g_return_if_fail(DBUSMENU_IS_SERVER(server)); + g_return_if_fail(dir == DBUSMENU_TEXT_DIRECTION_NONE || dir == DBUSMENU_TEXT_DIRECTION_LTR || dir == DBUSMENU_TEXT_DIRECTION_RTL); + + GValue newval = {0}; + g_value_init(&newval, DBUSMENU_TYPE_TEXT_DIRECTION); + g_value_set_enum(&newval, dir); + g_object_set_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_TEXT_DIRECTION, &newval); + g_value_unset(&newval); return; } -- cgit v1.2.3 From b376a0aeaecd0928f3222e36aad7f3faea1fffa7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 21:46:20 -0600 Subject: Adding code to determine the default text direction --- libdbusmenu-glib/server.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 9784c1d..a1f805e 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -30,6 +30,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif +#include #include #include "menuitem-private.h" @@ -55,6 +56,8 @@ struct _DbusmenuServerPrivate GDBusConnection * bus; GCancellable * bus_lookup; guint dbus_registration; + + DbusmenuTextDirection text_direction; }; #define DBUSMENU_SERVER_GET_PRIVATE(o) (DBUSMENU_SERVER(o)->priv) @@ -123,6 +126,7 @@ static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); +static void default_text_direction (DbusmenuServer * server); static void register_object (DbusmenuServer * server); static void bus_got_cb (GObject * obj, GAsyncResult * result, @@ -351,6 +355,8 @@ dbusmenu_server_init (DbusmenuServer *self) priv->bus_lookup = NULL; priv->dbus_registration = 0; + default_text_direction(self); + return; } @@ -480,6 +486,49 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) return; } +/* Determines the default text direction */ +static void +default_text_direction (DbusmenuServer * server) +{ + DbusmenuTextDirection dir = DBUSMENU_TEXT_DIRECTION_NONE; + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + const gchar * env = g_getenv("DBUSMENU_TEXT_DIRECTION"); + if (env != NULL) { + if (g_strcmp0(env, "ltr") == 0) { + dir = DBUSMENU_TEXT_DIRECTION_LTR; + } else if (g_strcmp0(env, "rtl") == 0) { + dir = DBUSMENU_TEXT_DIRECTION_RTL; + } else { + g_warning("Value of 'DBUSMENU_TEXT_DIRECTION' is '%s' which is not one of 'rtl' or 'ltr'", env); + } + } + + if (dir == DBUSMENU_TEXT_DIRECTION_NONE) { + /* TRANSLATORS: This is the direction of the text and can + either be the value 'ltr' for left-to-right text (English) + or 'rtl' for right-to-left (Arabic). */ + const gchar * default_dir = C_("default text direction", "ltr"); + + if (g_strcmp0(default_dir, "ltr") == 0) { + dir = DBUSMENU_TEXT_DIRECTION_LTR; + } else if (g_strcmp0(default_dir, "rtl") == 0) { + dir = DBUSMENU_TEXT_DIRECTION_RTL; + } else { + g_warning("Translation has an invalid value '%s' for default text direction. Defaulting to left-to-right.", default_dir); + dir = DBUSMENU_TEXT_DIRECTION_LTR; + } + } + + /* Shouldn't happen, but incase future patches make a mistake + this'll catch them */ + g_return_if_fail(dir != DBUSMENU_TEXT_DIRECTION_NONE); + + priv->text_direction = dir; + + return; +} + /* Register the object on the dbus bus */ static void register_object (DbusmenuServer * server) -- cgit v1.2.3 From f80eb0bcc21a8e1917b290b50ef400e2c8fb090f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 23:00:38 -0600 Subject: Handling set and get of the property. --- libdbusmenu-glib/server.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index a1f805e..3a7255c 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -444,6 +444,39 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) } layout_update_signal(DBUSMENU_SERVER(obj)); break; + case PROP_TEXT_DIRECTION: { + DbusmenuTextDirection indir = g_value_get_enum(value); + DbusmenuTextDirection olddir = priv->text_direction; + + /* If being set to none we need to go back to default, otherwise + we'll set things the way that we've been told */ + if (indir == DBUSMENU_TEXT_DIRECTION_NONE) { + default_text_direction(DBUSMENU_SERVER(obj)); + } else { + priv->text_direction = indir; + } + + /* If the value has changed we need to signal that on DBus */ + if (priv->text_direction != olddir && priv->bus != NULL && priv->dbusobject != NULL) { + GVariantBuilder params; + g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); + g_variant_builder_add_value(¶ms, g_variant_new_string(DBUSMENU_INTERFACE)); + GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("text-direction"), g_variant_new_string("ltr")); + g_variant_builder_add_value(¶ms, g_variant_new_array(NULL, &dict, 1)); + g_variant_builder_add_value(¶ms, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); + GVariant * vparams = g_variant_builder_end(¶ms); + + g_dbus_connection_emit_signal(priv->bus, + NULL, + priv->dbusobject, + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + vparams, + NULL); + } + + break; + } default: g_return_if_reached(); break; @@ -478,6 +511,9 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) case PROP_VERSION: g_value_set_uint(value, DBUSMENU_VERSION_NUMBER); break; + case PROP_TEXT_DIRECTION: + g_value_set_enum(value, priv->text_direction); + break; default: g_return_if_reached(); break; -- cgit v1.2.3 From 5c0f6f04e9be75e273049bf5b4134185c12d32c1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 23:24:41 -0600 Subject: Adding a get_nick function for our enums --- libdbusmenu-glib/enum-types.c.in | 25 +++++++++++++++++++++++++ libdbusmenu-glib/enum-types.h.in | 2 ++ 2 files changed, 27 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/enum-types.c.in b/libdbusmenu-glib/enum-types.c.in index d572d44..b0756d9 100644 --- a/libdbusmenu-glib/enum-types.c.in +++ b/libdbusmenu-glib/enum-types.c.in @@ -64,4 +64,29 @@ GType return etype; } +/** + @enum_name@_get_nick: + @value: The value of @EnumName@ to get the nick of + + Looks up in the enum table for the nick of @value. + + Return value: The nick for the given value or #NULL on error +*/ +const gchar * +@enum_name@_get_nick (@EnumName@ value) +{ + GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type())); + g_return_val_if_fail(class != NULL, NULL); + + const gchar * ret = NULL; + GEnumValue * val = g_enum_get_value(class, value); + if (val != NULL) { + ret = val->value_nick; + } + + g_type_class_unref(class); + return ret; +} + + /*** END value-tail ***/ diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in index 83b4bd2..eb24453 100644 --- a/libdbusmenu-glib/enum-types.h.in +++ b/libdbusmenu-glib/enum-types.h.in @@ -44,10 +44,12 @@ G_END_DECLS /*** BEGIN file-production ***/ /* Enumerations from file: "@filename@" */ +#include "@filename@" /*** END file-production ***/ /*** BEGIN value-header ***/ GType @enum_name@_get_type (void) G_GNUC_CONST; +const gchar * @enum_name@_get_nick (@EnumName@ value) G_GNUC_CONST; #define DBUSMENU_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) /*** END value-header ***/ -- cgit v1.2.3 From 8b29014f8cff75f937f49f07d3dcd6a86591bdc0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 23:26:01 -0600 Subject: Use the get_nick function to get the value for the signal --- libdbusmenu-glib/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 3a7255c..5cc04c6 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -461,7 +461,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) GVariantBuilder params; g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); g_variant_builder_add_value(¶ms, g_variant_new_string(DBUSMENU_INTERFACE)); - GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("text-direction"), g_variant_new_string("ltr")); + GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("text-direction"), g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction))); g_variant_builder_add_value(¶ms, g_variant_new_array(NULL, &dict, 1)); g_variant_builder_add_value(¶ms, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); GVariant * vparams = g_variant_builder_end(¶ms); -- cgit v1.2.3 From b5f10bb47ad432a6344bca52c352f42eb96290fb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 23:28:25 -0600 Subject: Making it so that the dbus properties can have more than one. --- libdbusmenu-glib/server.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 5cc04c6..c89b49e 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -682,9 +682,16 @@ bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * /* None of these should happen */ g_return_val_if_fail(g_strcmp0(interface, DBUSMENU_INTERFACE) == 0, NULL); g_return_val_if_fail(g_strcmp0(path, priv->dbusobject) == 0, NULL); - g_return_val_if_fail(g_strcmp0(property, "version") == 0, NULL); - return g_variant_new_uint32(DBUSMENU_VERSION_NUMBER); + if (g_strcmp0(property, "version") == 0) { + return g_variant_new_uint32(DBUSMENU_VERSION_NUMBER); + } else if (g_strcmp0(property, "text-direction") == 0) { + return g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction)); + } else { + g_warning("Unknown property '%s'", property); + } + + return NULL; } /* Handle actually signalling in the idle loop. This way we collect all -- cgit v1.2.3 From 28aed4b5a7b7ee69e7f6368e4deeb2836d7655d8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 10:57:33 -0600 Subject: Adding in the function prototypes for text direction in the client. --- libdbusmenu-glib/client.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 6d78edf..3bab503 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -33,6 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "menuitem.h" +#include "types.h" G_BEGIN_DECLS @@ -48,6 +49,7 @@ G_BEGIN_DECLS #define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM "new-menuitem" #define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE "item-activate" #define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT "event-result" +#define DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED "text-direction-changed" #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" @@ -65,6 +67,7 @@ typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate; @new_menuitem: Slot for #DbusmenuClient::new-menuitem. @item_activate: Slot for #DbusmenuClient::item-activate. @event_result: Slot for #DbusmenuClient::event-error. + @text_direction_changed: Slot for #DbusmenuClient::text-direction-changed. @reserved1: Reserved for future use. @reserved2: Reserved for future use. @reserved3: Reserved for future use. @@ -85,6 +88,7 @@ struct _DbusmenuClientClass { void (*new_menuitem) (DbusmenuMenuitem * newitem); void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); void (*event_result) (DbusmenuMenuitem * item, gchar * event, GVariant * data, guint timestamp, GError * error); + void (*text_direction_changed) (DbusmenuTextDirection newdirection); /*< Private >*/ void (*reserved1) (void); @@ -92,7 +96,6 @@ struct _DbusmenuClientClass { void (*reserved3) (void); void (*reserved4) (void); void (*reserved5) (void); - void (*reserved6) (void); }; /** @@ -155,6 +158,7 @@ void dbusmenu_client_send_about_to_show(DbusmenuClient * client, gint id, void (*cb) (gpointer user_data), gpointer cb_data); +DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client); /** SECTION:client -- cgit v1.2.3 From b36db6b1b5c8e92fe73bb31d34f8838da622c340 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 11:45:57 -0600 Subject: Adding the signal for text direction changing. --- libdbusmenu-glib/client-marshal.list | 1 + libdbusmenu-glib/client.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client-marshal.list b/libdbusmenu-glib/client-marshal.list index 866dfa8..96f9302 100644 --- a/libdbusmenu-glib/client-marshal.list +++ b/libdbusmenu-glib/client-marshal.list @@ -1,2 +1,3 @@ VOID: OBJECT, UINT VOID: OBJECT, STRING, VARIANT, UINT, POINTER +VOID: ENUM diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5e492a3..c643551 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -42,6 +42,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "server-marshal.h" #include "client-marshal.h" #include "dbus-menu-clean.xml.h" +#include "enum-types.h" /* How many property requests should we queue before sending the message on dbus */ @@ -61,6 +62,7 @@ enum { NEW_MENUITEM, ITEM_ACTIVATE, EVENT_RESULT, + TEXT_DIRECTION_CHANGED, LAST_SIGNAL }; @@ -248,6 +250,21 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) NULL, NULL, _dbusmenu_client_marshal_VOID__OBJECT_UINT, G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT); + /** + DbusmenuClient::text-direction-changed: + @arg0: The #DbusmenuClient object + @arg1: The new text direction + + Signal sent to show that there was an error in sending the event + to the server. + */ + signals[TEXT_DIRECTION_CHANGED] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED, + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (DbusmenuClientClass, text_direction_changed), + NULL, NULL, + _dbusmenu_client_marshal_VOID__ENUM, + G_TYPE_NONE, 1, DBUSMENU_TYPE_TEXT_DIRECTION); /** DbusmenuClient::event-error: @arg0: The #DbusmenuClient object -- cgit v1.2.3 From 796c5d6a0a13c7429b32607625eb0cde2503c50f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 11:49:25 -0600 Subject: Adding a stub for getting the text direction --- libdbusmenu-glib/client.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c643551..d74d627 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1823,3 +1823,20 @@ dbusmenu_client_add_type_handler_full (DbusmenuClient * client, const gchar * ty return TRUE; } +/** + dbusmenu_client_get_text_direction: + @client: #DbusmenuClient to check the text direction on + + Gets the text direction that the server is exporting. If + the server is not exporting a direction then the value + #DBUSMENU_TEXT_DIRECTION_NONE will be returned. + + Return value: Text direction being exported. +*/ +DbusmenuTextDirection +dbusmenu_client_get_text_direction (DbusmenuClient * client) +{ + + + return DBUSMENU_TEXT_DIRECTION_NONE; +} -- cgit v1.2.3 From b7434b48401a4049facc3eb455bb1075e1ad78ca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 12:48:23 -0600 Subject: Adding a nick to value translator --- libdbusmenu-glib/enum-types.c.in | 24 ++++++++++++++++++++++++ libdbusmenu-glib/enum-types.h.in | 1 + 2 files changed, 25 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/enum-types.c.in b/libdbusmenu-glib/enum-types.c.in index b0756d9..9395f5f 100644 --- a/libdbusmenu-glib/enum-types.c.in +++ b/libdbusmenu-glib/enum-types.c.in @@ -88,5 +88,29 @@ const gchar * return ret; } +/** + @enum_name@_get_value_from_nick: + @nick: The enum nick to lookup + + Looks up in the enum table for the value of @nick. + + Return value: The value for the given @nick +*/ +@EnumName@ +@enum_name@_get_value_from_nick (const gchar * nick) +{ + GEnumClass * class = G_ENUM_CLASS(g_type_class_ref(@enum_name@_get_type())); + g_return_val_if_fail(class != NULL, 0); + + @EnumName@ ret = 0; + GEnumValue * val = g_enum_get_value_by_nick(class, nick); + if (val != NULL) { + ret = val->value; + } + + g_type_class_unref(class); + return ret; +} + /*** END value-tail ***/ diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in index eb24453..8c5f463 100644 --- a/libdbusmenu-glib/enum-types.h.in +++ b/libdbusmenu-glib/enum-types.h.in @@ -50,6 +50,7 @@ G_END_DECLS /*** BEGIN value-header ***/ GType @enum_name@_get_type (void) G_GNUC_CONST; const gchar * @enum_name@_get_nick (@EnumName@ value) G_GNUC_CONST; +@EnumName@ @enum_name@_get_value_from_nick (const gchar * nick) G_GNUC_CONST; #define DBUSMENU_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) /*** END value-header ***/ -- cgit v1.2.3 From bcedc26848a0fe4f2f67a129d34976f69eb03fdf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 12:49:43 -0600 Subject: Start handling text direction and signal when it changes --- libdbusmenu-glib/client.c | 66 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d74d627..b285c91 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -95,6 +95,8 @@ struct _DbusmenuClientPrivate GArray * delayed_property_list; GArray * delayed_property_listeners; gint delayed_idle; + + DbusmenuTextDirection text_direction; }; typedef struct _newItemPropData newItemPropData; @@ -163,6 +165,7 @@ static void get_properties_globber (DbusmenuClient * client, gint id, const gcha static GQuark error_domain (void); static void item_activated (GDBusProxy * proxy, gint id, guint timestamp, DbusmenuClient * client); static void menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data); +static void menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv invalidated, gpointer user_data); static void menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_data); static void menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVariant * params, gpointer user_data); static void type_handler_destroy (gpointer user_data); @@ -349,6 +352,8 @@ dbusmenu_client_init (DbusmenuClient *self) priv->delayed_property_list = g_array_new(TRUE, FALSE, sizeof(gchar *)); priv->delayed_property_listeners = g_array_new(FALSE, FALSE, sizeof(properties_listener_t)); + priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE; + return; } @@ -1004,6 +1009,19 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) priv->menuproxy_cancel = NULL; } + /* Check the text direction if available */ + GVariant * textdir = g_dbus_proxy_get_cached_property(priv->menuproxy, "text-direction"); + if (textdir != NULL) { + GVariant * str = textdir; + if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { + str = g_variant_get_variant(str); + } + + priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL)); + + g_variant_unref(textdir); + } + /* If we get here, we don't need the DBus proxy */ if (priv->dbusproxy != 0) { g_bus_unwatch_name(priv->dbusproxy); @@ -1012,6 +1030,7 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) g_signal_connect(priv->menuproxy, "g-signal", G_CALLBACK(menuproxy_signal_cb), client); g_signal_connect(priv->menuproxy, "notify::g-name-owner", G_CALLBACK(menuproxy_name_changed_cb), client); + g_signal_connect(priv->menuproxy, "g-properties-changed", G_CALLBACK(menuproxy_prop_changed_cb), client); gchar * name_owner = g_dbus_proxy_get_name_owner(priv->menuproxy); if (name_owner != NULL) { @@ -1022,6 +1041,47 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data) return; } +/* Handle the properites changing */ +static void +menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv invalidated, gpointer user_data) +{ + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data); + DbusmenuTextDirection olddir = priv->text_direction; + + /* Invalidate first */ + gchar * invalid = *invalidated; + while (invalid != NULL) { + if (g_strcmp0(invalid, "text-direction") == 0) { + priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE; + } + invalid++; + } + + /* Check updates */ + GVariantIter iters; + gchar * key; GVariant * value; + g_variant_iter_init(&iters, properties); + while (g_variant_iter_next(&iters, "{sv}", &key, &value)) { + if (g_strcmp0(key, "text-direction") == 0) { + GVariant * str = value; + if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { + str = g_variant_get_variant(str); + } + + priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL)); + } + + g_variant_unref(value); + g_free(key); + } + + if (olddir != priv->text_direction) { + g_signal_emit(G_OBJECT(user_data), TEXT_DIRECTION_CHANGED, 0, priv->text_direction, TRUE); + } + + return; +} + /* Handle the case where we change owners */ static void menuproxy_name_changed_cb (GObject * object, GParamSpec * pspec, gpointer user_data) @@ -1836,7 +1896,7 @@ dbusmenu_client_add_type_handler_full (DbusmenuClient * client, const gchar * ty DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client) { - - - return DBUSMENU_TEXT_DIRECTION_NONE; + g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), DBUSMENU_TEXT_DIRECTION_NONE); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + return priv->text_direction; } -- cgit v1.2.3 From 8a50abe36f57629c1f1e38842c8ed3bbef602213 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 13:04:12 -0600 Subject: Use a for loop for looking at invalidated properties --- libdbusmenu-glib/client.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5aae5d6..c86ebf1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1045,12 +1045,12 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva DbusmenuTextDirection olddir = priv->text_direction; /* Invalidate first */ - gchar * invalid = *invalidated; - while (invalid != NULL) { + gchar * invalid; + gint i = 0; + for (invalid = invalidated[i]; invalid != NULL; invalid = invalidated[++i]) { if (g_strcmp0(invalid, "text-direction") == 0) { priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE; } - invalid++; } /* Check updates */ -- cgit v1.2.3 From 0c9a1f185b2e95466741afd61feaf6b57e0740d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 13:08:04 -0600 Subject: Using the proper signal value. Oops --- libdbusmenu-glib/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c86ebf1..5f967d0 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1072,7 +1072,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva } if (olddir != priv->text_direction) { - g_signal_emit(G_OBJECT(user_data), TEXT_DIRECTION_CHANGED, 0, priv->text_direction, TRUE); + g_signal_emit(G_OBJECT(user_data), signals[TEXT_DIRECTION_CHANGED], 0, priv->text_direction, TRUE); } return; -- cgit v1.2.3 From 9a4a97ad2363328818d5a7983ab2a5e3f7c46b72 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 13:21:14 -0600 Subject: Adding a stub for exposed checking --- libdbusmenu-glib/menuitem-private.h | 1 + libdbusmenu-glib/menuitem.c | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem-private.h b/libdbusmenu-glib/menuitem-private.h index 89319dc..336769d 100644 --- a/libdbusmenu-glib/menuitem-private.h +++ b/libdbusmenu-glib/menuitem-private.h @@ -38,6 +38,7 @@ gboolean dbusmenu_menuitem_realized (DbusmenuMenuitem * mi); void dbusmenu_menuitem_set_realized (DbusmenuMenuitem * mi); GVariant * dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** properties); gboolean dbusmenu_menuitem_property_is_default (DbusmenuMenuitem * mi, const gchar * property); +gboolean dbusmenu_menuitem_exposed (DbusmenuMenuitem * mi); G_END_DECLS diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 54d2540..cca20a4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1507,3 +1507,12 @@ dbusmenu_menuitem_property_is_default (DbusmenuMenuitem * mi, const gchar * prop /* No defaults system yet */ return FALSE; } + +/* Check to see if this menu item has been sent into the bus yet or + not. If no one cares we can give less info */ +gboolean +dbusmenu_menuitem_exposed (DbusmenuMenuitem * mi) +{ + + return TRUE; +} -- cgit v1.2.3 From 18fad06951c3293c268eb910d421960e15bcc371 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 13:25:50 -0600 Subject: Tracking whether we've been exposed --- libdbusmenu-glib/menuitem.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index cca20a4..23f3783 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -59,6 +59,7 @@ struct _DbusmenuMenuitemPrivate GHashTable * properties; gboolean root; gboolean realized; + gboolean exposed; }; /* Signals */ @@ -312,6 +313,7 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) priv->root = FALSE; priv->realized = FALSE; + priv->exposed = FALSE; return; } @@ -1338,6 +1340,8 @@ GVariant * dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** properties, gint recurse) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + priv->exposed = TRUE; gint id = 0; if (!dbusmenu_menuitem_get_root(mi)) { @@ -1513,6 +1517,7 @@ dbusmenu_menuitem_property_is_default (DbusmenuMenuitem * mi, const gchar * prop gboolean dbusmenu_menuitem_exposed (DbusmenuMenuitem * mi) { - - return TRUE; + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + return priv->exposed; } -- cgit v1.2.3 From 9c4d38ce605a99616d83918eb6ee7e200090b06d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 13:36:19 -0600 Subject: Adjusting so that we can check to see if the menu item has been exposed before sending the message. If it hasn't been we'll remove it from the signal, and perhaps not signal at all. --- libdbusmenu-glib/server.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index aa39991..09fb356 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -656,7 +656,7 @@ layout_update_signal (DbusmenuServer * server) typedef struct _prop_idle_item_t prop_idle_item_t; struct _prop_idle_item_t { - gint id; + DbusmenuMenuitem * mi; GArray * array; }; @@ -686,6 +686,7 @@ prop_array_teardown (GArray * prop_array) } } + g_object_unref(G_OBJECT(iitem->mi)); g_array_free(iitem->array, TRUE); } @@ -719,6 +720,12 @@ menuitem_property_idle (gpointer user_data) for (i = 0; i < priv->prop_array->len; i++) { prop_idle_item_t * iitem = &g_array_index(priv->prop_array, prop_idle_item_t, i); + /* if it's not exposed we're going to block it's properties + from getting into the dbus message */ + if (dbusmenu_menuitem_exposed(iitem->mi) == FALSE) { + continue; + } + GVariantBuilder dictbuilder; gboolean dictinit = FALSE; @@ -756,7 +763,7 @@ menuitem_property_idle (gpointer user_data) GVariantBuilder tuplebuilder; g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE); - g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id)); + g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(dbusmenu_menuitem_get_id(iitem->mi))); g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&dictbuilder)); if (!item_init) { @@ -773,7 +780,7 @@ menuitem_property_idle (gpointer user_data) GVariantBuilder tuplebuilder; g_variant_builder_init(&tuplebuilder, G_VARIANT_TYPE_TUPLE); - g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(iitem->id)); + g_variant_builder_add_value(&tuplebuilder, g_variant_new_int32(dbusmenu_menuitem_get_id(iitem->mi))); g_variant_builder_add_value(&tuplebuilder, g_variant_builder_end(&removedictbuilder)); if (!removeitem_init) { @@ -786,9 +793,11 @@ menuitem_property_idle (gpointer user_data) } GVariant * megadata[2]; + gboolean gotsomething = FALSE; if (item_init) { megadata[0] = g_variant_builder_end(&itembuilder); + gotsomething = TRUE; } else { GError * error = NULL; megadata[0] = g_variant_parse(G_VARIANT_TYPE("a(ia{sv})"), "[ ]", NULL, NULL, &error); @@ -801,6 +810,7 @@ menuitem_property_idle (gpointer user_data) if (removeitem_init) { megadata[1] = g_variant_builder_end(&removeitembuilder); + gotsomething = TRUE; } else { GError * error = NULL; megadata[1] = g_variant_parse(G_VARIANT_TYPE("a(ia(s))"), "[ ]", NULL, NULL, &error); @@ -811,7 +821,7 @@ menuitem_property_idle (gpointer user_data) } } - if (priv->dbusobject != NULL && priv->bus != NULL) { + if (gotsomething && priv->dbusobject != NULL && priv->bus != NULL) { g_dbus_connection_emit_signal(priv->bus, NULL, priv->dbusobject, @@ -854,7 +864,7 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v prop_idle_item_t * item = NULL; for (i = 0; i < priv->prop_array->len; i++) { prop_idle_item_t * iitem = &g_array_index(priv->prop_array, prop_idle_item_t, i); - if (iitem->id == item_id) { + if (iitem->mi == mi) { item = iitem; break; } @@ -864,7 +874,8 @@ menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GVariant * v /* If not, we'll need to build ourselves one */ if (item == NULL) { prop_idle_item_t myitem; - myitem.id = item_id; + myitem.mi = mi; + g_object_ref(G_OBJECT(mi)); myitem.array = g_array_new(FALSE, FALSE, sizeof(prop_idle_prop_t)); g_array_append_val(priv->prop_array, myitem); -- cgit v1.2.3 From f1263378cd61a113cdcc485c3a20e913f19f2631 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 15:11:23 -0600 Subject: Adding the 'state' property to the XML --- libdbusmenu-glib/dbus-menu.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 82bad03..3b42f7d 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -179,6 +179,16 @@ License version 3 and version 2.1 along with this program. If not, see + + + Tells if the menus are in a normal state or they believe that they + could use some attention. Cases for showing them would be if help + were referring to them or they accessors were being highlighted. + This property can have two values: "normal" in almost all cases and + "notice" when they should have a higher priority to be shown. + + + -- cgit v1.2.3 From cf9662c5be75f9e7fe16e4fe9513ee3e4223fba0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 15:16:54 -0600 Subject: Adding in a status enum for tracking the status --- libdbusmenu-glib/types.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/types.h b/libdbusmenu-glib/types.h index f6d8daf..e573476 100644 --- a/libdbusmenu-glib/types.h +++ b/libdbusmenu-glib/types.h @@ -47,6 +47,17 @@ typedef enum { /*< prefix=DBUSMENU_TEXT_DIRECTION >*/ DBUSMENU_TEXT_DIRECTION_RTL /*< nick=rtl >*/ } DbusmenuTextDirection; +/** + DbusmenuStatus: + @DBUSMENU_STATUS_NORMAL: Everything is normal + @DBUSMENU_STATUS_NOTICE: The menus should be shown at a higher priority + + Tracks how the menus should be presented to the user. +*/ +typedef enum { /*< prefix=DBUSMENU_STATUS >*/ + DBUSMENU_STATUS_NORMAL, /*< nick=normal >*/ + DBUSMENU_STATUS_NOTICE /*< nick=notice >*/ +} DbusmenuStatus; G_END_DECLS -- cgit v1.2.3 From 6401d13aa0455b609b9f3b8c67c1d985c4c0fd8d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 15:28:00 -0600 Subject: Adding in some stub functions for the status --- libdbusmenu-glib/server.c | 28 ++++++++++++++++++++++++++++ libdbusmenu-glib/server.h | 3 +++ 2 files changed, 31 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index baae3ce..57e4c79 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1606,3 +1606,31 @@ dbusmenu_server_set_text_direction (DbusmenuServer * server, DbusmenuTextDirecti return; } +/** + dbusmenu_server_get_status: + @server: The #DbusmenuServer to get the status from + + Gets the current statust hat the server is sending out over + DBus. + + Return value: The current status the server is sending +*/ +DbusmenuStatus +dbusmenu_server_get_status (DbusmenuServer * server) +{ + + return DBUSMENU_STATUS_NORMAL; +} + +/** + dbusmenu_server_set_status: + @server: The #DbusmenuServer to set the status on + + Changes the status of the server. +*/ +void +dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status) +{ + + return; +} diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 7923b45..6441570 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -115,6 +115,9 @@ void dbusmenu_server_set_root (DbusmenuServer * DbusmenuTextDirection dbusmenu_server_get_text_direction (DbusmenuServer * server); void dbusmenu_server_set_text_direction (DbusmenuServer * server, DbusmenuTextDirection dir); +DbusmenuStatus dbusmenu_server_get_status (DbusmenuServer * server); +void dbusmenu_server_set_status (DbusmenuServer * server, + DbusmenuStatus status); /** SECIONT:server -- cgit v1.2.3 From 84f77e8815f2747b4f76818d6f168cdd3e2f67c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 15:31:58 -0600 Subject: Fleshing out the getter and setter --- libdbusmenu-glib/server.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 57e4c79..3515896 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1618,8 +1618,16 @@ dbusmenu_server_set_text_direction (DbusmenuServer * server, DbusmenuTextDirecti DbusmenuStatus dbusmenu_server_get_status (DbusmenuServer * server) { + g_return_val_if_fail(DBUSMENU_IS_SERVER(server), DBUSMENU_STATUS_NORMAL); - return DBUSMENU_STATUS_NORMAL; + GValue val = {0}; + g_value_init(&val, DBUSMENU_TYPE_STATUS); + g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_STATUS, &val); + + DbusmenuStatus retval = g_value_get_enum(&val); + g_value_unset(&val); + + return retval; } /** @@ -1631,6 +1639,13 @@ dbusmenu_server_get_status (DbusmenuServer * server) void dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status) { + g_return_if_fail(DBUSMENU_IS_SERVER(server)); + + GValue val = {0}; + g_value_init(&val, DBUSMENU_TYPE_STATUS); + g_value_set_enum(&val, status); + g_object_set_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_STATUS, &val); + g_value_unset(&val); return; } -- cgit v1.2.3 From 948372f3a709d729524d6977ff49361fa06d80ac Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 15:33:51 -0600 Subject: Adding in the status property --- libdbusmenu-glib/server.c | 8 +++++++- libdbusmenu-glib/server.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 3515896..fe9e07c 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -82,7 +82,8 @@ enum { PROP_DBUS_OBJECT, PROP_ROOT_NODE, PROP_VERSION, - PROP_TEXT_DIRECTION + PROP_TEXT_DIRECTION, + PROP_STATUS }; /* Errors */ @@ -300,6 +301,11 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) "The object that represents this set of menus on DBus", DBUSMENU_TYPE_TEXT_DIRECTION, DBUSMENU_TEXT_DIRECTION_NONE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_STATUS, + g_param_spec_enum(DBUSMENU_SERVER_PROP_STATUS, "Status of viewing the menus", + "Exports over DBus whether the menus should be given special visuals", + DBUSMENU_TYPE_STATUS, DBUSMENU_STATUS_NORMAL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); if (dbusmenu_node_info == NULL) { GError * error = NULL; diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 6441570..54cf5fc 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -54,6 +54,7 @@ G_BEGIN_DECLS #define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node" #define DBUSMENU_SERVER_PROP_VERSION "version" #define DBUSMENU_SERVER_PROP_TEXT_DIRECTION "text-direction" +#define DBUSMENU_SERVER_PROP_STATUS "status" typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; -- cgit v1.2.3 From 1393edc283ac4b62f0e29612f77e7a95fbe7e7bc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 15:39:30 -0600 Subject: Tracking the status and signaling on DBus if it changes --- libdbusmenu-glib/server.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index fe9e07c..91e7a25 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -58,6 +58,7 @@ struct _DbusmenuServerPrivate guint dbus_registration; DbusmenuTextDirection text_direction; + DbusmenuStatus status; GArray * prop_array; guint property_idle; @@ -366,6 +367,7 @@ dbusmenu_server_init (DbusmenuServer *self) priv->dbus_registration = 0; default_text_direction(self); + priv->status = DBUSMENU_STATUS_NORMAL; return; } @@ -515,6 +517,31 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) break; } + case PROP_STATUS: { + DbusmenuStatus instatus = g_value_get_enum(value); + + /* If the value has changed we need to signal that on DBus */ + if (priv->status != instatus && priv->bus != NULL && priv->dbusobject != NULL) { + GVariantBuilder params; + g_variant_builder_init(¶ms, G_VARIANT_TYPE_ARRAY); + g_variant_builder_add_value(¶ms, g_variant_new_string(DBUSMENU_INTERFACE)); + GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("status"), g_variant_new_string(dbusmenu_status_get_nick(instatus))); + g_variant_builder_add_value(¶ms, g_variant_new_array(NULL, &dict, 1)); + g_variant_builder_add_value(¶ms, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); + GVariant * vparams = g_variant_builder_end(¶ms); + + g_dbus_connection_emit_signal(priv->bus, + NULL, + priv->dbusobject, + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + vparams, + NULL); + } + + priv->status = instatus; + break; + } default: g_return_if_reached(); break; @@ -541,6 +568,9 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) case PROP_TEXT_DIRECTION: g_value_set_enum(value, priv->text_direction); break; + case PROP_STATUS: + g_value_set_enum(value, priv->status); + break; default: g_return_if_reached(); break; -- cgit v1.2.3 From b6b89c9b74e0e2a90d8af7749d817a512bde95d8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 16:05:09 -0600 Subject: Adds a status property that is gotten over DBus --- libdbusmenu-glib/client.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++- libdbusmenu-glib/client.h | 2 ++ 2 files changed, 52 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5f967d0..61ea91d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -49,7 +49,8 @@ License version 3 and version 2.1 along with this program. If not, see enum { PROP_0, PROP_DBUSOBJECT, - PROP_DBUSNAME + PROP_DBUSNAME, + PROP_STATUS }; /* Signals */ @@ -94,6 +95,7 @@ struct _DbusmenuClientPrivate gint delayed_idle; DbusmenuTextDirection text_direction; + DbusmenuStatus status; }; typedef struct _newItemPropData newItemPropData; @@ -294,6 +296,11 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) "Name of the DBus client we're connecting to.", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_STATUS, + g_param_spec_enum(DBUSMENU_CLIENT_PROP_STATUS, "Status of viewing the menus", + "Whether the menus should be given special visuals", + DBUSMENU_TYPE_STATUS, DBUSMENU_STATUS_NORMAL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); if (dbusmenu_node_info == NULL) { GError * error = NULL; @@ -349,6 +356,7 @@ dbusmenu_client_init (DbusmenuClient *self) priv->delayed_property_listeners = g_array_new(FALSE, FALSE, sizeof(properties_listener_t)); priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE; + priv->status = DBUSMENU_STATUS_NORMAL; return; } @@ -494,6 +502,9 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) case PROP_DBUSOBJECT: g_value_set_string(value, priv->dbus_object); break; + case PROP_STATUS: + g_value_set_enum(value, priv->status); + break; default: g_warning("Unknown property %d.", id); return; @@ -1043,6 +1054,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data); DbusmenuTextDirection olddir = priv->text_direction; + DbusmenuStatus oldstatus = priv->status; /* Invalidate first */ gchar * invalid; @@ -1051,6 +1063,9 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva if (g_strcmp0(invalid, "text-direction") == 0) { priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE; } + if (g_strcmp0(invalid, "status") == 0) { + priv->status = DBUSMENU_STATUS_NORMAL; + } } /* Check updates */ @@ -1066,6 +1081,14 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL)); } + if (g_strcmp0(key, "status") == 0) { + GVariant * str = value; + if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) { + str = g_variant_get_variant(str); + } + + priv->status = dbusmenu_status_get_value_from_nick(g_variant_get_string(str, NULL)); + } g_variant_unref(value); g_free(key); @@ -1075,6 +1098,10 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva g_signal_emit(G_OBJECT(user_data), signals[TEXT_DIRECTION_CHANGED], 0, priv->text_direction, TRUE); } + if (oldstatus != priv->status) { + g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_STATUS); + } + return; } @@ -1928,3 +1955,25 @@ dbusmenu_client_get_text_direction (DbusmenuClient * client) DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); return priv->text_direction; } + +/** + dbusmenu_client_get_status: + @client: #DbusmenuClient to check the status on + + Gets the recommended current status that the server + is exporting for the menus. In situtations where the + value is #DBUSMENU_STATUS_NOTICE it is recommended that + the client show the menus to the user an a more noticible + way. + + Return value: Status being exported. +*/ +DbusmenuStatus +dbusmenu_client_get_status (DbusmenuClient * client) +{ + g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), DBUSMENU_STATUS_NORMAL); + DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); + return priv->status; +} + + diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 3bab503..e812aa2 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -53,6 +53,7 @@ G_BEGIN_DECLS #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" +#define DBUSMENU_CLIENT_PROP_STATUS "status" #define DBUSMENU_CLIENT_TYPES_DEFAULT "standard" #define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator" @@ -159,6 +160,7 @@ void dbusmenu_client_send_about_to_show(DbusmenuClient * client, void (*cb) (gpointer user_data), gpointer cb_data); DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client); +DbusmenuStatus dbusmenu_client_get_status (DbusmenuClient * client); /** SECTION:client -- cgit v1.2.3 From 5ab75937ec4ba21f9542fbe71dbf8ceb5b28e2ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Feb 2011 16:11:29 -0600 Subject: Instead of defining a signal let's make this a property and use 'notify' --- libdbusmenu-glib/client.c | 29 +++++++++++------------------ libdbusmenu-glib/client.h | 4 ++-- 2 files changed, 13 insertions(+), 20 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 5f967d0..828129a 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -49,7 +49,8 @@ License version 3 and version 2.1 along with this program. If not, see enum { PROP_0, PROP_DBUSOBJECT, - PROP_DBUSNAME + PROP_DBUSNAME, + PROP_TEXT_DIRECTION }; /* Signals */ @@ -59,7 +60,6 @@ enum { NEW_MENUITEM, ITEM_ACTIVATE, EVENT_RESULT, - TEXT_DIRECTION_CHANGED, LAST_SIGNAL }; @@ -249,21 +249,6 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) NULL, NULL, _dbusmenu_client_marshal_VOID__OBJECT_UINT, G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT); - /** - DbusmenuClient::text-direction-changed: - @arg0: The #DbusmenuClient object - @arg1: The new text direction - - Signal sent to show that there was an error in sending the event - to the server. - */ - signals[TEXT_DIRECTION_CHANGED] = g_signal_new(DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED, - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (DbusmenuClientClass, text_direction_changed), - NULL, NULL, - _dbusmenu_client_marshal_VOID__ENUM, - G_TYPE_NONE, 1, DBUSMENU_TYPE_TEXT_DIRECTION); /** DbusmenuClient::event-error: @arg0: The #DbusmenuClient object @@ -294,6 +279,11 @@ dbusmenu_client_class_init (DbusmenuClientClass *klass) "Name of the DBus client we're connecting to.", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_TEXT_DIRECTION, + g_param_spec_enum(DBUSMENU_CLIENT_PROP_TEXT_DIRECTION, "Direction text values have", + "Signals which direction the default text direction is for the menus", + DBUSMENU_TYPE_TEXT_DIRECTION, DBUSMENU_TEXT_DIRECTION_NONE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); if (dbusmenu_node_info == NULL) { GError * error = NULL; @@ -494,6 +484,9 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) case PROP_DBUSOBJECT: g_value_set_string(value, priv->dbus_object); break; + case PROP_TEXT_DIRECTION: + g_value_set_enum(value, priv->text_direction); + break; default: g_warning("Unknown property %d.", id); return; @@ -1072,7 +1065,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva } if (olddir != priv->text_direction) { - g_signal_emit(G_OBJECT(user_data), signals[TEXT_DIRECTION_CHANGED], 0, priv->text_direction, TRUE); + g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_TEXT_DIRECTION); } return; diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 3bab503..c11a285 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -53,6 +53,7 @@ G_BEGIN_DECLS #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" +#define DBUSMENU_CLIENT_PROP_TEXT_DIRECTION "text-direction" #define DBUSMENU_CLIENT_TYPES_DEFAULT "standard" #define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator" @@ -67,7 +68,6 @@ typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate; @new_menuitem: Slot for #DbusmenuClient::new-menuitem. @item_activate: Slot for #DbusmenuClient::item-activate. @event_result: Slot for #DbusmenuClient::event-error. - @text_direction_changed: Slot for #DbusmenuClient::text-direction-changed. @reserved1: Reserved for future use. @reserved2: Reserved for future use. @reserved3: Reserved for future use. @@ -88,7 +88,6 @@ struct _DbusmenuClientClass { void (*new_menuitem) (DbusmenuMenuitem * newitem); void (*item_activate) (DbusmenuMenuitem * item, guint timestamp); void (*event_result) (DbusmenuMenuitem * item, gchar * event, GVariant * data, guint timestamp, GError * error); - void (*text_direction_changed) (DbusmenuTextDirection newdirection); /*< Private >*/ void (*reserved1) (void); @@ -96,6 +95,7 @@ struct _DbusmenuClientClass { void (*reserved3) (void); void (*reserved4) (void); void (*reserved5) (void); + void (*reserved6) (void); }; /** -- cgit v1.2.3 From f938b05924b073e2fa348bcb336e05e55f0f8a89 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 11:43:31 -0600 Subject: Changing the naming of the CLIENT MENUITEM macro to be standard --- libdbusmenu-glib/client-menuitem.c | 4 ++-- libdbusmenu-glib/client-menuitem.h | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client-menuitem.c b/libdbusmenu-glib/client-menuitem.c index 0f14b85..b9e799f 100644 --- a/libdbusmenu-glib/client-menuitem.c +++ b/libdbusmenu-glib/client-menuitem.c @@ -39,7 +39,7 @@ struct _DbusmenuClientMenuitemPrivate }; #define DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemPrivate)) +(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_CLIENT_MENUITEM, DbusmenuClientMenuitemPrivate)) static void dbusmenu_client_menuitem_class_init (DbusmenuClientMenuitemClass *klass); static void dbusmenu_client_menuitem_init (DbusmenuClientMenuitem *self); @@ -94,7 +94,7 @@ dbusmenu_client_menuitem_finalize (GObject *object) DbusmenuClientMenuitem * dbusmenu_client_menuitem_new (gint id, DbusmenuClient * client) { - DbusmenuClientMenuitem * mi = g_object_new(DBUSMENU_CLIENT_MENUITEM_TYPE, "id", id, NULL); + DbusmenuClientMenuitem * mi = g_object_new(DBUSMENU_TYPE_CLIENT_MENUITEM, "id", id, NULL); DbusmenuClientMenuitemPrivate * priv = DBUSMENU_CLIENT_MENUITEM_GET_PRIVATE(mi); priv->client = client; return mi; diff --git a/libdbusmenu-glib/client-menuitem.h b/libdbusmenu-glib/client-menuitem.h index ef61213..2692192 100644 --- a/libdbusmenu-glib/client-menuitem.h +++ b/libdbusmenu-glib/client-menuitem.h @@ -35,12 +35,16 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS -#define DBUSMENU_CLIENT_MENUITEM_TYPE (dbusmenu_client_menuitem_get_type ()) -#define DBUSMENU_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitem)) -#define DBUSMENU_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemClass)) -#define DBUSMENU_IS_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE)) -#define DBUSMENU_IS_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_CLIENT_MENUITEM_TYPE)) -#define DBUSMENU_CLIENT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_CLIENT_MENUITEM_TYPE, DbusmenuClientMenuitemClass)) +/** + * DBUSMENU_TYPE_CLIENT_MENUITEM: + * Macro to get the #GType value for #DbusmenuClientMenuitem object + */ +#define DBUSMENU_TYPE_CLIENT_MENUITEM (dbusmenu_client_menuitem_get_type ()) +#define DBUSMENU_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_TYPE_CLIENT_MENUITEM, DbusmenuClientMenuitem)) +#define DBUSMENU_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_TYPE_CLIENT_MENUITEM, DbusmenuClientMenuitemClass)) +#define DBUSMENU_IS_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_TYPE_CLIENT_MENUITEM)) +#define DBUSMENU_IS_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_CLIENT_MENUITEM)) +#define DBUSMENU_CLIENT_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_CLIENT_MENUITEM, DbusmenuClientMenuitemClass)) typedef struct _DbusmenuClientMenuitem DbusmenuClientMenuitem; typedef struct _DbusmenuClientMenuitemClass DbusmenuClientMenuitemClass; -- cgit v1.2.3 From 1a80d862c6ad5629e69893de3f27c42c9c8363f3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 12:06:31 -0600 Subject: Dropping parents that are unused by gtk-doc --- libdbusmenu-glib/client.h | 1 - libdbusmenu-glib/server.h | 1 - 2 files changed, 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 79c0ee2..a8e0899 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -97,7 +97,6 @@ struct _DbusmenuClientClass { /** DbusmenuClient: - @parent: #GObject. The client for a #DbusmenuServer creating a shared object set of #DbusmenuMenuitem objects. diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 5668258..d407ce4 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -93,7 +93,6 @@ struct _DbusmenuServerClass { /** DbusmenuServer: - @parent: #GObject A server which represents a sharing of a set of #DbusmenuMenuitems across DBus to a #DbusmenuClient. -- cgit v1.2.3 From 75b874cd7464fc706e640be3f7d985f1da77a91a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 12:36:56 -0600 Subject: Fixing all of the server docs --- libdbusmenu-glib/server.h | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index d407ce4..11ce085 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -43,14 +43,54 @@ G_BEGIN_DECLS #define DBUSMENU_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_SERVER)) #define DBUSMENU_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_SERVER, DbusmenuServerClass)) +/** + * DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE: + * + * String to attach to signal #DbusmenuServer::item-property-updated + */ #define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "item-property-updated" +/** + * DBUSMENU_SERVER_SIGNAL_ID_UPDATE: + * + * String to attach to signal #DbusmenuServer::item-updated + */ #define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "item-updated" +/** + * DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED: + * + * String to attach to signal #DbusmenuServer::layout-updated + */ #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED "layout-updated" +/** + * DBUSMENU_SERVER_SIGNAL_ITEM_ACTIVATION: + * + * String to attach to signal #DbusmenuServer::item-activation-requested + */ #define DBUSMENU_SERVER_SIGNAL_ITEM_ACTIVATION "item-activation-requested" +/** + * DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE: + * + * String to attach to signal #DbusmenuServer::layout-updated + */ #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED +/** + * DBUSMENU_SERVER_PROP_DBUS_OBJECT: + * + * String to access property #DbusmenuServer:dbus-object + */ #define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object" +/** + * DBUSMENU_SERVER_PROP_ROOT_NODE: + * + * String to access property #DbusmenuServer:root-node + */ #define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node" +/** + * DBUSMENU_SERVER_PROP_VERSION: + * + * String to access property #DbusmenuServer:version + */ #define DBUSMENU_SERVER_PROP_VERSION "version" typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; @@ -61,8 +101,7 @@ typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; @id_prop_update: Slot for #DbusmenuServer::id-prop-update. @id_update: Slot for #DbusmenuServer::id-update. @layout_updated: Slot for #DbusmenuServer::layout-update. - @item_activation_requested: Slot for #DbusmenuServer::item-activation-requested. - + @item_activation: Slot for #DbusmenuServer::item-activation-requested. @reserved1: Reserved for future use. @reserved2: Reserved for future use. @reserved3: Reserved for future use. @@ -107,10 +146,10 @@ struct _DbusmenuServer { GType dbusmenu_server_get_type (void); DbusmenuServer * dbusmenu_server_new (const gchar * object); -void dbusmenu_server_set_root (DbusmenuServer * server, DbusmenuMenuitem * root); +void dbusmenu_server_set_root (DbusmenuServer * self, DbusmenuMenuitem * root); /** - SECIONT:server + SECTION:server @short_description: The server signals changed and updates on a tree of #DbusmenuMenuitem objecs. @stability: Unstable -- cgit v1.2.3 From c780c27de91ff7b36c25e50f11ccb051c6e8ac1d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 12:55:10 -0600 Subject: Fixup documentation and move the private functions to a private header file --- libdbusmenu-glib/Makefile.am | 1 + libdbusmenu-glib/client-menuitem.c | 1 + libdbusmenu-glib/client-private.h | 48 +++++++++++++++++++++++++++ libdbusmenu-glib/client.c | 1 + libdbusmenu-glib/client.h | 67 +++++++++++++++++++++++++++++++++----- 5 files changed, 109 insertions(+), 9 deletions(-) create mode 100644 libdbusmenu-glib/client-private.h (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am index 92de502..8c177f7 100644 --- a/libdbusmenu-glib/Makefile.am +++ b/libdbusmenu-glib/Makefile.am @@ -39,6 +39,7 @@ libdbusmenu_glib_la_SOURCES = \ client-marshal.c \ client-menuitem.h \ client-menuitem.c \ + client-private.h \ client.h \ client.c diff --git a/libdbusmenu-glib/client-menuitem.c b/libdbusmenu-glib/client-menuitem.c index b9e799f..60f8637 100644 --- a/libdbusmenu-glib/client-menuitem.c +++ b/libdbusmenu-glib/client-menuitem.c @@ -30,6 +30,7 @@ License version 3 and version 2.1 along with this program. If not, see #endif #include "client-menuitem.h" +#include "client-private.h" typedef struct _DbusmenuClientMenuitemPrivate DbusmenuClientMenuitemPrivate; diff --git a/libdbusmenu-glib/client-private.h b/libdbusmenu-glib/client-private.h new file mode 100644 index 0000000..f6df372 --- /dev/null +++ b/libdbusmenu-glib/client-private.h @@ -0,0 +1,48 @@ +/* +A library to communicate a menu object set accross DBus and +track updates and maintain consistency. + +Copyright 2011 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the +Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, as published by +the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR +PURPOSE. See the applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + +#ifndef __DBUSMENU_CLIENT_PRIVATE_H__ +#define __DBUSMENU_CLIENT_PRIVATE_H__ + +#include "client.h" + +G_BEGIN_DECLS + +void dbusmenu_client_send_event (DbusmenuClient * client, + gint id, + const gchar * name, + GVariant * variant, + guint timestamp); +void dbusmenu_client_send_about_to_show(DbusmenuClient * client, + gint id, + void (*cb) (gpointer user_data), + gpointer cb_data); + +G_END_DECLS + +#endif diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 0848294..ee1186b 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -33,6 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see #include #include "client.h" +#include "client-private.h" #include "menuitem.h" #include "menuitem-private.h" #include "client-menuitem.h" diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index a8e0899..7bb0e6a 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -43,17 +43,71 @@ G_BEGIN_DECLS #define DBUSMENU_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_CLIENT)) #define DBUSMENU_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_CLIENT, DbusmenuClientClass)) +/** + * DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED: + * + * String to attach to signal #DbusmenuClient::layout-updated + */ #define DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED "layout-updated" +/** + * DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED: + * + * String to attach to signal #DbusmenuClient::root-changed + */ #define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED "root-changed" +/** + * DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM: + * + * String to attach to signal #DbusmenuClient::new-menuitem + */ #define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM "new-menuitem" +/** + * DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE: + * + * String to attach to signal #DbusmenuClient::item-activate + */ #define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE "item-activate" +/** + * DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT: + * + * String to attach to signal #DbusmenuClient::event-result + */ #define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT "event-result" +/** + * DBUSMENU_CLIENT_PROP_DBUS_NAME: + * + * String to access property #DbusmenuClient:dbus-name + */ #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name" +/** + * DBUSMENU_CLIENT_PROP_DBUS_OBJECT: + * + * String to access property #DbusmenuClient:dbus-object + */ #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" +/** + * DBUSMENU_CLIENT_TYPES_DEFAULT: + * + * Used to set the 'type' property on a menu item to create + * a standard menu item. + */ #define DBUSMENU_CLIENT_TYPES_DEFAULT "standard" +/** + * DBUSMENU_CLIENT_TYPES_SEPARATOR: + * + * Used to set the 'type' property on a menu item to create + * a separator menu item. + */ #define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator" +/** + * DBUSMENU_CLIENT_TYPES_IMAGE: + * + * Used to set the 'type' property on a menu item to create + * an image menu item. Deprecated as standard menu items now + * support images as well. + */ #define DBUSMENU_CLIENT_TYPES_IMAGE "standard" typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate; @@ -62,6 +116,7 @@ typedef struct _DbusmenuClientPrivate DbusmenuClientPrivate; DbusmenuClientClass: @parent_class: #GObjectClass @layout_updated: Slot for #DbusmenuClient::layout-updated. + @root_changed: Slot for #DbusmenuClient::root-changed. @new_menuitem: Slot for #DbusmenuClient::new-menuitem. @item_activate: Slot for #DbusmenuClient::item-activate. @event_result: Slot for #DbusmenuClient::event-error. @@ -118,6 +173,9 @@ struct _DbusmenuClient { The type handler is called when a dbusmenu item is created with a matching type as setup in #dbusmenu_client_add_type_handler + + Return value: #TRUE if the type has been handled. #FALSE if this + function was somehow unable to handle it. */ typedef gboolean (*DbusmenuClientTypeHandler) (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); @@ -145,15 +203,6 @@ gboolean dbusmenu_client_add_type_handler_full (DbusmenuClient * cli DbusmenuClientTypeHandler newfunc, gpointer user_data, DbusmenuClientTypeDestroyHandler destroy_func); -void dbusmenu_client_send_event (DbusmenuClient * client, - gint id, - const gchar * name, - GVariant * variant, - guint timestamp); -void dbusmenu_client_send_about_to_show(DbusmenuClient * client, - gint id, - void (*cb) (gpointer user_data), - gpointer cb_data); /** SECTION:client -- cgit v1.2.3 From 2b1ff29007f59ddebc9c00234ad1267894970365 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 13:10:37 -0600 Subject: Fixing menuitem proxy docs --- libdbusmenu-glib/menuitem-proxy.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem-proxy.h b/libdbusmenu-glib/menuitem-proxy.h index 2a22efe..97d2741 100644 --- a/libdbusmenu-glib/menuitem-proxy.h +++ b/libdbusmenu-glib/menuitem-proxy.h @@ -67,7 +67,7 @@ struct _DbusmenuMenuitemProxyClass { }; /** - DbusmeneMenuitemProxy: + DbusmenuMenuitemProxy: @parent: The instance of #DbusmenuMenuitem Public instance data for a #DbusmenuMenuitemProxy. @@ -83,6 +83,17 @@ GType dbusmenu_menuitem_proxy_get_type (void); DbusmenuMenuitemProxy * dbusmenu_menuitem_proxy_new (DbusmenuMenuitem * mi); DbusmenuMenuitem * dbusmenu_menuitem_proxy_get_wrapped (DbusmenuMenuitemProxy * pmi); +/** + * SECTION:menuitem-proxy + * @short_description: A menuitem that proxies from another menuitem + * @stability: Unstable + * @include: libdbusmenu-glib/menuitem-proxy.h + * + * This small object allows for proxying all the properties from a remote + * menuitem to a new object that can be moved around appropriately within + * the new menu structure. + */ + G_END_DECLS #endif -- cgit v1.2.3 From 52380a969c8fcb140c35826a3bf55e8e835d65da Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 13:47:29 -0600 Subject: Fixing all the menuitem documentation --- libdbusmenu-glib/menuitem.c | 2 +- libdbusmenu-glib/menuitem.h | 194 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 192 insertions(+), 4 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index c994130..919552e 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1142,7 +1142,7 @@ dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * propert /** - * dbusmenu_menuitem_property_exit: + * dbusmenu_menuitem_property_exist: * @mi: The #DbusmenuMenuitem to look for the property on. * @property: The property to look for. * diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index afd6084..580c452 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -42,47 +42,231 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_MENUITEM, DbusmenuMenuitemClass)) +/** + * DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED: + * + * String to attach to signal #DbusmenuServer::property-changed + */ #define DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED "property-changed" +/** + * DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED: + * + * String to attach to signal #DbusmenuServer::item-activated + */ #define DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED "item-activated" +/** + * DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED: + * + * String to attach to signal #DbusmenuServer::child-added + */ #define DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED "child-added" +/** + * DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED: + * + * String to attach to signal #DbusmenuServer::child-removed + */ #define DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED "child-removed" +/** + * DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED: + * + * String to attach to signal #DbusmenuServer::child-moved + */ #define DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED "child-moved" +/** + * DBUSMENU_MENUITEM_SIGNAL_REALIZED: + * + * String to attach to signal #DbusmenuServer::realized + */ #define DBUSMENU_MENUITEM_SIGNAL_REALIZED "realized" +/** + * DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID: + * + * ID to attach to signal #DbusmenuServer::realized + */ #define DBUSMENU_MENUITEM_SIGNAL_REALIZED_ID (g_signal_lookup(DBUSMENU_MENUITEM_SIGNAL_REALIZED, DBUSMENU_TYPE_MENUITEM)) +/** + * DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER: + * + * String to attach to signal #DbusmenuServer::show-to-user + */ #define DBUSMENU_MENUITEM_SIGNAL_SHOW_TO_USER "show-to-user" +/** + * DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW: + * + * String to attach to signal #DbusmenuServer::about-to-show + */ #define DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW "about-to-show" +/** + * DBUSMENU_MENUITEM_PROP_TYPE: + * + * #DbusmenuMenuitem property used to represent what type of menuitem + * this object represents. Type: #G_VARIANT_TYPE_STRING. + */ #define DBUSMENU_MENUITEM_PROP_TYPE "type" +/** + * DBUSMENU_MENUITEM_PROP_VISIBLE: + * + * #DbusmenuMenuitem property used to represent whether the menuitem + * should be shown or not. Type: #G_VARIANT_TYPE_BOOLEAN. + */ #define DBUSMENU_MENUITEM_PROP_VISIBLE "visible" +/** + * DBUSMENU_MENUITEM_PROP_ENABLED: + * + * #DbusmenuMenuitem property used to represent whether the menuitem + * is clickable or not. Type: #G_VARIANT_TYPE_BOOLEAN. + */ #define DBUSMENU_MENUITEM_PROP_ENABLED "enabled" +/** + * DBUSMENU_MENUITEM_PROP_LABEL: + * + * #DbusmenuMenuitem property used for the text on the menu item. + * Type: #G_VARIANT_TYPE_STRING + */ #define DBUSMENU_MENUITEM_PROP_LABEL "label" +/** + * DBUSMENU_MENUITEM_PROP_ICON_NAME: + * + * #DbusmenuMenuitem property that is the name of the icon under the + * Freedesktop.org icon naming spec. Type: #G_VARIANT_TYPE_STRING + */ #define DBUSMENU_MENUITEM_PROP_ICON_NAME "icon-name" +/** + * DBUSMENU_MENUITEM_PROP_ICON_DATA: + * + * #DbusmenuMenuitem property that is the raw data of a custom icon + * used in the application. Type: #G_VARIANT_TYPE_VARIANT + * + * It is recommended that this is not set directly but instead the + * libdbusmenu-gtk library is used with the function dbusmenu_menuitem_property_set_image() + */ #define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data" +/** + * DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE: + * + * #DbusmenuMenuitem property that says what type of toggle entry should + * be shown in the menu. Should be either #DBUSMENU_MENUITEM_TOGGLE_CHECK + * or #DBUSMENU_MENUITEM_TOGGLE_RADIO. Type: #G_VARIANT_TYPE_STRING + */ #define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type" +/** + * DBUSMENU_MENUITEM_PROP_TOGGLE_STATE: + * + * #DbusmenuMenuitem property that says what state a toggle entry should + * be shown as the menu. Should be either #DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED + * #DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED or #DBUSMENU_MENUITEM_TOGGLE_STATUE_UNKNOWN. + * Type: #G_VARIANT_TYPE_INT32 + */ #define DBUSMENU_MENUITEM_PROP_TOGGLE_STATE "toggle-state" +/** + * DBUSMENU_MENUITEM_PROP_SHORTCUT: + * + * #DbusmenuMenuitem property that is the entries that represent a shortcut + * to activate the menuitem. It is an array of arrays of strings. + * Type: #G_VARIANT_TYPE_ARRAY + * + * It is recommended that this is not set directly but instead the + * libdbusmenu-gtk library is used with the function dbusmenu_menuitem_property_set_shortcut() + */ #define DBUSMENU_MENUITEM_PROP_SHORTCUT "shortcut" +/** + * DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY: + * + * #DbusmenuMenuitem property that tells how the children of this menuitem + * should be displayed. Most likely this will be unset or of the value + * #DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU. Type: #G_VARIANT_TYPE_STRING + */ #define DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY "children-display" +/** + * DBUSMENU_MENUITEM_TOGGLE_CHECK: + * + * Used to set #DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE to be a standard + * check mark item. + */ #define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark" +/** + * DBUSMENU_MENUITEM_TOGGLE_RADIO: + * + * Used to set #DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE to be a standard + * radio item. + */ #define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio" +/** + * DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED: + * + * Used to set #DBUSMENU_MENUITEM_PROP_TOGGLE_STATE so that the menu's + * toggle item is empty. + */ #define DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED 0 +/** + * DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED: + * + * Used to set #DBUSMENU_MENUITEM_PROP_TOGGLE_STATE so that the menu's + * toggle item is filled. + */ #define DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED 1 +/** + * DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN: + * + * Used to set #DBUSMENU_MENUITEM_PROP_TOGGLE_STATE so that the menu's + * toggle item is undecided. + */ #define DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN -1 +/** + * DBUSMENU_MENUITEM_ICON_NAME_BLANK: + * + * Used to set #DBUSMENU_MENUITEM_PROP_TOGGLE_STATE so that the menu's + * toggle item is undecided. + */ #define DBUSMENU_MENUITEM_ICON_NAME_BLANK "blank-icon" +/** + * DBUSMENU_MENUITEM_SHORTCUT_CONTROL: + * + * Used in #DBUSMENU_MENUITEM_PROP_SHORTCUT to represent the + * control key. + */ #define DBUSMENU_MENUITEM_SHORTCUT_CONTROL "Control" +/** + * DBUSMENU_MENUITEM_SHORTCUT_ALT: + * + * Used in #DBUSMENU_MENUITEM_PROP_SHORTCUT to represent the + * alternate key. + */ #define DBUSMENU_MENUITEM_SHORTCUT_ALT "Alt" +/** + * DBUSMENU_MENUITEM_SHORTCUT_SHIFT: + * + * Used in #DBUSMENU_MENUITEM_PROP_SHORTCUT to represent the + * shift key. + */ #define DBUSMENU_MENUITEM_SHORTCUT_SHIFT "Shift" +/** + * DBUSMENU_MENUITEM_SHORTCUT_SUPER: + * + * Used in #DBUSMENU_MENUITEM_PROP_SHORTCUT to represent the + * super key. + */ #define DBUSMENU_MENUITEM_SHORTCUT_SUPER "Super" +/** + * DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU: + * + * Used in #DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY to have the + * subitems displayed as a submenu. + */ #define DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU "submenu" typedef struct _DbusmenuMenuitemPrivate DbusmenuMenuitemPrivate; /** * DbusmenuMenuitem: + * @parent: Parent object + * @priv: Private data * * This is the #GObject based object that represents a menu * item. It gets created the same on both the client and @@ -113,16 +297,18 @@ typedef void (*dbusmenu_menuitem_about_to_show_cb) (DbusmenuMenuitem * mi, gpoin /** * dbusmenu_menuitem_buildvariant_slot_t: * @mi: (in): Menu item that should be built from + * @properties: (allow none): A list of properties that should be the only ones in the resulting variant structure * * This is the function that is called to represent this menu item * as a variant. Should call it's own children. * - * Return value: (transfer full) A variant representing this item and it's children + * Return value: (transfer full): A variant representing this item and it's children */ typedef GVariant * (*dbusmenu_menuitem_buildvariant_slot_t) (DbusmenuMenuitem * mi, gchar ** properties); /** * DbusmenuMenuitemClass: + * @parent_class: Functions and signals from our parent * @property_changed: Slot for #DbusmenuMenuitem::property-changed. * @item_activated: Slot for #DbusmenuMenuitem::item-activated. * @child_added: Slot for #DbusmenuMenuitem::child-added. @@ -130,17 +316,19 @@ typedef GVariant * (*dbusmenu_menuitem_buildvariant_slot_t) (DbusmenuMenuitem * * @child_moved: Slot for #DbusmenuMenuitem::child-moved. * @realized: Slot for #DbusmenuMenuitem::realized. * @about_to_show: Slot for #DbusmenuMenuitem::about-to-show. - * @buildxml: Virtual function that appends the strings required to represent this menu item in the menu XML file. + * @buildvariant: Virtual function that appends the strings required to represent this menu item in the menu variant. * @handle_event: This function is to override how events are handled by subclasses. Look at #dbusmenu_menuitem_handle_event for lots of good information. * @send_about_to_show: Virtual function that notifies server that the client is about to show a menu. * @show_to_user: Slot for #DbusmenuMenuitem::show-to-user. - * * @reserved1: Reserved for future use. * @reserved2: Reserved for future use. * @reserved3: Reserved for future use. * @reserved4: Reserved for future use. * @reserved5: Reserved for future use. * @reserved6: Reserved for future use. + * + * Functions and signals that every menuitem should know something + * about. */ typedef struct _DbusmenuMenuitemClass DbusmenuMenuitemClass; struct _DbusmenuMenuitemClass -- cgit v1.2.3 From 2a43ac2e5df3272f8db2a4a4c6878e10a0011c57 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 14:07:39 -0600 Subject: Removing some items that it said I needed before... I swear, constantly. --- libdbusmenu-glib/client-menuitem.h | 4 ---- libdbusmenu-glib/menuitem-proxy.h | 1 - 2 files changed, 5 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client-menuitem.h b/libdbusmenu-glib/client-menuitem.h index 2692192..a89cb11 100644 --- a/libdbusmenu-glib/client-menuitem.h +++ b/libdbusmenu-glib/client-menuitem.h @@ -35,10 +35,6 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS -/** - * DBUSMENU_TYPE_CLIENT_MENUITEM: - * Macro to get the #GType value for #DbusmenuClientMenuitem object - */ #define DBUSMENU_TYPE_CLIENT_MENUITEM (dbusmenu_client_menuitem_get_type ()) #define DBUSMENU_CLIENT_MENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_TYPE_CLIENT_MENUITEM, DbusmenuClientMenuitem)) #define DBUSMENU_CLIENT_MENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_TYPE_CLIENT_MENUITEM, DbusmenuClientMenuitemClass)) diff --git a/libdbusmenu-glib/menuitem-proxy.h b/libdbusmenu-glib/menuitem-proxy.h index 97d2741..ee988d8 100644 --- a/libdbusmenu-glib/menuitem-proxy.h +++ b/libdbusmenu-glib/menuitem-proxy.h @@ -68,7 +68,6 @@ struct _DbusmenuMenuitemProxyClass { /** DbusmenuMenuitemProxy: - @parent: The instance of #DbusmenuMenuitem Public instance data for a #DbusmenuMenuitemProxy. */ -- cgit v1.2.3 From e1c6f6e1ff157b43e1f07db384880749daa278c0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Feb 2011 14:14:56 -0600 Subject: Fixing allow annotation --- libdbusmenu-glib/menuitem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 580c452..4a1c156 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -297,7 +297,7 @@ typedef void (*dbusmenu_menuitem_about_to_show_cb) (DbusmenuMenuitem * mi, gpoin /** * dbusmenu_menuitem_buildvariant_slot_t: * @mi: (in): Menu item that should be built from - * @properties: (allow none): A list of properties that should be the only ones in the resulting variant structure + * @properties: (allow-none): A list of properties that should be the only ones in the resulting variant structure * * This is the function that is called to represent this menu item * as a variant. Should call it's own children. -- cgit v1.2.3 From b4fcda58ac462d058d589524c7a68592cf60b56e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Feb 2011 10:57:56 -0600 Subject: Should return VOID --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 7a279b1..b153900 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -261,7 +261,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_STRUCT_OFFSET(DbusmenuMenuitemClass, event), NULL, NULL, _dbusmenu_menuitem_marshal_VOID__STRING_VARIANT_UINT, - G_TYPE_BOOLEAN, 3, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_UINT); + G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_UINT); g_object_class_install_property (object_class, PROP_ID, g_param_spec_int(PROP_ID_S, "ID for the menu item", -- cgit v1.2.3 From d69242596c18abf533cabb4eba80b5200496349d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 09:36:15 -0600 Subject: Switch signal handler to return bool so that we can signal if someone has handled it --- libdbusmenu-glib/menuitem-marshal.list | 2 +- libdbusmenu-glib/menuitem.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem-marshal.list b/libdbusmenu-glib/menuitem-marshal.list index b2e02e5..4382ed7 100644 --- a/libdbusmenu-glib/menuitem-marshal.list +++ b/libdbusmenu-glib/menuitem-marshal.list @@ -4,4 +4,4 @@ VOID: OBJECT, UINT VOID: OBJECT VOID: VOID VOID: UINT -VOID: STRING, VARIANT, UINT +BOOLEAN: STRING, VARIANT, UINT diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index d8ae1a1..d420fd6 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -261,9 +261,9 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(DbusmenuMenuitemClass, event), - NULL, NULL, - _dbusmenu_menuitem_marshal_VOID__STRING_VARIANT_UINT, - G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_UINT); + g_signal_accumulator_true_handled, NULL, + _dbusmenu_menuitem_marshal_BOOLEAN__STRING_VARIANT_UINT, + G_TYPE_BOOLEAN, 3, G_TYPE_STRING, G_TYPE_VARIANT, G_TYPE_UINT); g_object_class_install_property (object_class, PROP_ID, g_param_spec_int(PROP_ID_S, "ID for the menu item", @@ -1533,12 +1533,13 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVari #endif DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi); - if (class->handle_event != NULL) { + gboolean handled = FALSE; + g_signal_emit(G_OBJECT(mi), EVENT, g_quark_from_string(name), name, variant, timestamp, &handled); + + if (!handled && class->handle_event != NULL) { return class->handle_event(mi, name, variant, timestamp); } - g_signal_emit(G_OBJECT(mi), EVENT, g_quark_from_string(name), name, variant, timestamp, TRUE); - return; } -- cgit v1.2.3 From 4c9b48b9f83801a398437f8fbf3f60a46d55b110 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 10:31:05 -0600 Subject: Redefine so that we don't recurse if we shouldn't --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ee18fab..f252afa 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1433,7 +1433,7 @@ dbusmenu_menuitem_build_variant (DbusmenuMenuitem * mi, const gchar ** propertie /* Pillage the children */ GList * children = dbusmenu_menuitem_get_children(mi); - if (children == NULL && recurse != 0) { + if (children == NULL || recurse == 0) { g_variant_builder_add_value(&tupleb, g_variant_new_array(G_VARIANT_TYPE_VARIANT, NULL, 0)); } else { GVariantBuilder childrenbuilder; -- cgit v1.2.3 From 3887a48a9c3557c396b472f7a8bb95101a025d0d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 11:21:10 -0600 Subject: If there's a singular NULL entry we also want the full list --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index bc38e24..3c8ff8d 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1274,7 +1274,7 @@ dbusmenu_menuitem_properties_variant (DbusmenuMenuitem * mi, const gchar ** prop GVariant * final_variant = NULL; - if (properties == NULL && g_hash_table_size(priv->properties) > 0) { + if ((properties == NULL || properties[0] == NULL) && g_hash_table_size(priv->properties) > 0) { GVariantBuilder builder; g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY); -- cgit v1.2.3 From 749be25d3f7736e518b3d33d3d64349118bfdf84 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 11:28:12 -0600 Subject: Adding visible and enabled to the initial grab. --- libdbusmenu-glib/client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index d990b93..b6a00fc 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -317,11 +317,13 @@ dbusmenu_client_init (DbusmenuClient *self) priv->layoutcall = NULL; - gchar * layout_props[3]; + gchar * layout_props[5]; layout_props[0] = DBUSMENU_MENUITEM_PROP_TYPE; layout_props[1] = DBUSMENU_MENUITEM_PROP_LABEL; - layout_props[2] = NULL; - priv->layout_props = g_variant_new_strv((const gchar * const *)layout_props, 2); + layout_props[2] = DBUSMENU_MENUITEM_PROP_VISIBLE; + layout_props[3] = DBUSMENU_MENUITEM_PROP_ENABLED; + layout_props[4] = NULL; + priv->layout_props = g_variant_new_strv((const gchar * const *)layout_props, 4); g_variant_ref_sink(priv->layout_props); priv->current_revision = 0; -- cgit v1.2.3 From 10859b3dd0cf399aa02a5adf7f848bb2e61121e5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 12:58:52 -0600 Subject: Search for and process type first --- libdbusmenu-glib/client.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b6a00fc..6e25ba1 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -1492,10 +1492,22 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem * menu item. Sometimes they may just be copies */ if (childmi != NULL) { GVariantIter iter; - g_variant_iter_init(&iter, g_variant_get_child_value(child, 1)); gchar * prop; GVariant * value; + /* Set the type first as it can manage the behavior of + all other properties. */ + g_variant_iter_init(&iter, g_variant_get_child_value(child, 1)); + while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) { + if (g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TYPE) == 0) { + dbusmenu_menuitem_property_set_variant(childmi, prop, value); + } + g_free(prop); + g_variant_unref(value); + } + + /* Now go through and do all the properties. */ + g_variant_iter_init(&iter, g_variant_get_child_value(child, 1)); while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) { dbusmenu_menuitem_property_set_variant(childmi, prop, value); g_free(prop); -- cgit v1.2.3 From c5550da0485ca4b51fb7721eba15322dc5f4f896 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 23 Feb 2011 13:24:04 -0600 Subject: Only look at defaults if we have a value to compare with. --- libdbusmenu-glib/menuitem.c | 47 ++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 22 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ee18fab..cdd2109 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1025,31 +1025,34 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro g_return_val_if_fail(property != NULL, FALSE); DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + GVariant * default_value = NULL; - const gchar * type = menuitem_get_type(mi); - - /* Check the expected type to see if we want to have a warning */ - GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); - if (default_type != NULL) { - /* If we have an expected type we should check to see if - the value we've been given is of the same type and generate - a warning if it isn't */ - if (!g_variant_is_of_type(value, default_type)) { - g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type)); + if (value != NULL) { + const gchar * type = menuitem_get_type(mi); + + /* Check the expected type to see if we want to have a warning */ + GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); + if (default_type != NULL) { + /* If we have an expected type we should check to see if + the value we've been given is of the same type and generate + a warning if it isn't */ + if (!g_variant_is_of_type(value, default_type)) { + g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type)); + } } - } - /* Check the defaults database to see if we have a default - for this property. */ - GVariant * default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); - if (default_value != NULL) { - /* Now see if we're setting this to the same value as the - default. If we are then we just want to swallow this variant - and make the function behave like we're clearing it. */ - if (g_variant_equal(default_value, value)) { - g_variant_ref_sink(value); - g_variant_unref(value); - value = NULL; + /* Check the defaults database to see if we have a default + for this property. */ + default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); + if (default_value != NULL) { + /* Now see if we're setting this to the same value as the + default. If we are then we just want to swallow this variant + and make the function behave like we're clearing it. */ + if (g_variant_equal(default_value, value)) { + g_variant_ref_sink(value); + g_variant_unref(value); + value = NULL; + } } } -- cgit v1.2.3 From ce5252f0de896c0d841fb250148285cf2be3c33e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 08:56:30 -0600 Subject: Bad merge, forgot this change in name --- libdbusmenu-glib/server.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index f49988d..3e07395 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -149,7 +149,7 @@ struct _DbusmenuServer { GType dbusmenu_server_get_type (void); DbusmenuServer * dbusmenu_server_new (const gchar * object); -void dbusmenu_server_set_root (DbusmenuServer * server, +void dbusmenu_server_set_root (DbusmenuServer * self, DbusmenuMenuitem * root); DbusmenuTextDirection dbusmenu_server_get_text_direction (DbusmenuServer * server); void dbusmenu_server_set_text_direction (DbusmenuServer * server, -- cgit v1.2.3 From 76b4e15adaf273d765fb9ef1f4e19c58fac67831 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 09:38:18 -0600 Subject: Documentation fixes --- libdbusmenu-glib/client.h | 15 +++++++++++++++ libdbusmenu-glib/defaults.c | 8 ++++---- libdbusmenu-glib/defaults.h | 4 ++-- libdbusmenu-glib/enum-types.h.in | 6 ++++++ libdbusmenu-glib/server.c | 2 ++ libdbusmenu-glib/server.h | 10 ++++++++++ libdbusmenu-glib/types.h | 11 +++++++++++ 7 files changed, 50 insertions(+), 6 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index 0b94eb2..28d4dd3 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -74,6 +74,11 @@ G_BEGIN_DECLS * String to attach to signal #DbusmenuClient::event-result */ #define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT "event-result" +/** + * DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED: + * + * String to attach to signal #DbusmenuClient::text-direction-changed + */ #define DBUSMENU_CLIENT_SIGNAL_TEXT_DIRECTION_CHANGED "text-direction-changed" /** @@ -88,7 +93,17 @@ G_BEGIN_DECLS * String to access property #DbusmenuClient:dbus-object */ #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object" +/** + * DBUSMENU_CLIENT_PROP_STATUS: + * + * String to access property #DbusmenuClient:status + */ #define DBUSMENU_CLIENT_PROP_STATUS "status" +/** + * DBUSMENU_CLIENT_PROP_TEXT_DIRECTION: + * + * String to access property #DbusmenuClient:text-direction + */ #define DBUSMENU_CLIENT_PROP_TEXT_DIRECTION "text-direction" /** diff --git a/libdbusmenu-glib/defaults.c b/libdbusmenu-glib/defaults.c index 3ad5d76..c05ef38 100644 --- a/libdbusmenu-glib/defaults.c +++ b/libdbusmenu-glib/defaults.c @@ -156,7 +156,7 @@ entry_destroy (gpointer entry) static DbusmenuDefaults * default_defaults = NULL; -/** +/* * dbusmenu_defaults_ref_default: * * Get a reference to the default instance. If it doesn't exist this @@ -177,7 +177,7 @@ dbusmenu_defaults_ref_default (void) return default_defaults; } -/** +/* * dbusmenu_defaults_default_set: * @defaults: The #DbusmenuDefaults object to add to * @type: (allow-none): The #DbusmenuMenuitem type for this default if #NULL will default to #DBUSMENU_CLIENT_TYPE_DEFAULT @@ -216,7 +216,7 @@ dbusmenu_defaults_default_set (DbusmenuDefaults * defaults, const gchar * type, return; } -/** +/* * dbusmenu_defaults_default_get: * @defaults: The default database to use * @type: (allow-none): The #DbusmenuMenuitem type for this default if #NULL will default to #DBUSMENU_CLIENT_TYPE_DEFAULT @@ -253,7 +253,7 @@ dbusmenu_defaults_default_get (DbusmenuDefaults * defaults, const gchar * type, return entry->value; } -/** +/* * dbusmenu_defaults_default_get_type: * @defaults: The default database to use * @type: (allow-none): The #DbusmenuMenuitem type for this default if #NULL will default to #DBUSMENU_CLIENT_TYPE_DEFAULT diff --git a/libdbusmenu-glib/defaults.h b/libdbusmenu-glib/defaults.h index ab377f7..a1a8158 100644 --- a/libdbusmenu-glib/defaults.h +++ b/libdbusmenu-glib/defaults.h @@ -45,7 +45,7 @@ typedef struct _DbusmenuDefaults DbusmenuDefaults; typedef struct _DbusmenuDefaultsClass DbusmenuDefaultsClass; typedef struct _DbusmenuDefaultsPrivate DbusmenuDefaultsPrivate; -/** +/* * DbusmenuDefaultsClass: * * All of the signals and functions for #DbusmenuDefaults @@ -54,7 +54,7 @@ struct _DbusmenuDefaultsClass { GObjectClass parent_class; }; -/** +/* * DbusmenuDefaults: * * A singleton to hold all of the defaults for the menuitems diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in index 8c5f463..488b615 100644 --- a/libdbusmenu-glib/enum-types.h.in +++ b/libdbusmenu-glib/enum-types.h.in @@ -51,6 +51,12 @@ G_END_DECLS GType @enum_name@_get_type (void) G_GNUC_CONST; const gchar * @enum_name@_get_nick (@EnumName@ value) G_GNUC_CONST; @EnumName@ @enum_name@_get_value_from_nick (const gchar * nick) G_GNUC_CONST; +/** + DBUSMENU_TYPE_@ENUMSHORT@: + + Gets the #GType value for the type associated with the + #@EnumName@ enumerated type. +*/ #define DBUSMENU_TYPE_@ENUMSHORT@ (@enum_name@_get_type()) /*** END value-header ***/ diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index c3faa6b..e3fd2cd 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -1635,6 +1635,7 @@ dbusmenu_server_get_text_direction (DbusmenuServer * server) /** dbusmenu_server_set_text_direction: @server: The #DbusmenuServer object to set the text direction on + @dir: Direction of the text Sets the text direction that should be exported over DBus for this server. If the value is set to #DBUSMENU_TEXT_DIRECTION_NONE @@ -1682,6 +1683,7 @@ dbusmenu_server_get_status (DbusmenuServer * server) /** dbusmenu_server_set_status: @server: The #DbusmenuServer to set the status on + @status: Status value to set on the server Changes the status of the server. */ diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 3e07395..80b7abb 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -93,7 +93,17 @@ G_BEGIN_DECLS * String to access property #DbusmenuServer:version */ #define DBUSMENU_SERVER_PROP_VERSION "version" +/** + * DBUSMENU_SERVER_PROP_TEXT_DIRECTION: + * + * String to access property #DbusmenuServer:text-direction + */ #define DBUSMENU_SERVER_PROP_TEXT_DIRECTION "text-direction" +/** + * DBUSMENU_SERVER_PROP_STATUS: + * + * String to access property #DbusmenuServer:status + */ #define DBUSMENU_SERVER_PROP_STATUS "status" typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; diff --git a/libdbusmenu-glib/types.h b/libdbusmenu-glib/types.h index e573476..03ae801 100644 --- a/libdbusmenu-glib/types.h +++ b/libdbusmenu-glib/types.h @@ -59,6 +59,17 @@ typedef enum { /*< prefix=DBUSMENU_STATUS >*/ DBUSMENU_STATUS_NOTICE /*< nick=notice >*/ } DbusmenuStatus; +/** + SECTION:types + @short_description: Types that are used by both client and + server. + @stability: Unstable + @include: libdbusmenu-glib/types.h + + Enums that are used to describe states of the server across the + bus. They are sent over dbus using their nicks but then turned + back into enums by the client. +*/ G_END_DECLS #endif /* __DBUSMENU_TYPES_H__ */ -- cgit v1.2.3 From 37fb090b4f9fb1e1a894c5c57e7c3d28eb71f92d Mon Sep 17 00:00:00 2001 From: Chris Coulson Date: Thu, 24 Feb 2011 15:43:25 +0000 Subject: Hold a weak pointer to each DbusmenuMenuitems parent. This avoids using g_object_{get/set}_data for storing a nodes parent in the parser code, and the associated problems with that (ie, a child out-living its parent, leading to invalid reads --- libdbusmenu-glib/menuitem.c | 102 +++++++++++++++++++++++++++++++++++++++++++- libdbusmenu-glib/menuitem.h | 4 ++ 2 files changed, 104 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 89b2b91..49b83ce 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -62,6 +62,7 @@ struct _DbusmenuMenuitemPrivate gboolean realized; DbusmenuDefaults * defaults; gboolean exposed; + DbusmenuMenuitem * parent; }; /* Signals */ @@ -339,6 +340,11 @@ dbusmenu_menuitem_dispose (GObject *object) priv->defaults = NULL; } + if (priv->parent) { + g_object_remove_weak_pointer(G_OBJECT(priv->parent), (gpointer *)&priv->parent); + priv->parent = NULL; + } + G_OBJECT_CLASS (dbusmenu_menuitem_parent_class)->dispose (object); return; } @@ -565,11 +571,12 @@ dbusmenu_menuitem_get_children (DbusmenuMenuitem * mi) /* For all the taken children we need to signal that they were removed */ static void -take_children_signal (gpointer data, gpointer user_data) +take_children_helper (gpointer data, gpointer user_data) { #ifdef MASSIVEDEBUGGING g_debug("Menuitem %d (%s) signalling child removed %d (%s)", ID(user_data), LABEL(user_data), ID(data), LABEL(data)); #endif + dbusmenu_menuitem_unparent(DBUSMENU_MENUITEM(data)); g_signal_emit(G_OBJECT(user_data), signals[CHILD_REMOVED], 0, DBUSMENU_MENUITEM(data), TRUE); return; } @@ -595,7 +602,7 @@ dbusmenu_menuitem_take_children (DbusmenuMenuitem * mi) DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); GList * children = priv->children; priv->children = NULL; - g_list_foreach(children, take_children_signal, mi); + g_list_foreach(children, take_children_helper, mi); dbusmenu_menuitem_property_remove(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY); @@ -704,6 +711,10 @@ dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE); + if (!dbusmenu_menuitem_set_parent(child, mi)) { + return FALSE; + } + if (priv->children == NULL && !dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY)) { dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU); } @@ -736,6 +747,10 @@ dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE); + if (!dbusmenu_menuitem_set_parent(child, mi)) { + return FALSE; + } + if (priv->children == NULL && !dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY)) { dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU); } @@ -768,6 +783,7 @@ dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); priv->children = g_list_remove(priv->children, child); + dbusmenu_menuitem_unparent(child); #ifdef MASSIVEDEBUGGING g_debug("Menuitem %d (%s) signalling child removed %d (%s)", ID(mi), LABEL(mi), ID(child), LABEL(child)); #endif @@ -802,6 +818,10 @@ dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE); + if (!dbusmenu_menuitem_set_parent(child, mi)) { + return FALSE; + } + if (priv->children == NULL && !dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY)) { dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU); } @@ -936,6 +956,84 @@ dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id) return find_id.mi; } +/** + * dbusmenu_menuitem_set_parent: + * @mi: The #DbusmenuMenuitem for which to set the parent + * @parent: The new parent #DbusmenuMenuitem + * + * Sets the parent of @mi to @parent. If @mi already + * has a parent, then this call will fail. The parent will + * be set automatically when using the usual methods to add a + * child menuitem, so this function should not normally be + * called directly + * + * Return value: Whether the parent was set successfully + */ +gboolean +dbusmenu_menuitem_set_parent (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent) +{ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + + if (priv->parent != NULL) { + g_warning ("Menu item already has a parent"); + return FALSE; + } + + priv->parent = parent; + g_object_add_weak_pointer(G_OBJECT(priv->parent), (gpointer *)&priv->parent); + + return TRUE; +} + +/** + * dbusmenu_menuitem_unparent: + * @mi: The #DbusmenuMenuitem to unparent + * + * Unparents the menu item @mi. If @mi doesn't have a + * parent, then this call will fail. The menuitem will + * be unparented automatically when using the usual methods + * to delete a child menuitem, so this function should not + * normally be called directly + * + * Return value: Whether the menu item was unparented successfully + */ +gboolean +dbusmenu_menuitem_unparent (DbusmenuMenuitem * mi) +{ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + + if (priv->parent == NULL) { + g_warning("Menu item doesn't have a parent"); + return FALSE; + } + + g_object_remove_weak_pointer(G_OBJECT(priv->parent), (gpointer *)&priv->parent); + priv->parent = NULL; + + return TRUE; +} + +/** + * dbusmenu_menuitem_get_parent: + * @mi: The #DbusmenuMenuitem for which to inspect the parent + * + * This function looks up the parent of @mi + * + * Return value: The parent of this menu item + */ +DbusmenuMenuitem * +dbusmenu_menuitem_get_parent (DbusmenuMenuitem * mi) +{ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + + return priv->parent; +} + /** * dbusmenu_menuitem_property_set: * @mi: The #DbusmenuMenuitem to set the property on. diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 4a1c156..5f56803 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -379,6 +379,10 @@ gboolean dbusmenu_menuitem_child_reorder (DbusmenuMenuitem * mi, DbusmenuMenuite DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, gint id); DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id); +gboolean dbusmenu_menuitem_set_parent (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent); +gboolean dbusmenu_menuitem_unparent (DbusmenuMenuitem *mi); +DbusmenuMenuitem * dbusmenu_menuitem_get_parent (DbusmenuMenuitem * mi); + gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); gboolean dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * property, GVariant * value); gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value); -- cgit v1.2.3 From 3cb0a087b79ef0af68b3ba73944f503823603bff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 10:26:27 -0600 Subject: Checking to ensure we're the parent before deleting --- libdbusmenu-glib/menuitem.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 49b83ce..0bbce8c 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -781,6 +781,11 @@ dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE); + if (dbusmenu_menuitem_get_parent(child) != mi) { + g_warning("Trying to remove a child that doesn't believe we're it's parent."); + return FALSE; + } + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); priv->children = g_list_remove(priv->children, child); dbusmenu_menuitem_unparent(child); -- cgit v1.2.3 From 2dce5a22fac21e608b85630a825c36fc86c1c592 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 10:27:07 -0600 Subject: Adding a transfer annotation for the get_parent function --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 0bbce8c..de8a1ad 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1028,7 +1028,7 @@ dbusmenu_menuitem_unparent (DbusmenuMenuitem * mi) * * This function looks up the parent of @mi * - * Return value: The parent of this menu item + * Return value: (transfer none): The parent of this menu item */ DbusmenuMenuitem * dbusmenu_menuitem_get_parent (DbusmenuMenuitem * mi) -- cgit v1.2.3 From 0e833536055614008cd6f75734d2c2a8c1e646bf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 10:35:55 -0600 Subject: Fixing signal emition to use the saved value instead of the enum --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 3dd98df..fb138b6 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1671,7 +1671,7 @@ dbusmenu_menuitem_handle_event (DbusmenuMenuitem * mi, const gchar * name, GVari DbusmenuMenuitemClass * class = DBUSMENU_MENUITEM_GET_CLASS(mi); gboolean handled = FALSE; - g_signal_emit(G_OBJECT(mi), EVENT, g_quark_from_string(name), name, variant, timestamp, &handled); + g_signal_emit(G_OBJECT(mi), signals[EVENT], g_quark_from_string(name), name, variant, timestamp, &handled); if (!handled && class->handle_event != NULL) { return class->handle_event(mi, name, variant, timestamp); -- cgit v1.2.3 From 5525e24ddca6e5ef60ba888b0032674464ccfd17 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 10:52:10 -0600 Subject: Document the event signal define. --- libdbusmenu-glib/menuitem.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 6d41e25..f4eb989 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -96,6 +96,11 @@ G_BEGIN_DECLS * String to attach to signal #DbusmenuServer::about-to-show */ #define DBUSMENU_MENUITEM_SIGNAL_ABOUT_TO_SHOW "about-to-show" +/** + * DBUSMENU_MENUITEM_SIGNAL_EVENT: + * + * String to attach to signal #DbusmenuServer::event + */ #define DBUSMENU_MENUITEM_SIGNAL_EVENT "event" /** -- cgit v1.2.3 From 3566852c8b4330cff84f4a7c6bcf18601264f747 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 13:52:01 -0600 Subject: Set property to status and return it --- libdbusmenu-glib/dbus-menu.xml | 2 +- libdbusmenu-glib/server.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 829c16e..0d2a2d6 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -179,7 +179,7 @@ License version 3 and version 2.1 along with this program. If not, see - + Tells if the menus are in a normal state or they believe that they could use some attention. Cases for showing them would be if help diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index e3fd2cd..056d6cb 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -744,6 +744,8 @@ bus_get_prop (GDBusConnection * connection, const gchar * sender, const gchar * return g_variant_new_uint32(DBUSMENU_VERSION_NUMBER); } else if (g_strcmp0(property, "text-direction") == 0) { return g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction)); + } else if (g_strcmp0(property, "status") == 0) { + return g_variant_new_string(dbusmenu_status_get_nick(priv->status)); } else { g_warning("Unknown property '%s'", property); } -- cgit v1.2.3 From 78f43d50ded332c262d28cfc268ea1c9928aef7e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 24 Feb 2011 14:21:43 -0600 Subject: Marking as having details available in the signal --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index fb138b6..5202aa1 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -261,7 +261,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) */ signals[EVENT] = g_signal_new(DBUSMENU_MENUITEM_SIGNAL_EVENT, G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, + G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, G_STRUCT_OFFSET(DbusmenuMenuitemClass, event), g_signal_accumulator_true_handled, NULL, _dbusmenu_menuitem_marshal_BOOLEAN__STRING_VARIANT_UINT, -- cgit v1.2.3