diff --git a/ChangeLog b/ChangeLog index 44e7728360..10c3c5405e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-10-24 Dan Williams + + Cleanup some applet stuff: + + - Animation timeouts. If NM died while the applet was animating, + the applet would not hide itself. This is now fixed. + + - Remove some dead code + + - Remove nmi_passphrase_dialog_schedule_cancel() and convert uses + to nmi_passphrase_dialog_cancel() since we no longer use threads. + + - Track animation timeout using a gboolean rather than the timeout's + ID, since timeout IDs can legally be 0. + 2005-10-24 Dan Williams * src/backends/interface_parser.c diff --git a/gnome/applet/applet-dbus-info.c b/gnome/applet/applet-dbus-info.c index fb190b99b9..b9d4bcb18f 100644 --- a/gnome/applet/applet-dbus-info.c +++ b/gnome/applet/applet-dbus-info.c @@ -1126,29 +1126,7 @@ DBusHandlerResult nmi_dbus_info_message_handler (DBusConnection *connection, DBu if (strcmp ("getKeyForNetwork", method) == 0) reply = nmi_dbus_get_key_for_network (applet, message); else if (strcmp ("cancelGetKeyForNetwork", method) == 0) - nmi_passphrase_dialog_schedule_cancel (applet); -#if 0 /* Not used at this time */ - else if (strcmp ("networkNotFound", method) == 0) - { - const char * network; - DBusError error; - - dbus_error_init (&error); - if (dbus_message_get_args (message, &error, DBUS_TYPE_STRING, &network, DBUS_TYPE_INVALID)) - { - GtkWidget *dialog; - char *text; - - dbus_error_free (&error); - text = g_strdup_printf (_("The requested wireless network '%s' does not appear to be in range. " - "A different wireless network will be used if any are available."), network); - - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, text, NULL); - gtk_window_present (GTK_WINDOW (dialog)); - g_signal_connect_swapped (dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); - } - } -#endif + nmi_passphrase_dialog_cancel (applet); else if (strcmp ("getNetworks", method) == 0) reply = nmi_dbus_get_networks (applet, message); else if (strcmp ("getNetworkProperties", method) == 0) diff --git a/gnome/applet/applet-dbus.c b/gnome/applet/applet-dbus.c index 88f16ad39f..6448e465a3 100644 --- a/gnome/applet/applet-dbus.c +++ b/gnome/applet/applet-dbus.c @@ -171,7 +171,7 @@ static DBusHandlerResult nmwa_dbus_filter (DBusConnection *connection, DBusMessa { applet->nm_running = FALSE; applet->nm_state = NM_STATE_DISCONNECTED; - nmi_passphrase_dialog_schedule_cancel (applet); + nmi_passphrase_dialog_cancel (applet); } } } diff --git a/gnome/applet/applet.c b/gnome/applet/applet.c index 83f7be1691..3eeb73d65f 100644 --- a/gnome/applet/applet.c +++ b/gnome/applet/applet.c @@ -75,6 +75,8 @@ static void nmwa_icons_free (NMWirelessApplet *applet); static void nmwa_about_cb (NMWirelessApplet *applet); static void nmwa_context_menu_update (NMWirelessApplet *applet); static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet); +static void nmwa_update_state (NMWirelessApplet *applet); + G_DEFINE_TYPE(NMWirelessApplet, nmwa, EGG_TYPE_TRAY_ICON) @@ -124,7 +126,7 @@ NetworkDevice * nmwa_get_first_active_device (GSList *dev_list) static void nmwa_init (NMWirelessApplet *applet) { - applet->animation_id = 0; + applet->animation_active = FALSE; applet->animation_step = 0; glade_gnome_init (); @@ -825,6 +827,7 @@ static VPNConnection *nmwa_get_first_activating_vpn_connection (NMWirelessApplet return NULL; } + static void nmwa_set_icon (NMWirelessApplet *applet, GdkPixbuf *link_icon, GdkPixbuf *vpn_icon) { GdkPixbuf *composite; @@ -981,8 +984,6 @@ static GdkPixbuf * nmwa_act_stage_to_pixbuf (NMWirelessApplet *applet, NetworkDe return pixbuf; } -static void nmwa_update_state (NMWirelessApplet *applet); - /* * animation_timeout * @@ -1000,14 +1001,16 @@ static gboolean animation_timeout (NMWirelessApplet *applet) if (!applet->nm_running) { applet->animation_step = 0; - return TRUE; + applet->animation_active = FALSE; + return FALSE; } act_dev = nmwa_get_first_active_device (applet->device_list); if (!act_dev) { applet->animation_step = 0; - return TRUE; + applet->animation_active = FALSE; + return FALSE; } if (applet->nm_state == NM_STATE_CONNECTING) @@ -1036,7 +1039,7 @@ static gboolean animation_timeout (NMWirelessApplet *applet) else { applet->animation_step = 0; - applet->animation_id = 0; + applet->animation_active = FALSE; nmwa_update_state (applet); return FALSE; } @@ -1148,15 +1151,19 @@ done: g_free (tip); applet->animation_step = 0; - if (applet->animation_id) + if (need_animation && !applet->animation_active) { - g_source_remove (applet->animation_id); - applet->animation_id = 0; - } - if (need_animation) applet->animation_id = g_timeout_add (100, (GSourceFunc) animation_timeout, applet); - else + applet->animation_active = TRUE; + } + else if (!need_animation) { + if (applet->animation_active) + { + g_source_remove (applet->animation_id); + applet->animation_active = FALSE; + } + if (pixbuf) nmwa_set_icon (applet, pixbuf, applet->vpn_lock_icon); else @@ -1179,15 +1186,10 @@ done: */ static int nmwa_redraw_timeout (NMWirelessApplet *applet) { - if (!applet->animation_id) + if (!applet->animation_active) nmwa_update_state (applet); - return (TRUE); -} - -static void nmwa_start_redraw_timeout (NMWirelessApplet *applet) -{ - applet->redraw_timeout_id = g_timeout_add (1000, (GtkFunction) nmwa_redraw_timeout, applet); + return TRUE; } @@ -2359,7 +2361,7 @@ static GtkWidget * nmwa_get_instance (NMWirelessApplet *applet) g_signal_connect (applet, "style-set", G_CALLBACK (nmwa_theme_change_cb), NULL); /* Start redraw timeout */ - nmwa_start_redraw_timeout (applet); + applet->redraw_timeout_id = g_timeout_add (1000, (GtkFunction) nmwa_redraw_timeout, applet); return GTK_WIDGET (applet); } diff --git a/gnome/applet/applet.h b/gnome/applet/applet.h index c397de1fd1..a52c815411 100644 --- a/gnome/applet/applet.h +++ b/gnome/applet/applet.h @@ -108,6 +108,7 @@ typedef struct /* Animation stuff */ int animation_step; + gboolean animation_active; guint animation_id; /* Direct UI elements */ diff --git a/gnome/applet/passphrase-dialog.c b/gnome/applet/passphrase-dialog.c index 8f57e4f55e..16017b5ff8 100644 --- a/gnome/applet/passphrase-dialog.c +++ b/gnome/applet/passphrase-dialog.c @@ -333,31 +333,15 @@ gboolean nmi_passphrase_dialog_schedule_show (NetworkDevice *dev, WirelessNetwor * Cancel and hide any user key dialog that might be up * */ -static gboolean nmi_passphrase_dialog_cancel (NMWirelessApplet *applet) +void nmi_passphrase_dialog_cancel (NMWirelessApplet *applet) { GtkWidget *dialog; - g_return_val_if_fail (applet != NULL, FALSE); + g_return_if_fail (applet != NULL); dialog = applet->passphrase_dialog; if (GTK_WIDGET_VISIBLE (dialog)) nmi_passphrase_dialog_clear (dialog); - - return FALSE; -} - - -/* - * nmi_passphrase_dialog_schedule_cancel - * - * Schedule the passphrase dialog cancellation - * - */ -void nmi_passphrase_dialog_schedule_cancel (NMWirelessApplet *applet) -{ - g_return_if_fail (applet != NULL); - - g_idle_add ((GSourceFunc) nmi_passphrase_dialog_cancel, applet); } diff --git a/gnome/applet/passphrase-dialog.h b/gnome/applet/passphrase-dialog.h index 048c6ef266..a20083dc50 100644 --- a/gnome/applet/passphrase-dialog.h +++ b/gnome/applet/passphrase-dialog.h @@ -32,6 +32,6 @@ void nmi_passphrase_dialog_destroy (GtkWidget *dialog); gboolean nmi_passphrase_dialog_schedule_show (NetworkDevice *dev, WirelessNetwork *net, DBusMessage *message, NMWirelessApplet *applet); -void nmi_passphrase_dialog_schedule_cancel (NMWirelessApplet *applet); +void nmi_passphrase_dialog_cancel (NMWirelessApplet *applet); #endif