From 473f8dca644b3f9f48529daeed44de2097ee311d Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 25 Aug 2009 00:09:45 -0400 Subject: Bug 511769 - Poor indication of when network is unavailable --- widgets/misc/e-online-button.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'widgets/misc') diff --git a/widgets/misc/e-online-button.c b/widgets/misc/e-online-button.c index c14114b9c3..444296dcef 100644 --- a/widgets/misc/e-online-button.c +++ b/widgets/misc/e-online-button.c @@ -24,10 +24,13 @@ ((obj), E_TYPE_ONLINE_BUTTON, EOnlineButtonPrivate)) #define ONLINE_TOOLTIP \ - "Evolution is currently online. Click this button to work offline." + _("Evolution is currently online. Click this button to work offline.") #define OFFLINE_TOOLTIP \ - "Evolution is currently offline. Click this button to work online." + _("Evolution is currently offline. Click this button to work online.") + +#define NETWORK_UNAVAILABLE_TOOLTIP \ + _("Evolution is currently offline because the network is unavailable.") struct _EOnlineButtonPrivate { GtkWidget *image; @@ -41,6 +44,21 @@ enum { static gpointer parent_class; +static void +online_button_update_tooltip (EOnlineButton *button) +{ + const gchar *tooltip; + + if (e_online_button_get_online (button)) + tooltip = ONLINE_TOOLTIP; + else if (GTK_WIDGET_SENSITIVE (button)) + tooltip = OFFLINE_TOOLTIP; + else + tooltip = NETWORK_UNAVAILABLE_TOOLTIP; + + gtk_widget_set_tooltip_text (GTK_WIDGET (button), tooltip); +} + static void online_button_set_property (GObject *object, guint property_id, @@ -130,6 +148,14 @@ online_button_init (EOnlineButton *button) gtk_container_add (GTK_CONTAINER (button), widget); button->priv->image = g_object_ref (widget); gtk_widget_show (widget); + + g_signal_connect ( + button, "notify::online", + G_CALLBACK (online_button_update_tooltip), NULL); + + g_signal_connect ( + button, "notify::sensitive", + G_CALLBACK (online_button_update_tooltip), NULL); } GType @@ -181,7 +207,6 @@ e_online_button_set_online (EOnlineButton *button, GtkIconTheme *icon_theme; const gchar *filename; const gchar *icon_name; - const gchar *tooltip; g_return_if_fail (E_IS_ONLINE_BUTTON (button)); @@ -198,8 +223,5 @@ e_online_button_set_online (EOnlineButton *button, gtk_image_set_from_file (image, filename); gtk_icon_info_free (icon_info); - tooltip = _(online ? ONLINE_TOOLTIP : OFFLINE_TOOLTIP); - gtk_widget_set_tooltip_text (GTK_WIDGET (button), tooltip); - g_object_notify (G_OBJECT (button), "online"); } -- cgit v1.2.3