aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorTravis Reitter <treitter@gmail.com>2010-03-03 02:57:36 +0800
committerTravis Reitter <treitter@gmail.com>2010-03-03 02:57:36 +0800
commit36ea10ea3a0bdbd6300bea47cedeab4cc08751a2 (patch)
treefcaabae67f2adf8716b172e599e54c07c1b9d7b2 /libempathy-gtk
parent56974492dc44aaa3b993e30b7338b58ab723afd3 (diff)
parent52d67df161e27a893bc24a13a50d86bf251f5ad9 (diff)
downloadgsoc2013-empathy-36ea10ea3a0bdbd6300bea47cedeab4cc08751a2.tar
gsoc2013-empathy-36ea10ea3a0bdbd6300bea47cedeab4cc08751a2.tar.gz
gsoc2013-empathy-36ea10ea3a0bdbd6300bea47cedeab4cc08751a2.tar.bz2
gsoc2013-empathy-36ea10ea3a0bdbd6300bea47cedeab4cc08751a2.tar.lz
gsoc2013-empathy-36ea10ea3a0bdbd6300bea47cedeab4cc08751a2.tar.xz
gsoc2013-empathy-36ea10ea3a0bdbd6300bea47cedeab4cc08751a2.tar.zst
gsoc2013-empathy-36ea10ea3a0bdbd6300bea47cedeab4cc08751a2.zip
Merge branch 'more-accounts-fixes'
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-account-widget.c44
-rw-r--r--libempathy-gtk/empathy-account-widget.h3
2 files changed, 44 insertions, 3 deletions
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 8ce6b5f52..8862c3ba4 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -73,6 +73,11 @@ typedef struct {
* modify it. When we are creating an account, this member is set to TRUE */
gboolean creating_account;
+ /* whether there are any other real accounts. Necessary so we know whether
+ * it's safe to dismiss this widget in some cases (eg, whether the Cancel
+ * button should be sensitive) */
+ gboolean other_accounts_exist;
+
/* if TRUE, the GTK+ destroy signal has been fired and so the widgets
* embedded in this account widget can't be used any more
* workaround because some async callbacks can be called after the
@@ -91,7 +96,8 @@ enum {
PROP_PROTOCOL = 1,
PROP_SETTINGS,
PROP_SIMPLE,
- PROP_CREATING_ACCOUNT
+ PROP_CREATING_ACCOUNT,
+ PROP_OTHER_ACCOUNTS_EXIST,
};
enum {
@@ -114,9 +120,14 @@ account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self,
if (!priv->simple)
{
+ /* we hit this case because of the 'other-accounts-exist' property handler
+ * being called during init (before constructed()) */
+ if (priv->apply_button == NULL || priv->cancel_button == NULL)
+ return;
+
gtk_widget_set_sensitive (priv->apply_button, sensitive);
- gtk_widget_set_sensitive (
- priv->cancel_button, sensitive || priv->creating_account);
+ gtk_widget_set_sensitive (priv->cancel_button,
+ (sensitive || priv->creating_account) && priv->other_accounts_exist);
}
}
@@ -1348,6 +1359,18 @@ account_widget_enabled_released_cb (GtkToggleButton *toggle_button,
account_widget_account_enabled_cb, user_data);
}
+void
+empathy_account_widget_set_other_accounts_exist (EmpathyAccountWidget *self,
+ gboolean others_exist)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+
+ priv->other_accounts_exist = others_exist;
+
+ if (priv->creating_account)
+ account_widget_handle_control_buttons_sensitivity (self);
+}
+
static void
do_set_property (GObject *object,
guint prop_id,
@@ -1367,6 +1390,10 @@ do_set_property (GObject *object,
case PROP_CREATING_ACCOUNT:
priv->creating_account = g_value_get_boolean (value);
break;
+ case PROP_OTHER_ACCOUNTS_EXIST:
+ empathy_account_widget_set_other_accounts_exist (
+ EMPATHY_ACCOUNT_WIDGET (object), g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -1395,6 +1422,9 @@ do_get_property (GObject *object,
case PROP_CREATING_ACCOUNT:
g_value_set_boolean (value, priv->creating_account);
break;
+ case PROP_OTHER_ACCOUNTS_EXIST:
+ g_value_set_boolean (value, priv->other_accounts_exist);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -1826,6 +1856,14 @@ empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (oclass, PROP_CREATING_ACCOUNT, param_spec);
+ param_spec = g_param_spec_boolean ("other-accounts-exist",
+ "other-accounts-exist",
+ "TRUE if there are any other accounts (even if this isn't yet saved)",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (oclass, PROP_OTHER_ACCOUNTS_EXIST,
+ param_spec);
+
signals[HANDLE_APPLY] =
g_signal_new ("handle-apply", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h
index 9ed989434..ecc52e6c6 100644
--- a/libempathy-gtk/empathy-account-widget.h
+++ b/libempathy-gtk/empathy-account-widget.h
@@ -79,6 +79,9 @@ void empathy_account_widget_set_account_param (EmpathyAccountWidget *widget,
void empathy_account_widget_set_password_param (EmpathyAccountWidget *self,
const gchar *password);
+void empathy_account_widget_set_other_accounts_exist (
+ EmpathyAccountWidget *self, gboolean others_exist);
+
/* protected methods */
void empathy_account_widget_changed (EmpathyAccountWidget *widget);