[empathy] make the presence chooser insensitive no accounts are enabled
- From: Sjoerd Simons <sjoerds src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [empathy] make the presence chooser insensitive no accounts are enabled
- Date: Wed, 14 Oct 2009 16:55:11 +0000 (UTC)
commit 0eb14eeb66bbec5985a12c0be24bf45d00ed311c
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date: Tue Oct 13 20:25:04 2009 -0400
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
libempathy-gtk/empathy-presence-chooser.c | 61 +++++++++++++++++++++++++++-
1 files changed, 58 insertions(+), 3 deletions(-)
---
diff --git a/libempathy-gtk/empathy-presence-chooser.c b/libempathy-gtk/empathy-presence-chooser.c
index 373b851..ab48775 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]