537
540
disconnect_cb (NMDevice *device, GError *error, gpointer user_data)
542
NMApplet *applet = NM_APPLET (user_data);
540
545
g_warning ("%s: device disconnect failed: (%d) %s",
542
547
error ? error->code : -1,
543
548
error && error->message ? error->message : "(unknown)");
551
applet_schedule_update_icon (applet);
552
applet_schedule_update_menu (applet);
2834
2840
NMConnection *connection;
2836
2842
connection = applet_find_active_connection_for_device (device, applet, NULL);
2843
/* device class returns a referenced pixbuf */
2837
2844
dclass->get_icon (device, state, connection, out_pixbuf, out_indicator_icon, out_tip, applet);
2838
2845
if (out_tip && !*out_tip)
2839
2846
*out_tip = get_tip_for_device_state (device, state, connection);
2931
2937
case NM_STATE_ASLEEP:
2932
2938
icon_name = g_strdup ("nm-no-connection");
2933
2939
pixbuf = nma_icon_check_and_load (icon_name, &applet->no_connection_icon, applet);
2935
g_object_ref (pixbuf);
2940
g_object_ref (pixbuf);
2936
2941
dev_tip = g_strdup (_("Networking disabled"));
2938
2943
case NM_STATE_DISCONNECTED:
2939
2944
icon_name = g_strdup ("nm-no-connection");
2940
2945
pixbuf = nma_icon_check_and_load (icon_name, &applet->no_connection_icon, applet);
2942
g_object_ref (pixbuf);
2946
g_object_ref (pixbuf);
2943
2947
dev_tip = g_strdup (_("No network connection"));
2968
2970
icon_name = g_strdup_printf ("nm-vpn-active-lock");
2970
2972
icon_name = g_strdup_printf ("%s-secure", app_indicator_get_icon (applet->app_indicator));
2973
#endif /* ENABLE_INDICATOR */
2972
2974
pixbuf = nma_icon_check_and_load (icon_name, &applet->vpn_lock_icon, applet);
2974
2976
case NM_VPN_CONNECTION_STATE_PREPARE:
2975
2977
case NM_VPN_CONNECTION_STATE_NEED_AUTH:
2976
2978
case NM_VPN_CONNECTION_STATE_CONNECT:
2977
2979
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET:
2978
for (i = 0; i < NUM_VPN_CONNECTING_FRAMES; i++) {
2979
icon_name = g_strdup_printf ("nm-vpn-connecting%02d", i+1);
2980
nma_icon_check_and_load (icon_name, &applet->vpn_connecting_icons[i], applet);
2984
pixbuf = applet->vpn_connecting_icons[applet->animation_step];
2985
applet->animation_step++;
2986
if (applet->animation_step >= NUM_VPN_CONNECTING_FRAMES)
2987
applet->animation_step = 0;
2980
for (i = 0; i < NUM_VPN_CONNECTING_FRAMES; i++) {
2983
name = g_strdup_printf ("nm-vpn-connecting%02d", i+1);
2984
nma_icon_check_and_load (name, &applet->vpn_connecting_icons[i], applet);
2988
pixbuf = applet->vpn_connecting_icons[applet->animation_step];
2989
2989
#ifdef ENABLE_INDICATOR
2990
icon_name = g_strdup_printf ("nm-vpn-connecting%02d", applet->animation_step+1);
2990
icon_name = g_strdup_printf ("nm-vpn-connecting%02d", applet->animation_step+1);
2992
applet->animation_step++;
2993
if (applet->animation_step >= NUM_VPN_CONNECTING_FRAMES)
2994
applet->animation_step = 0;
3000
vpn_tip = get_tip_for_vpn (active_vpn, vpn_state, applet);
2998
3002
foo_set_icon (applet, ICON_LAYER_VPN, pixbuf, icon_name, vpn_tip);
3001
3004
g_free (icon_name);
3251
applet_agent_registered_cb (AppletAgent *agent,
3255
NMApplet *applet = NM_APPLET (user_data);
3257
/* If the shell is running and the agent just got registered, unregister it */
3258
if ( (applet->shell_version >= 3.4)
3259
&& nm_secret_agent_get_registered (NM_SECRET_AGENT (agent))) {
3260
g_message ("Stopping registered applet secret agent because GNOME Shell is running");
3261
nm_secret_agent_unregister (NM_SECRET_AGENT (agent));
3247
3265
/*****************************************************************************/
3608
3626
embedded ? "embedded in" : "removed from");
3629
#if GLIB_CHECK_VERSION(2,26,0)
3631
delayed_start_agent (gpointer user_data)
3633
NMApplet *applet = user_data;
3635
applet->agent_start_id = 0;
3637
g_assert (applet->agent);
3639
/* If the agent is already running, there's nothing to do. */
3640
if (nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent)) == TRUE)
3643
if (nm_secret_agent_register (NM_SECRET_AGENT (applet->agent)))
3644
g_message ("Starting applet secret agent because GNOME Shell disappeared");
3646
g_warning ("Failed to start applet secret agent!");
3651
get_shell_version (GDBusProxy *proxy, gdouble *out_version)
3655
gboolean success = FALSE;
3658
/* Ask for the shell's version */
3659
v = g_dbus_proxy_get_cached_property (proxy, "ShellVersion");
3661
g_warn_if_fail (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING));
3662
version = g_variant_dup_string (v, NULL);
3664
/* Terminate at the second dot if there is one */
3665
p = strchr (version, '.');
3666
if (p && (p = strchr (p + 1, '.')))
3669
converted = strtod (version, NULL);
3670
g_warn_if_fail (converted > 0);
3671
g_warn_if_fail (converted < 1000);
3672
if (converted > 0 && converted < 1000) {
3673
*out_version = converted;
3678
g_variant_unref (v);
3684
name_owner_changed_cb (GDBusProxy *proxy, GParamSpec *pspec, gpointer user_data)
3686
NMApplet *applet = user_data;
3689
owner = g_dbus_proxy_get_name_owner (proxy);
3691
applet->shell_version = 0;
3692
if (applet->agent_start_id)
3693
g_source_remove (applet->agent_start_id);
3695
if ( get_shell_version (proxy, &applet->shell_version)
3696
&& applet->shell_version >= 3.4
3698
&& nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent))) {
3699
g_message ("Stopping applet secret agent because GNOME Shell appeared");
3700
nm_secret_agent_unregister (NM_SECRET_AGENT (applet->agent));
3703
/* If the shell quit and our agent wasn't already registered, do it
3704
* now on a delay (just in case the shell is restarting.
3706
applet->shell_version = 0;
3707
if (applet->agent_start_id)
3708
g_source_remove (applet->agent_start_id);
3710
if (nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent)) == FALSE)
3711
applet->agent_start_id = g_timeout_add_seconds (4, delayed_start_agent, applet);
3611
3717
static gboolean
3612
3718
dbus_setup (NMApplet *applet, GError **error)
3771
3877
G_CALLBACK (applet_agent_get_secrets_cb), applet);
3772
3878
g_signal_connect (applet->agent, APPLET_AGENT_CANCEL_SECRETS,
3773
3879
G_CALLBACK (applet_agent_cancel_secrets_cb), applet);
3880
g_signal_connect (applet->agent, "notify::" NM_SECRET_AGENT_REGISTERED,
3881
G_CALLBACK (applet_agent_registered_cb), applet);
3775
3883
/* Initialize device classes */
3776
3884
applet->wired_class = applet_device_wired_get_class (applet);
3798
3906
G_CALLBACK (applet_embedded_cb), NULL);
3799
3907
applet_embedded_cb (G_OBJECT (applet->status_icon), NULL, NULL);
3909
#if GLIB_CHECK_VERSION(2,26,0)
3910
/* Watch GNOME Shell so we can unregister our applet agent if it appears */
3911
applet->shell_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
3912
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
3919
g_signal_connect (applet->shell_proxy,
3920
"notify::g-name-owner",
3921
G_CALLBACK (name_owner_changed_cb),
3923
name_owner_changed_cb (applet->shell_proxy, NULL, applet);
3801
3926
return G_OBJECT (applet);