summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Šimerda <psimerda@redhat.com>2014-12-17 14:38:42 +0100
committerDan Williams <dcbw@redhat.com>2015-02-17 14:05:09 -0600
commit756b3cc9527f9cd24d8a7db5b6c951d1b00a2d63 (patch)
tree88479cdc048906a7701e24bd0174efce112d60d5
parent5455c67d58820b1050fff5dc31e5bbf89c92d769 (diff)
downloadnetwork-manager-applet-756b3cc9527f9cd24d8a7db5b6c951d1b00a2d63.tar.gz
applet: add support for --with-appindicator (bgo #740574)
Add new configure option --with-appindicator which implies a optional dependency on libappindicator. This is the way systray is done in the current versions of Unity, KDE and Enlightenment and others. Some of the systray implementations already dropped support for Xembed, others are going to, mostly to gain independence on X11 as part of being ported to Wayland. Keep the previous functionality intact. (many cleanups and consolidations by dcbw) https://bugzilla.gnome.org/show_bug.cgi?id=740574
-rw-r--r--configure.ac6
-rw-r--r--src/Makefile.am2
-rw-r--r--src/ap-menu-item.c18
-rw-r--r--src/applet.c140
-rw-r--r--src/applet.h9
-rw-r--r--src/mb-menu-item.c16
6 files changed, 190 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 5452784b..639810b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,12 @@ case "${with_bluetooth}" in
;;
esac
+AC_ARG_WITH([appindicator], AS_HELP_STRING([--with-appindicator|--without-appindicator], [Build with libappindicator support instead of xembed systray support.]))
+if test "$with_appindicator" == "yes"; then
+ PKG_CHECK_MODULES(APPINDICATOR, appindicator3-0.1)
+ AC_DEFINE([ENABLE_INDICATOR], 1, [Enable using libappindicator])
+fi
+
AM_CONDITIONAL(HAVE_GBT, test x"$have_gbt" = "xyes")
dnl ModemManager1 with libmm-glib for WWAN support
diff --git a/src/Makefile.am b/src/Makefile.am
index 903102cf..c0407a60 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,6 +8,7 @@ nm_applet_CPPFLAGS = \
$(LIBSECRET_CFLAGS) \
$(NOTIFY_CFLAGS) \
$(MM_GLIB_CFLAGS) \
+ $(APPINDICATOR_CFLAGS) \
-DNM_VERSION_MIN_REQUIRED=NM_VERSION_0_9_10 \
-DNM_VERSION_MAX_ALLOWED=NM_VERSION_0_9_10 \
-DICONDIR=\""$(datadir)/icons"\" \
@@ -82,6 +83,7 @@ nm_applet_LDADD = \
$(LIBSECRET_LIBS) \
$(NOTIFY_LIBS) \
$(MM_GLIB_LIBS) \
+ $(APPINDICATOR_LIBS) \
${top_builddir}/src/marshallers/libmarshallers.la \
${top_builddir}/src/utils/libutils.la \
${top_builddir}/src/wireless-security/libwireless-security.la \
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index d8aad760..a622eb2b 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -39,10 +39,12 @@ G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_IMAGE_MENU_ITEM
#define NM_NETWORK_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_NETWORK_MENU_ITEM, NMNetworkMenuItemPrivate))
typedef struct {
+#ifndef ENABLE_INDICATOR
GtkWidget * ssid;
GtkWidget * strength;
GtkWidget * detail;
GtkWidget * hbox;
+#endif
char * ssid_string;
guint32 int_strength;
@@ -131,9 +133,16 @@ update_icon (NMNetworkMenuItem *item, NMApplet *applet)
pixbuf = scaled;
}
+#ifdef ENABLE_INDICATOR
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), gtk_image_new_from_pixbuf (pixbuf));
+ /* For some reason we must always re-set always-show after setting the image */
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#else
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), pixbuf);
+#endif
g_object_unref (pixbuf);
+#ifndef ENABLE_INDICATOR
if (priv->is_adhoc && !gtk_image_get_pixbuf (GTK_IMAGE (priv->detail))) {
scaled = NULL;
pixbuf = nma_icon_check_and_load ("nm-adhoc", applet);
@@ -142,6 +151,7 @@ update_icon (NMNetworkMenuItem *item, NMApplet *applet)
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->detail), scaled ? scaled : pixbuf);
g_clear_object (&scaled);
}
+#endif
}
void
@@ -196,6 +206,9 @@ update_label (NMNetworkMenuItem *item, gboolean use_bold)
{
NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
+#ifdef ENABLE_INDICATOR
+ gtk_menu_item_set_label (GTK_MENU_ITEM (item), priv->ssid_string);
+#else
gtk_label_set_use_markup (GTK_LABEL (priv->ssid), use_bold);
if (use_bold) {
char *markup = g_markup_printf_escaped ("<b>%s</b>", priv->ssid_string);
@@ -204,6 +217,7 @@ update_label (NMNetworkMenuItem *item, gboolean use_bold)
g_free (markup);
} else
gtk_label_set_text (GTK_LABEL (priv->ssid), priv->ssid_string);
+#endif
}
void
@@ -314,6 +328,7 @@ nm_network_menu_item_new (NMAccessPoint *ap,
static void
nm_network_menu_item_init (NMNetworkMenuItem *item)
{
+#ifndef ENABLE_INDICATOR
NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -333,6 +348,9 @@ nm_network_menu_item_init (NMNetworkMenuItem *item)
gtk_widget_show (priv->ssid);
gtk_widget_show (priv->detail);
gtk_widget_show (priv->hbox);
+#else
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#endif
}
static void
diff --git a/src/applet.c b/src/applet.c
index 2b42002c..a7b4ffc3 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -677,6 +677,9 @@ applet_menu_item_add_complex_separator_helper (GtkWidget *menu,
NMApplet *applet,
const gchar* label)
{
+#ifdef ENABLE_INDICATOR
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
+#else
GtkWidget *menu_item = gtk_image_menu_item_new ();
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
GtkWidget *xlabel = NULL;
@@ -696,6 +699,7 @@ applet_menu_item_add_complex_separator_helper (GtkWidget *menu,
"sensitive", FALSE,
NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
+#endif
}
GtkWidget *
@@ -706,6 +710,7 @@ applet_new_menu_item_helper (NMConnection *connection,
NMSettingConnection *s_con = nm_connection_get_setting_connection (connection);
GtkWidget *item = gtk_image_menu_item_new_with_label ("");
+#ifndef ENABLE_INDICATOR
if (add_active && (active == connection)) {
char *markup;
GtkWidget *label;
@@ -717,12 +722,14 @@ applet_new_menu_item_helper (NMConnection *connection,
gtk_label_set_markup (GTK_LABEL (label), markup);
g_free (markup);
} else
+#endif
gtk_menu_item_set_label (GTK_MENU_ITEM (item), nm_setting_connection_get_id (s_con));
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
return item;
}
+#ifndef ENABLE_INDICATOR
#define TITLE_TEXT_R ((double) 0x5e / 255.0 )
#define TITLE_TEXT_G ((double) 0x5e / 255.0 )
#define TITLE_TEXT_B ((double) 0x5e / 255.0 )
@@ -786,6 +793,7 @@ menu_title_item_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data)
menu_item_draw_generic (widget, cr);
return TRUE;
}
+#endif /* ENABLE_INDICATOR */
GtkWidget *
applet_menu_item_create_device_item_helper (NMDevice *device,
@@ -796,7 +804,9 @@ applet_menu_item_create_device_item_helper (NMDevice *device,
item = gtk_menu_item_new_with_label (text);
gtk_widget_set_sensitive (item, FALSE);
+#ifndef ENABLE_INDICATOR
g_signal_connect (item, "draw", G_CALLBACK (menu_title_item_draw), NULL);
+#endif
return item;
}
@@ -854,8 +864,13 @@ applet_do_notify (NMApplet *applet,
g_return_if_fail (summary != NULL);
g_return_if_fail (message != NULL);
+#ifdef ENABLE_INDICATOR
+ if (app_indicator_get_status (applet->app_indicator) == APP_INDICATOR_STATUS_PASSIVE)
+ return;
+#else
if (!gtk_status_icon_is_embedded (applet->status_icon))
return;
+#endif
/* if we're not acting as a secret agent, don't notify either */
if (!applet->agent)
@@ -1195,6 +1210,10 @@ activate_vpn_cb (NMClient *client,
g_free (info);
}
+#ifdef ENABLE_INDICATOR
+static void nma_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer user_data);
+#endif
+
static void
nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
{
@@ -1218,6 +1237,9 @@ nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data)
}
if (applet_get_active_for_connection (applet, connection)) {
+#ifdef ENABLE_INDICATOR
+ nma_menu_disconnect_vpn_item_activate (item, applet);
+#endif
/* Connection already active; do nothing */
return;
}
@@ -1879,6 +1901,7 @@ nma_set_networking_enabled_cb (GtkWidget *widget, NMApplet *applet)
}
+#ifndef ENABLE_INDICATOR
static void
nma_set_notifications_enabled_cb (GtkWidget *widget, NMApplet *applet)
{
@@ -1901,6 +1924,7 @@ nma_set_notifications_enabled_cb (GtkWidget *widget, NMApplet *applet)
PREF_SUPPRESS_WIFI_NETWORKS_AVAILABLE,
!state);
}
+#endif /* ENABLE_INDICATOR */
static gboolean
has_usable_wifi (NMApplet *applet)
@@ -1937,7 +1961,9 @@ static void nma_menu_show_cb (GtkWidget *menu, NMApplet *applet)
g_return_if_fail (menu != NULL);
g_return_if_fail (applet != NULL);
+#ifndef ENABLE_INDICATOR
gtk_status_icon_set_tooltip_text (applet->status_icon, NULL);
+#endif
if (!nm_client_get_manager_running (applet->nm_client)) {
nma_menu_add_text_item (menu, _("NetworkManager is not running..."));
@@ -1959,11 +1985,14 @@ static void nma_menu_show_cb (GtkWidget *menu, NMApplet *applet)
nma_menu_add_create_network_item (menu, applet);
}
+#ifndef ENABLE_INDICATOR
gtk_widget_show_all (menu);
+#endif
// nmi_dbus_signal_user_interface_activated (applet->connection);
}
+#ifndef ENABLE_INDICATOR
static gboolean
destroy_old_menu (gpointer user_data)
{
@@ -1985,6 +2014,7 @@ nma_menu_deactivate_cb (GtkWidget *widget, NMApplet *applet)
/* Re-set the tooltip */
gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip);
}
+#endif
static gboolean
is_permission_yes (NMApplet *applet, NMClientPermission perm)
@@ -2010,7 +2040,9 @@ nma_context_menu_update (NMApplet *applet)
gboolean wifi_hw_enabled;
gboolean wwan_hw_enabled;
gboolean wimax_hw_enabled;
+#ifndef ENABLE_INDICATOR
gboolean notifications_enabled = TRUE;
+#endif
gboolean sensitive = FALSE;
state = nm_client_get_state (applet->nm_client);
@@ -2070,6 +2102,7 @@ nma_context_menu_update (NMApplet *applet)
gtk_widget_set_sensitive (GTK_WIDGET (applet->wimax_enabled_item),
wimax_hw_enabled && is_permission_yes (applet, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX));
+#ifndef ENABLE_INDICATOR
/* Enabled notifications */
g_signal_handler_block (G_OBJECT (applet->notifications_enabled_item),
applet->notifications_enabled_toggled_id);
@@ -2081,6 +2114,7 @@ nma_context_menu_update (NMApplet *applet)
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->notifications_enabled_item), notifications_enabled);
g_signal_handler_unblock (G_OBJECT (applet->notifications_enabled_item),
applet->notifications_enabled_toggled_id);
+#endif
/* Don't show wifi-specific stuff if wifi is off */
if (state != NM_STATE_ASLEEP) {
@@ -2156,7 +2190,9 @@ applet_connection_info_cb (NMApplet *applet)
static GtkWidget *nma_context_menu_create (NMApplet *applet)
{
GtkMenuShell *menu;
+#ifndef ENABLE_INDICATOR
GtkWidget *menu_item;
+#endif
GtkWidget *image;
guint id;
@@ -2202,6 +2238,7 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
nma_menu_add_separator_item (GTK_WIDGET (menu));
+#ifndef ENABLE_INDICATOR
/* Toggle notifications item */
applet->notifications_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable N_otifications"));
id = g_signal_connect (applet->notifications_enabled_item,
@@ -2212,6 +2249,7 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
gtk_menu_shell_append (menu, applet->notifications_enabled_item);
nma_menu_add_separator_item (GTK_WIDGET (menu));
+#endif
/* 'Connection Information' item */
applet->info_menu_item = gtk_image_menu_item_new_with_mnemonic (_("Connection _Information"));
@@ -2236,6 +2274,7 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
/* Separator */
nma_menu_add_separator_item (GTK_WIDGET (menu));
+#ifndef ENABLE_INDICATOR
#if 0 /* FIXME: Implement the help callback, nma_help_cb()! */
/* Help item */
menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Help"));
@@ -2252,6 +2291,7 @@ static GtkWidget *nma_context_menu_create (NMApplet *applet)
image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
gtk_menu_shell_append (menu, menu_item);
+#endif
gtk_widget_show_all (GTK_WIDGET (menu));
@@ -2354,9 +2394,31 @@ applet_add_default_connection_item (NMDevice *device,
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
}
+#ifdef ENABLE_INDICATOR
+static gboolean
+applet_update_indicator_menu (gpointer user_data)
+{
+ NMApplet *applet = NM_APPLET (user_data);
+ GtkWidget *menu = nma_context_menu_create (applet);
+
+ nma_menu_show_cb (menu, applet);
+ nma_menu_add_separator_item (menu);
+ nma_context_menu_update (applet);
+
+ app_indicator_set_menu (applet->app_indicator, GTK_MENU (menu));
+
+ applet->update_menu_id = 0;
+ return FALSE;
+}
+#endif /* ENABLE_INDICATOR */
+
void
applet_schedule_update_menu (NMApplet *applet)
{
+#ifdef ENABLE_INDICATOR
+ if (!applet->update_menu_id)
+ applet->update_menu_id = g_idle_add (applet_update_indicator_menu, applet);
+#endif
}
/*****************************************************************************/
@@ -2366,6 +2428,16 @@ foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_nam
{
g_return_if_fail (layer == ICON_LAYER_LINK || layer == ICON_LAYER_VPN);
+#ifdef ENABLE_INDICATOR
+ /* FIXME: We rely on the fact that VPN icon gets drawn later and therefore
+ * wins but we cannot currently set a combined pixmap made of both the link
+ * icon and the VPN icon.
+ */
+ if (icon_name == NULL && layer == ICON_LAYER_LINK)
+ icon_name = g_strdup ("nm-no-connection");
+ if (icon_name != NULL && g_strcmp0 (app_indicator_get_icon (applet->app_indicator), icon_name) != 0)
+ app_indicator_set_icon_full (applet->app_indicator, icon_name, applet->tip);
+#else
/* Load the pixbuf by icon name */
if (icon_name && !pixbuf)
pixbuf = nma_icon_check_and_load (icon_name, applet);
@@ -2403,6 +2475,7 @@ foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_nam
gtk_status_icon_set_from_pixbuf (applet->status_icon, pixbuf);
g_object_unref (pixbuf);
+#endif
}
NMRemoteConnection *
@@ -2557,6 +2630,17 @@ foo_client_state_changed_cb (NMClient *client, GParamSpec *pspec, gpointer user_
applet_schedule_update_menu (applet);
}
+#ifdef ENABLE_INDICATOR
+static void
+foo_device_removed_cb (NMClient *client, NMDevice *device, gpointer user_data)
+{
+ NMApplet *applet = NM_APPLET (user_data);
+
+ applet_schedule_update_icon (applet);
+ applet_schedule_update_menu (applet);
+}
+#endif
+
static void
foo_manager_running_cb (NMClient *client,
GParamSpec *pspec,
@@ -2653,6 +2737,11 @@ foo_client_setup (NMApplet *applet)
g_signal_connect (applet->nm_client, "device-added",
G_CALLBACK (foo_device_added_cb),
applet);
+#ifdef ENABLE_INDICATOR
+ g_signal_connect (applet->nm_client, "device-removed",
+ G_CALLBACK (foo_device_removed_cb),
+ applet);
+#endif
g_signal_connect (applet->nm_client, "notify::manager-running",
G_CALLBACK (foo_manager_running_cb),
applet);
@@ -2925,7 +3014,11 @@ applet_update_icon (gpointer user_data)
if (!nm_running)
state = NM_STATE_UNKNOWN;
+#ifdef ENABLE_INDICATOR
+ app_indicator_set_status (applet->app_indicator, nm_running ? APP_INDICATOR_STATUS_ACTIVE : APP_INDICATOR_STATUS_PASSIVE);
+#else
gtk_status_icon_set_visible (applet->status_icon, applet->visible);
+#endif
switch (state) {
case NM_STATE_UNKNOWN:
@@ -2986,7 +3079,13 @@ applet_update_icon (gpointer user_data)
/* update tooltip */
g_free (applet->tip);
applet->tip = g_strdup (vpn_tip ? vpn_tip : dev_tip);
+#ifdef ENABLE_INDICATOR
+ /* FIXME: The applet->tip attribute seems to only be picked up by
+ * the next call to foo_set_icon() which is not particularly nice.
+ */
+#else
gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip);
+#endif
g_free (vpn_tip);
g_free (dev_tip);
@@ -3341,7 +3440,11 @@ static void nma_icons_init (NMApplet *applet)
g_object_unref (G_OBJECT (applet->icon_theme));
}
+#ifdef ENABLE_INDICATOR
+ applet->icon_theme = gtk_icon_theme_get_default ();
+#else
applet->icon_theme = gtk_icon_theme_get_for_screen (gtk_status_icon_get_screen (applet->status_icon));
+#endif
/* If not done yet, append our search path */
path_appended = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (applet->icon_theme),
@@ -3356,6 +3459,7 @@ static void nma_icons_init (NMApplet *applet)
g_signal_connect (applet->icon_theme, "changed", G_CALLBACK (nma_icons_reload), applet);
}
+#ifndef ENABLE_INDICATOR
static void
status_icon_screen_changed_cb (GtkStatusIcon *icon,
GParamSpec *pspec,
@@ -3427,11 +3531,18 @@ status_icon_popup_menu_cb (GtkStatusIcon *icon,
gtk_status_icon_position_menu, icon,
button, activate_time);
}
+#endif /* ENABLE_INDICATOR */
static gboolean
setup_widgets (NMApplet *applet)
{
-
+#ifdef ENABLE_INDICATOR
+ applet->app_indicator = app_indicator_new
+ ("nm-applet", "nm-no-connection",
+ APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+ app_indicator_set_title(applet->app_indicator, _("Network"));
+ applet_schedule_update_menu (applet);
+#else
applet->status_icon = gtk_status_icon_new ();
if (shell_debug)
@@ -3449,10 +3560,20 @@ setup_widgets (NMApplet *applet)
applet->context_menu = nma_context_menu_create (applet);
if (!applet->context_menu)
return FALSE;
+#endif
return TRUE;
}
+#ifdef ENABLE_INDICATOR
+static void
+new_connection_cb (NMRemoteSettings *settings, NMRemoteConnection *connection, gpointer user_data)
+{
+ NMApplet *applet = NM_APPLET (user_data);
+
+ applet_schedule_update_menu (applet);
+}
+#else
static void
applet_embedded_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
{
@@ -3461,6 +3582,7 @@ applet_embedded_cb (GObject *object, GParamSpec *pspec, gpointer user_data)
g_debug ("applet now %s the notification area",
embedded ? "embedded in" : "removed from");
}
+#endif
static void
register_agent (NMApplet *applet)
@@ -3473,6 +3595,12 @@ register_agent (NMApplet *applet)
G_CALLBACK (applet_agent_get_secrets_cb), applet);
g_signal_connect (applet->agent, APPLET_AGENT_CANCEL_SECRETS,
G_CALLBACK (applet_agent_cancel_secrets_cb), applet);
+#ifdef ENABLE_INDICATOR
+ /* Watch for new connections */
+ g_signal_connect (applet->settings, "new-connection",
+ G_CALLBACK (new_connection_cb),
+ applet);
+#endif
}
static gboolean
@@ -3517,7 +3645,9 @@ applet_gsettings_show_changed (GSettings *settings,
applet->visible = g_settings_get_boolean (settings, key);
+#ifndef ENABLE_INDICATOR
gtk_status_icon_set_visible (applet->status_icon, applet->visible);
+#endif
}
static gboolean
@@ -3618,12 +3748,14 @@ initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
mm1_client_setup (applet);
#endif
+#ifndef ENABLE_INDICATOR
/* Track embedding to help debug issues where user has removed the
* notification area applet from the panel, and thus nm-applet too.
*/
g_signal_connect (applet->status_icon, "notify::embedded",
G_CALLBACK (applet_embedded_cb), NULL);
applet_embedded_cb (G_OBJECT (applet->status_icon), NULL, NULL);
+#endif
if (with_agent)
register_agent (applet);
@@ -3651,12 +3783,18 @@ static void finalize (GObject *object)
if (applet->update_icon_id)
g_source_remove (applet->update_icon_id);
+#ifdef ENABLE_INDICATOR
+ g_clear_object (&applet->app_indicator);
+ if (applet->update_menu_id)
+ g_source_remove (applet->update_menu_id);
+#else
g_clear_object (&applet->status_icon);
g_clear_object (&applet->menu);
g_clear_pointer (&applet->icon_cache, g_hash_table_destroy);
g_clear_object (&applet->fallback_icon);
g_free (applet->tip);
nma_icons_free (applet);
+#endif
while (g_slist_length (applet->secrets_reqs))
applet_secrets_request_free ((SecretsRequest *) applet->secrets_reqs->data);
diff --git a/src/applet.h b/src/applet.h
index 28629190..b8228142 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -36,6 +36,10 @@
#include <libnotify/notify.h>
+#ifdef ENABLE_INDICATOR
+#include <libappindicator/app-indicator.h>
+#endif
+
#include <nm-connection.h>
#include <nm-client.h>
#include <nm-access-point.h>
@@ -135,6 +139,10 @@ typedef struct
GdkPixbuf * icon_layers[ICON_LAYER_MAX + 1];
/* Direct UI elements */
+#ifdef ENABLE_INDICATOR
+ AppIndicator * app_indicator;
+ guint update_menu_id;
+#else
GtkStatusIcon * status_icon;
GtkWidget * menu;
@@ -142,6 +150,7 @@ typedef struct
GtkWidget * notifications_enabled_item;
guint notifications_enabled_toggled_id;
+#endif
GtkWidget * networking_enabled_item;
guint networking_enabled_toggled_id;
diff --git a/src/mb-menu-item.c b/src/mb-menu-item.c
index 5b0c8fd9..216f7b6f 100644
--- a/src/mb-menu-item.c
+++ b/src/mb-menu-item.c
@@ -36,10 +36,12 @@ G_DEFINE_TYPE (NMMbMenuItem, nm_mb_menu_item, GTK_TYPE_IMAGE_MENU_ITEM);
#define NM_MB_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_MB_MENU_ITEM, NMMbMenuItemPrivate))
typedef struct {
+#ifndef ENABLE_INDICATOR
GtkWidget *strength;
GtkWidget *detail;
GtkWidget *hbox;
GtkWidget *desc;
+#endif
char *desc_string;
guint32 int_strength;
@@ -84,6 +86,9 @@ update_label (NMMbMenuItem *item, gboolean use_bold)
{
NMMbMenuItemPrivate *priv = NM_MB_MENU_ITEM_GET_PRIVATE (item);
+#ifdef ENABLE_INDICATOR
+ gtk_menu_item_set_label (GTK_MENU_ITEM (item), priv->desc_string);
+#else
gtk_label_set_use_markup (GTK_LABEL (priv->desc), use_bold);
if (use_bold) {
char *markup = g_markup_printf_escaped ("<b>%s</b>", priv->desc_string);
@@ -92,6 +97,7 @@ update_label (NMMbMenuItem *item, gboolean use_bold)
g_free (markup);
} else
gtk_label_set_text (GTK_LABEL (priv->desc), priv->desc_string);
+#endif
}
GtkWidget *
@@ -190,7 +196,13 @@ nm_mb_menu_item_new (const char *connection_name,
const char *icon_name = mobile_helper_get_quality_icon_name (strength);
GdkPixbuf *pixbuf = nma_icon_check_and_load (icon_name, applet);
+#ifdef ENABLE_INDICATOR
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), gtk_image_new_from_pixbuf (pixbuf));
+ /* For some reason we must always re-set always-show after setting the image */
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
+#else
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), pixbuf);
+#endif
}
return GTK_WIDGET (item);
@@ -201,6 +213,7 @@ nm_mb_menu_item_new (const char *connection_name,
static void
nm_mb_menu_item_init (NMMbMenuItem *self)
{
+#ifndef ENABLE_INDICATOR
NMMbMenuItemPrivate *priv = NM_MB_MENU_ITEM_GET_PRIVATE (self);
priv->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
@@ -216,6 +229,9 @@ nm_mb_menu_item_init (NMMbMenuItem *self)
gtk_widget_show (priv->desc);
gtk_widget_show (priv->strength);
gtk_widget_show (priv->hbox);
+#else
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (self), TRUE);
+#endif
}
static void