static void account_manager_prepared_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { TpAccountManager *manager = TP_ACCOUNT_MANAGER (source_object); EmpathyImportWidget *self = user_data; GtkTreeModel *model; GtkTreeIter iter; GList *l; EmpathyImportWidgetPriv *priv = GET_PRIV (self); GError *error = NULL; if (!tp_proxy_prepare_finish (manager, result, &error)) { DEBUG ("Failed to prepare account manager: %s", error->message); g_error_free (error); return; } model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); for (l = priv->accounts; l; l = l->next) { GValue *value; EmpathyImportAccountData *data = l->data; gboolean import; GList *accounts; TpConnectionManager *cm = NULL; if (!empathy_import_protocol_is_supported (data->protocol, &cm)) continue; data->connection_manager = g_strdup ( tp_connection_manager_get_name (cm)); value = g_hash_table_lookup (data->settings, "account"); accounts = tp_account_manager_get_valid_accounts (manager); /* Only set the "Import" cell to be active if there isn't already an * account set up with the same account id. */ import = !import_widget_account_id_in_list (accounts, g_value_get_string (value)); g_list_free (accounts); gtk_list_store_append (GTK_LIST_STORE (model), &iter); gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_IMPORT, import, COL_PROTOCOL, data->protocol, COL_NAME, g_value_get_string (value), COL_SOURCE, data->source, COL_ACCOUNT_DATA, data, -1); } }
static void import_widget_add_accounts_to_model (EmpathyImportWidget *self) { TpAccountManager *manager; GtkTreeModel *model; GList *l; EmpathyImportWidgetPriv *priv = GET_PRIV (self); gint min, natural; manager = tp_account_manager_dup (); model = gtk_tree_view_get_model (GTK_TREE_VIEW (priv->treeview)); for (l = priv->accounts; l; l = l->next) { GValue *value; EmpathyImportAccountData *data = l->data; gboolean import; GList *accounts; TpConnectionManager *cm = NULL; if (!empathy_import_protocol_is_supported (data->protocol, &cm)) continue; data->connection_manager = g_strdup ( tp_connection_manager_get_name (cm)); value = g_hash_table_lookup (data->settings, "account"); accounts = tp_account_manager_dup_valid_accounts (manager); /* Only set the "Import" cell to be active if there isn't already an * account set up with the same account id. */ import = !import_widget_account_id_in_list (accounts, g_value_get_string (value)); g_list_free_full (accounts, g_object_unref); gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, -1, COL_IMPORT, import, COL_PROTOCOL, data->protocol, COL_NAME, g_value_get_string (value), COL_SOURCE, data->source, COL_ACCOUNT_DATA, data, -1); } /* Display as much rows as possible */ gtk_widget_get_preferred_height (priv->treeview, &min, &natural); gtk_widget_set_size_request (priv->scrolledwindow, -1, MIN (natural, MAX_TREEVIEW_HEIGHT)); g_object_unref (manager); }