aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog3
-rw-r--r--libdbusmenu-glib/client.c49
-rw-r--r--libdbusmenu-glib/client.h2
-rw-r--r--libdbusmenu-glib/dbus-menu.xml10
-rw-r--r--libdbusmenu-glib/server.c81
-rw-r--r--libdbusmenu-glib/server.h4
-rw-r--r--libdbusmenu-glib/types.h11
7 files changed, 158 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index de4d66b..bae4272 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,8 +6,9 @@ libdbusmenu (0.3.98-0ubuntu2~ppa1) UNRELASED; urgency=low
* Only send property updates if the menu item has been
seen on the bus.
* Add a property for text direction.
+ * Add a property for needing attention.
- -- Ted Gould <ted@ubuntu.com> Mon, 21 Feb 2011 22:29:36 -0600
+ -- Ted Gould <ted@ubuntu.com> Mon, 21 Feb 2011 22:30:06 -0600
libdbusmenu (0.3.98-0ubuntu1) natty; urgency=low
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 00a7b3f..9422baf 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -50,6 +50,7 @@ enum {
PROP_0,
PROP_DBUSOBJECT,
PROP_DBUSNAME,
+ PROP_STATUS,
PROP_TEXT_DIRECTION
};
@@ -95,6 +96,7 @@ struct _DbusmenuClientPrivate
gint delayed_idle;
DbusmenuTextDirection text_direction;
+ DbusmenuStatus status;
};
typedef struct _newItemPropData newItemPropData;
@@ -280,6 +282,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));
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",
@@ -347,6 +354,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;
}
@@ -497,6 +505,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;
case PROP_TEXT_DIRECTION:
g_value_set_enum(value, priv->text_direction);
break;
@@ -1049,6 +1060,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;
@@ -1057,6 +1069,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 */
@@ -1072,6 +1087,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);
@@ -1081,6 +1104,10 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva
g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_TEXT_DIRECTION);
}
+ if (oldstatus != priv->status) {
+ g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_STATUS);
+ }
+
return;
}
@@ -1949,3 +1976,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 4d20a97..c04e840 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_PROP_TEXT_DIRECTION "text-direction"
#define DBUSMENU_CLIENT_TYPES_DEFAULT "standard"
@@ -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
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
</dox:d>
</property>
+ <property name="state" type="s" access="read">
+ <dox:d>
+ 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.
+ </dox:d>
+ </property>
+
<!-- Functions -->
<method name="GetLayout">
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index 3978167..bbff238 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;
@@ -82,7 +83,8 @@ enum {
PROP_DBUS_OBJECT,
PROP_ROOT_NODE,
PROP_VERSION,
- PROP_TEXT_DIRECTION
+ PROP_TEXT_DIRECTION,
+ PROP_STATUS
};
/* Errors */
@@ -300,6 +302,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;
@@ -360,6 +367,7 @@ dbusmenu_server_init (DbusmenuServer *self)
priv->dbus_registration = 0;
default_text_direction(self);
+ priv->status = DBUSMENU_STATUS_NORMAL;
return;
}
@@ -509,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(&params, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_add_value(&params, 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(&params, g_variant_new_array(NULL, &dict, 1));
+ g_variant_builder_add_value(&params, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0));
+ GVariant * vparams = g_variant_builder_end(&params);
+
+ 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;
@@ -535,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;
@@ -1617,3 +1653,46 @@ 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)
+{
+ g_return_val_if_fail(DBUSMENU_IS_SERVER(server), 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;
+}
+
+/**
+ 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)
+{
+ 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;
+}
diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h
index 7923b45..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;
@@ -115,6 +116,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
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