#include <libmissioncontrol/mc-profile.h>
#include <libmissioncontrol/mission-control.h>
#include <libmissioncontrol/mc-account-monitor.h>
+#include <telepathy-glib/util.h>
#include <libtelepathy/tp-constants.h>
#include <libempathy/empathy-debug.h>
#include "empathy-account-widget-generic.h"
#include "empathy-account-widget-jabber.h"
#include "empathy-account-widget-msn.h"
+#include "empathy-account-widget-salut.h"
#define DEBUG_DOMAIN "AccountDialog"
GtkWidget *treeview;
+ GtkWidget *button_add;
GtkWidget *button_remove;
GtkWidget *button_connect;
COL_COUNT
};
-static void accounts_dialog_setup (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
- McAccount *account);
-static void accounts_dialog_model_setup (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column,
- GtkCellRenderer *cell,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- EmpathyAccountsDialog *dialog);
-static McAccount *accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
- McAccount *account);
-static gboolean accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
- McAccount *account);
-static void accounts_dialog_account_added_cb (McAccountMonitor *monitor,
- gchar *unique_name,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_account_removed_cb (McAccountMonitor *monitor,
- gchar *unique_name,
- EmpathyAccountsDialog *dialog);
-static gboolean accounts_dialog_row_changed_foreach (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
- gpointer user_data);
-static gboolean accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog);
-static void accounts_dialog_status_changed_cb (MissionControl *mc,
- TelepathyConnectionStatus status,
- McPresence presence,
- TelepathyConnectionStatusReason reason,
- const gchar *unique_name,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_create_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_back_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_connect_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_button_add_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_remove_response_cb (GtkWidget *dialog,
- gint response,
- McAccount *account);
-static void accounts_dialog_button_remove_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_treeview_row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_response_cb (GtkWidget *widget,
- gint response,
- EmpathyAccountsDialog *dialog);
-static void accounts_dialog_destroy_cb (GtkWidget *widget,
- EmpathyAccountsDialog *dialog);
+static void accounts_dialog_setup (EmpathyAccountsDialog *dialog);
+static void accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
+ McAccount *account);
+static void accounts_dialog_model_setup (EmpathyAccountsDialog *dialog);
+static void accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog);
+static void accounts_dialog_model_select_first (EmpathyAccountsDialog *dialog);
+static void accounts_dialog_model_pixbuf_data_func (GtkTreeViewColumn *tree_column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ EmpathyAccountsDialog *dialog);
+static McAccount *accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog);
+static void accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
+ McAccount *account);
+static gboolean accounts_dialog_model_remove_selected (EmpathyAccountsDialog *dialog);
+static void accounts_dialog_model_selection_changed (GtkTreeSelection *selection,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
+ McAccount *account);
+static void accounts_dialog_account_added_cb (McAccountMonitor *monitor,
+ gchar *unique_name,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_account_removed_cb (McAccountMonitor *monitor,
+ gchar *unique_name,
+ EmpathyAccountsDialog *dialog);
+static gboolean accounts_dialog_row_changed_foreach (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data);
+static gboolean accounts_dialog_flash_connecting_cb (EmpathyAccountsDialog *dialog);
+static void accounts_dialog_status_changed_cb (MissionControl *mc,
+ TpConnectionStatus status,
+ McPresence presence,
+ TpConnectionStatusReason reason,
+ const gchar *unique_name,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_button_create_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_button_back_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_button_connect_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_button_add_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_remove_response_cb (GtkWidget *dialog,
+ gint response,
+ McAccount *account);
+static void accounts_dialog_button_remove_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_treeview_row_activated_cb (GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_response_cb (GtkWidget *widget,
+ gint response,
+ EmpathyAccountsDialog *dialog);
+static void accounts_dialog_destroy_cb (GtkWidget *widget,
+ EmpathyAccountsDialog *dialog);
static void
accounts_dialog_setup (EmpathyAccountsDialog *dialog)
accounts = mc_accounts_list ();
for (l = accounts; l; l = l->next) {
- McAccount *account;
- const gchar *name;
- TelepathyConnectionStatus status;
+ McAccount *account;
+ const gchar *name;
+ TpConnectionStatus status;
account = l->data;
accounts_dialog_status_changed_cb (dialog->mc,
status,
MC_PRESENCE_UNSET,
- TP_CONN_STATUS_REASON_NONE_SPECIFIED,
+ TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED,
mc_account_get_unique_name (account),
dialog);
if (!account) {
GtkTreeView *view;
GtkTreeModel *model;
+ GString *string;
+ gchar *str;
gtk_widget_show (dialog->frame_no_account);
gtk_widget_hide (dialog->vbox_details);
view = GTK_TREE_VIEW (dialog->treeview);
model = gtk_tree_view_get_model (view);
+ if (empathy_profile_chooser_n_profiles (dialog->combobox_profile) > 0) {
+ string = g_string_new (_("To add a new account, you can click on the "
+ "'Add' button and a new entry will be created "
+ "for you to start configuring."));
+ } else {
+ string = g_string_new (_("To add a new account, you first have to "
+ "install a backend for each protocol "
+ "you want to use."));
+ }
+
if (gtk_tree_model_iter_n_children (model, NULL) > 0) {
gtk_label_set_markup (GTK_LABEL (dialog->label_no_account),
_("<b>No Account Selected</b>"));
- gtk_label_set_markup (GTK_LABEL (dialog->label_no_account_blurb),
- _("To add a new account, you can click on the "
- "'Add' button and a new entry will be created "
- "for you to start configuring.\n"
- "\n"
- "If you do not want to add an account, simply "
- "click on the account you want to configure in "
- "the list on the left."));
+ g_string_append (string, _("\n\n"
+ "If you do not want to add an account, simply "
+ "click on the account you want to configure in "
+ "the list on the left."));
} else {
gtk_label_set_markup (GTK_LABEL (dialog->label_no_account),
_("<b>No Accounts Configured</b>"));
- gtk_label_set_markup (GTK_LABEL (dialog->label_no_account_blurb),
- _("To add a new account, you can click on the "
- "'Add' button and a new entry will be created "
- "for you to start configuring."));
}
+
+ str = g_string_free (string, FALSE);
+ gtk_label_set_markup (GTK_LABEL (dialog->label_no_account_blurb),
+ str);
+ g_free (str);
} else {
McProfile *profile;
const gchar *config_ui;
config_ui = mc_profile_get_configuration_ui (profile);
g_object_unref (profile);
- if (!empathy_strdiff (config_ui, "jabber")) {
+ if (!tp_strdiff (config_ui, "jabber")) {
dialog->settings_widget =
empathy_account_widget_jabber_new (account);
}
- else if (!empathy_strdiff (config_ui, "msn")) {
+ else if (!tp_strdiff (config_ui, "msn")) {
dialog ->settings_widget =
empathy_account_widget_msn_new (account);
}
+ else if (!tp_strdiff (config_ui, "local-xmpp")) {
+ dialog->settings_widget =
+ empathy_account_widget_salut_new (account);
+ }
else {
dialog->settings_widget =
empathy_account_widget_generic_new (account);
gtk_image_set_from_icon_name (GTK_IMAGE (dialog->image_type),
mc_profile_get_icon_name (profile),
GTK_ICON_SIZE_DIALOG);
- /* FIXME: Uncomment once we depend on GTK+ 2.12
gtk_widget_set_tooltip_text (dialog->image_type,
mc_profile_get_display_name (profile));
- */
text = g_strdup_printf ("<big><b>%s</b></big>", mc_account_get_display_name (account));
gtk_label_set_markup (GTK_LABEL (dialog->label_name), text);
GtkTreeIter *iter,
EmpathyAccountsDialog *dialog)
{
- McAccount *account;
- const gchar *icon_name;
- GdkPixbuf *pixbuf;
- TelepathyConnectionStatus status;
+ McAccount *account;
+ const gchar *icon_name;
+ GdkPixbuf *pixbuf;
+ TpConnectionStatus status;
gtk_tree_model_get (model, iter,
COL_STATUS, &status,
pixbuf = empathy_pixbuf_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON);
if (pixbuf) {
- if (status == TP_CONN_STATUS_DISCONNECTED ||
- (status == TP_CONN_STATUS_CONNECTING &&
+ if (status == TP_CONNECTION_STATUS_DISCONNECTED ||
+ (status == TP_CONNECTION_STATUS_CONNECTING &&
!dialog->connecting_show)) {
GdkPixbuf *modded_pixbuf;
is_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
+ gtk_widget_set_sensitive (dialog->button_add, TRUE);
gtk_widget_set_sensitive (dialog->button_remove, is_selection);
gtk_widget_set_sensitive (dialog->button_connect, is_selection);
accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
McAccount *account)
{
- TelepathyConnectionStatus status;
- const gchar *name;
- GtkTreeView *view;
- GtkTreeModel *model;
- GtkListStore *store;
- GtkTreeIter iter;
- gboolean ok;
+ TpConnectionStatus status;
+ const gchar *name;
+ GtkTreeView *view;
+ GtkTreeModel *model;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ gboolean ok;
view = GTK_TREE_VIEW (dialog->treeview);
model = gtk_tree_view_get_model (view);
}
static void
-accounts_dialog_status_changed_cb (MissionControl *mc,
- TelepathyConnectionStatus status,
- McPresence presence,
- TelepathyConnectionStatusReason reason,
- const gchar *unique_name,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_status_changed_cb (MissionControl *mc,
+ TpConnectionStatus status,
+ McPresence presence,
+ TpConnectionStatusReason reason,
+ const gchar *unique_name,
+ EmpathyAccountsDialog *dialog)
{
GtkTreeView *view;
GtkTreeSelection *selection;
break;
}
}
-
g_object_unref (account);
- /* Start to flash account if status is connecting */
- if (status == TP_CONN_STATUS_CONNECTING) {
- if (!dialog->connecting_id) {
- dialog->connecting_id = g_timeout_add (FLASH_TIMEOUT,
- (GSourceFunc) accounts_dialog_flash_connecting_cb,
- dialog);
- }
-
- return;
- }
-
- /* Stop to flash if no account is connecting */
+ /* Check if there is still accounts in CONNECTING state */
accounts = mc_accounts_list ();
for (l = accounts; l; l = l->next) {
- McAccount *this_account;
+ McAccount *this_account;
+ TpConnectionStatus status;
this_account = l->data;
- if (mission_control_get_connection_status (mc, this_account, NULL) == TP_CONN_STATUS_CONNECTING) {
+ status = mission_control_get_connection_status (mc, this_account, NULL);
+ if (status == TP_CONNECTION_STATUS_CONNECTING) {
found = TRUE;
break;
}
g_source_remove (dialog->connecting_id);
dialog->connecting_id = 0;
}
-
- gtk_widget_show (dialog->window);
+ if (found && !dialog->connecting_id) {
+ dialog->connecting_id = g_timeout_add (FLASH_TIMEOUT,
+ (GSourceFunc) accounts_dialog_flash_connecting_cb,
+ dialog);
+ }
}
static void
gtk_widget_hide (dialog->frame_no_account);
gtk_widget_hide (dialog->frame_new_account);
+ gtk_widget_set_sensitive (dialog->button_add, TRUE);
+
account = accounts_dialog_model_get_selected (dialog);
accounts_dialog_update_account (dialog, account);
}
}
static void
-accounts_dialog_button_add_clicked_cb (GtkWidget *button,
+accounts_dialog_button_add_clicked_cb (GtkWidget *button,
EmpathyAccountsDialog *dialog)
{
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+
+ view = GTK_TREE_VIEW (dialog->treeview);
+ selection = gtk_tree_view_get_selection (view);
+ gtk_tree_selection_unselect_all (selection);
+
+ gtk_widget_set_sensitive (dialog->button_add, FALSE);
gtk_widget_hide (dialog->vbox_details);
gtk_widget_hide (dialog->frame_no_account);
gtk_widget_show (dialog->frame_new_account);
g_signal_handlers_disconnect_by_func (dialog->monitor,
accounts_dialog_account_removed_cb,
dialog);
+ g_signal_handlers_disconnect_by_func (dialog->monitor,
+ accounts_dialog_update_connect_button,
+ dialog);
dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (dialog->mc),
"AccountStatusChanged",
G_CALLBACK (accounts_dialog_status_changed_cb),
"button_back", &dialog->button_back,
"image_type", &dialog->image_type,
"label_name", &dialog->label_name,
+ "button_add", &dialog->button_add,
"button_remove", &dialog->button_remove,
"button_connect", &dialog->button_connect,
"button_close", &button_close,
dialog->combobox_profile,
TRUE, TRUE, 0);
gtk_widget_show (dialog->combobox_profile);
+ if (empathy_profile_chooser_n_profiles (dialog->combobox_profile) <= 0) {
+ gtk_widget_set_sensitive (dialog->button_add, FALSE);
+ }
/* Set up signalling */
dialog->mc = empathy_mission_control_new ();
dialog->monitor = mc_account_monitor_new ();
- /* FIXME: connect account-enabled/disabled too */
g_signal_connect (dialog->monitor, "account-created",
G_CALLBACK (accounts_dialog_account_added_cb),
dialog);
g_signal_connect (dialog->monitor, "account-deleted",
G_CALLBACK (accounts_dialog_account_removed_cb),
dialog);
+ g_signal_connect_swapped (dialog->monitor, "account-enabled",
+ G_CALLBACK (accounts_dialog_update_connect_button),
+ dialog);
+ g_signal_connect_swapped (dialog->monitor, "account-disabled",
+ G_CALLBACK (accounts_dialog_update_connect_button),
+ dialog);
dbus_g_proxy_connect_signal (DBUS_G_PROXY (dialog->mc), "AccountStatusChanged",
G_CALLBACK (accounts_dialog_status_changed_cb),
dialog, NULL);