#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-accounts-dialog.h"
#include "empathy-profile-chooser.h"
-#include "empathy-account-widget-generic.h"
-#include "empathy-account-widget-jabber.h"
+#include "empathy-account-widget.h"
+#include "empathy-account-widget-irc.h"
#define DEBUG_DOMAIN "AccountDialog"
GtkWidget *treeview;
+ GtkWidget *button_add;
GtkWidget *button_remove;
- GtkWidget *button_connect;
GtkWidget *frame_new_account;
GtkWidget *combobox_profile;
- GtkWidget *entry_name;
- GtkWidget *table_new_account;
+ GtkWidget *hbox_type;
GtkWidget *button_create;
GtkWidget *button_back;
} EmpathyAccountsDialog;
enum {
+ COL_ENABLED,
COL_NAME,
COL_STATUS,
COL_ACCOUNT_POINTER,
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_entry_name_changed_cb (GtkWidget *widget,
- 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_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_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)
{
- GtkTreeView *view;
- GtkListStore *store;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
- GList *accounts, *l;
+ GtkTreeView *view;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GList *accounts, *l;
view = GTK_TREE_VIEW (dialog->treeview);
store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
- selection = gtk_tree_view_get_selection (view);
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;
+ gboolean enabled;
account = l->data;
}
status = mission_control_get_connection_status (dialog->mc, account, NULL);
+ enabled = mc_account_is_enabled (account);
gtk_list_store_insert_with_values (store, &iter,
-1,
+ COL_ENABLED, enabled,
COL_NAME, name,
COL_STATUS, status,
COL_ACCOUNT_POINTER, account,
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);
g_list_free (accounts);
}
-static void
-accounts_dialog_update_connect_button (EmpathyAccountsDialog *dialog)
-{
- McAccount *account;
- GtkWidget *image;
- const gchar *stock_id;
- const gchar *label;
-
- account = accounts_dialog_model_get_selected (dialog);
-
- if (!account) {
- gtk_widget_set_sensitive (dialog->button_connect, FALSE);
- return;
- }
-
- if (mc_account_is_enabled (account)) {
- label = _("Disable");
- stock_id = GTK_STOCK_DISCONNECT;
- } else {
- label = _("Enable");
- stock_id = GTK_STOCK_CONNECT;
- }
-
- image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
-
- gtk_button_set_label (GTK_BUTTON (dialog->button_connect), label);
- gtk_button_set_image (GTK_BUTTON (dialog->button_connect), image);
-}
-
static void
accounts_dialog_update_account (EmpathyAccountsDialog *dialog,
McAccount *account)
if (!account) {
GtkTreeView *view;
GtkTreeModel *model;
+ GString *string;
+ gchar *str;
gtk_widget_show (dialog->frame_no_account);
gtk_widget_hide (dialog->vbox_details);
- gtk_widget_set_sensitive (dialog->button_connect, FALSE);
gtk_widget_set_sensitive (dialog->button_remove, FALSE);
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;
profile = mc_account_get_profile (account);
config_ui = mc_profile_get_configuration_ui (profile);
+ g_object_unref (profile);
- if (strcmp (config_ui, "jabber") == 0) {
+ if (!tp_strdiff (config_ui, "jabber")) {
dialog->settings_widget =
empathy_account_widget_jabber_new (account);
- } else {
+ }
+ 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 if (!tp_strdiff (config_ui, "irc")) {
+ dialog->settings_widget =
+ empathy_account_widget_irc_new (account);
+ }
+ else if (!tp_strdiff(config_ui, "icq")) {
+ dialog->settings_widget =
+ empathy_account_widget_icq_new (account);
+ }
+ else if (!tp_strdiff (config_ui, "yahoo")) {
+ dialog->settings_widget =
+ empathy_account_widget_yahoo_new (account);
+ }
+ else {
dialog->settings_widget =
- empathy_account_widget_generic_new (account,
- dialog->label_name);
+ empathy_account_widget_generic_new (account);
}
-
- gtk_widget_grab_focus (dialog->settings_widget);
}
if (dialog->settings_widget) {
if (account) {
McProfile *profile;
+ gchar *text;
profile = mc_account_get_profile (account);
gtk_image_set_from_icon_name (GTK_IMAGE (dialog->image_type),
mc_profile_get_icon_name (profile),
GTK_ICON_SIZE_DIALOG);
-
+ gtk_widget_set_tooltip_text (dialog->image_type,
+ mc_profile_get_display_name (profile));
- gtk_label_set_text (GTK_LABEL (dialog->label_type),
- mc_profile_get_display_name (profile));
- gtk_label_set_text (GTK_LABEL (dialog->label_name),
- mc_account_get_display_name (account));
+ 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);
+ g_free (text);
}
}
GtkTreeSelection *selection;
store = gtk_list_store_new (COL_COUNT,
+ G_TYPE_BOOLEAN, /* enabled */
G_TYPE_STRING, /* name */
G_TYPE_UINT, /* status */
MC_TYPE_ACCOUNT); /* account */
g_object_unref (store);
}
+static void
+accounts_dialog_name_edited_cb (GtkCellRendererText *renderer,
+ gchar *path,
+ gchar *new_text,
+ EmpathyAccountsDialog *dialog)
+{
+ McAccount *account;
+ GtkTreeModel *model;
+ GtkTreePath *treepath;
+ GtkTreeIter iter;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
+ treepath = gtk_tree_path_new_from_string (path);
+ gtk_tree_model_get_iter (model, &iter, treepath);
+ gtk_tree_model_get (model, &iter,
+ COL_ACCOUNT_POINTER, &account,
+ -1);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_NAME, new_text,
+ -1);
+ gtk_tree_path_free (treepath);
+
+ mc_account_set_display_name (account, new_text);
+ g_object_unref (account);
+}
+
+static void
+accounts_dialog_enable_toggled_cb (GtkCellRendererToggle *cell_renderer,
+ gchar *path,
+ EmpathyAccountsDialog *dialog)
+{
+ McAccount *account;
+ GtkTreeModel *model;
+ GtkTreePath *treepath;
+ GtkTreeIter iter;
+ gboolean enabled;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
+ treepath = gtk_tree_path_new_from_string (path);
+ gtk_tree_model_get_iter (model, &iter, treepath);
+ gtk_tree_model_get (model, &iter,
+ COL_ACCOUNT_POINTER, &account,
+ -1);
+ gtk_tree_path_free (treepath);
+
+ enabled = mc_account_is_enabled (account);
+ mc_account_set_enabled (account, !enabled);
+
+ empathy_debug (DEBUG_DOMAIN, "%s account %s",
+ enabled ? "Disabled" : "Enable",
+ mc_account_get_display_name(account));
+
+ g_object_unref (account);
+}
+
static void
accounts_dialog_model_add_columns (EmpathyAccountsDialog *dialog)
{
view = GTK_TREE_VIEW (dialog->treeview);
gtk_tree_view_set_headers_visible (view, TRUE);
- /* account name/status */
+ /* Enabled column */
+ cell = gtk_cell_renderer_toggle_new ();
+ gtk_tree_view_insert_column_with_attributes (view, -1,
+ _("Enabled"),
+ cell,
+ "active", COL_ENABLED,
+ NULL);
+ g_signal_connect (cell, "toggled",
+ G_CALLBACK (accounts_dialog_enable_toggled_cb),
+ dialog);
+
+ /* Account column */
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_title (column, _("Accounts"));
+ gtk_tree_view_column_set_expand (column, TRUE);
+ gtk_tree_view_append_column (view, column);
+ /* Icon renderer */
cell = gtk_cell_renderer_pixbuf_new ();
gtk_tree_view_column_pack_start (column, cell, FALSE);
gtk_tree_view_column_set_cell_data_func (column, cell,
dialog,
NULL);
+ /* Name renderer */
cell = gtk_cell_renderer_text_new ();
- g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ g_object_set (cell,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "editable", TRUE,
+ NULL);
gtk_tree_view_column_pack_start (column, cell, TRUE);
- gtk_tree_view_column_add_attribute (column,
- cell,
- "text", COL_NAME);
-
- gtk_tree_view_column_set_expand (column, TRUE);
- gtk_tree_view_append_column (view, column);
+ gtk_tree_view_column_add_attribute (column, cell, "text", COL_NAME);
+ g_signal_connect (cell, "edited",
+ G_CALLBACK (accounts_dialog_name_edited_cb),
+ dialog);
}
static void
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;
}
}
+static gboolean
+accounts_dialog_get_account_iter (EmpathyAccountsDialog *dialog,
+ McAccount *account,
+ GtkTreeIter *iter)
+{
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ gboolean ok;
+
+ /* Update the status in the model */
+ view = GTK_TREE_VIEW (dialog->treeview);
+ selection = gtk_tree_view_get_selection (view);
+ model = gtk_tree_view_get_model (view);
+
+ for (ok = gtk_tree_model_get_iter_first (model, iter);
+ ok;
+ ok = gtk_tree_model_iter_next (model, iter)) {
+ McAccount *this_account;
+ gboolean equal;
+
+ gtk_tree_model_get (model, iter,
+ COL_ACCOUNT_POINTER, &this_account,
+ -1);
+
+ equal = empathy_account_equal (this_account, account);
+ g_object_unref (this_account);
+
+ if (equal) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
static McAccount *
accounts_dialog_model_get_selected (EmpathyAccountsDialog *dialog)
{
static void
accounts_dialog_model_set_selected (EmpathyAccountsDialog *dialog,
- McAccount *account)
+ McAccount *account)
{
- GtkTreeView *view;
GtkTreeSelection *selection;
- GtkTreeModel *model;
GtkTreeIter iter;
- gboolean ok;
- view = GTK_TREE_VIEW (dialog->treeview);
- model = gtk_tree_view_get_model (view);
- selection = gtk_tree_view_get_selection (view);
-
- for (ok = gtk_tree_model_get_iter_first (model, &iter);
- ok;
- ok = gtk_tree_model_iter_next (model, &iter)) {
- McAccount *this_account;
- gboolean equal;
-
- gtk_tree_model_get (model, &iter,
- COL_ACCOUNT_POINTER, &this_account,
- -1);
-
- equal = empathy_account_equal (this_account, account);
- g_object_unref (this_account);
-
- if (equal) {
- gtk_tree_selection_select_iter (selection, &iter);
- break;
- }
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->treeview));
+ if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
+ gtk_tree_selection_select_iter (selection, &iter);
}
}
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_update_connect_button (dialog);
account = accounts_dialog_model_get_selected (dialog);
accounts_dialog_update_account (dialog, account);
if (account) {
g_object_unref (account);
}
+
+ /* insure new account frame is hidden when a row is selected*/
+ gtk_widget_hide (dialog->frame_new_account);
}
static void
accounts_dialog_add_account (EmpathyAccountsDialog *dialog,
- McAccount *account)
+ McAccount *account)
{
- TelepathyConnectionStatus 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);
- store = GTK_LIST_STORE (model);
-
- for (ok = gtk_tree_model_get_iter_first (model, &iter);
- ok;
- ok = gtk_tree_model_iter_next (model, &iter)) {
- McAccount *this_account;
- gboolean equal;
-
- gtk_tree_model_get (model, &iter,
- COL_ACCOUNT_POINTER, &this_account,
- -1);
-
- equal = empathy_account_equal (this_account, account);
- g_object_unref (this_account);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ TpConnectionStatus status;
+ const gchar *name;
+ gboolean enabled;
- if (equal) {
- return;
- }
+ if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
+ return;
}
status = mission_control_get_connection_status (dialog->mc, account, NULL);
name = mc_account_get_display_name (account);
+ enabled = mc_account_is_enabled (account);
g_return_if_fail (name != NULL);
empathy_debug (DEBUG_DOMAIN, "Adding new account: %s", name);
- gtk_list_store_insert_with_values (store, &iter,
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
+ gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter,
-1,
+ COL_ENABLED, enabled,
COL_NAME, name,
COL_STATUS, status,
COL_ACCOUNT_POINTER, account,
}
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;
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean ok;
- McAccount *account;
- GList *accounts, *l;
- gboolean found = FALSE;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ McAccount *account;
+ GList *accounts, *l;
+ gboolean found = FALSE;
/* Update the status in the model */
- view = GTK_TREE_VIEW (dialog->treeview);
- selection = gtk_tree_view_get_selection (view);
- model = gtk_tree_view_get_model (view);
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
account = mc_account_lookup (unique_name);
empathy_debug (DEBUG_DOMAIN, "Status changed for account %s: "
"status=%d presence=%d",
unique_name, status, presence);
- for (ok = gtk_tree_model_get_iter_first (model, &iter);
- ok;
- ok = gtk_tree_model_iter_next (model, &iter)) {
- McAccount *this_account;
- gboolean equal;
+ if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
+ GtkTreePath *path;
- gtk_tree_model_get (model, &iter,
- COL_ACCOUNT_POINTER, &this_account,
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_STATUS, status,
-1);
- equal = empathy_account_equal (this_account, account);
- g_object_unref (this_account);
-
- if (equal) {
- GtkTreePath *path;
-
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_STATUS, status,
- -1);
-
- path = gtk_tree_model_get_path (model, &iter);
- gtk_tree_model_row_changed (model, path, &iter);
- gtk_tree_path_free (path);
-
- break;
- }
+ path = gtk_tree_model_get_path (model, &iter);
+ gtk_tree_model_row_changed (model, path, &iter);
+ gtk_tree_path_free (path);
}
-
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
-accounts_dialog_entry_name_changed_cb (GtkWidget *widget,
- EmpathyAccountsDialog *dialog)
+static void
+accounts_dialog_account_enabled_cb (McAccountMonitor *monitor,
+ gchar *unique_name,
+ EmpathyAccountsDialog *dialog)
{
- const gchar *str;
-
- str = gtk_entry_get_text (GTK_ENTRY (widget));
- gtk_widget_set_sensitive (dialog->button_create, !G_STR_EMPTY (str));
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ McAccount *account;
+ gboolean enabled;
+
+ /* Update the status in the model */
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview));
+ account = mc_account_lookup (unique_name);
+ enabled = mc_account_is_enabled (account);
+
+ empathy_debug (DEBUG_DOMAIN, "Account %s is now %s",
+ mc_account_get_display_name (account),
+ enabled ? "enabled" : "disabled");
+
+ if (accounts_dialog_get_account_iter (dialog, account, &iter)) {
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_ENABLED, enabled,
+ -1);
+ }
+
+ g_object_unref (account);
}
static void
/* Create account */
account = mc_account_create (profile);
- str = gtk_entry_get_text (GTK_ENTRY (dialog->entry_name));
+ str = mc_account_get_unique_name (account);
mc_account_set_display_name (account, str);
accounts_dialog_add_account (dialog, account);
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_connect_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
+accounts_dialog_button_add_clicked_cb (GtkWidget *button,
+ EmpathyAccountsDialog *dialog)
{
- McAccount *account;
- gboolean enable;
-
- account = accounts_dialog_model_get_selected (dialog);
- enable = (!mc_account_is_enabled (account));
- mc_account_set_enabled (account, enable);
- accounts_dialog_update_connect_button (dialog);
+ GtkTreeView *view;
+ GtkTreeSelection *selection;
- g_object_unref (account);
-}
+ view = GTK_TREE_VIEW (dialog->treeview);
+ selection = gtk_tree_view_get_selection (view);
+ gtk_tree_selection_unselect_all (selection);
-static void
-accounts_dialog_button_add_clicked_cb (GtkWidget *button,
- EmpathyAccountsDialog *dialog)
-{
+ 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);
gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->combobox_profile), 0);
- gtk_entry_set_text (GTK_ENTRY (dialog->entry_name), "");
- gtk_widget_grab_focus (dialog->entry_name);
+ gtk_widget_grab_focus (dialog->combobox_profile);
}
static void
gtk_widget_show (message_dialog);
}
-static void
-accounts_dialog_treeview_row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EmpathyAccountsDialog *dialog)
-{
-
- accounts_dialog_button_connect_clicked_cb (dialog->button_connect,
- dialog);
-}
-
static void
accounts_dialog_response_cb (GtkWidget *widget,
gint response,
g_signal_handlers_disconnect_by_func (dialog->monitor,
accounts_dialog_account_removed_cb,
dialog);
+ g_signal_handlers_disconnect_by_func (dialog->monitor,
+ accounts_dialog_account_enabled_cb,
+ dialog);
dbus_g_proxy_disconnect_signal (DBUS_G_PROXY (dialog->mc),
"AccountStatusChanged",
G_CALLBACK (accounts_dialog_status_changed_cb),
"dialog-action_area", &bbox,
"treeview", &dialog->treeview,
"frame_new_account", &dialog->frame_new_account,
- "entry_name", &dialog->entry_name,
- "table_new_account", &dialog->table_new_account,
+ "hbox_type", &dialog->hbox_type,
"button_create", &dialog->button_create,
"button_back", &dialog->button_back,
"image_type", &dialog->image_type,
- "label_type", &dialog->label_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,
NULL);
"accounts_dialog", "response", accounts_dialog_response_cb,
"button_create", "clicked", accounts_dialog_button_create_clicked_cb,
"button_back", "clicked", accounts_dialog_button_back_clicked_cb,
- "entry_name", "changed", accounts_dialog_entry_name_changed_cb,
- "treeview", "row-activated", accounts_dialog_treeview_row_activated_cb,
- "button_connect", "clicked", accounts_dialog_button_connect_clicked_cb,
"button_add", "clicked", accounts_dialog_button_add_clicked_cb,
"button_remove", "clicked", accounts_dialog_button_remove_clicked_cb,
NULL);
/* Create profile chooser */
dialog->combobox_profile = empathy_profile_chooser_new ();
- gtk_table_attach_defaults (GTK_TABLE (dialog->table_new_account),
- dialog->combobox_profile,
- 1, 2,
- 0, 1);
+ gtk_box_pack_end (GTK_BOX (dialog->hbox_type),
+ 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 (dialog->monitor, "account-enabled",
+ G_CALLBACK (accounts_dialog_account_enabled_cb),
+ dialog);
+ g_signal_connect (dialog->monitor, "account-disabled",
+ G_CALLBACK (accounts_dialog_account_enabled_cb),
+ dialog);
dbus_g_proxy_connect_signal (DBUS_G_PROXY (dialog->mc), "AccountStatusChanged",
G_CALLBACK (accounts_dialog_status_changed_cb),
dialog, NULL);