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.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/widgets/misc/e-online-button.c b/widgets/misc/e-online-button.c
index 114d76ac32..444296dcef 100644
--- a/widgets/misc/e-online-button.c
+++ b/widgets/misc/e-online-button.c
@@ -23,6 +23,15 @@
(G_TYPE_INSTANCE_GET_PRIVATE \
((obj), E_TYPE_ONLINE_BUTTON, EOnlineButtonPrivate))
+#define ONLINE_TOOLTIP \
+ _("Evolution is currently online. Click this button to work offline.")
+
+#define OFFLINE_TOOLTIP \
+ _("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;
gboolean online;
@@ -36,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,
@@ -124,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