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