From 0eb92a1061c5e00827169f3f419daf01e1a006fc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 22 Jul 2011 12:06:02 -0500 Subject: Adding in the clear attention menu item --- src/messages-service.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/messages-service.c') diff --git a/src/messages-service.c b/src/messages-service.c index 63549e3..dfa7725 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -28,6 +28,7 @@ with this program. If not, see . #include #include #include +#include #include #include @@ -49,6 +50,7 @@ static GList * launcherList = NULL; static DbusmenuMenuitem * root_menuitem = NULL; static DbusmenuMenuitem * status_separator = NULL; +static DbusmenuMenuitem * clear_attention = NULL; static GMainLoop * mainloop = NULL; static MessageServiceDbus * dbus_interface = NULL; @@ -1439,12 +1441,31 @@ service_shutdown (IndicatorService * service, gpointer user_data) return; } +/* Respond to changing status by updating the icon that + is on the panel */ static void status_update_callback (void) { return; } +/* The clear attention item has been clicked on, what to do? */ +static void +clear_attention_activate (DbusmenuMenuitem * mi, guint timestamp, MessageServiceDbus * dbus) +{ + message_service_dbus_set_attention(dbus, FALSE); + return; +} + +/* Handle an update of the active state to ensure that we're + only enabled when we could do something. */ +static void +clear_attention_handler (MessageServiceDbus * msd, gboolean attention, DbusmenuMenuitem * clearitem) +{ + dbusmenu_menuitem_property_set_bool(clearitem, DBUSMENU_MENUITEM_PROP_ENABLED, attention); + return; +} + /* Oh, if you don't know what main() is for we really shouldn't be talking. */ int @@ -1484,6 +1505,13 @@ main (int argc, char ** argv) dbusmenu_menuitem_property_set(status_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR); dbusmenu_menuitem_child_append(root_menuitem, status_separator); + /* Add in the clear attention item */ + clear_attention = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(clear_attention, DBUSMENU_MENUITEM_PROP_LABEL, _("Clear Attention")); + dbusmenu_menuitem_child_append(root_menuitem, clear_attention); + g_signal_connect(G_OBJECT(dbus_interface), MESSAGE_SERVICE_DBUS_SIGNAL_ATTENTION_CHANGED, G_CALLBACK(clear_attention_handler), clear_attention); + g_signal_connect(G_OBJECT(clear_attention), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(clear_attention_activate), dbus_interface); + /* Start up the libindicate listener */ listener = indicate_listener_ref_default(); serverList = NULL; -- cgit v1.2.3 From 6fdaf03987ca48e4ca6683c472405f1e44ff60c5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 22 Jul 2011 12:07:19 -0500 Subject: No need to track the last separator as we now have a menu item below it. --- src/messages-service.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'src/messages-service.c') diff --git a/src/messages-service.c b/src/messages-service.c index dfa7725..692960d 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -837,7 +837,6 @@ resort_menu (DbusmenuMenuitem * menushell) guint position = 0; GList * serverentry; GList * launcherentry = launcherList; - DbusmenuMenuitem * last_separator = NULL; g_debug("Reordering Menu:"); @@ -874,7 +873,6 @@ resort_menu (DbusmenuMenuitem * menushell) if (!launcher_menu_item_get_eclipsed(li->menuitem)) { /* Only clear the visiblity if we're not eclipsed */ dbusmenu_menuitem_property_set_bool(li->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - last_separator = li->separator; } position++; @@ -930,7 +928,6 @@ resort_menu (DbusmenuMenuitem * menushell) /* Note, this isn't the last if we can't see it */ } else { dbusmenu_menuitem_property_set_bool(si->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - last_separator = si->separator; } dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), DBUSMENU_MENUITEM(si->separator), position); @@ -962,19 +959,12 @@ resort_menu (DbusmenuMenuitem * menushell) if (!launcher_menu_item_get_eclipsed(li->menuitem)) { /* Only clear the visiblity if we're not eclipsed */ dbusmenu_menuitem_property_set_bool(li->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - last_separator = li->separator; } position++; launcherentry = launcherentry->next; } - if (last_separator != NULL) { - dbusmenu_menuitem_property_set_bool(last_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); - } else { - g_warning("No last separator on resort"); - } - return; } -- cgit v1.2.3 From 3fc0ec76ff87ba2249171a0dc5527b876df584c3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 22 Jul 2011 12:15:00 -0500 Subject: Make sure clear attention stays at the end --- src/messages-service.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/messages-service.c') diff --git a/src/messages-service.c b/src/messages-service.c index 692960d..f0ccc80 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -965,6 +965,11 @@ resort_menu (DbusmenuMenuitem * menushell) launcherentry = launcherentry->next; } + if (clear_attention != NULL) { + dbusmenu_menuitem_child_reorder(DBUSMENU_MENUITEM(menushell), clear_attention, position); + position++; /* Not needed, but reduce bugs on code tacked on here, compiler will remove */ + } + return; } -- cgit v1.2.3