← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~ted/dbusmenu/need-some-love into lp:dbusmenu

 

Ted Gould has proposed merging lp:~ted/dbusmenu/need-some-love into lp:dbusmenu with lp:~ted/dbusmenu/ltr-rtl-property as a prerequisite.

Requested reviews:
  DBus Menu Team (dbusmenu-team)

For more details, see:
https://code.launchpad.net/~ted/dbusmenu/need-some-love/+merge/50403

Adds in a status for tracking whether the server believes the menus should be given special attention.
-- 
https://code.launchpad.net/~ted/dbusmenu/need-some-love/+merge/50403
Your team ayatana-commits is subscribed to branch lp:dbusmenu.
=== modified file 'libdbusmenu-glib/client.c'
--- libdbusmenu-glib/client.c	2011-02-18 22:21:22 +0000
+++ libdbusmenu-glib/client.c	2011-02-18 22:21:22 +0000
@@ -50,6 +50,7 @@
 	PROP_0,
 	PROP_DBUSOBJECT,
 	PROP_DBUSNAME,
+	PROP_STATUS,
 	PROP_TEXT_DIRECTION
 };
 
@@ -94,6 +95,7 @@
 	gint delayed_idle;
 
 	DbusmenuTextDirection text_direction;
+	DbusmenuStatus status;
 };
 
 typedef struct _newItemPropData newItemPropData;
@@ -279,6 +281,11 @@
 	                                              "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",
@@ -339,6 +346,7 @@
 	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;
 }
@@ -484,6 +492,9 @@
 	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;
@@ -1036,6 +1047,7 @@
 {
 	DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data);
 	DbusmenuTextDirection olddir = priv->text_direction;
+	DbusmenuStatus oldstatus = priv->status;
 
 	/* Invalidate first */
 	gchar * invalid;
@@ -1044,6 +1056,9 @@
 		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 */
@@ -1059,6 +1074,14 @@
 
 			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);
@@ -1068,6 +1091,10 @@
 		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;
 }
 
@@ -1921,3 +1948,25 @@
 	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;
+}
+
+

=== modified file 'libdbusmenu-glib/client.h'
--- libdbusmenu-glib/client.h	2011-02-18 22:21:22 +0000
+++ libdbusmenu-glib/client.h	2011-02-18 22:21:22 +0000
@@ -53,6 +53,7 @@
 
 #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 (*cb) (gpointer user_data),
                                                         gpointer cb_data);
 DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client);
+DbusmenuStatus       dbusmenu_client_get_status        (DbusmenuClient * client);
 
 /**
 	SECTION:client

=== modified file 'libdbusmenu-glib/dbus-menu.xml'
--- libdbusmenu-glib/dbus-menu.xml	2011-02-18 22:21:22 +0000
+++ libdbusmenu-glib/dbus-menu.xml	2011-02-18 22:21:22 +0000
@@ -179,6 +179,16 @@
 			</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">

=== modified file 'libdbusmenu-glib/server.c'
--- libdbusmenu-glib/server.c	2011-02-18 22:21:22 +0000
+++ libdbusmenu-glib/server.c	2011-02-18 22:21:22 +0000
@@ -58,6 +58,7 @@
 	guint dbus_registration;
 
 	DbusmenuTextDirection text_direction;
+	DbusmenuStatus status;
 
 	GArray * prop_array;
 	guint property_idle;
@@ -82,7 +83,8 @@
 	PROP_DBUS_OBJECT,
 	PROP_ROOT_NODE,
 	PROP_VERSION,
-	PROP_TEXT_DIRECTION
+	PROP_TEXT_DIRECTION,
+	PROP_STATUS
 };
 
 /* Errors */
@@ -300,6 +302,11 @@
 	                                              "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 @@
 	priv->dbus_registration = 0;
 
 	default_text_direction(self);
+	priv->status = DBUSMENU_STATUS_NORMAL;
 
 	return;
 }
@@ -509,6 +517,31 @@
 
 		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 @@
 	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;
@@ -1606,3 +1642,46 @@
 	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;
+}

=== modified file 'libdbusmenu-glib/server.h'
--- libdbusmenu-glib/server.h	2011-02-18 22:21:22 +0000
+++ libdbusmenu-glib/server.h	2011-02-18 22:21:22 +0000
@@ -54,6 +54,7 @@
 #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 @@
 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

=== modified file 'libdbusmenu-glib/types.h'
--- libdbusmenu-glib/types.h	2011-02-18 22:21:22 +0000
+++ libdbusmenu-glib/types.h	2011-02-18 22:21:22 +0000
@@ -47,6 +47,17 @@
 	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
 


Follow ups