Merge lp:~ted/libdbusmenu/need-some-love into lp:libdbusmenu/0.5

Proposed by Ted Gould
Status: Merged
Approved by: Kalle Valo
Approved revision: 244
Merged at revision: 225
Proposed branch: lp:~ted/libdbusmenu/need-some-love
Merge into: lp:libdbusmenu/0.5
Prerequisite: lp:~ted/libdbusmenu/ltr-rtl-property
Diff against target: 334 lines (+156/-1)
6 files modified
libdbusmenu-glib/client.c (+49/-0)
libdbusmenu-glib/client.h (+2/-0)
libdbusmenu-glib/dbus-menu.xml (+10/-0)
libdbusmenu-glib/server.c (+80/-1)
libdbusmenu-glib/server.h (+4/-0)
libdbusmenu-glib/types.h (+11/-0)
To merge this branch: bzr merge lp:~ted/libdbusmenu/need-some-love
Reviewer Review Type Date Requested Status
Kalle Valo (community) Approve
Review via email: mp+50403@code.launchpad.net

Description of the change

Adds in a status for tracking whether the server believes the menus should be given special attention.

To post a comment you must log in.
Revision history for this message
Kalle Valo (kvalo) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libdbusmenu-glib/client.c'
2--- libdbusmenu-glib/client.c 2011-02-18 22:21:22 +0000
3+++ libdbusmenu-glib/client.c 2011-02-18 22:21:22 +0000
4@@ -50,6 +50,7 @@
5 PROP_0,
6 PROP_DBUSOBJECT,
7 PROP_DBUSNAME,
8+ PROP_STATUS,
9 PROP_TEXT_DIRECTION
10 };
11
12@@ -94,6 +95,7 @@
13 gint delayed_idle;
14
15 DbusmenuTextDirection text_direction;
16+ DbusmenuStatus status;
17 };
18
19 typedef struct _newItemPropData newItemPropData;
20@@ -279,6 +281,11 @@
21 "Name of the DBus client we're connecting to.",
22 NULL,
23 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
24+ g_object_class_install_property (object_class, PROP_STATUS,
25+ g_param_spec_enum(DBUSMENU_CLIENT_PROP_STATUS, "Status of viewing the menus",
26+ "Whether the menus should be given special visuals",
27+ DBUSMENU_TYPE_STATUS, DBUSMENU_STATUS_NORMAL,
28+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
29 g_object_class_install_property (object_class, PROP_TEXT_DIRECTION,
30 g_param_spec_enum(DBUSMENU_CLIENT_PROP_TEXT_DIRECTION, "Direction text values have",
31 "Signals which direction the default text direction is for the menus",
32@@ -339,6 +346,7 @@
33 priv->delayed_property_listeners = g_array_new(FALSE, FALSE, sizeof(properties_listener_t));
34
35 priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE;
36+ priv->status = DBUSMENU_STATUS_NORMAL;
37
38 return;
39 }
40@@ -484,6 +492,9 @@
41 case PROP_DBUSOBJECT:
42 g_value_set_string(value, priv->dbus_object);
43 break;
44+ case PROP_STATUS:
45+ g_value_set_enum(value, priv->status);
46+ break;
47 case PROP_TEXT_DIRECTION:
48 g_value_set_enum(value, priv->text_direction);
49 break;
50@@ -1036,6 +1047,7 @@
51 {
52 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(user_data);
53 DbusmenuTextDirection olddir = priv->text_direction;
54+ DbusmenuStatus oldstatus = priv->status;
55
56 /* Invalidate first */
57 gchar * invalid;
58@@ -1044,6 +1056,9 @@
59 if (g_strcmp0(invalid, "text-direction") == 0) {
60 priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE;
61 }
62+ if (g_strcmp0(invalid, "status") == 0) {
63+ priv->status = DBUSMENU_STATUS_NORMAL;
64+ }
65 }
66
67 /* Check updates */
68@@ -1059,6 +1074,14 @@
69
70 priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL));
71 }
72+ if (g_strcmp0(key, "status") == 0) {
73+ GVariant * str = value;
74+ if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) {
75+ str = g_variant_get_variant(str);
76+ }
77+
78+ priv->status = dbusmenu_status_get_value_from_nick(g_variant_get_string(str, NULL));
79+ }
80
81 g_variant_unref(value);
82 g_free(key);
83@@ -1068,6 +1091,10 @@
84 g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_TEXT_DIRECTION);
85 }
86
87+ if (oldstatus != priv->status) {
88+ g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_STATUS);
89+ }
90+
91 return;
92 }
93
94@@ -1921,3 +1948,25 @@
95 DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
96 return priv->text_direction;
97 }
98+
99+/**
100+ dbusmenu_client_get_status:
101+ @client: #DbusmenuClient to check the status on
102+
103+ Gets the recommended current status that the server
104+ is exporting for the menus. In situtations where the
105+ value is #DBUSMENU_STATUS_NOTICE it is recommended that
106+ the client show the menus to the user an a more noticible
107+ way.
108+
109+ Return value: Status being exported.
110+*/
111+DbusmenuStatus
112+dbusmenu_client_get_status (DbusmenuClient * client)
113+{
114+ g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), DBUSMENU_STATUS_NORMAL);
115+ DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
116+ return priv->status;
117+}
118+
119+
120
121=== modified file 'libdbusmenu-glib/client.h'
122--- libdbusmenu-glib/client.h 2011-02-18 22:21:22 +0000
123+++ libdbusmenu-glib/client.h 2011-02-18 22:21:22 +0000
124@@ -53,6 +53,7 @@
125
126 #define DBUSMENU_CLIENT_PROP_DBUS_NAME "dbus-name"
127 #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT "dbus-object"
128+#define DBUSMENU_CLIENT_PROP_STATUS "status"
129 #define DBUSMENU_CLIENT_PROP_TEXT_DIRECTION "text-direction"
130
131 #define DBUSMENU_CLIENT_TYPES_DEFAULT "standard"
132@@ -159,6 +160,7 @@
133 void (*cb) (gpointer user_data),
134 gpointer cb_data);
135 DbusmenuTextDirection dbusmenu_client_get_text_direction (DbusmenuClient * client);
136+DbusmenuStatus dbusmenu_client_get_status (DbusmenuClient * client);
137
138 /**
139 SECTION:client
140
141=== modified file 'libdbusmenu-glib/dbus-menu.xml'
142--- libdbusmenu-glib/dbus-menu.xml 2011-02-18 22:21:22 +0000
143+++ libdbusmenu-glib/dbus-menu.xml 2011-02-18 22:21:22 +0000
144@@ -179,6 +179,16 @@
145 </dox:d>
146 </property>
147
148+ <property name="state" type="s" access="read">
149+ <dox:d>
150+ Tells if the menus are in a normal state or they believe that they
151+ could use some attention. Cases for showing them would be if help
152+ were referring to them or they accessors were being highlighted.
153+ This property can have two values: "normal" in almost all cases and
154+ "notice" when they should have a higher priority to be shown.
155+ </dox:d>
156+ </property>
157+
158 <!-- Functions -->
159
160 <method name="GetLayout">
161
162=== modified file 'libdbusmenu-glib/server.c'
163--- libdbusmenu-glib/server.c 2011-02-18 22:21:22 +0000
164+++ libdbusmenu-glib/server.c 2011-02-18 22:21:22 +0000
165@@ -58,6 +58,7 @@
166 guint dbus_registration;
167
168 DbusmenuTextDirection text_direction;
169+ DbusmenuStatus status;
170
171 GArray * prop_array;
172 guint property_idle;
173@@ -82,7 +83,8 @@
174 PROP_DBUS_OBJECT,
175 PROP_ROOT_NODE,
176 PROP_VERSION,
177- PROP_TEXT_DIRECTION
178+ PROP_TEXT_DIRECTION,
179+ PROP_STATUS
180 };
181
182 /* Errors */
183@@ -300,6 +302,11 @@
184 "The object that represents this set of menus on DBus",
185 DBUSMENU_TYPE_TEXT_DIRECTION, DBUSMENU_TEXT_DIRECTION_NONE,
186 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
187+ g_object_class_install_property (object_class, PROP_STATUS,
188+ g_param_spec_enum(DBUSMENU_SERVER_PROP_STATUS, "Status of viewing the menus",
189+ "Exports over DBus whether the menus should be given special visuals",
190+ DBUSMENU_TYPE_STATUS, DBUSMENU_STATUS_NORMAL,
191+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
192
193 if (dbusmenu_node_info == NULL) {
194 GError * error = NULL;
195@@ -360,6 +367,7 @@
196 priv->dbus_registration = 0;
197
198 default_text_direction(self);
199+ priv->status = DBUSMENU_STATUS_NORMAL;
200
201 return;
202 }
203@@ -509,6 +517,31 @@
204
205 break;
206 }
207+ case PROP_STATUS: {
208+ DbusmenuStatus instatus = g_value_get_enum(value);
209+
210+ /* If the value has changed we need to signal that on DBus */
211+ if (priv->status != instatus && priv->bus != NULL && priv->dbusobject != NULL) {
212+ GVariantBuilder params;
213+ g_variant_builder_init(&params, G_VARIANT_TYPE_ARRAY);
214+ g_variant_builder_add_value(&params, g_variant_new_string(DBUSMENU_INTERFACE));
215+ GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("status"), g_variant_new_string(dbusmenu_status_get_nick(instatus)));
216+ g_variant_builder_add_value(&params, g_variant_new_array(NULL, &dict, 1));
217+ g_variant_builder_add_value(&params, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0));
218+ GVariant * vparams = g_variant_builder_end(&params);
219+
220+ g_dbus_connection_emit_signal(priv->bus,
221+ NULL,
222+ priv->dbusobject,
223+ "org.freedesktop.DBus.Properties",
224+ "PropertiesChanged",
225+ vparams,
226+ NULL);
227+ }
228+
229+ priv->status = instatus;
230+ break;
231+ }
232 default:
233 g_return_if_reached();
234 break;
235@@ -535,6 +568,9 @@
236 case PROP_TEXT_DIRECTION:
237 g_value_set_enum(value, priv->text_direction);
238 break;
239+ case PROP_STATUS:
240+ g_value_set_enum(value, priv->status);
241+ break;
242 default:
243 g_return_if_reached();
244 break;
245@@ -1606,3 +1642,46 @@
246 return;
247 }
248
249+/**
250+ dbusmenu_server_get_status:
251+ @server: The #DbusmenuServer to get the status from
252+
253+ Gets the current statust hat the server is sending out over
254+ DBus.
255+
256+ Return value: The current status the server is sending
257+*/
258+DbusmenuStatus
259+dbusmenu_server_get_status (DbusmenuServer * server)
260+{
261+ g_return_val_if_fail(DBUSMENU_IS_SERVER(server), DBUSMENU_STATUS_NORMAL);
262+
263+ GValue val = {0};
264+ g_value_init(&val, DBUSMENU_TYPE_STATUS);
265+ g_object_get_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_STATUS, &val);
266+
267+ DbusmenuStatus retval = g_value_get_enum(&val);
268+ g_value_unset(&val);
269+
270+ return retval;
271+}
272+
273+/**
274+ dbusmenu_server_set_status:
275+ @server: The #DbusmenuServer to set the status on
276+
277+ Changes the status of the server.
278+*/
279+void
280+dbusmenu_server_set_status (DbusmenuServer * server, DbusmenuStatus status)
281+{
282+ g_return_if_fail(DBUSMENU_IS_SERVER(server));
283+
284+ GValue val = {0};
285+ g_value_init(&val, DBUSMENU_TYPE_STATUS);
286+ g_value_set_enum(&val, status);
287+ g_object_set_property(G_OBJECT(server), DBUSMENU_SERVER_PROP_STATUS, &val);
288+ g_value_unset(&val);
289+
290+ return;
291+}
292
293=== modified file 'libdbusmenu-glib/server.h'
294--- libdbusmenu-glib/server.h 2011-02-18 22:21:22 +0000
295+++ libdbusmenu-glib/server.h 2011-02-18 22:21:22 +0000
296@@ -54,6 +54,7 @@
297 #define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node"
298 #define DBUSMENU_SERVER_PROP_VERSION "version"
299 #define DBUSMENU_SERVER_PROP_TEXT_DIRECTION "text-direction"
300+#define DBUSMENU_SERVER_PROP_STATUS "status"
301
302 typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate;
303
304@@ -115,6 +116,9 @@
305 DbusmenuTextDirection dbusmenu_server_get_text_direction (DbusmenuServer * server);
306 void dbusmenu_server_set_text_direction (DbusmenuServer * server,
307 DbusmenuTextDirection dir);
308+DbusmenuStatus dbusmenu_server_get_status (DbusmenuServer * server);
309+void dbusmenu_server_set_status (DbusmenuServer * server,
310+ DbusmenuStatus status);
311
312 /**
313 SECIONT:server
314
315=== modified file 'libdbusmenu-glib/types.h'
316--- libdbusmenu-glib/types.h 2011-02-18 22:21:22 +0000
317+++ libdbusmenu-glib/types.h 2011-02-18 22:21:22 +0000
318@@ -47,6 +47,17 @@
319 DBUSMENU_TEXT_DIRECTION_RTL /*< nick=rtl >*/
320 } DbusmenuTextDirection;
321
322+/**
323+ DbusmenuStatus:
324+ @DBUSMENU_STATUS_NORMAL: Everything is normal
325+ @DBUSMENU_STATUS_NOTICE: The menus should be shown at a higher priority
326+
327+ Tracks how the menus should be presented to the user.
328+*/
329+typedef enum { /*< prefix=DBUSMENU_STATUS >*/
330+ DBUSMENU_STATUS_NORMAL, /*< nick=normal >*/
331+ DBUSMENU_STATUS_NOTICE /*< nick=notice >*/
332+} DbusmenuStatus;
333
334 G_END_DECLS
335

Subscribers

People subscribed via source and target branches