aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-10-14 08:25:04 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-10-15 00:54:31 +0800
commit0eb14eeb66bbec5985a12c0be24bf45d00ed311c (patch)
treec2d1b0ecba6e01d7bfe5537d23ae1db860049a71 /libempathy-gtk
parent85c083ccf5ecdb66d13a597e9306a08dbeed3237 (diff)
downloadgsoc2013-empathy-0eb14eeb66bbec5985a12c0be24bf45d00ed311c.tar
gsoc2013-empathy-0eb14eeb66bbec5985a12c0be24bf45d00ed311c.tar.gz
gsoc2013-empathy-0eb14eeb66bbec5985a12c0be24bf45d00ed311c.tar.bz2
gsoc2013-empathy-0eb14eeb66bbec5985a12c0be24bf45d00ed311c.tar.lz
gsoc2013-empathy-0eb14eeb66bbec5985a12c0be24bf45d00ed311c.tar.xz
gsoc2013-empathy-0eb14eeb66bbec5985a12c0be24bf45d00ed311c.tar.zst
gsoc2013-empathy-0eb14eeb66bbec5985a12c0be24bf45d00ed311c.zip
make the presence chooser insensitive no accounts are enabled
When there are no accounts enabled, there isn't really any point in setting a presence and it's a bit confusing to the user as their action doesn't actually have a result Fixes #598354
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-presence-chooser.c61
1 files changed, 58 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c
index 373b851d5..ab48775fa 100644
--- a/libempathy-gtk/empathy-presence-chooser.c
+++ b/libempathy-gtk/empathy-presence-chooser.c
@@ -39,6 +39,7 @@
#include <libempathy/empathy-idle.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-status-presets.h>
+#include <libempathy/empathy-account-manager.h>
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
@@ -114,6 +115,8 @@ typedef struct {
TpConnectionPresenceType flash_state_1;
TpConnectionPresenceType flash_state_2;
guint flash_timeout_id;
+
+ EmpathyAccountManager *account_manager;
} EmpathyPresenceChooserPriv;
/* States to be listed in the menu.
@@ -714,11 +717,45 @@ presence_chooser_entry_focus_out_cb (EmpathyPresenceChooser *chooser,
}
static void
+presence_chooser_update_sensitivity (EmpathyPresenceChooser *chooser)
+{
+ EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser);
+ gboolean sensitive = FALSE;
+ GList *accounts, *l;
+
+ accounts = empathy_account_manager_dup_accounts (priv->account_manager);
+
+ for (l = accounts ; l != NULL ; l = g_list_next (l)) {
+ EmpathyAccount *a = EMPATHY_ACCOUNT (l->data);
+
+ if (empathy_account_is_enabled (a))
+ sensitive = TRUE;
+
+ g_object_unref (a);
+ }
+
+ g_list_free (accounts);
+
+ if (!empathy_connectivity_is_online (priv->connectivity))
+ sensitive = FALSE;
+
+ gtk_widget_set_sensitive (GTK_WIDGET (chooser), sensitive);
+}
+
+static void
+presence_chooser_account_manager_account (EmpathyAccountManager *manager,
+ EmpathyAccount *account,
+ EmpathyPresenceChooser *chooser)
+{
+ presence_chooser_update_sensitivity (chooser);
+}
+
+static void
presence_chooser_connectivity_state_change (EmpathyConnectivity *connectivity,
gboolean new_online,
EmpathyPresenceChooser *chooser)
{
- gtk_widget_set_sensitive (GTK_WIDGET (chooser), new_online);
+ presence_chooser_update_sensitivity (chooser);
}
static void
@@ -789,6 +826,21 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
G_CALLBACK (presence_chooser_presence_changed_cb),
chooser);
+ priv->account_manager = empathy_account_manager_dup_singleton ();
+
+ g_signal_connect (priv->account_manager, "account-created",
+ G_CALLBACK (presence_chooser_account_manager_account),
+ chooser);
+ g_signal_connect (priv->account_manager, "account-deleted",
+ G_CALLBACK (presence_chooser_account_manager_account),
+ chooser);
+ g_signal_connect (priv->account_manager, "account-enabled",
+ G_CALLBACK (presence_chooser_account_manager_account),
+ chooser);
+ g_signal_connect (priv->account_manager, "account-disabled",
+ G_CALLBACK (presence_chooser_account_manager_account),
+ chooser);
+
/* FIXME: this string sucks */
gtk_widget_set_tooltip_text (GTK_WIDGET (chooser),
_("Set your presence and current status"));
@@ -798,8 +850,8 @@ empathy_presence_chooser_init (EmpathyPresenceChooser *chooser)
"state-change",
G_CALLBACK (presence_chooser_connectivity_state_change),
chooser);
- presence_chooser_connectivity_state_change (priv->connectivity,
- empathy_connectivity_is_online (priv->connectivity), chooser);
+
+ presence_chooser_update_sensitivity (chooser);
}
static void
@@ -817,6 +869,9 @@ presence_chooser_finalize (GObject *object)
g_source_remove (priv->focus_out_idle_source);
}
+ if (priv->account_manager != NULL)
+ g_object_unref (priv->account_manager);
+
g_signal_handlers_disconnect_by_func (priv->idle,
presence_chooser_presence_changed_cb,
object);