diff --git a/ChangeLog b/ChangeLog index ca3b1d5f91..f62fa73e87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-01-11 Robert Love + + * gnome/applet/applet-dbus-devices.c, gnome/applet/applet-dbus.c, + gnome/applet/applet.c, gnome/applet/applet.h: Consolidating + assignments to applet->nm_state into a new nmwa_set_state() function + for both cleanliness and to help debugging. + 2006-01-10 Robert Love * src/autoip.c: Fix FIXME. In performing the link-local zeroconf IP diff --git a/gnome/applet/applet-dbus-devices.c b/gnome/applet/applet-dbus-devices.c index c485da2971..19b7c78d59 100644 --- a/gnome/applet/applet-dbus-devices.c +++ b/gnome/applet/applet-dbus-devices.c @@ -66,10 +66,8 @@ static void nmwa_dbus_nm_state_cb (DBusPendingCall *pcall, void *user_data) goto out; } - if (dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &nm_state, DBUS_TYPE_INVALID)) { - applet->nm_state = nm_state; - nmwa_enable_networking_set_active (applet); - } + if (dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &nm_state, DBUS_TYPE_INVALID)) + nmwa_set_state (applet, nm_state); dbus_message_unref (reply); diff --git a/gnome/applet/applet-dbus.c b/gnome/applet/applet-dbus.c index 182e77b47e..b9c5d946d3 100644 --- a/gnome/applet/applet-dbus.c +++ b/gnome/applet/applet-dbus.c @@ -119,7 +119,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa { /* NetworkManager started up */ applet->nm_running = TRUE; - applet->nm_state = NM_STATE_DISCONNECTED; + nmwa_set_state (applet, NM_STATE_DISCONNECTED); nmwa_dbus_update_nm_state (applet); nmwa_dbus_update_devices (applet); nmwa_dbus_update_dialup (applet); @@ -128,7 +128,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa else if (old_owner_good && !new_owner_good) { applet->nm_running = FALSE; - applet->nm_state = NM_STATE_DISCONNECTED; + nmwa_set_state (applet, NM_STATE_DISCONNECTED); nmi_passphrase_dialog_destroy (applet); } } @@ -145,13 +145,11 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa /* If we've switched to connecting, update the active device to ensure that we have * valid wireless network information for it. */ - if ( (state == NM_STATE_CONNECTING) - && act_dev - && network_device_is_wireless (act_dev)) + if (state == NM_STATE_CONNECTING && act_dev && network_device_is_wireless (act_dev)) { nmwa_dbus_device_update_one_device (applet, network_device_get_nm_path (act_dev)); } - applet->nm_state = state; + nmwa_set_state (applet, state); } } else if ( dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceAdded") @@ -415,7 +413,7 @@ static gboolean nmwa_dbus_connection_watcher (gpointer user_data) if ((applet->connection = nmwa_dbus_init (applet))) { applet->nm_running = nmwa_dbus_nm_is_running (applet->connection); - applet->nm_state = NM_STATE_DISCONNECTED; + nmwa_set_state (applet, NM_STATE_DISCONNECTED); nmwa_dbus_update_nm_state (applet); nmwa_dbus_update_devices (applet); nmwa_dbus_update_dialup (applet); diff --git a/gnome/applet/applet.c b/gnome/applet/applet.c index 421b929d5f..ef44d4dcb1 100644 --- a/gnome/applet/applet.c +++ b/gnome/applet/applet.c @@ -1098,7 +1098,7 @@ static void nmwa_update_state (NMWirelessApplet *applet) #if 0 if (!act_dev) - applet->nm_state = NM_STATE_DISCONNECTED; + nmwa_set_state (applet, NM_STATE_DISCONNECTED); #endif switch (applet->nm_state) @@ -1828,7 +1828,7 @@ static void nmwa_menu_add_devices (GtkWidget *menu, NMWirelessApplet *applet) g_return_if_fail (menu != NULL); g_return_if_fail (applet != NULL); - if (! applet->device_list) + if (!applet->device_list) { nmwa_menu_add_text_item (menu, _("No network devices have been found")); return; @@ -2140,12 +2140,27 @@ void nmwa_enable_wireless_set_active (NMWirelessApplet *applet) * message might not have been sent yet or in case the daemon state changes * out from under us. */ -void nmwa_enable_networking_set_active (NMWirelessApplet *applet) +static inline void nmwa_enable_networking_set_active (NMWirelessApplet *applet) { gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->enable_networking_item), applet->nm_state != NM_STATE_ASLEEP); } +/* + * nmwa_set_state + * + * Set the applet's state to one of the NMState enumerations. + * + */ +void nmwa_set_state (NMWirelessApplet *applet, enum NMState state) +{ + g_return_if_fail (applet != NULL); + g_return_if_fail (state >= NM_STATE_UNKNOWN && state <= NM_STATE_DISCONNECTED); + applet->nm_state = state; + nmwa_enable_networking_set_active (applet); +} + + /* * nmwa_context_menu_create * diff --git a/gnome/applet/applet.h b/gnome/applet/applet.h index d70fc56e4f..2dc456ce86 100644 --- a/gnome/applet/applet.h +++ b/gnome/applet/applet.h @@ -149,7 +149,7 @@ VPNConnection * nmwa_get_first_active_vpn_connection (NMWirelessApplet *applet); void nmwa_enable_wireless_set_active (NMWirelessApplet *applet); -void nmwa_enable_networking_set_active (NMWirelessApplet *applet); +void nmwa_set_state (NMWirelessApplet *applet, NMState state); int nm_null_safe_strcmp (const char *s1, const char *s2);