aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-09-04 16:44:46 -0500
committerTed Gould <ted@canonical.com>2009-09-04 16:44:46 -0500
commit44fddda84b6084f940e740ab3620c3d0e4860c52 (patch)
tree60241963619f1790315bd9b18ef87791213703fc
parente740035a0d5605e07034ea026948cec8da3b3ee7 (diff)
parent366dbb549bca2b6b6d901fc60780710cb3f36224 (diff)
downloadayatana-indicator-messages-44fddda84b6084f940e740ab3620c3d0e4860c52.tar.gz
ayatana-indicator-messages-44fddda84b6084f940e740ab3620c3d0e4860c52.tar.bz2
ayatana-indicator-messages-44fddda84b6084f940e740ab3620c3d0e4860c52.zip
Adding in a show state.
-rw-r--r--src/im-menu-item.c32
-rw-r--r--src/im-menu-item.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/src/im-menu-item.c b/src/im-menu-item.c
index d64a917..52cf80c 100644
--- a/src/im-menu-item.c
+++ b/src/im-menu-item.c
@@ -51,6 +51,7 @@ struct _ImMenuItemPrivate
gchar * count;
gulong indicator_changed;
gboolean attention;
+ gboolean show;
guint time_update_min;
};
@@ -412,9 +413,12 @@ im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server,
priv->count = NULL;
priv->time_update_min = 0;
priv->attention = FALSE;
+ priv->show = TRUE;
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), "type", INDICATOR_MENUITEM_TYPE);
+ indicate_listener_displayed(listener, server, indicator, TRUE);
+
indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_NAME, sender_cb, self);
indicate_listener_get_property_time(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_TIME, time_cb, self);
indicate_listener_get_property(listener, server, indicator, INDICATE_INDICATOR_MESSAGES_PROP_ICON, icon_cb, self);
@@ -449,3 +453,31 @@ im_menu_item_get_attention (ImMenuItem * menuitem)
ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(menuitem);
return priv->attention;
}
+
+/* This takes care of items that need to be hidden, this is
+ usually because they go over the count of allowed indicators.
+ Which is more than a little bit silly. We shouldn't do that.
+ But we need to enforce it to save users against bad apps. */
+void
+im_menu_item_show (ImMenuItem * menuitem, gboolean show)
+{
+ g_return_if_fail(IS_IM_MENU_ITEM(menuitem));
+
+ ImMenuItemPrivate * priv = IM_MENU_ITEM_GET_PRIVATE(menuitem);
+
+ if (priv->show == show) {
+ return;
+ }
+
+ priv->show = show;
+ /* Tell the app what we're doing to it. If it's being
+ punished it needs to know about it. */
+ indicate_listener_displayed(priv->listener, priv->server, priv->indicator, priv->show);
+ if (priv->attention) {
+ /* If we were asking for attention we can ask for it
+ again if we're being shown, otherwise no. */
+ g_signal_emit(G_OBJECT(menuitem), signals[ATTENTION_CHANGED], 0, priv->show, TRUE);
+ }
+
+ return;
+}
diff --git a/src/im-menu-item.h b/src/im-menu-item.h
index 1ec9bf0..244c32a 100644
--- a/src/im-menu-item.h
+++ b/src/im-menu-item.h
@@ -58,6 +58,7 @@ GType im_menu_item_get_type (void);
ImMenuItem * im_menu_item_new (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator);
glong im_menu_item_get_seconds (ImMenuItem * menuitem);
gboolean im_menu_item_get_attention (ImMenuItem * menuitem);
+void im_menu_item_show (ImMenuItem * menuitem, gboolean show);
G_END_DECLS