diff options
author | Ted Gould <ted@canonical.com> | 2009-08-26 11:20:24 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-08-26 11:20:24 -0500 |
commit | 0ec0fbd9c08c5fd04fda87aa674be17824cdaec0 (patch) | |
tree | 7fb145bf886ea8146bedeee676cc858e6d067ecb | |
parent | 379ea85a351384a9a4cce07902dcd884fb714e8d (diff) | |
parent | a13c1cb4fad904f91df3b32bad5d49918cab01da (diff) | |
download | ayatana-indicator-messages-0ec0fbd9c08c5fd04fda87aa674be17824cdaec0.tar.gz ayatana-indicator-messages-0ec0fbd9c08c5fd04fda87aa674be17824cdaec0.tar.bz2 ayatana-indicator-messages-0ec0fbd9c08c5fd04fda87aa674be17824cdaec0.zip |
Hide the icon, with logic.
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | src/launcher-menu-item.c | 13 | ||||
-rw-r--r-- | src/launcher-menu-item.h | 1 | ||||
-rw-r--r-- | src/messages-service.c | 45 |
4 files changed, 65 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index a8d9a10..bdb5074 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +indicator-messages (0.2.0~bzr126-0ubuntu1~ppa2~dot-and-hide5) UNRELEASED; urgency=low + + * Hide the icon, with logic. + + -- Ted Gould <ted@ubuntu.com> Wed, 26 Aug 2009 11:20:10 -0500 + indicator-messages (0.2.0~bzr126-0ubuntu1~ppa2~dot-and-hide4) karmic; urgency=low * Registering the signals first. diff --git a/src/launcher-menu-item.c b/src/launcher-menu-item.c index 6c79adb..d9c35a8 100644 --- a/src/launcher-menu-item.c +++ b/src/launcher-menu-item.c @@ -194,3 +194,16 @@ launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed) dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(li), "show", eclipsed ? "false" : "true"); return; } + +gboolean +launcher_menu_item_get_eclipsed (LauncherMenuItem * li) +{ + const gchar * show = dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(li), "show"); + if (show == NULL) { + return FALSE; + } + if (!g_strcmp0(show, "true")) { + return TRUE; + } + return FALSE; +} diff --git a/src/launcher-menu-item.h b/src/launcher-menu-item.h index 2b39073..920194e 100644 --- a/src/launcher-menu-item.h +++ b/src/launcher-menu-item.h @@ -57,6 +57,7 @@ LauncherMenuItem * launcher_menu_item_new (const gchar * desktop_file); const gchar * launcher_menu_item_get_name (LauncherMenuItem * appitem); const gchar * launcher_menu_item_get_desktop (LauncherMenuItem * launchitem); void launcher_menu_item_set_eclipsed (LauncherMenuItem * li, gboolean eclipsed); +gboolean launcher_menu_item_get_eclipsed (LauncherMenuItem * li); G_END_DECLS diff --git a/src/messages-service.c b/src/messages-service.c index 6b11e8c..23721be 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -60,6 +60,7 @@ static gboolean blacklist_remove (gpointer data); static void blacklist_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static void app_dir_changed (GFileMonitor * monitor, GFile * file, GFile * other_file, GFileMonitorEvent event_type, gpointer user_data); static gboolean destroy_launcher (gpointer data); +static void check_hidden (void); /* @@ -167,6 +168,29 @@ launcherList_sort (gconstpointer a, gconstpointer b) return g_strcmp0(pan, pbn); } +static void +launcherList_count_helper (gpointer data, gpointer user_data) +{ + guint * count = (guint *)user_data; + launcherList_t * li = (launcherList_t *)data; + + if (!launcher_menu_item_get_eclipsed(li->menuitem)) { + *count = *count + 1; + } + + return; +} + +static guint +launcherList_count (void) +{ + guint count = 0; + + g_list_foreach(launcherList, launcherList_count_helper, &count); + + return count; +} + /* * Black List */ @@ -263,6 +287,8 @@ blacklist_add (gpointer udata) } } + check_hidden(); + return FALSE; } @@ -312,6 +338,8 @@ blacklist_remove (gpointer data) g_warning("Unable to remove '%s' with value '%s'", definition_file, (gchar *)key); } + check_hidden(); + return FALSE; } @@ -409,6 +437,7 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha /* Should be prepend ^ */ resort_menu(menushell); + check_hidden(); return; } @@ -511,6 +540,7 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc /* Simulate a server saying zero to recalculate icon */ server_count_changed(NULL, 0, NULL); + check_hidden(); return; } @@ -543,6 +573,21 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { } static void +check_hidden (void) +{ + gboolean hide = FALSE; + if (launcherList_count() == 0) { + /* If we don't have visible launchers we need to look more */ + if (serverList != NULL) { /* Basically if there are zero entries it'll be NULL */ + hide = TRUE; + } + } + + message_service_dbus_set_icon(dbus_interface, hide); + return; +} + +static void resort_menu (DbusmenuMenuitem * menushell) { guint position = 0; |