diff options
Diffstat (limited to 'src/messages-service.c')
-rw-r--r-- | src/messages-service.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/src/messages-service.c b/src/messages-service.c index e4982a2..a5af895 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -33,6 +33,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include "launcher-menu-item.h" #include "dbus-data.h" #include "dirs.h" +#include "messages-service-dbus.h" static IndicateListener * listener; static GList * serverList = NULL; @@ -41,6 +42,8 @@ static GList * launcherList = NULL; static DbusmenuMenuitem * root_menuitem = NULL; static GMainLoop * mainloop = NULL; +static MessageServiceDbus * dbus_interface = NULL; + static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); @@ -57,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); /* @@ -164,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 */ @@ -260,6 +287,8 @@ blacklist_add (gpointer udata) } } + check_hidden(); + return FALSE; } @@ -309,6 +338,8 @@ blacklist_remove (gpointer data) g_warning("Unable to remove '%s' with value '%s'", definition_file, (gchar *)key); } + check_hidden(); + return FALSE; } @@ -406,6 +437,7 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha /* Should be prepend ^ */ resort_menu(menushell); + check_hidden(); return; } @@ -438,7 +470,7 @@ server_count_changed (AppMenuItem * appitem, guint count, gpointer data) if (count != 0) { g_debug("Setting image to 'new'"); showing_new_icon = TRUE; - /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages-new", DESIGN_TEAM_SIZE); */ + message_service_dbus_set_attention(dbus_interface, TRUE); return; } @@ -459,7 +491,7 @@ server_count_changed (AppMenuItem * appitem, guint count, gpointer data) if (!we_have_indicators) { g_debug("Setting image to boring"); showing_new_icon = FALSE; - /* gtk_image_set_from_icon_name(GTK_IMAGE(main_image), "indicator-messages", DESIGN_TEAM_SIZE); */ + message_service_dbus_set_attention(dbus_interface, FALSE); } return; @@ -508,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; } @@ -540,6 +573,24 @@ menushell_foreach_cb (DbusmenuMenuitem * data_mi, gpointer data_ms) { } static void +check_hidden (void) +{ + g_debug("Checking Hidden..."); + gboolean hide = FALSE; + if (launcherList_count() == 0) { + g_debug("\tZero Launchers"); + /* If we don't have visible launchers we need to look more */ + if (g_list_length(serverList) == 0) { + g_debug("\tZero Applications"); + hide = TRUE; + } + } + + message_service_dbus_set_icon(dbus_interface, hide); + return; +} + +static void resort_menu (DbusmenuMenuitem * menushell) { guint position = 0; @@ -986,6 +1037,8 @@ main (int argc, char ** argv) return 1; } + dbus_interface = message_service_dbus_new(); + listener = indicate_listener_ref_default(); serverList = NULL; |