=== modified file 'configure.ac' --- a/configure.ac +++ b/configure.ac @@ -59,6 +59,7 @@ GNOME_CONTROL_CENTER_GTK3_REQUIRED=2.31.4 INDICATE_REQUIRED=0.4.91 INDICATE_GTK_REQUIRED=0.4.91 +UNITY_REQUIRED=3.4.0 # telepathy-yell prev_top_build_prefix=$ac_top_build_prefix @@ -524,12 +525,41 @@ fi if test "x$enable_libindicate" = "xyes" -a "x$have_libindicate" != "xyes"; then - AC_MSG_ERROR([Couldn't find libindicate.]) + AC_MSG_ERROR([Could not find libindicate.]) fi AM_CONDITIONAL(HAVE_LIBINDICATE, test "x$have_libindicate" = "xyes") # ----------------------------------------------------------- +# libunity +# ----------------------------------------------------------- +AC_ARG_ENABLE(libunity, + AS_HELP_STRING([--enable-libunity=@<:@no/yes/auto@:>@], + [build libunity support]), , + enable_libunity=auto) + +if test "x$enable_unity" != "xno"; then + PKG_CHECK_MODULES(UNITY, + [ + unity >= $UNITY_REQUIRED + ], have_unity="yes", have_unity="no") + + if test "x$have_unity" = "xyes"; then + AC_DEFINE(HAVE_UNITY, 1, [Define if you have unity]) + fi +else + have_unity=no +fi + +if test "x$enable_unity" = "xyes" -a "x$have_unity" != "xyes"; then + AC_MSG_ERROR([Could not find libunity.]) +fi + +AM_CONDITIONAL(HAVE_UNITY, test "x$have_unity" = "xyes") +AC_SUBST([UNITY_CFLAGS]) +AC_SUBST([UNITY_LIBS]) + +# ----------------------------------------------------------- # nautilus-sendto # ----------------------------------------------------------- AC_ARG_ENABLE(nautilus-sendto, @@ -632,6 +662,7 @@ Features: Message indicator support (libindicate): ${have_libindicate} + Unity panel support (unity).: ${have_unity} Spell checking (enchant)....: ${have_enchant} Display maps (libchamplain).: ${have_libchamplain} Location awareness (Geoclue): ${have_geoclue} --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,6 +19,7 @@ $(CPPFLAGS_COMMON) \ $(LIBNOTIFY_CFLAGS) \ $(INDICATE_CFLAGS) \ + $(UNITY_CFLAGS) \ $(UNIQUE_CFLAGS) \ $(LIBCHAMPLAIN_CFLAGS) \ $(WEBKIT_CFLAGS) \ @@ -30,6 +31,7 @@ $(top_builddir)/extensions/libemp-extensions.la \ $(LIBNOTIFY_LIBS) \ $(INDICATE_LIBS) \ + $(UNITY_LIBS) \ $(UNIQUE_LIBS) \ $(EMPATHY_LIBS) \ $(GTK_LIBS) \ @@ -204,6 +206,7 @@ $(UNIQUE_LIBS) \ $(EMPATHY_LIBS) \ $(INDICATE_LIBS) \ + $(UNITY_LIBS) \ $(LIBCHAMPLAIN_LIBS) \ $(WEBKIT_LIBS) \ $(NULL) --- a/src/empathy-chat-window.c +++ b/src/empathy-chat-window.c @@ -71,6 +71,10 @@ #define DEBUG_FLAG EMPATHY_DEBUG_CHAT #include +#ifdef HAVE_UNITY +#include +#endif + /* Macro to compare guint32 X timestamps, while accounting for wrapping around */ #define X_EARLIER_OR_EQL(t1, t2) \ @@ -96,6 +100,9 @@ /* EmpathyChat -> EmpathyIndicator for that chat, if any */ GHashTable *indicators; #endif +#ifdef HAVE_UNITY + UnityLauncherEntry *launcher; +#endif GtkTargetList *contact_targets; GtkTargetList *file_targets; @@ -1381,8 +1388,19 @@ sender, body); g_signal_connect (indicator, "activate", G_CALLBACK (chat_window_indicator_activate_cb), chat); - g_hash_table_insert (priv->indicators, chat, indicator); +#ifdef HAVE_UNITY + if (priv->launcher != NULL) + { + gint count = g_hash_table_size (priv->indicators); + DEBUG ("unity launcher: count is now %d", count); + if (count > 0) + { + unity_launcher_entry_set_count (priv->launcher, count); + unity_launcher_entry_set_count_visible (priv->launcher, TRUE); + } + } +#endif } empathy_indicator_show (indicator); } @@ -1399,6 +1417,25 @@ DEBUG ("indicator is %p", indicator); empathy_indicator_hide (indicator); g_hash_table_remove (priv->indicators, chat); +#ifdef HAVE_UNITY + if (priv->launcher != NULL) + { + gint count = g_hash_table_size (priv->indicators); + DEBUG ("unity launcher: count is %d", count); + if (count > 0) + { + DEBUG ("unity launcher: setting count to %d", count); + unity_launcher_entry_set_count (priv->launcher, count); + unity_launcher_entry_set_count_visible (priv->launcher, TRUE); + } else { + unity_launcher_entry_set_count (priv->launcher, count); + DEBUG ("unity launcher: hiding count"); + unity_launcher_entry_set_count_visible (priv->launcher, FALSE); + } + } +#endif + + } else { DEBUG ("indicator is NULL, nothing to remove"); } @@ -2034,6 +2071,11 @@ priv->chat_manager = NULL; } + if (priv->launcher) { + g_object_unref (priv->launcher); + priv->launcher = NULL; + } + chat_windows = g_list_remove (chat_windows, window); gtk_widget_destroy (priv->dialog); @@ -2132,6 +2174,9 @@ priv->indicators = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref); #endif +#ifdef HAVE_UNITY + priv->launcher = unity_launcher_entry_get_for_desktop_id ("empathy.desktop"); +#endif priv->notebook = gtk_notebook_new (); gtk_notebook_set_group (GTK_NOTEBOOK (priv->notebook), "EmpathyChatWindow"); --- a/src/empathy-indicator-manager.c +++ b/src/empathy-indicator-manager.c @@ -45,6 +45,10 @@ #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include +#ifdef HAVE_UNITY +#include +#endif + #define INDICATOR_LOGIN_TIMEOUT 15 #define EMPATHY_DESKTOP_PATH DESKTOPDIR "/empathy.desktop" @@ -62,6 +66,9 @@ IndicateServer *indicate_server; GSList *indicator_events; GHashTable *login_timeouts; +#ifdef HAVE_UNITY + UnityLauncherEntry *launcher; +#endif } EmpathyIndicatorManagerPriv; typedef struct { @@ -174,6 +181,20 @@ g_object_unref (indicator); priv->indicator_events = g_slist_prepend (priv->indicator_events, indicator_event); +#ifdef HAVE_UNITY + if (priv->launcher == NULL) + { + return; + } + gint count = g_slist_length (priv->indicator_events); + DEBUG ("unity launcher: count is %d", count); + if (count > 0) + { + unity_launcher_entry_set_count (priv->launcher, count); + unity_launcher_entry_set_count_visible (priv->launcher, TRUE); + } +#endif + } static void @@ -197,6 +218,26 @@ priv->indicator_events = g_slist_remove (priv->indicator_events, indicator_event); empathy_indicator_hide (indicator_event->indicator); +#ifdef HAVE_UNITY + if (priv->launcher == NULL) + { + DEBUG ("unity launcher: launcher is NULL"); + return; + } + + gint count = g_slist_length (priv->indicator_events); + DEBUG ("unity launcher: count is %d", count); + if (count > 0) + { + DEBUG ("unity launcher: setting count to %d", count); + unity_launcher_entry_set_count (priv->launcher, count); + unity_launcher_entry_set_count_visible (priv->launcher, TRUE); + } else { + unity_launcher_entry_set_count (priv->launcher, count); + DEBUG ("unity launcher: hiding count"); + unity_launcher_entry_set_count_visible (priv->launcher, FALSE); + } +#endif return; } } @@ -213,6 +254,8 @@ priv = GET_PRIV (manager); + DEBUG ("Event updated"); + for (l = priv->indicator_events; l; l = l->next) { IndicatorEvent *indicator_event; @@ -307,6 +350,10 @@ g_object_unref (priv->indicate_server); priv->indicate_server = NULL; } + if (priv->launcher) { + g_object_unref (priv->launcher); + priv->launcher = NULL; + } if (priv->login_timeouts) { g_hash_table_unref (priv->login_timeouts); priv->login_timeouts = NULL; @@ -381,6 +428,10 @@ G_CALLBACK (indicate_server_activate), manager); +#ifdef HAVE_UNITY + priv->launcher = unity_launcher_entry_get_for_desktop_id ("empathy.desktop"); +#endif + g_signal_connect (priv->event_manager, "event-added", G_CALLBACK (indicator_manager_event_added_cb), manager);