aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-online-button.c
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/misc/e-online-button.c')
-rw-r--r--widgets/misc/e-online-button.c34
1 files changed, 28 insertions, 6 deletions
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;
@@ -42,6 +45,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,
const GValue *value,
@@ -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");
}