2 * empathy-contact-blocking-dialog.c
4 * EmpathyContactBlockingDialog
6 * Copyright (C) 2011 Collabora Ltd.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
26 #include <glib/gi18n-lib.h>
28 #include <libempathy/empathy-utils.h>
30 #include <libempathy/empathy-contact-manager.h>
31 #include <libempathy/empathy-tp-contact-list.h>
33 #include <libempathy-gtk/empathy-account-chooser.h>
34 #include <libempathy-gtk/empathy-ui-utils.h>
36 #include "empathy-contact-blocking-dialog.h"
38 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
39 #include <libempathy/empathy-debug.h>
41 #define GET_PRIVATE(o) (EMPATHY_CONTACT_BLOCKING_DIALOG (o)->priv)
42 #define DECLARE_CALLBACK(func) \
43 static void func (GObject *, GAsyncResult *, gpointer);
45 G_DEFINE_TYPE (EmpathyContactBlockingDialog, empathy_contact_blocking_dialog,
48 struct _EmpathyContactBlockingDialogPrivate
50 /* a map of all active connections to their 'deny' channel */
51 GHashTable *channels; /* reffed TpConnection* -> reffed TpChannel* */
53 guint block_account_changed;
55 GtkListStore *blocked_contacts;
56 GtkListStore *completion_contacts;
57 GtkTreeSelection *selection;
59 GtkWidget *account_chooser;
60 GtkWidget *add_button;
61 GtkWidget *add_contact_entry;
63 GtkWidget *info_bar_label;
64 GtkWidget *remove_button;
67 enum /* blocked-contacts columns */
69 COL_BLOCKED_IDENTIFIER,
74 enum /* completion_contacts columns */
76 COL_COMPLETION_IDENTIFIER,
82 get_pretty_conn_name (TpConnection *conn)
84 return tp_proxy_get_object_path (conn) + strlen (TP_CONN_OBJECT_PATH_BASE);
88 contact_blocking_dialog_filter_account_chooser (TpAccount *account,
89 EmpathyAccountChooserFilterResultCallback callback,
90 gpointer callback_data,
93 EmpathyContactBlockingDialog *self = user_data;
94 TpConnection *conn = tp_account_get_connection (account);
99 g_hash_table_lookup (self->priv->channels, conn) != NULL;
101 callback (enable, callback_data);
104 static void contact_blocking_dialog_account_changed (GtkWidget *,
105 EmpathyContactBlockingDialog *);
108 contact_blocking_dialog_refilter_account_chooser (
109 EmpathyContactBlockingDialog *self)
111 EmpathyAccountChooser *chooser =
112 EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser);
116 DEBUG ("Refiltering account chooser");
118 /* set the filter to refilter the account chooser */
119 self->priv->block_account_changed++;
120 empathy_account_chooser_set_filter (chooser,
121 contact_blocking_dialog_filter_account_chooser, self);
122 self->priv->block_account_changed--;
124 conn = empathy_account_chooser_get_connection (chooser);
125 enabled = (empathy_account_chooser_get_account (chooser) != NULL &&
127 g_hash_table_lookup (self->priv->channels, conn) != NULL);
130 DEBUG ("No account selected");
132 gtk_widget_set_sensitive (self->priv->add_button, enabled);
133 gtk_widget_set_sensitive (self->priv->add_contact_entry, enabled);
135 contact_blocking_dialog_account_changed (self->priv->account_chooser, self);
138 static void contact_blocking_dialog_inspected_handles (TpConnection *,
139 const char **, const GError *, gpointer, GObject *);
142 contact_blocking_dialog_add_contacts_to_list (
143 EmpathyContactBlockingDialog *self,
147 if (handles->len > 0)
148 tp_cli_connection_call_inspect_handles (conn, -1,
149 TP_HANDLE_TYPE_CONTACT, handles,
150 contact_blocking_dialog_inspected_handles,
151 g_boxed_copy (DBUS_TYPE_G_UINT_ARRAY, handles),
152 (GDestroyNotify) g_array_unref, G_OBJECT (self));
156 contact_blocking_dialog_inspected_handles (TpConnection *conn,
157 const char **identifiers,
158 const GError *in_error,
162 EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
163 GArray *handles = user_data;
166 if (in_error != NULL)
168 DEBUG ("Failed to inspect handles: %s", in_error->message);
172 DEBUG ("Adding %u identifiers", handles->len);
174 for (i = 0; i < handles->len; i++)
176 const char *identifier = identifiers[i];
177 TpHandle handle = g_array_index (handles, TpHandle, i);
179 gtk_list_store_insert_with_values (priv->blocked_contacts, NULL, -1,
180 COL_BLOCKED_IDENTIFIER, identifier,
181 COL_BLOCKED_HANDLE, handle,
186 DECLARE_CALLBACK (contact_blocking_dialog_connection_prepared);
189 contact_blocking_dialog_connection_status_changed (TpAccount *account,
193 const char *dbus_reason,
195 EmpathyContactBlockingDialog *self)
197 TpConnection *conn = tp_account_get_connection (account);
201 case TP_CONNECTION_STATUS_DISCONNECTED:
202 DEBUG ("Connection %s invalidated", get_pretty_conn_name (conn));
204 /* remove the channel from the hash table */
205 g_hash_table_remove (self->priv->channels, conn);
206 contact_blocking_dialog_refilter_account_chooser (self);
209 case TP_CONNECTION_STATUS_CONNECTING:
212 case TP_CONNECTION_STATUS_CONNECTED:
213 DEBUG ("Connection %s reconnected", get_pretty_conn_name (conn));
215 tp_proxy_prepare_async (conn, NULL,
216 contact_blocking_dialog_connection_prepared, self);
221 contact_blocking_dialog_deny_channel_members_changed (TpChannel *channel,
225 GArray *local_pending,
226 GArray *remote_pending,
229 EmpathyContactBlockingDialog *self)
231 TpConnection *conn = tp_channel_borrow_connection (channel);
232 GtkTreeModel *model = GTK_TREE_MODEL (self->priv->blocked_contacts);
234 TpIntset *removed_set;
237 /* we only care about changes to the selected connection */
238 /* FIXME: can we compare proxy pointers directly? */
240 tp_proxy_get_object_path (tp_channel_borrow_connection (channel)),
241 tp_proxy_get_object_path (empathy_account_chooser_get_connection (
242 EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)))))
245 DEBUG ("deny list changed on %s: %u added, %u removed",
246 get_pretty_conn_name (conn), added->len, removed->len);
249 contact_blocking_dialog_add_contacts_to_list (self, conn, added);
251 /* remove contacts */
252 removed_set = tp_intset_from_array (removed);
254 valid = gtk_tree_model_get_iter_first (model, &iter);
259 gtk_tree_model_get (model, &iter,
260 COL_BLOCKED_HANDLE, &handle,
263 if (tp_intset_is_member (removed_set, handle))
264 valid = gtk_list_store_remove (self->priv->blocked_contacts, &iter);
266 valid = gtk_tree_model_iter_next (model, &iter);
269 tp_intset_destroy (removed_set);
272 DECLARE_CALLBACK (contact_blocking_dialog_connection_prepared);
275 contact_blocking_dialog_am_prepared (GObject *am,
276 GAsyncResult *result,
279 EmpathyContactBlockingDialog *self = user_data;
280 GList *accounts, *ptr;
281 GError *error = NULL;
283 if (!tp_proxy_prepare_finish (am, result, &error))
285 g_critical ("Could not prepare Account Manager: %s", error->message);
286 g_error_free (error);
290 accounts = tp_account_manager_get_valid_accounts (TP_ACCOUNT_MANAGER (am));
292 for (ptr = accounts; ptr != NULL; ptr = ptr->next)
294 TpAccount *account = ptr->data;
297 tp_g_signal_connect_object (account, "status-changed",
298 G_CALLBACK (contact_blocking_dialog_connection_status_changed),
301 conn = tp_account_get_connection (TP_ACCOUNT (account));
305 tp_proxy_prepare_async (conn, NULL,
306 contact_blocking_dialog_connection_prepared, self);
310 g_list_free (accounts);
313 static void contact_blocking_dialog_got_deny_channel (TpConnection *,
314 gboolean, const char *, GHashTable *, const GError *, gpointer, GObject *);
317 contact_blocking_dialog_connection_prepared (GObject *conn,
318 GAsyncResult *result,
321 EmpathyContactBlockingDialog *self = user_data;
323 GError *error = NULL;
325 if (!tp_proxy_prepare_finish (conn, result, &error))
327 DEBUG ("Failed to prepare connection %s: %s",
328 get_pretty_conn_name ((TpConnection *) conn), error->message);
329 g_error_free (error);
333 /* request the deny channel */
334 request = tp_asv_new (
335 TP_PROP_CHANNEL_CHANNEL_TYPE,
337 TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
339 TP_PROP_CHANNEL_TARGET_HANDLE_TYPE,
343 TP_PROP_CHANNEL_TARGET_ID,
349 tp_cli_connection_interface_requests_call_ensure_channel (
350 TP_CONNECTION (conn), -1, request,
351 contact_blocking_dialog_got_deny_channel, NULL, NULL, G_OBJECT (self));
353 g_hash_table_destroy (request);
356 DECLARE_CALLBACK (contact_blocking_dialog_deny_channel_prepared);
359 contact_blocking_dialog_got_deny_channel (TpConnection *conn,
361 const char *channel_path,
363 const GError *in_error,
368 GError *error = NULL;
370 const GQuark features[] = {
371 TP_CHANNEL_FEATURE_CORE,
372 TP_CHANNEL_FEATURE_GROUP,
375 if (in_error != NULL)
377 DEBUG ("Failed to get 'deny' channel on %s: %s",
378 get_pretty_conn_name (conn), in_error->message);
382 channel = tp_channel_new_from_properties (conn, channel_path, props, &error);
386 DEBUG ("Failed to create channel proxy on %s: %s",
387 get_pretty_conn_name (conn), in_error->message);
388 g_error_free (error);
392 tp_proxy_prepare_async (channel, features,
393 contact_blocking_dialog_deny_channel_prepared, self);
397 contact_blocking_dialog_deny_channel_prepared (GObject *channel,
398 GAsyncResult *result,
401 EmpathyContactBlockingDialog *self = user_data;
403 GError *error = NULL;
405 if (!tp_proxy_prepare_finish (channel, result, &error))
407 DEBUG ("Failed to prepare channel %s: %s",
408 tp_proxy_get_object_path (channel), error->message);
409 g_error_free (error);
413 conn = tp_channel_borrow_connection (TP_CHANNEL (channel));
415 DEBUG ("Channel %s prepared for connection %s",
416 tp_proxy_get_object_path (channel), get_pretty_conn_name (conn));
418 g_hash_table_insert (self->priv->channels,
419 g_object_ref (conn), channel);
420 contact_blocking_dialog_refilter_account_chooser (self);
422 tp_g_signal_connect_object (channel, "group-members-changed",
423 G_CALLBACK (contact_blocking_dialog_deny_channel_members_changed),
428 contact_blocking_dialog_set_error (EmpathyContactBlockingDialog *self,
431 const char *msg = NULL;
433 if (error->domain == TP_ERRORS)
435 if (error->code == TP_ERROR_INVALID_HANDLE)
436 msg = _("Unknown or invalid identifier");
437 else if (error->code == TP_ERROR_NOT_AVAILABLE)
438 msg = _("Contact blocking temporarily unavailable");
439 else if (error->code == TP_ERROR_NOT_CAPABLE)
440 msg = _("Contact blocking unavailable");
441 else if (error->code == TP_ERROR_PERMISSION_DENIED)
442 msg = _("Permission Denied");
446 msg = _("Could not block contact");
448 gtk_label_set_text (GTK_LABEL (self->priv->info_bar_label), msg);
449 gtk_widget_show (self->priv->info_bar);
452 static void contact_blocking_dialog_add_contact_got_handle (TpConnection *,
453 const GArray *, const GError *, gpointer, GObject *);
456 contact_blocking_dialog_add_contact (GtkWidget *widget,
457 EmpathyContactBlockingDialog *self)
459 TpConnection *conn = empathy_account_chooser_get_connection (
460 EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
461 const char *identifiers[2] = { NULL, };
463 identifiers[0] = gtk_entry_get_text (
464 GTK_ENTRY (self->priv->add_contact_entry));
466 DEBUG ("Looking up handle for '%s' on %s",
467 identifiers[0], get_pretty_conn_name (conn));
469 tp_cli_connection_call_request_handles (conn, -1,
470 TP_HANDLE_TYPE_CONTACT, identifiers,
471 contact_blocking_dialog_add_contact_got_handle,
472 NULL, NULL, G_OBJECT (self));
474 gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), "");
475 gtk_widget_hide (self->priv->info_bar);
479 contact_blocking_dialog_added_contact (TpChannel *, const GError *,
480 gpointer, GObject *);
483 contact_blocking_dialog_add_contact_got_handle (TpConnection *conn,
484 const GArray *handles,
485 const GError *in_error,
489 EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
490 TpChannel *channel = g_hash_table_lookup (priv->channels, conn);
492 if (in_error != NULL)
494 DEBUG ("Error getting handle on %s: %s",
495 get_pretty_conn_name (conn), in_error->message);
497 contact_blocking_dialog_set_error (
498 EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
503 g_return_if_fail (handles->len == 1);
505 DEBUG ("Adding handle %u to deny channel on %s",
506 g_array_index (handles, TpHandle, 0), get_pretty_conn_name (conn));
508 tp_cli_channel_interface_group_call_add_members (channel, -1,
510 contact_blocking_dialog_added_contact, NULL, NULL, self);
514 contact_blocking_dialog_added_contact (TpChannel *channel,
515 const GError *in_error,
519 if (in_error != NULL)
521 DEBUG ("Error adding contact to deny list %s: %s",
522 tp_proxy_get_object_path (channel), in_error->message);
524 contact_blocking_dialog_set_error (
525 EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
530 DEBUG ("Contact added to %s", tp_proxy_get_object_path (channel));
534 contact_blocking_dialog_removed_contacts (TpChannel *,
535 const GError *, gpointer, GObject *);
538 contact_blocking_dialog_remove_contacts (GtkWidget *button,
539 EmpathyContactBlockingDialog *self)
541 TpConnection *conn = empathy_account_chooser_get_connection (
542 EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
543 TpChannel *channel = g_hash_table_lookup (self->priv->channels, conn);
546 GArray *handles = g_array_new (FALSE, FALSE, sizeof (TpHandle));
548 rows = gtk_tree_selection_get_selected_rows (self->priv->selection, &model);
550 for (ptr = rows; ptr != NULL; ptr = ptr->next)
552 GtkTreePath *path = ptr->data;
556 if (!gtk_tree_model_get_iter (model, &iter, path))
559 gtk_tree_model_get (model, &iter,
560 COL_BLOCKED_HANDLE, &handle,
563 g_array_append_val (handles, handle);
564 gtk_tree_path_free (path);
569 if (handles->len > 0)
571 DEBUG ("Removing %u handles", handles->len);
573 tp_cli_channel_interface_group_call_remove_members (channel, -1,
575 contact_blocking_dialog_removed_contacts,
576 NULL, NULL, G_OBJECT (self));
579 g_array_unref (handles);
583 contact_blocking_dialog_removed_contacts (TpChannel *channel,
584 const GError *in_error,
588 if (in_error != NULL)
590 DEBUG ("Error removing contacts from deny list: %s", in_error->message);
592 contact_blocking_dialog_set_error (
593 EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
598 DEBUG ("Contacts removed");
602 contact_blocking_dialog_account_changed (GtkWidget *account_chooser,
603 EmpathyContactBlockingDialog *self)
605 TpConnection *conn = empathy_account_chooser_get_connection (
606 EMPATHY_ACCOUNT_CHOOSER (account_chooser));
609 EmpathyContactManager *contact_manager;
610 EmpathyTpContactList *contact_list;
611 GList *members, *ptr;
613 if (self->priv->block_account_changed > 0)
616 /* clear the lists of contacts */
617 gtk_list_store_clear (self->priv->blocked_contacts);
618 gtk_list_store_clear (self->priv->completion_contacts);
623 DEBUG ("Account changed: %s", get_pretty_conn_name (conn));
625 /* load the deny list */
626 channel = g_hash_table_lookup (self->priv->channels, conn);
631 g_return_if_fail (TP_IS_CHANNEL (channel));
633 blocked = tp_intset_to_array (tp_channel_group_get_members (channel));
635 DEBUG ("%u contacts on blocked list", blocked->len);
637 contact_blocking_dialog_add_contacts_to_list (self, conn, blocked);
638 g_array_unref (blocked);
640 /* load the completion list */
641 g_return_if_fail (empathy_contact_manager_initialized ());
643 DEBUG ("Loading contacts");
645 contact_manager = empathy_contact_manager_dup_singleton ();
646 contact_list = empathy_contact_manager_get_list (contact_manager, conn);
647 members = empathy_contact_list_get_members (
648 EMPATHY_CONTACT_LIST (contact_list));
650 for (ptr = members; ptr != NULL; ptr = ptr->next)
652 EmpathyContact *contact = ptr->data;
655 tmpstr = g_strdup_printf ("%s (%s)",
656 empathy_contact_get_alias (contact),
657 empathy_contact_get_id (contact));
659 gtk_list_store_insert_with_values (self->priv->completion_contacts,
661 COL_COMPLETION_IDENTIFIER, empathy_contact_get_id (contact),
662 COL_COMPLETION_TEXT, tmpstr,
666 g_object_unref (contact);
669 g_list_free (members);
670 g_object_unref (contact_manager);
674 contact_blocking_dialog_view_selection_changed (GtkTreeSelection *selection,
675 EmpathyContactBlockingDialog *self)
677 GList *rows = gtk_tree_selection_get_selected_rows (selection, NULL);
679 /* update the sensitivity of the remove button */
680 gtk_widget_set_sensitive (self->priv->remove_button, rows != NULL);
682 g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
687 contact_selector_dialog_match_func (GtkEntryCompletion *completion,
696 model = gtk_entry_completion_get_model (completion);
697 if (model == NULL || iter == NULL)
700 gtk_tree_model_get (model, iter, COL_COMPLETION_TEXT, &str, -1);
701 lower = g_utf8_strdown (str, -1);
702 if (strstr (lower, key))
704 DEBUG ("Key %s is matching name **%s**", key, str);
711 gtk_tree_model_get (model, iter, COL_COMPLETION_IDENTIFIER, &str, -1);
712 lower = g_utf8_strdown (str, -1);
713 if (strstr (lower, key))
715 DEBUG ("Key %s is matching ID **%s**", key, str);
728 contact_selector_dialog_match_selected_cb (GtkEntryCompletion *widget,
731 EmpathyContactBlockingDialog *self)
735 if (iter == NULL || model == NULL)
738 gtk_tree_model_get (model, iter, COL_COMPLETION_IDENTIFIER, &id, -1);
739 gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), id);
741 DEBUG ("Got selected match **%s**", id);
749 contact_blocking_dialog_dispose (GObject *self)
751 EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
753 tp_clear_pointer (&priv->channels, g_hash_table_destroy);
755 G_OBJECT_CLASS (empathy_contact_blocking_dialog_parent_class)->dispose (self);
759 empathy_contact_blocking_dialog_class_init (
760 EmpathyContactBlockingDialogClass *klass)
762 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
764 gobject_class->dispose = contact_blocking_dialog_dispose;
766 g_type_class_add_private (gobject_class,
767 sizeof (EmpathyContactBlockingDialogPrivate));
771 empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self)
776 GtkWidget *account_hbox, *blocked_contacts_view, *blocked_contacts_sw,
778 GtkEntryCompletion *completion;
779 TpAccountManager *am;
780 GtkStyleContext *context;
782 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
783 EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG,
784 EmpathyContactBlockingDialogPrivate);
786 self->priv->channels = g_hash_table_new_full (NULL, NULL,
787 g_object_unref, g_object_unref);
789 gtk_window_set_title (GTK_WINDOW (self), _("Edit Blocked Contacts"));
790 gtk_dialog_add_button (GTK_DIALOG (self),
791 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
793 filename = empathy_file_lookup ("empathy-contact-blocking-dialog.ui",
796 gui = empathy_builder_get_file (filename,
797 "contents", &contents,
798 "account-hbox", &account_hbox,
799 "add-button", &self->priv->add_button,
800 "add-contact-entry", &self->priv->add_contact_entry,
801 "blocked-contacts", &self->priv->blocked_contacts,
802 "blocked-contacts-sw", &blocked_contacts_sw,
803 "blocked-contacts-view", &blocked_contacts_view,
804 "remove-button", &self->priv->remove_button,
805 "remove-toolbar", &remove_toolbar,
808 empathy_builder_connect (gui, self,
809 "add-button", "clicked", contact_blocking_dialog_add_contact,
810 "add-contact-entry", "activate", contact_blocking_dialog_add_contact,
811 "remove-button", "clicked", contact_blocking_dialog_remove_contacts,
814 /* join the remove toolbar to the treeview */
815 context = gtk_widget_get_style_context (blocked_contacts_sw);
816 gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
817 context = gtk_widget_get_style_context (remove_toolbar);
818 gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
820 /* add the contents to the dialog */
822 GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))),
824 gtk_widget_show (contents);
826 /* set up the tree selection */
827 self->priv->selection = gtk_tree_view_get_selection (
828 GTK_TREE_VIEW (blocked_contacts_view));
829 gtk_tree_selection_set_mode (self->priv->selection, GTK_SELECTION_MULTIPLE);
830 g_signal_connect (self->priv->selection, "changed",
831 G_CALLBACK (contact_blocking_dialog_view_selection_changed), self);
833 /* build the contact entry */
834 self->priv->completion_contacts = gtk_list_store_new (N_COMPLETION_COLUMNS,
835 G_TYPE_STRING, /* id */
836 G_TYPE_UINT, /* handle */
837 G_TYPE_STRING); /* text */
838 completion = gtk_entry_completion_new ();
839 gtk_entry_completion_set_model (completion,
840 GTK_TREE_MODEL (self->priv->completion_contacts));
841 gtk_entry_completion_set_text_column (completion, COL_COMPLETION_TEXT);
842 gtk_entry_completion_set_match_func (completion,
843 contact_selector_dialog_match_func,
845 g_signal_connect (completion, "match-selected",
846 G_CALLBACK (contact_selector_dialog_match_selected_cb),
848 gtk_entry_set_completion (GTK_ENTRY (self->priv->add_contact_entry),
850 g_object_unref (completion);
851 g_object_unref (self->priv->completion_contacts);
853 /* add the account chooser */
854 self->priv->account_chooser = empathy_account_chooser_new ();
855 contact_blocking_dialog_refilter_account_chooser (self);
856 g_signal_connect (self->priv->account_chooser, "changed",
857 G_CALLBACK (contact_blocking_dialog_account_changed), self);
859 gtk_box_pack_start (GTK_BOX (account_hbox), self->priv->account_chooser,
861 gtk_widget_show (self->priv->account_chooser);
863 /* add an error warning info bar */
864 self->priv->info_bar = gtk_info_bar_new ();
865 gtk_box_pack_start (GTK_BOX (contents), self->priv->info_bar, FALSE, TRUE, 0);
866 gtk_info_bar_set_message_type (GTK_INFO_BAR (self->priv->info_bar),
869 self->priv->info_bar_label = gtk_label_new ("");
870 gtk_container_add (GTK_CONTAINER (
871 gtk_info_bar_get_content_area (GTK_INFO_BAR (self->priv->info_bar))),
872 self->priv->info_bar_label);
873 gtk_widget_show (self->priv->info_bar_label);
875 /* prepare the account manager */
876 am = tp_account_manager_dup ();
877 tp_proxy_prepare_async (am, NULL, contact_blocking_dialog_am_prepared, self);
881 g_object_unref (gui);
885 empathy_contact_blocking_dialog_new (GtkWindow *parent)
887 GtkWidget *self = g_object_new (EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG,
892 gtk_window_set_transient_for (GTK_WINDOW (self), parent);