Re: Minimizing redrawing the disconnected popup



On Fri, 2009-03-06 at 15:15 -0700, Drew Moseley wrote:
> Our system seems to get a lot of disconnected state changes due to the way the hardware is powered down.  This resulted in the "Network Disconnected" popup being flashed on and off quite a bit.  I have the following patch in nm-applet to ensure that it only gets popped up one time.
> 
> Comments?

There's actually a slightly better way to do this, and something I've
been meaning to do for a while.  The current "disconnected" popup is
trigged by the overall NM state property, while I think it should
actually be triggered instead by each *device* state change.  This would
allow finer-grained control over the popup, and also allow us to
actually put somewhat useful information into the popup about what
failed.  Furthermore, it would allow us to suppress the disconnected
popup in some cases where it's clearly not wanted (ie, cases where the
user makes an explicit action like disabling networking or wireless,
which currently results in an unwanted popup).

That said, it may not fix your problem if during shutdown the repeatedly
starts activating and fails.  In that case, it might be more worth your
time to turn wireless off via D-Bus when shutting down.  The problem is
that we still want to notify the user about a failure to connect since
that failure could be long-running.  The patch you've got here will
suppress *all* failure popups if there wasn't a successful connection in
the first place.

Dan

> Drew
> 
> 
> 
> diff --git a/src/applet.c b/src/applet.c
> index 5801606..56ce49d 100644
> --- a/src/applet.c
> +++ b/src/applet.c
> @@ -1669,15 +1669,21 @@ static void
>  foo_client_state_changed_cb (NMClient *client, GParamSpec *pspec, gpointer user_data)
>  {
>  	NMApplet *applet = NM_APPLET (user_data);
> +	static gboolean previously_connected = FALSE;
>  
>  	switch (nm_client_get_state (client)) {
> +	case NM_STATE_CONNECTED:
> +		previously_connected = TRUE;
> +		break;
>  	case NM_STATE_DISCONNECTED:
> -		applet_do_notify_with_pref (applet, _("Disconnected"),
> -		                            _("The network connection has been disconnected."),
> -		                            "nm-no-connection",
> -		                            PREF_DISABLE_DISCONNECTED_NOTIFICATIONS);
>  		/* Fall through */
>  	default:
> +		if (previously_connected == TRUE)
> +			applet_do_notify_with_pref (applet, _("Disconnected"),
> +			                            _("The network connection has been disconnected."),
> +			                            "nm-no-connection",
> +			                            PREF_DISABLE_DISCONNECTED_NOTIFICATIONS);
> +		previously_connected = FALSE;
>  		break;
>  	}
> _______________________________________________
> NetworkManager-list mailing list
> NetworkManager-list gnome org
> http://mail.gnome.org/mailman/listinfo/networkmanager-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]