aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-07-22 12:15:29 -0500
committerTed Gould <ted@gould.cx>2011-07-22 12:15:29 -0500
commit0e09129f85bcfba44880654507cb9093c4298f25 (patch)
tree81eedcfdeaaba5b7dce3dc7b209c5172d45eb357
parent3a5ded2687b74d61f3bffdfd5f1f44a4a1db240c (diff)
parent3fc0ec76ff87ba2249171a0dc5527b876df584c3 (diff)
downloadayatana-indicator-messages-0e09129f85bcfba44880654507cb9093c4298f25.tar.gz
ayatana-indicator-messages-0e09129f85bcfba44880654507cb9093c4298f25.tar.bz2
ayatana-indicator-messages-0e09129f85bcfba44880654507cb9093c4298f25.zip
Add a clear attention menu item and attach it to middle click
-rw-r--r--configure.ac12
-rw-r--r--src/indicator-messages.c27
-rw-r--r--src/messages-service-dbus.c9
-rw-r--r--src/messages-service.c39
-rw-r--r--src/messages-service.xml4
5 files changed, 72 insertions, 19 deletions
diff --git a/configure.ac b/configure.ac
index 92f5c88..cb5a9e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,20 +43,20 @@ INDICATE_REQUIRED_VERSION=0.4.90
INDICATOR_REQUIRED_VERSION=0.3.19
DBUSMENUGTK_REQUIRED_VERSION=0.3.94
-AC_ARG_WITH([indicator-gtk],
- [AS_HELP_STRING([--with-indicator-gtk],
+AC_ARG_WITH([gtk],
+ [AS_HELP_STRING([--with-gtk],
[Which version of gtk to use for the indicator @<:@default=3@:>@])],
[],
- [with_indicator_gtk=3])
+ [with_gtk=3])
-AS_IF([test "x$with_indicator_gtk" = x3],
+AS_IF([test "x$with_gtk" = x3],
[PKG_CHECK_MODULES(APPLET, gtk+-3.0 >= $GTK3_REQUIRED_VERSION
gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION
indicate-0.5 >= $INDICATE_REQUIRED_VERSION
dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION)
],
- [test "x$with_indicator_gtk" = x2],
+ [test "x$with_gtk" = x2],
[PKG_CHECK_MODULES(APPLET, gtk+-2.0 >= $GTK_REQUIRED_VERSION
gio-unix-2.0 >= $GIO_UNIX_REQUIRED_VERSION
indicator-0.4 >= $INDICATOR_REQUIRED_VERSION
@@ -104,7 +104,7 @@ AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [install all
if test "x$with_localinstall" = "xyes"; then
INDICATORDIR="${libdir}/indicators/2/"
INDICATORICONSDIR="${datadir}/libindicate/icons/"
-elif test "x$with_indicator_gtk" = x2; then
+elif test "x$with_gtk" = x2; then
INDICATORDIR=`$PKG_CONFIG --variable=indicatordir indicator-0.4`
INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir indicator-0.4`
else
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index bb88c57..82a9315 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -89,7 +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 const gchar * get_accessible_desc (IndicatorObject * io);
+static void indicator_messages_middle_click (IndicatorObject * io,
+ IndicatorObjectEntry * entry,
+ guint time, gpointer data);
+static const gchar * get_accessible_desc (IndicatorObject * io);
static void connection_change (IndicatorServiceManager * sm,
gboolean connected,
gpointer user_data);
@@ -131,6 +134,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 +759,24 @@ 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, gpointer data)
+{
+ if (icon_proxy == NULL) {
+ return;
+ }
+
+ g_dbus_proxy_call(icon_proxy,
+ "ClearAttention",
+ NULL, /* params */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, /* timeout */
+ NULL, /* cancel */
+ NULL,
+ NULL);
+
+ return;
+}
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);
}
diff --git a/src/messages-service.c b/src/messages-service.c
index c891f88..43e79d3 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -28,6 +28,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicate/listener.h>
#include <libindicator/indicator-service.h>
#include <gio/gio.h>
+#include <glib/gi18n.h>
#include <libdbusmenu-glib/client.h>
#include <libdbusmenu-glib/server.h>
@@ -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;
@@ -837,7 +839,6 @@ resort_menu (DbusmenuMenuitem * menushell)
guint position = 0;
GList * serverentry;
GList * launcherentry = launcherList;
- DbusmenuMenuitem * last_separator = NULL;
g_debug("Reordering Menu:");
@@ -874,7 +875,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 +930,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,17 +961,15 @@ 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");
+ 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;
@@ -1441,12 +1438,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
@@ -1486,6 +1502,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;
diff --git a/src/messages-service.xml b/src/messages-service.xml
index 8a592db..d79049e 100644
--- a/src/messages-service.xml
+++ b/src/messages-service.xml
@@ -3,15 +3,13 @@
<interface name="com.canonical.indicator.messages.service">
<!-- Methods -->
- <method name="Watch">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true" />
- </method>
<method name="AttentionRequested">
<arg type="b" name="dot" direction="out" />
</method>
<method name="IconShown">
<arg type="b" name="hidden" direction="out" />
</method>
+ <method name="ClearAttention" />
<!-- Signals -->
<signal name="AttentionChanged">