From 201ede58be208e088d123b1243ab0c485858d217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 11 Jul 2011 03:51:33 +0200 Subject: Reset the un-attention icon on secondary-activate over indicator When the messaging menu is in the "attention" state, middle-clicking over the indicator-messages will clear the attention icon. --- src/indicator-messages.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index bb88c57..bee5e66 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -89,6 +89,10 @@ static void indicator_messages_dispose (GObject *object); static void indicator_messages_finalize (GObject *object); static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); +static void indicator_messages_middle_click (IndicatorObject * io, + IndicatorObjectEntry * entry, + guint time, gint x, gint y, + gpointer data); static const gchar * get_accessible_desc (IndicatorObject * io); static void connection_change (IndicatorServiceManager * sm, gboolean connected, @@ -131,6 +135,7 @@ indicator_messages_class_init (IndicatorMessagesClass *klass) io_class->get_image = get_icon; io_class->get_menu = get_menu; io_class->get_accessible_desc = get_accessible_desc; + io_class->secondary_activate = indicator_messages_middle_click; if (bus_node_info == NULL) { GError * error = NULL; @@ -755,3 +760,13 @@ get_accessible_desc (IndicatorObject * io) { return accessible_desc; } + +/* Hide the notifications on middle-click over the indicator-messages */ +static void +indicator_messages_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, + guint time, gint x, gint y, gpointer data) +{ + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + accessible_desc = _("Messages"); + update_a11y_desc(); +} -- cgit v1.2.3 From f23ee31ab2140f3776f54eca4a4594534d11d313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 19 Jul 2011 19:34:01 +0200 Subject: Added a "Clear notifications" menu as well... --- src/indicator-messages.c | 56 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index bee5e66..56f90b0 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -75,12 +75,14 @@ INDICATOR_SET_TYPE(INDICATOR_MESSAGES_TYPE) /* Globals */ static GtkWidget * main_image = NULL; +static GtkWidget * clear_notifications = NULL; static GDBusProxy * icon_proxy = NULL; static GtkSizeGroup * indicator_right_group = NULL; static GDBusNodeInfo * bus_node_info = NULL; static GDBusInterfaceInfo * bus_interface_info = NULL; static const gchar * accessible_desc = NULL; static IndicatorObject * indicator = NULL; +static gboolean attention = FALSE; /* Prototypes */ static void indicator_messages_class_init (IndicatorMessagesClass *klass); @@ -121,6 +123,33 @@ update_a11y_desc (void) return; } +static void +clear_notifications_show(gboolean show) +{ + g_return_if_fail(clear_notifications); + + GtkWidget *separator = g_object_get_data(G_OBJECT(clear_notifications), "separator"); + g_return_if_fail(separator); + + if (show) { + gtk_widget_show(separator); + gtk_widget_show(clear_notifications); + } else { + gtk_widget_hide(separator); + gtk_widget_hide(clear_notifications); + } +} + +static void +clear_attention(void) { + g_return_if_fail(attention); + + indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); + accessible_desc = _("Messages"); + clear_notifications_show(FALSE); + update_a11y_desc(); +} + /* Initialize the one-timers */ static void indicator_messages_class_init (IndicatorMessagesClass *klass) @@ -213,10 +242,13 @@ proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GV if (prop) { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); accessible_desc = _("New Messages"); + attention = TRUE; } else { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); accessible_desc = _("Messages"); + attention = FALSE; } + clear_notifications_show(attention); } else if (g_strcmp0("IconChanged", signal) == 0) { if (prop) { gtk_widget_hide(main_image); @@ -250,11 +282,15 @@ attention_cb (GObject * object, GAsyncResult * ares, gpointer user_data) if (prop) { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); accessible_desc = _("New Messages"); + attention = TRUE; } else { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); accessible_desc = _("Messages"); + attention = FALSE; } + clear_notifications_show(attention); + update_a11y_desc(); return; @@ -751,6 +787,18 @@ get_menu (IndicatorObject * io) dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), INDICATOR_MENUITEM_TYPE, new_indicator_item); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), APPLICATION_MENUITEM_TYPE, new_application_item); + GtkWidget *sep = gtk_separator_menu_item_new(); + gtk_widget_show(sep); + gtk_container_add (GTK_CONTAINER(menu), sep); + + clear_notifications = gtk_menu_item_new_with_label(_("Clear Notifications")); + gtk_widget_show(clear_notifications); + gtk_container_add(GTK_CONTAINER(menu), clear_notifications); + g_object_set_data(G_OBJECT(clear_notifications), "separator", sep); + g_signal_connect(clear_notifications, "activate", G_CALLBACK(clear_attention), NULL); + + clear_notifications_show(attention); + return GTK_MENU(menu); } @@ -764,9 +812,9 @@ get_accessible_desc (IndicatorObject * io) /* Hide the notifications on middle-click over the indicator-messages */ static void indicator_messages_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, - guint time, gint x, gint y, gpointer data) + guint time, gint x, gint y, gpointer data) { - indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); - accessible_desc = _("Messages"); - update_a11y_desc(); + g_return_if_fail(attention); + + clear_attention(); } -- cgit v1.2.3 From 6cb0f2f76838e6d25e96bece26bdf65ed8e1c4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 21 Jul 2011 18:20:19 +0200 Subject: X and Y pointer position aren't supported anymore by libindicator Dropping them! --- src/indicator-messages.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 56f90b0..4849e77 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -93,9 +93,8 @@ static GtkImage * get_icon (IndicatorObject * io); static GtkMenu * get_menu (IndicatorObject * io); static void indicator_messages_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, - guint time, gint x, gint y, - gpointer data); -static const gchar * get_accessible_desc (IndicatorObject * io); + guint time, gpointer data); +static const gchar * get_accessible_desc (IndicatorObject * io); static void connection_change (IndicatorServiceManager * sm, gboolean connected, gpointer user_data); @@ -812,7 +811,7 @@ get_accessible_desc (IndicatorObject * io) /* Hide the notifications on middle-click over the indicator-messages */ static void indicator_messages_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, - guint time, gint x, gint y, gpointer data) + guint time, gpointer data) { g_return_if_fail(attention); -- cgit v1.2.3 From 496912ca7cf829cb919b1e4f124a4ca0b1271097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 21 Jul 2011 19:35:59 +0200 Subject: Don't use g_return_if_fail in middle-click cb function We don't need an assertion there. --- src/indicator-messages.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 4849e77..c2b32e9 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -813,7 +813,8 @@ static void indicator_messages_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, guint time, gpointer data) { - g_return_if_fail(attention); + if (!attention) + return; clear_attention(); } -- cgit v1.2.3 From dbd11689629e2d7be0d2365f455bb9a0b7e02c80 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 21 Jul 2011 16:16:42 -0500 Subject: Adding a method to clear the attention --- src/messages-service.xml | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/messages-service.xml b/src/messages-service.xml index 8a592db..6c2920d 100644 --- a/src/messages-service.xml +++ b/src/messages-service.xml @@ -12,6 +12,7 @@ + -- cgit v1.2.3 From bace9e0b978cf636ea605a638c26e0354e9fc5f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 21 Jul 2011 16:17:09 -0500 Subject: Removing Watch method as that's been moved to libindicator (for a while) --- src/messages-service.xml | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/messages-service.xml b/src/messages-service.xml index 6c2920d..d79049e 100644 --- a/src/messages-service.xml +++ b/src/messages-service.xml @@ -3,9 +3,6 @@ - - - -- cgit v1.2.3 From 390e002e058128b5fe6b2d257dcfb4819bb799a1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 21 Jul 2011 16:20:01 -0500 Subject: Switching to calling a method instead of clearing in the indictor. --- src/indicator-messages.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index c2b32e9..fabf791 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -813,8 +813,18 @@ static void indicator_messages_middle_click (IndicatorObject * io, IndicatorObjectEntry * entry, guint time, gpointer data) { - if (!attention) + if (icon_proxy == NULL) { return; + } - clear_attention(); + g_dbus_proxy_call(icon_proxy, + "ClearAttention", + NULL, /* params */ + G_DBUS_CALL_FLAGS_NONE, + -1, /* timeout */ + NULL, /* cancel */ + NULL, + NULL); + + return; } -- cgit v1.2.3 From 3ef95ace644808ca261a90144a08030efec4365f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 21 Jul 2011 16:25:58 -0500 Subject: Responding to clear attention method by clearing the dot --- src/messages-service-dbus.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c index 6cc33e0..1585ac0 100644 --- a/src/messages-service-dbus.c +++ b/src/messages-service-dbus.c @@ -200,7 +200,10 @@ message_service_dbus_new (void) static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data) { - MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data); + MessageServiceDbus * ms = MESSAGE_SERVICE_DBUS(user_data); + if (ms == NULL) { return; } + + MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(ms); if (g_strcmp0("AttentionRequested", method) == 0) { g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->dot)); @@ -208,6 +211,10 @@ bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar } else if (g_strcmp0("IconShown", method) == 0) { g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->hidden)); return; + } else if (g_strcmp0("ClearAttention", method) == 0) { + message_service_dbus_set_attention(ms, FALSE); + g_dbus_method_invocation_return_value(invocation, NULL); + return; } else { g_warning("Unknown function call '%s'", method); } -- cgit v1.2.3 From f525c9fe26e3c1393d3c97b2d984f0829a121940 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 21 Jul 2011 16:31:18 -0500 Subject: Removing the menu item from the indicator --- src/indicator-messages.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'src') diff --git a/src/indicator-messages.c b/src/indicator-messages.c index fabf791..82a9315 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -75,14 +75,12 @@ INDICATOR_SET_TYPE(INDICATOR_MESSAGES_TYPE) /* Globals */ static GtkWidget * main_image = NULL; -static GtkWidget * clear_notifications = NULL; static GDBusProxy * icon_proxy = NULL; static GtkSizeGroup * indicator_right_group = NULL; static GDBusNodeInfo * bus_node_info = NULL; static GDBusInterfaceInfo * bus_interface_info = NULL; static const gchar * accessible_desc = NULL; static IndicatorObject * indicator = NULL; -static gboolean attention = FALSE; /* Prototypes */ static void indicator_messages_class_init (IndicatorMessagesClass *klass); @@ -122,33 +120,6 @@ update_a11y_desc (void) return; } -static void -clear_notifications_show(gboolean show) -{ - g_return_if_fail(clear_notifications); - - GtkWidget *separator = g_object_get_data(G_OBJECT(clear_notifications), "separator"); - g_return_if_fail(separator); - - if (show) { - gtk_widget_show(separator); - gtk_widget_show(clear_notifications); - } else { - gtk_widget_hide(separator); - gtk_widget_hide(clear_notifications); - } -} - -static void -clear_attention(void) { - g_return_if_fail(attention); - - indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); - accessible_desc = _("Messages"); - clear_notifications_show(FALSE); - update_a11y_desc(); -} - /* Initialize the one-timers */ static void indicator_messages_class_init (IndicatorMessagesClass *klass) @@ -241,13 +212,10 @@ proxy_signal (GDBusProxy * proxy, const gchar * sender, const gchar * signal, GV if (prop) { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); accessible_desc = _("New Messages"); - attention = TRUE; } else { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); accessible_desc = _("Messages"); - attention = FALSE; } - clear_notifications_show(attention); } else if (g_strcmp0("IconChanged", signal) == 0) { if (prop) { gtk_widget_hide(main_image); @@ -281,15 +249,11 @@ attention_cb (GObject * object, GAsyncResult * ares, gpointer user_data) if (prop) { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages-new"); accessible_desc = _("New Messages"); - attention = TRUE; } else { indicator_image_helper_update(GTK_IMAGE(main_image), "indicator-messages"); accessible_desc = _("Messages"); - attention = FALSE; } - clear_notifications_show(attention); - update_a11y_desc(); return; @@ -786,18 +750,6 @@ get_menu (IndicatorObject * io) dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), INDICATOR_MENUITEM_TYPE, new_indicator_item); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), APPLICATION_MENUITEM_TYPE, new_application_item); - GtkWidget *sep = gtk_separator_menu_item_new(); - gtk_widget_show(sep); - gtk_container_add (GTK_CONTAINER(menu), sep); - - clear_notifications = gtk_menu_item_new_with_label(_("Clear Notifications")); - gtk_widget_show(clear_notifications); - gtk_container_add(GTK_CONTAINER(menu), clear_notifications); - g_object_set_data(G_OBJECT(clear_notifications), "separator", sep); - g_signal_connect(clear_notifications, "activate", G_CALLBACK(clear_attention), NULL); - - clear_notifications_show(attention); - return GTK_MENU(menu); } -- cgit v1.2.3 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') 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') 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') 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