Merge lp:~dbarth/indicator-me/radio-buttons-and-indeterminate-status into lp:indicator-me

Proposed by David Barth
Status: Merged
Merge reported by: David Barth
Merged at revision: not available
Proposed branch: lp:~dbarth/indicator-me/radio-buttons-and-indeterminate-status
Merge into: lp:indicator-me
Diff against target: 121 lines (+66/-29)
1 file modified
src/me-service.c (+66/-29)
To merge this branch: bzr merge lp:~dbarth/indicator-me/radio-buttons-and-indeterminate-status
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+21436@code.launchpad.net

Description of the change

This branch enables proper radio marks on status items and also computes the "indeterminate status" based on diverging online statuses.

To post a comment you must log in.
Revision history for this message
David Barth (dbarth) wrote :

Hmm, let me know how to re-indent that btw.

Revision history for this message
Ted Gould (ted) wrote :

On Tue, 2010-03-16 at 10:46 +0000, David Barth wrote:
> This branch enables proper radio marks on status items
> and also computes the "indeterminate status" based on
> diverging online statuses.

For the indentation, just use tabs :)

If you want to add a new icon name you need to add the icon to the
default fallback set that is provided by the package.

Otherwise it seems sane.

  review approve

review: Approve
Revision history for this message
Ted Gould (ted) wrote :

Oh, and when the state is indeterminate the radio buttons should be set to DBUSMENU_MENUITEM_TOGGLE_STATE_UNKNOWN.

Revision history for this message
David Barth (dbarth) wrote :

Comments turned into TODO items

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/me-service.c'
2--- src/me-service.c 2010-03-11 13:06:53 +0000
3+++ src/me-service.c 2010-03-16 10:46:19 +0000
4@@ -92,44 +92,75 @@
5 status_update (void) {
6 StatusProviderStatus oldglobal = global_status;
7 global_status = STATUS_PROVIDER_STATUS_DISCONNECTED;
8+ gboolean indeterminate = FALSE;
9
10 /* Ask everyone what they think the status should be, if
11 they're more connected, up the global level */
12- int i;
13+ StatusProviderStatus i;
14 for (i = 0; i < STATUS_PROVIDER_CNT; i++) {
15+ if (status_providers[i] == NULL) continue;
16 StatusProviderStatus localstatus = status_provider_get_status(status_providers[i]);
17- if (localstatus < global_status) {
18+ g_debug ("provider[%d]: %s", i, status_strings[localstatus]);
19+
20+ if (localstatus >= STATUS_PROVIDER_STATUS_OFFLINE)
21+ /* offline and disconnected is similar for some providers
22+ so it's not meaningful to determine the 'indeterminate' status
23+ */
24+ continue;
25+
26+ if (localstatus != global_status) {
27+ if (global_status < STATUS_PROVIDER_STATUS_OFFLINE)
28+ /* at least one provider was maintaining a status better than 'offline'
29+ and there's now another one with something different */
30+ indeterminate = TRUE;
31 global_status = localstatus;
32 }
33 }
34
35- /* If changed */
36- if (global_status != oldglobal) {
37- g_debug("Global status changed to: %s", _(status_strings[global_status]));
38-
39- /* Configure the icon on the panel */
40- status_service_dbus_set_status(dbus_interface, status_icons[global_status]);
41-
42- /* If we're now disconnected, make setting the statuses
43- insensitive. */
44- if (global_status == STATUS_PROVIDER_STATUS_DISCONNECTED) {
45- StatusProviderStatus i;
46- for (i = STATUS_PROVIDER_STATUS_ONLINE; i < STATUS_PROVIDER_STATUS_LAST; i++) {
47- if (status_menuitems[i] == NULL) continue;
48- dbusmenu_menuitem_property_set_bool(status_menuitems[i], DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
49- }
50- }
51-
52- /* If we're now back to a state where we have an IM client
53- connected then we need to resensitize the items. */
54- if (oldglobal == STATUS_PROVIDER_STATUS_DISCONNECTED) {
55- StatusProviderStatus i;
56- for (i = STATUS_PROVIDER_STATUS_ONLINE; i < STATUS_PROVIDER_STATUS_LAST; i++) {
57- if (status_menuitems[i] == NULL) continue;
58- dbusmenu_menuitem_property_set_bool(status_menuitems[i], DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
59- }
60- }
61- }
62+ /* Configure the icon on the panel */
63+ status_service_dbus_set_status(dbus_interface, indeterminate ? "user-indeterminate" : status_icons[global_status]);
64+
65+ g_debug("Global status changed to: %s", indeterminate ? "indeterminate" : status_strings[global_status]);
66+
67+ /* If we're now disconnected, make setting the statuses
68+ insensitive. */
69+ if (global_status == STATUS_PROVIDER_STATUS_DISCONNECTED) {
70+ StatusProviderStatus i;
71+ for (i = STATUS_PROVIDER_STATUS_ONLINE;
72+ i < STATUS_PROVIDER_STATUS_LAST; i++) {
73+ if (status_menuitems[i] == NULL) continue;
74+ dbusmenu_menuitem_property_set_bool(status_menuitems[i],
75+ DBUSMENU_MENUITEM_PROP_ENABLED,
76+ FALSE);
77+ }
78+ return;
79+ }
80+
81+ /* Ensure items are sensititive if they were previoulsy disabled */
82+ if (oldglobal == STATUS_PROVIDER_STATUS_DISCONNECTED) {
83+ StatusProviderStatus i;
84+ for (i = STATUS_PROVIDER_STATUS_ONLINE;
85+ i < STATUS_PROVIDER_STATUS_LAST; i++) {
86+ if (status_menuitems[i] == NULL) continue;
87+ dbusmenu_menuitem_property_set_bool(status_menuitems[i], DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
88+ }
89+ }
90+
91+ /* add a radio mark to the user status entry */
92+ for (i = STATUS_PROVIDER_STATUS_ONLINE;
93+ i < STATUS_PROVIDER_STATUS_LAST; i++) {
94+ if (status_menuitems[i] == NULL) continue;
95+ if (indeterminate
96+ || (i != global_status)) {
97+ dbusmenu_menuitem_property_set_int (status_menuitems[i],
98+ DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
99+ DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED);
100+ } else {
101+ dbusmenu_menuitem_property_set_int (status_menuitems[i],
102+ DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
103+ DBUSMENU_MENUITEM_TOGGLE_STATE_CHECKED);
104+ }
105+ }
106
107 return;
108 }
109@@ -346,6 +377,12 @@
110
111 dbusmenu_menuitem_property_set(status_menuitems[i], DBUSMENU_MENUITEM_PROP_LABEL, _(status_strings[i]));
112 dbusmenu_menuitem_property_set(status_menuitems[i], DBUSMENU_MENUITEM_PROP_ICON_NAME, status_icons[i]);
113+ dbusmenu_menuitem_property_set (status_menuitems[i],
114+ DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE,
115+ DBUSMENU_MENUITEM_TOGGLE_RADIO);
116+ dbusmenu_menuitem_property_set_int (status_menuitems[i],
117+ DBUSMENU_MENUITEM_PROP_TOGGLE_STATE,
118+ DBUSMENU_MENUITEM_TOGGLE_STATE_UNCHECKED);
119 if (global_status == STATUS_PROVIDER_STATUS_DISCONNECTED) {
120 dbusmenu_menuitem_property_set_bool(status_menuitems[i], DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
121 }

Subscribers

People subscribed via source and target branches