*/
#include "config.h"
+#include "empathy-accounts-dialog.h"
#include <glib/gi18n-lib.h>
-
-#include "libempathy/empathy-utils.h"
-#include "libempathy/empathy-pkg-kit.h"
-
-#include "libempathy-gtk/empathy-ui-utils.h"
-#include "libempathy-gtk/empathy-account-widget-sip.h"
-#include "libempathy-gtk/empathy-user-info.h"
-#include "libempathy-gtk/empathy-local-xmpp-assistant-widget.h"
-#include "libempathy-gtk/empathy-new-account-dialog.h"
+#include <tp-account-widgets/tpaw-account-widget.h>
+#include <tp-account-widgets/tpaw-builder.h>
+#include <tp-account-widgets/tpaw-user-info.h>
+#include <tp-account-widgets/tpaw-pixbuf-utils.h>
+#include <tp-account-widgets/tpaw-utils.h>
#include "empathy-accounts-common.h"
-#include "empathy-accounts-dialog.h"
#include "empathy-import-dialog.h"
#include "empathy-import-utils.h"
+#include "empathy-local-xmpp-assistant-widget.h"
+#include "empathy-new-account-dialog.h"
+#include "empathy-pkg-kit.h"
+#include "empathy-ui-utils.h"
+#include "empathy-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
-#include "libempathy/empathy-debug.h"
+#include "empathy-debug.h"
/* Flashing delay for icons (milliseconds). */
#define FLASH_TIMEOUT 500
/* The primary text of the dialog shown to the user when he is about to lose
* unsaved changes */
#define PENDING_CHANGES_QUESTION_PRIMARY_TEXT \
- _("There are unsaved modifications to your %s account.")
+ _("There are unsaved modifications to your %.50s account.")
/* The primary text of the dialog shown to the user when he is about to lose
* an unsaved new account */
#define UNSAVED_NEW_ACCOUNT_QUESTION_PRIMARY_TEXT \
GtkWidget *spinner;
gboolean loading;
- /* We have to keep a weak reference on the actual EmpathyAccountWidget, not
+ /* We have to keep a weak reference on the actual TpawAccountWidget, not
* just its GtkWidget. It is the only reliable source we can query to know if
* there are any unsaved changes to the currently selected account. We can't
* look at the account settings because it does not contain everything that
- * can be changed using the EmpathyAccountWidget. For instance, it does not
+ * can be changed using the TpawAccountWidget. For instance, it does not
* contain the state of the "Enabled" checkbox.
*
* Even if we create it ourself, we just get a weak ref and not a strong one
- * as EmpathyAccountWidget unrefs itself when the GtkWidget is destroyed.
+ * as TpawAccountWidget unrefs itself when the GtkWidget is destroyed.
* That's kinda ugly; cf bgo #640417.
*
* */
- EmpathyAccountWidget *setting_widget;
+ TpawAccountWidget *setting_widget;
gboolean connecting_show;
guint connecting_id;
gulong settings_ready_id;
- EmpathyAccountSettings *settings_ready;
+ TpawAccountSettings *settings_ready;
TpAccountManager *account_manager;
- EmpathyConnectionManagers *cms;
+ TpawConnectionManagers *cms;
GNetworkMonitor *connectivity;
GtkWindow *parent_window;
PROP_PARENT = 1
};
-static EmpathyAccountSettings * accounts_dialog_model_get_selected_settings (
+static TpawAccountSettings * accounts_dialog_model_get_selected_settings (
EmpathyAccountsDialog *dialog);
static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog);
static void accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
- EmpathyAccountSettings *settings);
+ TpawAccountSettings *settings);
static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
TpAccount *account);
static gboolean accounts_dialog_has_pending_change (
EmpathyAccountsDialog *dialog, TpAccount **account);
-static void
-accounts_dialog_update_name_label (EmpathyAccountsDialog *dialog,
- const gchar *display_name)
-{
- gchar *text;
- EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
-
- text = g_markup_printf_escaped ("<b>%s</b>", display_name);
- gtk_label_set_markup (GTK_LABEL (priv->label_name), text);
-
- g_free (text);
-}
-
static void
accounts_dialog_status_infobar_set_message (EmpathyAccountsDialog *dialog,
const gchar *message)
{
am = tp_account_manager_dup ();
- empathy_connect_new_account (account, am);
+ tpaw_connect_new_account (account, am);
g_object_unref (am);
}
}
GParamSpec *spec,
EmpathyAccountsDialog *dialog)
{
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
TpAccount *account;
gboolean enable;
if (settings == NULL)
return;
- account = empathy_account_settings_get_account (settings);
+ account = tpaw_account_settings_get_account (settings);
if (account == NULL)
return;
return FALSE;
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
+ if (selection == NULL)
+ return FALSE;
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
return FALSE;
if (account != NULL)
{
+ gchar *text;
+
status = tp_account_get_connection_status (account, &reason);
presence = tp_account_get_current_presence (account, NULL, &status_message);
account_enabled = tp_account_is_enabled (account);
presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
display_switch = account_can_be_enabled (account);
+
+ text = g_markup_printf_escaped ("<b>%.50s</b>",
+ tp_account_get_display_name (account));
+ gtk_label_set_markup (GTK_LABEL (priv->label_name), text);
+ g_free (text);
}
else
{
GtkTreeModel *model;
GtkTreeSelection *selection;
GtkTreeIter iter;
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
TpAccount *account;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
COL_ACCOUNT_SETTINGS, &settings,
COL_ACCOUNT, &account, -1);
- empathy_account_widget_discard_pending_changes (priv->setting_widget);
+ tpaw_account_widget_discard_pending_changes (priv->setting_widget);
if (account == NULL)
{
static void
empathy_account_dialog_widget_cancelled_cb (
- EmpathyAccountWidget *widget_object,
+ TpawAccountWidget *widget_object,
EmpathyAccountsDialog *dialog)
{
empathy_account_dialog_cancel (dialog);
account_dialog_create_edit_params_dialog (EmpathyAccountsDialog *dialog)
{
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
GtkWidget *subdialog, *content_area, *align;
settings = accounts_dialog_model_get_selected_settings (dialog);
gtk_window_set_resizable (GTK_WINDOW (subdialog), FALSE);
- priv->setting_widget = (EmpathyAccountWidget *)
- empathy_account_widget_new_for_protocol (settings, FALSE);
+ priv->setting_widget = (TpawAccountWidget *)
+ tpaw_account_widget_new_for_protocol (settings, NULL, FALSE);
g_object_add_weak_pointer (G_OBJECT (priv->setting_widget),
(gpointer *) &priv->setting_widget);
if (accounts_dialog_has_valid_accounts (dialog))
- empathy_account_widget_set_other_accounts_exist (
+ tpaw_account_widget_set_other_accounts_exist (
priv->setting_widget, TRUE);
g_signal_connect (priv->setting_widget, "cancelled",
}
else if (!tp_strdiff (provider, EMPATHY_UOA_PROVIDER))
{
- empathy_launch_external_app ("gnome-credentials-panel.desktop",
+ empathy_launch_external_app ("unity-credentials-panel.desktop",
NULL, NULL);
return;
}
account_dialow_show_edit_params_dialog (EmpathyAccountsDialog *dialog,
GtkButton *button)
{
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
TpAccount *account;
TpStorageRestrictionFlags storage_restrictions;
if (settings == NULL)
return;
- account = empathy_account_settings_get_account (settings);
+ account = tpaw_account_settings_get_account (settings);
g_return_if_fail (account != NULL);
storage_restrictions = tp_account_get_storage_restrictions (account);
static void
account_dialog_create_dialog_content (EmpathyAccountsDialog *dialog,
- EmpathyAccountSettings *settings)
+ TpawAccountSettings *settings)
{
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
const gchar *icon_name;
GtkWidget *bbox, *button;
GtkWidget *alig;
- account = empathy_account_settings_get_account (settings);
+ account = tpaw_account_settings_get_account (settings);
priv->dialog_content = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (priv->alignment_settings),
gtk_widget_show (priv->dialog_content);
alig = gtk_alignment_new (0.5, 0, 1, 1);
- priv->user_info = empathy_user_info_new (account);
+ priv->user_info = tpaw_user_info_new (account);
gtk_container_add (GTK_CONTAINER (alig), priv->user_info);
gtk_box_pack_start (GTK_BOX (priv->dialog_content), alig, TRUE, TRUE, 0);
gtk_widget_show (alig);
gtk_box_pack_end (GTK_BOX (priv->dialog_content), bbox, FALSE, TRUE, 0);
gtk_widget_show (bbox);
- button = gtk_button_new_with_mnemonic (_("_Edit Connection Parameters..."));
+ button = gtk_button_new_with_mnemonic (_("_Edit Connection Parameters…"));
gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, TRUE, 0);
gtk_widget_show (button);
g_signal_connect_swapped (button, "clicked",
G_CALLBACK (account_dialow_show_edit_params_dialog), dialog);
- icon_name = empathy_account_settings_get_icon_name (settings);
+ icon_name = tpaw_account_settings_get_icon_name (settings);
if (!gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
icon_name))
gtk_image_set_from_icon_name (GTK_IMAGE (priv->image_type),
icon_name, GTK_ICON_SIZE_DIALOG);
gtk_widget_set_tooltip_text (priv->image_type,
- empathy_protocol_name_to_display_name
- (empathy_account_settings_get_protocol (settings)));
+ tpaw_protocol_name_to_display_name
+ (tpaw_account_settings_get_protocol (settings)));
gtk_widget_show (priv->image_type);
- accounts_dialog_update_name_label (dialog,
- empathy_account_settings_get_display_name (settings));
-
accounts_dialog_update_status_infobar (dialog, account);
}
static void
-account_dialog_settings_ready_cb (EmpathyAccountSettings *settings,
+account_dialog_settings_ready_cb (TpawAccountSettings *settings,
GParamSpec *spec,
EmpathyAccountsDialog *dialog)
{
- if (empathy_account_settings_is_ready (settings))
+ if (tpaw_account_settings_is_ready (settings))
account_dialog_create_dialog_content (dialog, settings);
}
gtk_tree_model_get (model, &iter, COL_ACCOUNT, account, -1);
return priv->setting_widget != NULL
- && empathy_account_widget_contains_pending_changes (
+ && tpaw_account_widget_contains_pending_changes (
priv->setting_widget);
}
if (response == GTK_RESPONSE_APPLY)
{
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
TpAccount *account;
settings = empathy_new_account_dialog_get_settings (
/* The newly created account has already been added by
* accounts_dialog_account_validity_changed_cb so we just
* have to select it. */
- account = empathy_account_settings_get_account (settings);
+ account = tpaw_account_settings_get_account (settings);
accounts_dialog_model_set_selected (self, account);
}
static void
accounts_dialog_update_settings (EmpathyAccountsDialog *dialog,
- EmpathyAccountSettings *settings)
+ TpawAccountSettings *settings)
{
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
if (priv->user_info != NULL)
{
- empathy_user_info_apply_async ((EmpathyUserInfo *) priv->user_info,
+ tpaw_user_info_apply_async ((TpawUserInfo *) priv->user_info,
NULL, NULL);
priv->user_info = NULL;
}
priv->dialog_content = NULL;
}
- if (empathy_account_settings_is_ready (settings))
+ if (tpaw_account_settings_is_ready (settings))
{
account_dialog_create_dialog_content (dialog, settings);
}
pixbuf = g_hash_table_lookup (priv->icons_cache, icon_name);
if (pixbuf == NULL)
{
- pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
+ pixbuf = tpaw_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
if (pixbuf == NULL)
return NULL;
GtkTreeIter *iter,
EmpathyAccountsDialog *dialog)
{
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
gchar *icon_name;
GdkPixbuf *pixbuf;
TpConnectionStatus status;
COL_ACCOUNT_SETTINGS, &settings,
-1);
- icon_name = empathy_account_settings_get_icon_name (settings);
+ icon_name = tpaw_account_settings_get_icon_name (settings);
pixbuf = ensure_icon (dialog, icon_name);
g_object_set (cell,
gchar *new_text,
EmpathyAccountsDialog *dialog)
{
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
GtkTreeModel *model;
GtkTreePath *treepath;
GtkTreeIter iter;
-1);
gtk_tree_path_free (treepath);
- empathy_account_settings_set_display_name_async (settings, new_text,
+ tpaw_account_settings_set_display_name_async (settings, new_text,
NULL, NULL);
g_object_set (settings, "display-name-overridden", TRUE, NULL);
g_object_unref (settings);
}
question_dialog_primary_text = g_strdup_printf (
- _("Do you want to remove %s from your computer?"),
+ _("Do you want to remove %.50s from your computer?"),
tp_account_get_display_name (account));
accounts_dialog_show_question_dialog (dialog, question_dialog_primary_text,
g_object_set (priv->name_renderer, "ypad", 4, NULL);
}
-static EmpathyAccountSettings *
+static TpawAccountSettings *
accounts_dialog_model_get_selected_settings (EmpathyAccountsDialog *dialog)
{
GtkTreeView *view;
GtkTreeModel *model;
GtkTreeSelection *selection;
GtkTreeIter iter;
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
view = GTK_TREE_VIEW (priv->treeview);
EmpathyAccountsDialog *dialog)
{
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
GtkTreeModel *model;
GtkTreeIter iter;
gboolean is_selection;
GtkTreeSelection *selection;
priv->force_change_row = TRUE;
- empathy_account_widget_discard_pending_changes (
+ tpaw_account_widget_discard_pending_changes (
priv->setting_widget);
path = gtk_tree_row_reference_get_path (priv->destination_row);
G_TYPE_STRING, /* name */
G_TYPE_UINT, /* status */
TP_TYPE_ACCOUNT, /* account */
- EMPATHY_TYPE_ACCOUNT_SETTINGS); /* settings */
+ TPAW_TYPE_ACCOUNT_SETTINGS); /* settings */
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->treeview),
GTK_TREE_MODEL (store));
static void
reload_account_widget (EmpathyAccountsDialog *self)
{
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
settings = accounts_dialog_model_get_selected_settings (self);
accounts_dialog_update_settings (self, settings);
static void
accounts_dialog_account_display_name_changed_cb (TpAccount *account,
GParamSpec *pspec,
- gpointer user_data)
+ EmpathyAccountsDialog *dialog)
{
- const gchar *display_name;
- GtkTreeIter iter;
- GtkTreeModel *model;
- EmpathyAccountSettings *settings;
- TpAccount *selected_account;
- EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (user_data);
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- display_name = tp_account_get_display_name (account);
model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview));
- settings = accounts_dialog_model_get_selected_settings (dialog);
- if (settings == NULL)
- return;
-
- selected_account = empathy_account_settings_get_account (settings);
-
if (accounts_dialog_get_account_iter (dialog, account, &iter))
{
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_NAME, display_name,
+ COL_NAME, tp_account_get_display_name (account),
-1);
}
- if (selected_account == account)
- accounts_dialog_update_name_label (dialog, display_name);
-
- g_object_unref (settings);
+ accounts_dialog_update_status_infobar (dialog, account);
}
static void
accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
TpAccount *account)
{
- EmpathyAccountSettings *settings;
+ TpawAccountSettings *settings;
GtkTreeModel *model;
GtkTreeIter iter;
TpConnectionStatus status;
status = tp_account_get_connection_status (account, NULL);
name = tp_account_get_display_name (account);
- settings = empathy_account_settings_new_for_account (account);
+ settings = tpaw_account_settings_new_for_account (account);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
if (priv->setting_widget != NULL &&
accounts_dialog_has_valid_accounts (dialog))
{
- empathy_account_widget_set_other_accounts_exist (
+ tpaw_account_widget_set_other_accounts_exist (
priv->setting_widget, TRUE);
}
}
if (priv->setting_widget != NULL &&
!accounts_dialog_has_valid_accounts (dialog))
{
- empathy_account_widget_set_other_accounts_exist (
+ tpaw_account_widget_set_other_accounts_exist (
priv->setting_widget, FALSE);
}
}
GAsyncResult *result,
gpointer user_data)
{
- EmpathyConnectionManagers *cms = EMPATHY_CONNECTION_MANAGERS (source);
+ TpawConnectionManagers *cms = TPAW_CONNECTION_MANAGERS (source);
EmpathyAccountsDialog *dialog = user_data;
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- if (!empathy_connection_managers_prepare_finish (cms, result, NULL))
+ if (!tpaw_connection_managers_prepare_finish (cms, result, NULL))
goto out;
/* No need to update the settings if we are already preparing one */
}
g_list_free_full (accounts, g_object_unref);
- priv->cms = empathy_connection_managers_dup_singleton ();
+ priv->cms = tpaw_connection_managers_dup_singleton ();
- empathy_connection_managers_prepare_async (priv->cms,
+ tpaw_connection_managers_prepare_async (priv->cms,
accounts_dialog_cms_prepare_cb, dialog);
accounts_dialog_model_select_first (dialog);
filename = empathy_file_lookup ("empathy-accounts-dialog.ui", "src");
- gui = empathy_builder_get_file (filename,
+ gui = tpaw_builder_get_file (filename,
"accounts_dialog_hbox", &top_hbox,
"vbox_details", &priv->vbox_details,
"alignment_settings", &priv->alignment_settings,
NULL);
g_free (filename);
- empathy_builder_connect (gui, dialog,
+ tpaw_builder_connect (gui, dialog,
"button_add", "clicked", accounts_dialog_button_add_clicked_cb,
"button_remove", "clicked", accounts_dialog_button_remove_clicked_cb,
"button_import", "clicked", accounts_dialog_button_import_clicked_cb,
/* first row */
priv->label_name = gtk_label_new (NULL);
+ gtk_label_set_ellipsize (GTK_LABEL (priv->label_name), PANGO_ELLIPSIZE_END);
gtk_grid_attach (GTK_GRID (grid), priv->label_name, 1, 0, 1, 1);
/* second row */
if (priv->user_info != NULL)
{
- empathy_user_info_apply_async ((EmpathyUserInfo *) priv->user_info,
+ tpaw_user_info_apply_async ((TpawUserInfo *) priv->user_info,
NULL, NULL);
priv->user_info = NULL;
}
if (selected_account)
{
- if (priv->cms != NULL && empathy_connection_managers_is_ready (priv->cms))
+ if (priv->cms != NULL && tpaw_connection_managers_is_ready (priv->cms))
accounts_dialog_set_selected_account (dialog, selected_account);
else
/* save the selection to set it later when the cms
args = g_strdup_printf ("account-details=%u", g_value_get_uint (value));
}
- empathy_launch_external_app ("gnome-credentials-panel.desktop", args, NULL);
+ empathy_launch_external_app ("unity-credentials-panel.desktop", args, NULL);
g_free (args);
out: