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(+) 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 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 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 c4dc796cc3fa9905db875e021ccc29763fda616e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Feb 2011 22:22:56 -0600 Subject: Add the enum helper make file from Clutter --- Makefile.am.enum | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Makefile.am.enum diff --git a/Makefile.am.enum b/Makefile.am.enum new file mode 100644 index 0000000..0503de0 --- /dev/null +++ b/Makefile.am.enum @@ -0,0 +1,45 @@ +# Rules for generating enumeration types using glib-mkenums +# +# Define: +# glib_enum_h = header template file +# glib_enum_c = source template file +# glib_enum_headers = list of headers to parse +# +# before including Makefile.am.enums. You will also need to have +# the following targets already defined: +# +# CLEANFILES +# DISTCLEANFILES +# BUILT_SOURCES +# EXTRA_DIST +# +# Author: Emmanuele Bassi + +enum_tmpl_h=$(glib_enum_h:.h=.h.in) +enum_tmpl_c=$(glib_enum_c:.c=.c.in) + +CLEANFILES += stamp-enum-types +DISTCLEANFILES += $(glib_enum_h) $(glib_enum_c) +BUILT_SOURCES += $(glib_enum_h) $(glib_enum_c) +EXTRA_DIST += $(enum_tmpl_h) $(enum_tmpl_c) + +stamp-enum-types: $(glib_enum_headers) + $(QUIET_GEN)mkdir -p `dirname $(builddir)/$(glib_enum_h)` + $(QUIET_GEN)$(GLIB_MKENUMS) \ + --template $(srcdir)/$(enum_tmpl_h) \ + $(glib_enum_headers) > xgen-eh \ + && (cmp -s xgen-eh $(builddir)/$(glib_enum_h) || cp -f xgen-eh $(builddir)/$(glib_enum_h)) \ + && rm -f xgen-eh \ + && echo timestamp > $(@F) + +$(glib_enum_h): stamp-enum-types + @true + +$(glib_enum_c): $(glib_enum_h) + $(QUIET_GEN)mkdir -p `dirname $(builddir)/$(glib_enum_c)` + $(QUIET_GEN)$(GLIB_MKENUMS) \ + --template $(srcdir)/$(enum_tmpl_c) \ + $(glib_enum_headers) > xgen-ec \ + && cp -f xgen-ec $(builddir)/$(glib_enum_c) \ + && rm -f xgen-ec + -- 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 --- configure.ac | 2 ++ libdbusmenu-glib/Makefile.am | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 4510b6d..f1c275f 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,8 @@ AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) +AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]) + AC_ARG_ENABLE([deprecations], [AS_HELP_STRING([--enable-deprecations], [allow deprecated API usage @<:@default=yes@:>@])], 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(-) 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(-) 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 80845fd8f04b15f2932fadcd372523ca21365f83 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Feb 2011 22:56:18 -0600 Subject: Ignoring the enum built files --- .bzrignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.bzrignore b/.bzrignore index 39be2d5..29ec5a8 100644 --- a/.bzrignore +++ b/.bzrignore @@ -227,3 +227,7 @@ libdbusmenu-gtk/libdbusmenu_gtk_la-parser.lo test-gtk-parser test-gtk-parser-test test-gtk-parser.xml +enum-types.c +enum-types.h +libdbusmenu_glib_la-enum-types.lo +stamp-enum-types -- 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(-) 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(+) 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(-) 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(+) 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(-) 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(+) 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 8905d4a0b3964e12e484423c1883535c70014a17 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Feb 2011 21:47:58 -0600 Subject: Adding in the server.c file to POTFILES.in to get the default text direction --- po/POTFILES.in | 1 + 1 file changed, 1 insertion(+) diff --git a/po/POTFILES.in b/po/POTFILES.in index e69de29..3536e22 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -0,0 +1 @@ +libdbusmenu-glib/server.c -- 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(+) 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(+) 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(-) 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(-) 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(-) 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(+) 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(+) 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(+) 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(-) 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(-) 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(-) 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 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(-) 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