#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-#ifdef HAVE_MOBLIN
-#include <nbtk/nbtk-gtk.h>
-#endif
+#ifdef HAVE_MEEGO
+#include <mx/mx-gtk.h>
+#endif /* HAVE_MEEGO */
#include <libempathy/empathy-utils.h>
* 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);
- 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
gboolean enabled_checked;
enabled_checked =
-#ifdef HAVE_MOBLIN
- nbtk_gtk_light_switch_get_active (
- NBTK_GTK_LIGHT_SWITCH (priv->enabled_checkbox));
+#ifdef HAVE_MEEGO
+ mx_gtk_light_switch_get_active (
+ MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox));
#else
gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (priv->enabled_checkbox));
-#endif
+#endif /* HAVE_MEEGO */
if (tp_account_is_enabled (account) && enabled_checked)
{
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,
self->ui_details->default_focus = g_strdup ("entry_id_g_simple");
}
- /* TODO: Simple widget for Facebook */
+ else if (priv->simple && is_facebook)
+ {
+ /* Simple widget for Facebook */
+ self->ui_details->gui = empathy_builder_get_file (filename,
+ "vbox_fb_simple", &self->ui_details->widget,
+ "entry_id_fb_simple", &entry_id,
+ NULL);
+
+ empathy_account_widget_handle_params (self,
+ "entry_password_fb_simple", "password",
+ NULL);
+
+ setup_facebook_id_widget (self, entry_id);
+
+ self->ui_details->default_focus = g_strdup ("entry_id_fb_simple");
+ }
else
{
/* Full widget for XMPP, Google Talk and Facebook*/
"label_username_f_example", &label_example_fb,
"expander_advanced", &expander_advanced,
"entry_id", &entry_id,
+ "label_id", &label_id,
NULL);
empathy_account_widget_handle_params (self,
if (is_facebook)
{
+ gtk_label_set_label (GTK_LABEL (label_id), _("Username:"));
+
/* Facebook special case the entry ID widget to hide the
* "@chat.facebook.com" part */
setup_facebook_id_widget (self, entry_id);
if (priv->enabled_checkbox != NULL)
{
-#ifdef HAVE_MOBLIN
- nbtk_gtk_light_switch_set_active (
- NBTK_GTK_LIGHT_SWITCH (priv->enabled_checkbox),
+#ifdef HAVE_MEEGO
+ mx_gtk_light_switch_set_active (
+ MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox),
enabled);
#else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
enabled);
-#endif /* HAVE_MOBLIN */
+#endif /* HAVE_MEEGO */
}
}
static void
-#ifdef HAVE_MOBLIN
-account_widget_switch_flipped_cb (NbtkGtkLightSwitch *sw,
+#ifdef HAVE_MEEGO
+account_widget_switch_flipped_cb (MxGtkLightSwitch *sw,
gboolean state,
gpointer user_data)
#else
account_widget_enabled_released_cb (GtkToggleButton *toggle_button,
gpointer user_data)
-#endif /* HAVE_MOBLIN */
+#endif /* HAVE_MEEGO */
{
EmpathyAccountWidgetPriv *priv = GET_PRIV (user_data);
TpAccount *account;
-#ifndef HAVE_MOBLIN
+#ifndef HAVE_MEEGO
gboolean state;
state = gtk_toggle_button_get_active (toggle_button);
-#endif
+#endif /* HAVE_MEEGO */
account = empathy_account_settings_get_account (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);
}
/* This button doesn't exist in 'simple' mode */
return;
- if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
+ if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE &&
+ priv->creating_account)
{
- /* We are online, display a Login button */
+ /* We are online and creating a new account, display a Login button */
GtkWidget *image;
gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
}
else
{
- /* We are offline, display a Save button */
+ /* We are offline or modifying an existing account, display
+ * a Save button */
gtk_button_set_image (GTK_BUTTON (priv->apply_button), NULL);
gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), TRUE);
- gtk_button_set_label (GTK_BUTTON (priv->apply_button), GTK_STOCK_SAVE);
+ gtk_button_set_label (GTK_BUTTON (priv->apply_button), GTK_STOCK_APPLY);
}
}
TpAccount *account)
{
EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
-#ifdef HAVE_MOBLIN
+#ifdef HAVE_MEEGO
GtkWidget *w;
#else
GtkWidget *vbox = self->ui_details->widget;
-#endif
+#endif /* HAVE_MEEGO */
guint nb_rows, nb_columns;
gboolean is_enabled;
is_enabled = tp_account_is_enabled (account);
-#ifdef HAVE_MOBLIN
+#ifdef HAVE_MEEGO
w = gtk_label_new (_("Account:"));
gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
- priv->enabled_checkbox = nbtk_gtk_light_switch_new ();
+ priv->enabled_checkbox = mx_gtk_light_switch_new ();
- nbtk_gtk_light_switch_set_active (
- NBTK_GTK_LIGHT_SWITCH (priv->enabled_checkbox), is_enabled);
+ mx_gtk_light_switch_set_active (
+ MX_GTK_LIGHT_SWITCH (priv->enabled_checkbox), is_enabled);
gtk_widget_show (w);
#else
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
is_enabled);
-#endif /* HAVE_MOBLIN */
+#endif /* HAVE_MEEGO */
g_object_get (priv->table_common_settings, "n-rows", &nb_rows,
"n-columns", &nb_columns, NULL);
gtk_table_resize (GTK_TABLE (priv->table_common_settings), ++nb_rows,
nb_columns);
-#ifdef HAVE_MOBLIN
+#ifdef HAVE_MEEGO
gtk_table_attach (GTK_TABLE (priv->table_common_settings),
w,
0, 1, nb_rows - 1, nb_rows,
#else
gtk_box_pack_start (GTK_BOX (vbox), priv->enabled_checkbox, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (vbox), priv->enabled_checkbox, 0);
-#endif /* HAVE_MOBLIN */
+#endif /* HAVE_MEEGO */
gtk_widget_show (priv->enabled_checkbox);
-#ifdef HAVE_MOBLIN
+#ifdef HAVE_MEEGO
g_signal_connect (G_OBJECT (priv->enabled_checkbox), "switch-flipped",
G_CALLBACK (account_widget_switch_flipped_cb), self);
#else
g_signal_connect (G_OBJECT (priv->enabled_checkbox), "released",
G_CALLBACK (account_widget_enabled_released_cb), self);
-#endif /* HAVE_MOBLIN */
+#endif /* HAVE_MEEGO */
}
-#ifndef HAVE_MOBLIN
-/* Moblin doesn't support registration */
+#ifndef HAVE_MEEGO
+/* Meego doesn't support registration */
static void
add_register_buttons (EmpathyAccountWidget *self,
TpAccount *account)
gtk_widget_show (priv->radiobutton_reuse);
gtk_widget_show (radiobutton_register);
}
-#endif
+#endif /* HAVE_MEEGO */
static void
do_constructed (GObject *obj)
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;
priv->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- if (priv->creating_account)
- {
- /* Assumre we are offline, display a Save button. We'll update
- * it once the account manager is ready if needed */
- priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
+ priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
- empathy_signal_connect_weak (priv->account_manager,
- "most-available-presence-changed",
- G_CALLBACK (presence_changed_cb), obj);
- }
- else
- {
- /* We are editing an existing account, display an Apply button */
- priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
- }
+ /* We'll change this button to a "Log in" one if we are creating a new
+ * account and are connected. */
+ empathy_signal_connect_weak (priv->account_manager,
+ "most-available-presence-changed",
+ G_CALLBACK (presence_changed_cb), obj);
gtk_box_pack_end (GTK_BOX (hbox), priv->apply_button, TRUE,
TRUE, 3);
G_CALLBACK (empathy_account_widget_enabled_cb), self);
}
-#ifndef HAVE_MOBLIN
+#ifndef HAVE_MEEGO
add_register_buttons (self, account);
-#endif
+#endif /* HAVE_MEEGO */
add_enable_checkbox (self, account);
/* hook up to widget destruction to unref ourselves */
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);