diff --git a/ChangeLog b/ChangeLog index 99c3feb625..436ff10a5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-09-08 Christopher Aillon + + * gnome/applet/vpn-connection.c: + * gnome/applet/vpn-connection.h: + Add nmwa_vpn_connection_is_activating () + + * gnome/applet/applet.c: + * gnome/applet/applet.h: + * gnome/applet/icons/nm-vpn-connecting*.png: + Add new VPN connecting icons from Diana Fong , letting + the user know something's happening between clicking the VPN item and it + actually being connected. + 2005-09-07 Christopher Aillon * gnome/applet/applet-dbus-info.c: need to free attributes in the diff --git a/gnome/applet/applet.c b/gnome/applet/applet.c index 79c0337de0..adfb08a409 100644 --- a/gnome/applet/applet.c +++ b/gnome/applet/applet.c @@ -892,29 +892,47 @@ VPNConnection *nmwa_get_first_active_vpn_connection (NMWirelessApplet *applet) return NULL; } +VPNConnection *nmwa_get_first_activating_vpn_connection (NMWirelessApplet *applet) +{ + VPNConnection * vpn; + GSList * elt; -static void nmwa_set_icon (NMWirelessApplet *applet, GdkPixbuf *new_icon) + for (elt = applet->vpn_connections; elt; elt = g_slist_next (elt)) + { + vpn = (VPNConnection*) elt->data; + if (nmwa_vpn_connection_is_activating (vpn)) + return vpn; + } + + return NULL; +} + +static void nmwa_set_icon (NMWirelessApplet *applet, GdkPixbuf *link_icon, GdkPixbuf *vpn_icon) { GdkPixbuf *composite; VPNConnection *vpn; g_return_if_fail (applet != NULL); - g_return_if_fail (new_icon != NULL); + g_return_if_fail (link_icon != NULL); - composite = gdk_pixbuf_copy (new_icon); + composite = gdk_pixbuf_copy (link_icon); vpn = nmwa_get_first_active_vpn_connection (applet); + if (!vpn) + vpn = nmwa_get_first_activating_vpn_connection (applet); if (vpn) { - int dest_x = gdk_pixbuf_get_width (new_icon) - gdk_pixbuf_get_width (applet->vpn_lock_icon); - int dest_y = gdk_pixbuf_get_height (new_icon) - gdk_pixbuf_get_height (applet->vpn_lock_icon) - 2; + if (!vpn_icon) + goto out; - gdk_pixbuf_composite (applet->vpn_lock_icon, composite, dest_x, dest_y, gdk_pixbuf_get_width (applet->vpn_lock_icon), - gdk_pixbuf_get_height (applet->vpn_lock_icon), dest_x, dest_y, 1.0, 1.0, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite (vpn_icon, composite, 0, 0, gdk_pixbuf_get_width (vpn_icon), + gdk_pixbuf_get_height (vpn_icon), 0, 0, 1.0, 1.0, GDK_INTERP_NEAREST, 255); } +out: gtk_image_set_from_pixbuf (GTK_IMAGE (applet->pixmap), composite); + g_object_unref (composite); } @@ -930,6 +948,37 @@ static void nmwa_set_progress (NMWirelessApplet *applet, GdkPixbuf *progress_ico gtk_widget_show (applet->progress_bar); } +static GdkPixbuf *nmwa_get_wireless_connection_strength_icon (NMWirelessApplet *applet) +{ + NetworkDevice *act_dev; + WirelessNetwork *active_network; + int strength = 0; + GdkPixbuf *pixbuf = NULL; + + g_return_val_if_fail (applet != NULL, NULL); + + act_dev = nmwa_get_first_active_device (applet->device_list); + if (act_dev && network_device_is_wireless (act_dev)) + { + active_network = network_device_get_active_wireless_network (act_dev); + strength = CLAMP ((int)network_device_get_strength (act_dev), 0, 100); + } + + if (strength > 75) + pixbuf = applet->wireless_100_icon; + else if (strength > 50) + pixbuf = applet->wireless_75_icon; + else if (strength > 25) + pixbuf = applet->wireless_50_icon; + else if (strength > 0) + pixbuf = applet->wireless_25_icon; + else + pixbuf = applet->wireless_00_icon; + + return pixbuf; +} + + /* * animation_timeout * @@ -939,7 +988,11 @@ static void nmwa_set_progress (NMWirelessApplet *applet, GdkPixbuf *progress_ico */ static gboolean animation_timeout (NMWirelessApplet *applet) { - NetworkDevice *act_dev = nmwa_get_first_active_device (applet->device_list); + NetworkDevice *act_dev; + + g_return_val_if_fail (applet != NULL, FALSE); + + act_dev = nmwa_get_first_active_device (applet->device_list); if (!applet->nm_running) { @@ -947,26 +1000,31 @@ static gboolean animation_timeout (NMWirelessApplet *applet) return TRUE; } - switch (applet->nm_state) + if (applet->nm_state == NM_STATE_CONNECTING) { - case NM_STATE_CONNECTING: - if (act_dev && network_device_is_wireless (act_dev)) - { - if (applet->animation_step >= NUM_WIRELESS_CONNECTING_FRAMES) - applet->animation_step = 0; - nmwa_set_icon (applet, applet->wireless_connecting_icons[applet->animation_step]); - } - else if (act_dev) - { - if (applet->animation_step >= NUM_WIRED_CONNECTING_FRAMES) - applet->animation_step = 0; - nmwa_set_icon (applet, applet->wired_connecting_icons[applet->animation_step]); - } - applet->animation_step ++; - break; + if (act_dev && network_device_is_wireless (act_dev)) + { + if (applet->animation_step >= NUM_WIRELESS_CONNECTING_FRAMES) + applet->animation_step = 0; + nmwa_set_icon (applet, applet->wireless_connecting_icons[applet->animation_step], NULL); + } + else if (act_dev) + { + if (applet->animation_step >= NUM_WIRED_CONNECTING_FRAMES) + applet->animation_step = 0; + nmwa_set_icon (applet, applet->wired_connecting_icons[applet->animation_step], NULL); + } + applet->animation_step ++; + } + else if (nmwa_get_first_activating_vpn_connection (applet) != NULL) + { + GdkPixbuf *connected_icon; + connected_icon = nmwa_get_wireless_connection_strength_icon (applet); - default: - break; + if (applet->animation_step >= NUM_VPN_CONNECTING_FRAMES) + applet->animation_step = 0; + nmwa_set_icon (applet, connected_icon, applet->vpn_connecting_icons[applet->animation_step]); + applet->animation_step ++; } return TRUE; @@ -1064,6 +1122,7 @@ static void nmwa_update_state (NMWirelessApplet *applet) GdkPixbuf * progress = NULL; gint strength = -1; char * tip = NULL; + char * vpntip = NULL; WirelessNetwork * active_network = NULL; NetworkDevice * act_dev = NULL; VPNConnection *vpn; @@ -1107,16 +1166,7 @@ static void nmwa_update_state (NMWirelessApplet *applet) } else { - if (strength > 75) - pixbuf = applet->wireless_100_icon; - else if (strength > 50) - pixbuf = applet->wireless_75_icon; - else if (strength > 25) - pixbuf = applet->wireless_50_icon; - else if (strength > 0) - pixbuf = applet->wireless_25_icon; - else - pixbuf = applet->wireless_00_icon; + pixbuf = nmwa_get_wireless_connection_strength_icon (applet); tip = g_strdup_printf (_("Wireless network connection to '%s' (%d%%)"), active_network ? wireless_network_get_essid (active_network) : "(unknown)", strength); } @@ -1132,28 +1182,40 @@ static void nmwa_update_state (NMWirelessApplet *applet) break; } -done: - if (!applet->tooltips) - applet->tooltips = gtk_tooltips_new (); - vpn = nmwa_get_first_active_vpn_connection (applet); if (vpn != NULL) { - char *newtip; - char *vpntip; - vpntip = g_strdup_printf (_("VPN connection to '%s'"), nmwa_vpn_connection_get_name (vpn)); + } + else + { + vpn = nmwa_get_first_activating_vpn_connection (applet); + if (vpn != NULL) + { + need_animation = TRUE; + vpntip = g_strdup_printf (_("VPN connecting to '%s'"), nmwa_vpn_connection_get_name (vpn)); + } + } + + if (vpntip) + { + char *newtip; newtip = g_strconcat (tip, "\n", vpntip, NULL); g_free (vpntip); g_free (tip); tip = newtip; } +done: + if (!applet->tooltips) + applet->tooltips = gtk_tooltips_new (); + gtk_tooltips_set_tip (applet->tooltips, applet->event_box, tip, NULL); g_free (tip); - nmwa_set_progress (applet, progress); + nmwa_set_progress (applet, progress); + applet->animation_step = 0; if (applet->animation_id) g_source_remove (applet->animation_id); if (need_animation) @@ -1161,7 +1223,7 @@ done: else { if (pixbuf) - nmwa_set_icon (applet, pixbuf); + nmwa_set_icon (applet, pixbuf, applet->vpn_lock_icon); else show_applet = FALSE; } @@ -2576,6 +2638,13 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme) g_free (name); } + for (i = 0; i < NUM_VPN_CONNECTING_FRAMES; i++) + { + name = g_strdup_printf ("nm-vpn-connecting%02d", i+1); + ICON_LOAD(applet->vpn_connecting_icons[i], name); + g_free (name); + } + success = TRUE; out: diff --git a/gnome/applet/applet.h b/gnome/applet/applet.h index b98b18f52b..63f0fb9b70 100644 --- a/gnome/applet/applet.h +++ b/gnome/applet/applet.h @@ -105,6 +105,8 @@ typedef struct GdkPixbuf * wireless_100_icon; #define NUM_WIRELESS_CONNECTING_FRAMES 11 GdkPixbuf * wireless_connecting_icons[NUM_WIRELESS_CONNECTING_FRAMES]; +#define NUM_VPN_CONNECTING_FRAMES 14 + GdkPixbuf * vpn_connecting_icons[NUM_VPN_CONNECTING_FRAMES]; GdkPixbuf * vpn_lock_icon; /* Animation stuff */ diff --git a/gnome/applet/icons/nm-vpn-connecting01.png b/gnome/applet/icons/nm-vpn-connecting01.png new file mode 100644 index 0000000000..ac75086945 Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting01.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting02.png b/gnome/applet/icons/nm-vpn-connecting02.png new file mode 100644 index 0000000000..427551ea1d Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting02.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting03.png b/gnome/applet/icons/nm-vpn-connecting03.png new file mode 100644 index 0000000000..f7e6517d1f Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting03.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting04.png b/gnome/applet/icons/nm-vpn-connecting04.png new file mode 100644 index 0000000000..7e0b576055 Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting04.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting05.png b/gnome/applet/icons/nm-vpn-connecting05.png new file mode 100644 index 0000000000..a2fb80915b Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting05.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting06.png b/gnome/applet/icons/nm-vpn-connecting06.png new file mode 100644 index 0000000000..7c611d8608 Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting06.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting07.png b/gnome/applet/icons/nm-vpn-connecting07.png new file mode 100644 index 0000000000..d5cebd27cb Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting07.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting08.png b/gnome/applet/icons/nm-vpn-connecting08.png new file mode 100644 index 0000000000..99fb4f3e9f Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting08.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting09.png b/gnome/applet/icons/nm-vpn-connecting09.png new file mode 100644 index 0000000000..d6d5bb83cf Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting09.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting10.png b/gnome/applet/icons/nm-vpn-connecting10.png new file mode 100644 index 0000000000..3c668c86c6 Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting10.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting11.png b/gnome/applet/icons/nm-vpn-connecting11.png new file mode 100644 index 0000000000..d97483c2b4 Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting11.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting12.png b/gnome/applet/icons/nm-vpn-connecting12.png new file mode 100644 index 0000000000..1dab59b884 Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting12.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting13.png b/gnome/applet/icons/nm-vpn-connecting13.png new file mode 100644 index 0000000000..a7c1ff78ea Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting13.png differ diff --git a/gnome/applet/icons/nm-vpn-connecting14.png b/gnome/applet/icons/nm-vpn-connecting14.png new file mode 100644 index 0000000000..645c2461bd Binary files /dev/null and b/gnome/applet/icons/nm-vpn-connecting14.png differ diff --git a/gnome/applet/icons/nm-vpn-lock.png b/gnome/applet/icons/nm-vpn-lock.png index 73d1a41318..8a616968b2 100644 Binary files a/gnome/applet/icons/nm-vpn-lock.png and b/gnome/applet/icons/nm-vpn-lock.png differ diff --git a/gnome/applet/vpn-connection.c b/gnome/applet/vpn-connection.c index d06b5c7a62..e73d6443ac 100644 --- a/gnome/applet/vpn-connection.c +++ b/gnome/applet/vpn-connection.c @@ -149,3 +149,18 @@ void nmwa_vpn_connection_set_state (VPNConnection *vpn, NMVPNActStage state) vpn->state = state; } + +gboolean nmwa_vpn_connection_is_activating (VPNConnection *vpn) +{ + NMVPNActStage stage; + + g_return_val_if_fail (vpn != NULL, FALSE); + + stage = nmwa_vpn_connection_get_state (vpn); + if (stage == NM_VPN_ACT_STAGE_PREPARE || + stage == NM_VPN_ACT_STAGE_CONNECT || + stage == NM_VPN_ACT_STAGE_IP_CONFIG_GET) + return TRUE; + + return FALSE; +} diff --git a/gnome/applet/vpn-connection.h b/gnome/applet/vpn-connection.h index 8b45a9dbd2..e5f137650b 100644 --- a/gnome/applet/vpn-connection.h +++ b/gnome/applet/vpn-connection.h @@ -37,6 +37,8 @@ void nmwa_vpn_connection_set_service (VPNConnection *vpn, const char *service NMVPNActStage nmwa_vpn_connection_get_state (VPNConnection *vpn); void nmwa_vpn_connection_set_state (VPNConnection *vpn, NMVPNActStage state); +gboolean nmwa_vpn_connection_is_activating (VPNConnection *vpn); + VPNConnection * nmwa_vpn_connection_find_by_name (GSList *list, const char *name); #endif