* 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
PROP_PROTOCOL = 1,
PROP_SETTINGS,
PROP_SIMPLE,
- PROP_CREATING_ACCOUNT
+ PROP_CREATING_ACCOUNT,
+ PROP_OTHER_ACCOUNTS_EXIST,
};
enum {
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);
}
}
TpAccount *account = TP_ACCOUNT (source_object);
EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
- TpConnectionPresenceType presence;
- gchar *message = NULL;
- gchar *status = NULL;
tp_account_set_enabled_finish (account, res, &error);
}
else
{
- /* only force presence if presence was offline, unknown or unset */
- presence = tp_account_get_requested_presence (account, NULL, NULL);
- switch (presence)
- {
- case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
- case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
- case TP_CONNECTION_PRESENCE_TYPE_UNSET:
- presence = tp_account_manager_get_most_available_presence (
- priv->account_manager, &status, &message);
-
- if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
- /* Global presence is offline; we force it so user doesn't have to
- * manually change the presence to connect his new account. */
- presence = TP_CONNECTION_PRESENCE_TYPE_AVAILABLE;
-
- tp_account_request_presence_async (account, presence,
- status, NULL, NULL, NULL);
- break;
- default:
- /* do nothing if the presence is not offline */
- break;
- }
+ empathy_connect_new_account (account, priv->account_manager);
}
/* unref widget - part of the workaround */
g_object_unref (widget);
- g_free (message);
- g_free (status);
}
static void
EmpathyAccountWidget *self)
{
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ gboolean display_name_overridden;
if (priv->radiobutton_reuse != NULL)
{
empathy_account_settings_set_boolean (priv->settings, "register", !reuse);
}
+ g_object_get (priv->settings,
+ "display-name-overridden", &display_name_overridden, NULL);
+
+ if (priv->creating_account || !display_name_overridden)
+ {
+ gchar *display_name;
+
+ /* set default display name for new accounts or update if user didn't
+ * manually override it. */
+ display_name = empathy_account_widget_get_default_display_name (self);
+
+ empathy_account_settings_set_display_name_async (priv->settings,
+ display_name, NULL, NULL);
+
+ g_free (display_name);
+ }
+
/* workaround to keep widget alive during async call */
g_object_ref (self);
empathy_account_settings_apply_async (priv->settings,
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,
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);
}
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);
}
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
TpAccount *account;
const gchar *protocol, *cm_name;
+ const gchar *display_name, *default_display_name;
guint i = 0;
struct {
const gchar *cm_name;
empathy_builder_unref_and_keep_widget (self->ui_details->gui,
self->ui_details->widget);
self->ui_details->gui = NULL;
+
+ display_name = empathy_account_settings_get_display_name (priv->settings);
+ default_display_name = empathy_account_widget_get_default_display_name (self);
+
+ if (tp_strdiff (display_name, default_display_name))
+ {
+ /* The display name of the account is not the one that we'd assign by
+ * default; assume that the user changed it manually */
+ g_object_set (priv->settings, "display-name-overridden", TRUE, NULL);
+ }
}
static void
priv->dispose_run = TRUE;
- empathy_account_settings_is_ready (priv->settings);
-
if (priv->settings != NULL)
{
TpAccount *account;
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,
signals[ACCOUNT_CREATED] =
g_signal_new ("account-created", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
+ g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE,
1, G_TYPE_OBJECT);