Commit db4f5ced authored by Dan Williams's avatar Dan Williams
Browse files

2005-05-05 Dan Williams <dcbw@redhat.com>

	* Expose activation stages to NetworkManager clients, like the applet
	* Add Diana's progress icons to the applet, cued off NM activation stage
	* Use more descriptive tooltips, cued off NM activation stage


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@611 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 8b6b5aea
2005-05-05 Dan Williams <dcbw@redhat.com>
* Expose activation stages to NetworkManager clients, like the applet
* Add Diana's progress icons to the applet, cued off NM activation stage
* Use more descriptive tooltips, cued off NM activation stage
2005-05-05 Ray Strode <rstrode@redhat.com>
* src/nm-netlink-monitor.c:
......
......@@ -186,4 +186,23 @@ typedef enum NMVPNState
NM_VPN_STATE_STOPPED
} NMVPNState;
/*
* Device activation stages
*/
typedef enum NMActStage
{
NM_ACT_STAGE_UNKNOWN = 0,
NM_ACT_STAGE_DEVICE_PREPARE,
NM_ACT_STAGE_DEVICE_CONFIG,
NM_ACT_STAGE_NEED_USER_KEY,
NM_ACT_STAGE_IP_CONFIG_START,
NM_ACT_STAGE_IP_CONFIG_GET,
NM_ACT_STAGE_IP_CONFIG_COMMIT,
NM_ACT_STAGE_ACTIVATED,
NM_ACT_STAGE_FAILED,
NM_ACT_STAGE_CANCELLED
} NMActStage;
#endif
......@@ -835,6 +835,7 @@ void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_data)
dbus_uint32_t driver_support_level = 0;
char ** networks = NULL;
int num_networks = 0;
NMActStage act_stage = NM_ACT_STAGE_UNKNOWN;
g_return_if_fail (pcall != NULL);
g_return_if_fail (applet != NULL);
......@@ -858,6 +859,7 @@ void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_data)
DBUS_TYPE_UINT32, &type,
DBUS_TYPE_STRING, &udi,
DBUS_TYPE_BOOLEAN,&active,
DBUS_TYPE_UINT32, &act_stage,
DBUS_TYPE_UINT32, &ip4_address,
DBUS_TYPE_STRING, &hw_addr,
DBUS_TYPE_UINT32, &mode,
......@@ -876,6 +878,7 @@ void nmwa_dbus_device_properties_cb (DBusPendingCall *pcall, void *user_data)
network_device_set_active (dev, active);
network_device_set_link (dev, link_active);
network_device_set_driver_support_level (dev, driver_support_level);
network_device_set_act_stage (dev, act_stage);
/* If the device already exists in our list for some reason, remove it so we
* can add the new one with updated data.
......@@ -1054,14 +1057,14 @@ void nmwa_dbus_set_device (DBusConnection *connection, NetworkDevice *dev, const
g_return_if_fail (connection != NULL);
g_return_if_fail (dev != NULL);
if ((network_device_get_type (dev) == DEVICE_TYPE_WIRED_ETHERNET) && !passphrase && (key_type != -1))
if (network_device_is_wired (dev) && !passphrase && (key_type != -1))
return;
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "setActiveDevice")))
{
const char *dev_path = network_device_get_nm_path (dev);
if ((network_device_get_type (dev) == DEVICE_TYPE_WIRELESS_ETHERNET) && essid)
if (network_device_is_wireless (dev) && essid)
{
nm_info ("Forcing device '%s' and network '%s' %s passphrase\n", dev_path, essid, passphrase ? "with" : "without");
......@@ -1100,7 +1103,7 @@ void nmwa_dbus_create_network (DBusConnection *connection, NetworkDevice *dev, c
g_return_if_fail (connection != NULL);
g_return_if_fail (dev != NULL);
g_return_if_fail (essid != NULL);
g_return_if_fail (network_device_get_type (dev) == DEVICE_TYPE_WIRELESS_ETHERNET);
g_return_if_fail (network_device_is_wireless (dev));
if ((message = dbus_message_new_method_call (NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, "createWirelessNetwork")))
{
......@@ -1312,13 +1315,13 @@ sort_devices_function (gconstpointer a, gconstpointer b)
{
return strcmp (name_a, name_b);
}
if (network_device_get_type (dev_a) == DEVICE_TYPE_WIRED_ETHERNET)
if (network_device_is_wired (dev_a))
return -1;
if (network_device_get_type (dev_b) == DEVICE_TYPE_WIRED_ETHERNET)
if (network_device_is_wired (dev_b))
return 1;
if (network_device_get_type (dev_a) == DEVICE_TYPE_WIRELESS_ETHERNET)
if (network_device_is_wireless (dev_a))
return -1;
if (network_device_get_type (dev_b) == DEVICE_TYPE_WIRELESS_ETHERNET)
if (network_device_is_wireless (dev_b))
return 1;
/* Unknown device types. Sort by name only at this point. */
......
......@@ -404,13 +404,23 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
{
NMWirelessApplet *applet = (NMWirelessApplet *)user_data;
gboolean handled = TRUE;
DBusError error;
const char * object_path;
const char * member;
const char * interface;
g_return_val_if_fail (applet != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
g_return_val_if_fail (connection != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
g_return_val_if_fail (message != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
dbus_error_init (&error);
if (!(object_path = dbus_message_get_path (message)))
return FALSE;
if (!(member = dbus_message_get_member (message)))
return FALSE;
if (!(interface = dbus_message_get_interface (message)))
return FALSE;
/* nm_info ("signal(): got signal op='%s' member='%s' interface='%s'", object_path, member, interface); */
if (dbus_message_is_signal (message, DBUS_INTERFACE_DBUS, "NameOwnerChanged"))
{
......@@ -418,7 +428,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
char *old_owner;
char *new_owner;
if (dbus_message_get_args (message, &error,
if (dbus_message_get_args (message, NULL,
DBUS_TYPE_STRING, &service,
DBUS_TYPE_STRING, &old_owner,
DBUS_TYPE_STRING, &new_owner,
......@@ -460,7 +470,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
*/
if ( (state == NM_STATE_CONNECTING)
&& act_dev
&& (network_device_get_type (act_dev) == DEVICE_TYPE_WIRELESS_ETHERNET))
&& network_device_is_wireless (act_dev))
{
nmwa_dbus_device_update_one_device (applet, network_device_get_nm_path (act_dev));
}
......@@ -552,18 +562,10 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
{
char *dev = NULL;
char *net = NULL;
DBusError error;
dbus_error_init (&error);
if (!dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &dev, DBUS_TYPE_STRING, &net, DBUS_TYPE_INVALID))
{
if (dbus_error_is_set (&error))
dbus_error_free (&error);
dbus_error_init (&error);
dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &dev, DBUS_TYPE_INVALID);
}
if (dbus_error_is_set (&error))
dbus_error_free (&error);
if (!dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &dev, DBUS_TYPE_STRING, &net, DBUS_TYPE_INVALID))
dbus_message_get_args (message, NULL, DBUS_TYPE_STRING, &dev, DBUS_TYPE_INVALID);
if (dev && net)
{
char *string = g_strdup_printf (_("Connection to the wireless network '%s' failed.\n"), net);
......@@ -573,12 +575,25 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa
else if (dev)
nmwa_schedule_warning_dialog (applet, _("Connection to the wired network failed.\n"));
}
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceActivationStage"))
{
char * dev_path = NULL;
NMActStage stage;
if (dbus_message_get_args (message, NULL, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_UINT32, &stage, DBUS_TYPE_INVALID))
{
NetworkDevice *dev;
if ((dev = nmwa_get_device_for_nm_device (applet->dbus_device_list, dev_path)))
network_device_set_act_stage (dev, stage);
if ((dev = nmwa_get_device_for_nm_device (applet->gui_device_list, dev_path)))
network_device_set_act_stage (dev, stage);
}
}
else
handled = FALSE;
if (dbus_error_is_set (&error))
dbus_error_free (&error);
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
}
......
......@@ -622,6 +622,17 @@ static void nmwa_set_icon (NMWirelessApplet *applet, GdkPixbuf *new_icon)
}
static void nmwa_set_progress (NMWirelessApplet *applet, GdkPixbuf *progress_icon)
{
g_return_if_fail (applet != NULL);
gtk_image_set_from_pixbuf (GTK_IMAGE (applet->progress_bar), progress_icon);
if (!progress_icon)
gtk_widget_hide (applet->progress_bar);
else
gtk_widget_show (applet->progress_bar);
}
/*
* animation_timeout
*
......@@ -642,7 +653,7 @@ static gboolean animation_timeout (NMWirelessApplet *applet)
switch (applet->gui_nm_state)
{
case NM_STATE_CONNECTING:
if (act_dev && (network_device_get_type (act_dev) == DEVICE_TYPE_WIRELESS_ETHERNET))
if (act_dev && network_device_is_wireless (act_dev))
{
if (applet->animation_step >= NUM_WIRELESS_CONNECTING_FRAMES)
applet->animation_step = 0;
......@@ -665,6 +676,82 @@ static gboolean animation_timeout (NMWirelessApplet *applet)
}
static GdkPixbuf * nmwa_act_stage_to_pixbuf (NMWirelessApplet *applet, NetworkDevice *dev, WirelessNetwork *net, char **tip)
{
const char *essid;
const char *iface;
g_return_val_if_fail (applet != NULL, NULL);
g_return_val_if_fail (dev != NULL, NULL);
g_return_val_if_fail (tip != NULL, NULL);
iface = network_device_get_iface (dev);
essid = net ? wireless_network_get_essid (net) : NULL;
switch (network_device_get_act_stage (dev))
{
case NM_ACT_STAGE_DEVICE_PREPARE:
{
if (network_device_is_wired (dev))
*tip = g_strdup_printf (_("Preparing device %s for the wired network..."), iface);
else if (network_device_is_wireless (dev))
*tip = g_strdup_printf (_("Preparing device %s for the wireless network '%s'..."), iface, essid);
return applet->progress_icons[1];
}
case NM_ACT_STAGE_DEVICE_CONFIG:
{
if (network_device_is_wired (dev))
*tip = g_strdup_printf (_("Configuring device %s for the wired network..."), iface);
else if (network_device_is_wireless (dev))
*tip = g_strdup_printf (_("Configuring device %s for the wireless network '%s'..."), iface, essid);
return applet->progress_icons[3];
}
case NM_ACT_STAGE_NEED_USER_KEY:
{
if (network_device_is_wireless (dev))
*tip = g_strdup_printf (_("Waiting for Network Key for the wireless network '%s'..."), essid);
return applet->progress_icons[4];
}
case NM_ACT_STAGE_IP_CONFIG_START:
{
if (network_device_is_wired (dev))
*tip = g_strdup_printf (_("Requesting a network address from the wired network..."));
else if (network_device_is_wireless (dev))
*tip = g_strdup_printf (_("Requesting a network address from the wireless network '%s'..."), essid);
return applet->progress_icons[5];
}
case NM_ACT_STAGE_IP_CONFIG_GET:
{
if (network_device_is_wired (dev))
*tip = g_strdup_printf (_("Requesting a network address from the wired network..."));
else if (network_device_is_wireless (dev))
*tip = g_strdup_printf (_("Requesting a network address from the wireless network '%s'..."), essid);
return applet->progress_icons[8];
}
case NM_ACT_STAGE_IP_CONFIG_COMMIT:
{
if (network_device_is_wired (dev))
*tip = g_strdup_printf (_("Finishing connection to the wired network..."));
else if (network_device_is_wireless (dev))
*tip = g_strdup_printf (_("Finishing connection to the wireless network '%s'..."), essid);
return applet->progress_icons[10];
}
default:
case NM_ACT_STAGE_ACTIVATED:
case NM_ACT_STAGE_FAILED:
case NM_ACT_STAGE_CANCELLED:
case NM_ACT_STAGE_UNKNOWN:
break;
}
return NULL;
}
/*
* nmwa_update_state
*
......@@ -678,6 +765,7 @@ static void nmwa_update_state (NMWirelessApplet *applet)
gboolean need_animation = FALSE;
gboolean active_vpn = FALSE;
GdkPixbuf * pixbuf = NULL;
GdkPixbuf * progress = NULL;
gint strength = -1;
char * tip = NULL;
WirelessNetwork * active_network = NULL;
......@@ -686,7 +774,7 @@ static void nmwa_update_state (NMWirelessApplet *applet)
g_mutex_lock (applet->data_mutex);
act_dev = nmwa_get_first_active_device (applet->gui_device_list);
if (act_dev && (network_device_get_type (act_dev) == DEVICE_TYPE_WIRELESS_ETHERNET))
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);
......@@ -710,12 +798,12 @@ static void nmwa_update_state (NMWirelessApplet *applet)
break;
case NM_STATE_CONNECTED:
if (network_device_get_type (act_dev) == DEVICE_TYPE_WIRED_ETHERNET)
if (network_device_is_wired (act_dev))
{
pixbuf = applet->wired_icon;
tip = g_strdup (_("Wired network connection"));
}
else if (network_device_get_type (act_dev) == DEVICE_TYPE_WIRELESS_ETHERNET)
else if (network_device_is_wireless (act_dev))
{
if (applet->is_adhoc)
{
......@@ -741,11 +829,7 @@ static void nmwa_update_state (NMWirelessApplet *applet)
break;
case NM_STATE_CONNECTING:
if (network_device_get_type (act_dev) == DEVICE_TYPE_WIRED_ETHERNET)
tip = g_strdup (_("Connecting to a wired network..."));
else if (network_device_get_type (act_dev) == DEVICE_TYPE_WIRELESS_ETHERNET)
tip = g_strdup_printf (_("Connecting to wireless network '%s'..."),
active_network ? wireless_network_get_essid (active_network) : "(unknown)");
progress = nmwa_act_stage_to_pixbuf (applet, act_dev, active_network, &tip);
need_animation = TRUE;
break;
......@@ -761,6 +845,8 @@ done:
gtk_tooltips_set_tip (applet->tooltips, applet->event_box, tip, NULL);
g_free (tip);
nmwa_set_progress (applet, progress);
if (applet->animation_id)
g_source_remove (applet->animation_id);
if (need_animation)
......@@ -1198,7 +1284,7 @@ static void nmwa_menu_device_add_networks (GtkWidget *menu, NetworkDevice *dev,
g_return_if_fail (applet != NULL);
g_return_if_fail (dev != NULL);
if (network_device_get_type (dev) != DEVICE_TYPE_WIRELESS_ETHERNET)
if (!network_device_is_wireless (dev))
return;
/* Check for any security */
......@@ -1674,11 +1760,17 @@ static void nmwa_setup_widgets (NMWirelessApplet *applet)
applet->dropdown_menu = nmwa_dropdown_menu_create (GTK_MENU_ITEM (applet->top_menu_item), applet);
applet->pixmap = gtk_image_new ();
applet->progress_bar = gtk_image_new ();
applet->icon_box = gtk_hbox_new (FALSE, 3);
gtk_container_set_border_width (GTK_CONTAINER (applet->icon_box), 0);
/* Set up the widget structure and show the applet */
gtk_container_add (GTK_CONTAINER(applet->top_menu_item), applet->pixmap);
gtk_menu_shell_append (GTK_MENU_SHELL(menu_bar), applet->top_menu_item);
gtk_container_add (GTK_CONTAINER(applet->event_box), menu_bar);
gtk_container_add (GTK_CONTAINER (applet->icon_box), applet->progress_bar);
gtk_container_add (GTK_CONTAINER (applet->icon_box), applet->pixmap);
gtk_container_add (GTK_CONTAINER (applet->top_menu_item), applet->icon_box);
gtk_menu_shell_append (GTK_MENU_SHELL (menu_bar), applet->top_menu_item);
gtk_container_add (GTK_CONTAINER (applet->event_box), menu_bar);
gtk_container_add (GTK_CONTAINER (applet), applet->event_box);
gtk_widget_show_all (GTK_WIDGET (applet));
......@@ -1932,7 +2024,7 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme)
{
char * name;
int i;
gboolean success = TRUE;
gboolean success = FALSE;
/* Assume icons are square */
gint icon_size = 22;
......@@ -1951,7 +2043,16 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme)
if (!applet->no_connection_icon || !applet->wired_icon || !applet->adhoc_icon || !applet->vpn_lock_icon
|| !applet->wireless_00_icon || !applet->wireless_25_icon || !applet->wireless_50_icon || !applet->wireless_75_icon
|| !applet->wireless_100_icon)
success = FALSE;
goto out;
for (i = 0; i < NUM_PROGRESS_FRAMES; i++)
{
name = g_strdup_printf ("nm-progress%02d", i+1);
applet->progress_icons[i] = gtk_icon_theme_load_icon (icon_theme, name, icon_size, 0, NULL);
g_free (name);
if (!applet->progress_icons[i])
goto out;
}
for (i = 0; i < NUM_WIRED_CONNECTING_FRAMES; i++)
{
......@@ -1959,7 +2060,7 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme)
applet->wired_connecting_icons[i] = gtk_icon_theme_load_icon (icon_theme, name, icon_size, 0, NULL);
g_free (name);
if (!applet->wired_connecting_icons[i])
success = FALSE;
goto out;
}
for (i = 0; i < NUM_WIRELESS_CONNECTING_FRAMES; i++)
......@@ -1968,9 +2069,12 @@ nmwa_icons_load_from_disk (NMWirelessApplet *applet, GtkIconTheme *icon_theme)
applet->wireless_connecting_icons[i] = gtk_icon_theme_load_icon (icon_theme, name, icon_size, 0, NULL);
g_free (name);
if (!applet->wireless_connecting_icons[i])
success = FALSE;
goto out;
}
success = TRUE;
out:
if (!success)
{
show_warning_dialog (_("The NetworkManager applet could not find some required resources. It cannot continue.\n"));
......
......@@ -101,6 +101,8 @@ typedef struct
GdkPixbuf * no_connection_icon;
GdkPixbuf * wired_icon;
GdkPixbuf * adhoc_icon;
#define NUM_PROGRESS_FRAMES 11
GdkPixbuf * progress_icons[NUM_PROGRESS_FRAMES];
#define NUM_WIRED_CONNECTING_FRAMES 11
GdkPixbuf * wired_connecting_icons[NUM_WIRED_CONNECTING_FRAMES];
GdkPixbuf * wireless_00_icon;
......@@ -117,7 +119,9 @@ typedef struct
guint animation_id;
/* Direct UI elements */
GtkWidget * icon_box;
GtkWidget * pixmap;
GtkWidget * progress_bar;
GtkWidget * top_menu_item;
GtkWidget * dropdown_menu;
GtkWidget * vpn_menu;
......
......@@ -21,6 +21,18 @@ smallicon_DATA= \
nm-connecting09.png \
nm-connecting10.png \
nm-connecting11.png \
nm-progress11.png \
nm-progress01.png \
nm-progress02.png \
nm-progress03.png \
nm-progress04.png \
nm-progress05.png \
nm-progress06.png \
nm-progress07.png \
nm-progress08.png \
nm-progress09.png \
nm-progress10.png \
nm-progress11.png \
nm-signal-00.png \
nm-signal-25.png \
nm-signal-50.png \
......
......@@ -83,7 +83,7 @@ void wired_menu_item_update (NMWiredMenuItem *item, NetworkDevice *dev, const gi
g_return_if_fail (dev != NULL);
g_return_if_fail (item != NULL);
g_assert (network_device_get_type (dev) == DEVICE_TYPE_WIRED_ETHERNET);
g_assert (network_device_is_wired (dev));
dev_name = network_device_get_desc (dev) ? network_device_get_desc (dev) : network_device_get_iface (dev);
......@@ -157,7 +157,7 @@ void wireless_menu_item_update (NMWirelessMenuItem *item, NetworkDevice *dev, co
g_return_if_fail (dev != NULL);
g_return_if_fail (item != NULL);
g_assert (network_device_get_type (dev) == DEVICE_TYPE_WIRELESS_ETHERNET);
g_assert (network_device_is_wireless (dev));
n_essids = network_device_get_num_wireless_networks (dev);
dev_name = network_device_get_desc (dev) ? network_device_get_desc (dev) : network_device_get_iface (dev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment