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/indicator-messages.c') 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/indicator-messages.c') 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/indicator-messages.c') 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/indicator-messages.c') 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 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/indicator-messages.c') 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 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/indicator-messages.c') 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