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 */
76 get_pretty_conn_name (TpConnection *conn)
78 return tp_proxy_get_object_path (conn) + strlen (TP_CONN_OBJECT_PATH_BASE);
82 contact_blocking_dialog_filter_account_chooser (TpAccount *account,
83 EmpathyAccountChooserFilterResultCallback callback,
84 gpointer callback_data,
87 EmpathyContactBlockingDialog *self = user_data;
88 TpConnection *conn = tp_account_get_connection (account);
93 g_hash_table_lookup (self->priv->channels, conn) != NULL;
95 callback (enable, callback_data);
98 static void contact_blocking_dialog_account_changed (GtkWidget *,
99 EmpathyContactBlockingDialog *);
102 contact_blocking_dialog_refilter_account_chooser (
103 EmpathyContactBlockingDialog *self)
105 EmpathyAccountChooser *chooser =
106 EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser);
110 DEBUG ("Refiltering account chooser");
112 /* set the filter to refilter the account chooser */
113 self->priv->block_account_changed++;
114 empathy_account_chooser_set_filter (chooser,
115 contact_blocking_dialog_filter_account_chooser, self);
116 self->priv->block_account_changed--;
118 conn = empathy_account_chooser_get_connection (chooser);
119 enabled = (empathy_account_chooser_get_account (chooser) != NULL &&
121 g_hash_table_lookup (self->priv->channels, conn) != NULL);
124 DEBUG ("No account selected");
126 gtk_widget_set_sensitive (self->priv->add_button, enabled);
127 gtk_widget_set_sensitive (self->priv->add_contact_entry, enabled);
129 contact_blocking_dialog_account_changed (self->priv->account_chooser, self);
132 static void contact_blocking_dialog_inspected_handles (TpConnection *,
133 const char **, const GError *, gpointer, GObject *);
136 contact_blocking_dialog_add_contacts_to_list (
137 EmpathyContactBlockingDialog *self,
141 if (handles->len > 0)
142 tp_cli_connection_call_inspect_handles (conn, -1,
143 TP_HANDLE_TYPE_CONTACT, handles,
144 contact_blocking_dialog_inspected_handles,
145 g_boxed_copy (DBUS_TYPE_G_UINT_ARRAY, handles),
146 (GDestroyNotify) g_array_unref, G_OBJECT (self));
150 contact_blocking_dialog_inspected_handles (TpConnection *conn,
151 const char **identifiers,
152 const GError *in_error,
156 EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
157 GArray *handles = user_data;
160 if (in_error != NULL)
162 DEBUG ("Failed to inspect handles: %s", in_error->message);
166 DEBUG ("Adding %u identifiers", handles->len);
168 for (i = 0; i < handles->len; i++)
170 const char *identifier = identifiers[i];
171 TpHandle handle = g_array_index (handles, TpHandle, i);
173 gtk_list_store_insert_with_values (priv->blocked_contacts, NULL, -1,
174 COL_IDENTIFIER, identifier,
180 DECLARE_CALLBACK (contact_blocking_dialog_connection_prepared);
183 contact_blocking_dialog_connection_status_changed (TpAccount *account,
187 const char *dbus_reason,
189 EmpathyContactBlockingDialog *self)
191 TpConnection *conn = tp_account_get_connection (account);
195 case TP_CONNECTION_STATUS_DISCONNECTED:
196 DEBUG ("Connection %s invalidated", get_pretty_conn_name (conn));
198 /* remove the channel from the hash table */
199 g_hash_table_remove (self->priv->channels, conn);
200 contact_blocking_dialog_refilter_account_chooser (self);
203 case TP_CONNECTION_STATUS_CONNECTING:
206 case TP_CONNECTION_STATUS_CONNECTED:
207 DEBUG ("Connection %s reconnected", get_pretty_conn_name (conn));
209 tp_proxy_prepare_async (conn, NULL,
210 contact_blocking_dialog_connection_prepared, self);
215 contact_blocking_dialog_deny_channel_members_changed (TpChannel *channel,
219 GArray *local_pending,
220 GArray *remote_pending,
223 EmpathyContactBlockingDialog *self)
225 TpConnection *conn = tp_channel_borrow_connection (channel);
226 GtkTreeModel *model = GTK_TREE_MODEL (self->priv->blocked_contacts);
228 TpIntset *removed_set;
231 /* we only care about changes to the selected connection */
232 /* FIXME: can we compare proxy pointers directly? */
234 tp_proxy_get_object_path (tp_channel_borrow_connection (channel)),
235 tp_proxy_get_object_path (empathy_account_chooser_get_connection (
236 EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser)))))
239 DEBUG ("deny list changed on %s: %u added, %u removed",
240 get_pretty_conn_name (conn), added->len, removed->len);
243 contact_blocking_dialog_add_contacts_to_list (self, conn, added);
245 /* remove contacts */
246 removed_set = tp_intset_from_array (removed);
248 valid = gtk_tree_model_get_iter_first (model, &iter);
253 gtk_tree_model_get (model, &iter,
257 if (tp_intset_is_member (removed_set, handle))
258 valid = gtk_list_store_remove (self->priv->blocked_contacts, &iter);
260 valid = gtk_tree_model_iter_next (model, &iter);
263 tp_intset_destroy (removed_set);
266 DECLARE_CALLBACK (contact_blocking_dialog_connection_prepared);
269 contact_blocking_dialog_am_prepared (GObject *am,
270 GAsyncResult *result,
273 EmpathyContactBlockingDialog *self = user_data;
274 GList *accounts, *ptr;
275 GError *error = NULL;
277 if (!tp_proxy_prepare_finish (am, result, &error))
279 g_critical ("Could not prepare Account Manager: %s", error->message);
280 g_error_free (error);
284 accounts = tp_account_manager_get_valid_accounts (TP_ACCOUNT_MANAGER (am));
286 for (ptr = accounts; ptr != NULL; ptr = ptr->next)
288 TpAccount *account = ptr->data;
291 tp_g_signal_connect_object (account, "status-changed",
292 G_CALLBACK (contact_blocking_dialog_connection_status_changed),
295 conn = tp_account_get_connection (TP_ACCOUNT (account));
299 tp_proxy_prepare_async (conn, NULL,
300 contact_blocking_dialog_connection_prepared, self);
304 g_list_free (accounts);
307 static void contact_blocking_dialog_got_deny_channel (TpConnection *,
308 gboolean, const char *, GHashTable *, const GError *, gpointer, GObject *);
311 contact_blocking_dialog_connection_prepared (GObject *conn,
312 GAsyncResult *result,
315 EmpathyContactBlockingDialog *self = user_data;
317 GError *error = NULL;
319 if (!tp_proxy_prepare_finish (conn, result, &error))
321 DEBUG ("Failed to prepare connection %s: %s",
322 get_pretty_conn_name ((TpConnection *) conn), error->message);
323 g_error_free (error);
327 /* request the deny channel */
328 request = tp_asv_new (
329 TP_PROP_CHANNEL_CHANNEL_TYPE,
331 TP_IFACE_CHANNEL_TYPE_CONTACT_LIST,
333 TP_PROP_CHANNEL_TARGET_HANDLE_TYPE,
337 TP_PROP_CHANNEL_TARGET_ID,
343 tp_cli_connection_interface_requests_call_ensure_channel (
344 TP_CONNECTION (conn), -1, request,
345 contact_blocking_dialog_got_deny_channel, NULL, NULL, G_OBJECT (self));
347 g_hash_table_destroy (request);
350 DECLARE_CALLBACK (contact_blocking_dialog_deny_channel_prepared);
353 contact_blocking_dialog_got_deny_channel (TpConnection *conn,
355 const char *channel_path,
357 const GError *in_error,
362 GError *error = NULL;
364 const GQuark features[] = {
365 TP_CHANNEL_FEATURE_CORE,
366 TP_CHANNEL_FEATURE_GROUP,
369 if (in_error != NULL)
371 DEBUG ("Failed to get 'deny' channel on %s: %s",
372 get_pretty_conn_name (conn), in_error->message);
376 channel = tp_channel_new_from_properties (conn, channel_path, props, &error);
380 DEBUG ("Failed to create channel proxy on %s: %s",
381 get_pretty_conn_name (conn), in_error->message);
382 g_error_free (error);
386 tp_proxy_prepare_async (channel, features,
387 contact_blocking_dialog_deny_channel_prepared, self);
391 contact_blocking_dialog_deny_channel_prepared (GObject *channel,
392 GAsyncResult *result,
395 EmpathyContactBlockingDialog *self = user_data;
397 GError *error = NULL;
399 if (!tp_proxy_prepare_finish (channel, result, &error))
401 DEBUG ("Failed to prepare channel %s: %s",
402 tp_proxy_get_object_path (channel), error->message);
403 g_error_free (error);
407 conn = tp_channel_borrow_connection (TP_CHANNEL (channel));
409 DEBUG ("Channel %s prepared for connection %s",
410 tp_proxy_get_object_path (channel), get_pretty_conn_name (conn));
412 g_hash_table_insert (self->priv->channels,
413 g_object_ref (conn), channel);
414 contact_blocking_dialog_refilter_account_chooser (self);
416 tp_g_signal_connect_object (channel, "group-members-changed",
417 G_CALLBACK (contact_blocking_dialog_deny_channel_members_changed),
422 contact_blocking_dialog_set_error (EmpathyContactBlockingDialog *self,
425 const char *msg = NULL;
427 if (error->domain == TP_ERRORS)
429 if (error->code == TP_ERROR_INVALID_HANDLE)
430 msg = _("Unknown or invalid identifier");
431 else if (error->code == TP_ERROR_NOT_AVAILABLE)
432 msg = _("Contact blocking temporarily unavailable");
433 else if (error->code == TP_ERROR_NOT_CAPABLE)
434 msg = _("Contact blocking unavailable");
435 else if (error->code == TP_ERROR_PERMISSION_DENIED)
436 msg = _("Permission Denied");
440 msg = _("Could not block contact");
442 gtk_label_set_text (GTK_LABEL (self->priv->info_bar_label), msg);
443 gtk_widget_show (self->priv->info_bar);
446 static void contact_blocking_dialog_add_contact_got_handle (TpConnection *,
447 const GArray *, const GError *, gpointer, GObject *);
450 contact_blocking_dialog_add_contact (GtkWidget *widget,
451 EmpathyContactBlockingDialog *self)
453 TpConnection *conn = empathy_account_chooser_get_connection (
454 EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
455 const char *identifiers[2] = { NULL, };
457 identifiers[0] = gtk_entry_get_text (
458 GTK_ENTRY (self->priv->add_contact_entry));
460 DEBUG ("Looking up handle for '%s' on %s",
461 identifiers[0], get_pretty_conn_name (conn));
463 tp_cli_connection_call_request_handles (conn, -1,
464 TP_HANDLE_TYPE_CONTACT, identifiers,
465 contact_blocking_dialog_add_contact_got_handle,
466 NULL, NULL, G_OBJECT (self));
468 gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), "");
469 gtk_widget_hide (self->priv->info_bar);
473 contact_blocking_dialog_added_contact (TpChannel *, const GError *,
474 gpointer, GObject *);
477 contact_blocking_dialog_add_contact_got_handle (TpConnection *conn,
478 const GArray *handles,
479 const GError *in_error,
483 EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
484 TpChannel *channel = g_hash_table_lookup (priv->channels, conn);
486 if (in_error != NULL)
488 DEBUG ("Error getting handle on %s: %s",
489 get_pretty_conn_name (conn), in_error->message);
491 contact_blocking_dialog_set_error (
492 EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
497 g_return_if_fail (handles->len == 1);
499 DEBUG ("Adding handle %u to deny channel on %s",
500 g_array_index (handles, TpHandle, 0), get_pretty_conn_name (conn));
502 tp_cli_channel_interface_group_call_add_members (channel, -1,
504 contact_blocking_dialog_added_contact, NULL, NULL, self);
508 contact_blocking_dialog_added_contact (TpChannel *channel,
509 const GError *in_error,
513 if (in_error != NULL)
515 DEBUG ("Error adding contact to deny list %s: %s",
516 tp_proxy_get_object_path (channel), in_error->message);
518 contact_blocking_dialog_set_error (
519 EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
524 DEBUG ("Contact added to %s", tp_proxy_get_object_path (channel));
528 contact_blocking_dialog_removed_contacts (TpChannel *,
529 const GError *, gpointer, GObject *);
532 contact_blocking_dialog_remove_contacts (GtkWidget *button,
533 EmpathyContactBlockingDialog *self)
535 TpConnection *conn = empathy_account_chooser_get_connection (
536 EMPATHY_ACCOUNT_CHOOSER (self->priv->account_chooser));
537 TpChannel *channel = g_hash_table_lookup (self->priv->channels, conn);
540 GArray *handles = g_array_new (FALSE, FALSE, sizeof (TpHandle));
542 rows = gtk_tree_selection_get_selected_rows (self->priv->selection, &model);
544 for (ptr = rows; ptr != NULL; ptr = ptr->next)
546 GtkTreePath *path = ptr->data;
550 if (!gtk_tree_model_get_iter (model, &iter, path))
553 gtk_tree_model_get (model, &iter,
557 g_array_append_val (handles, handle);
558 gtk_tree_path_free (path);
563 if (handles->len > 0)
565 DEBUG ("Removing %u handles", handles->len);
567 tp_cli_channel_interface_group_call_remove_members (channel, -1,
569 contact_blocking_dialog_removed_contacts,
570 NULL, NULL, G_OBJECT (self));
573 g_array_unref (handles);
577 contact_blocking_dialog_removed_contacts (TpChannel *channel,
578 const GError *in_error,
582 if (in_error != NULL)
584 DEBUG ("Error removing contacts from deny list: %s", in_error->message);
586 contact_blocking_dialog_set_error (
587 EMPATHY_CONTACT_BLOCKING_DIALOG (self), in_error);
592 DEBUG ("Contacts removed");
596 contact_blocking_dialog_account_changed (GtkWidget *account_chooser,
597 EmpathyContactBlockingDialog *self)
599 TpConnection *conn = empathy_account_chooser_get_connection (
600 EMPATHY_ACCOUNT_CHOOSER (account_chooser));
603 EmpathyContactManager *contact_manager;
604 EmpathyTpContactList *contact_list;
605 GList *members, *ptr;
607 if (self->priv->block_account_changed > 0)
610 /* clear the lists of contacts */
611 gtk_list_store_clear (self->priv->blocked_contacts);
612 gtk_list_store_clear (self->priv->completion_contacts);
617 DEBUG ("Account changed: %s", get_pretty_conn_name (conn));
619 /* load the deny list */
620 channel = g_hash_table_lookup (self->priv->channels, conn);
625 g_return_if_fail (TP_IS_CHANNEL (channel));
627 blocked = tp_intset_to_array (tp_channel_group_get_members (channel));
629 DEBUG ("%u contacts on blocked list", blocked->len);
631 contact_blocking_dialog_add_contacts_to_list (self, conn, blocked);
632 g_array_unref (blocked);
634 /* load the completion list */
635 g_return_if_fail (empathy_contact_manager_initialized ());
637 DEBUG ("Loading contacts");
639 contact_manager = empathy_contact_manager_dup_singleton ();
640 contact_list = empathy_contact_manager_get_list (contact_manager, conn);
641 members = empathy_contact_list_get_members (
642 EMPATHY_CONTACT_LIST (contact_list));
644 for (ptr = members; ptr != NULL; ptr = ptr->next)
646 EmpathyContact *contact = ptr->data;
649 tmpstr = g_strdup_printf ("%s (%s)",
650 empathy_contact_get_alias (contact),
651 empathy_contact_get_id (contact));
653 gtk_list_store_insert_with_values (self->priv->completion_contacts,
655 COL_IDENTIFIER, empathy_contact_get_id (contact),
660 g_object_unref (contact);
663 g_list_free (members);
664 g_object_unref (contact_manager);
668 contact_blocking_dialog_view_selection_changed (GtkTreeSelection *selection,
669 EmpathyContactBlockingDialog *self)
671 GList *rows = gtk_tree_selection_get_selected_rows (selection, NULL);
673 /* update the sensitivity of the remove button */
674 gtk_widget_set_sensitive (self->priv->remove_button, rows != NULL);
676 g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
681 contact_selector_dialog_match_func (GtkEntryCompletion *completion,
690 model = gtk_entry_completion_get_model (completion);
691 if (model == NULL || iter == NULL)
694 gtk_tree_model_get (model, iter, COL_TEXT, &str, -1);
695 lower = g_utf8_strdown (str, -1);
696 if (strstr (lower, key))
698 DEBUG ("Key %s is matching name **%s**", key, str);
705 gtk_tree_model_get (model, iter, COL_IDENTIFIER, &str, -1);
706 lower = g_utf8_strdown (str, -1);
707 if (strstr (lower, key))
709 DEBUG ("Key %s is matching ID **%s**", key, str);
722 contact_selector_dialog_match_selected_cb (GtkEntryCompletion *widget,
725 EmpathyContactBlockingDialog *self)
729 if (iter == NULL || model == NULL)
732 gtk_tree_model_get (model, iter, COL_IDENTIFIER, &id, -1);
733 gtk_entry_set_text (GTK_ENTRY (self->priv->add_contact_entry), id);
735 DEBUG ("Got selected match **%s**", id);
743 contact_blocking_dialog_dispose (GObject *self)
745 EmpathyContactBlockingDialogPrivate *priv = GET_PRIVATE (self);
747 tp_clear_pointer (&priv->channels, g_hash_table_destroy);
749 G_OBJECT_CLASS (empathy_contact_blocking_dialog_parent_class)->dispose (self);
753 empathy_contact_blocking_dialog_class_init (
754 EmpathyContactBlockingDialogClass *klass)
756 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
758 gobject_class->dispose = contact_blocking_dialog_dispose;
760 g_type_class_add_private (gobject_class,
761 sizeof (EmpathyContactBlockingDialogPrivate));
765 empathy_contact_blocking_dialog_init (EmpathyContactBlockingDialog *self)
770 GtkWidget *account_hbox, *blocked_contacts_view, *blocked_contacts_sw,
772 GtkEntryCompletion *completion;
773 TpAccountManager *am;
774 GtkStyleContext *context;
776 self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
777 EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG,
778 EmpathyContactBlockingDialogPrivate);
780 self->priv->channels = g_hash_table_new_full (NULL, NULL,
781 g_object_unref, g_object_unref);
783 gtk_window_set_title (GTK_WINDOW (self), _("Edit Blocked Contacts"));
784 gtk_dialog_add_button (GTK_DIALOG (self),
785 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
787 filename = empathy_file_lookup ("empathy-contact-blocking-dialog.ui",
790 gui = empathy_builder_get_file (filename,
791 "contents", &contents,
792 "account-hbox", &account_hbox,
793 "add-button", &self->priv->add_button,
794 "add-contact-entry", &self->priv->add_contact_entry,
795 "blocked-contacts", &self->priv->blocked_contacts,
796 "blocked-contacts-sw", &blocked_contacts_sw,
797 "blocked-contacts-view", &blocked_contacts_view,
798 "remove-button", &self->priv->remove_button,
799 "remove-toolbar", &remove_toolbar,
802 empathy_builder_connect (gui, self,
803 "add-button", "clicked", contact_blocking_dialog_add_contact,
804 "add-contact-entry", "activate", contact_blocking_dialog_add_contact,
805 "remove-button", "clicked", contact_blocking_dialog_remove_contacts,
808 /* join the remove toolbar to the treeview */
809 context = gtk_widget_get_style_context (blocked_contacts_sw);
810 gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
811 context = gtk_widget_get_style_context (remove_toolbar);
812 gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
814 /* add the contents to the dialog */
816 GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (self))),
818 gtk_widget_show (contents);
820 /* set up the tree selection */
821 self->priv->selection = gtk_tree_view_get_selection (
822 GTK_TREE_VIEW (blocked_contacts_view));
823 gtk_tree_selection_set_mode (self->priv->selection, GTK_SELECTION_MULTIPLE);
824 g_signal_connect (self->priv->selection, "changed",
825 G_CALLBACK (contact_blocking_dialog_view_selection_changed), self);
827 /* build the contact entry */
828 self->priv->completion_contacts = gtk_list_store_new (N_COLUMNS,
829 G_TYPE_STRING, /* id */
830 G_TYPE_UINT, /* handle */
831 G_TYPE_STRING); /* text */
832 completion = gtk_entry_completion_new ();
833 gtk_entry_completion_set_model (completion,
834 GTK_TREE_MODEL (self->priv->completion_contacts));
835 gtk_entry_completion_set_text_column (completion, COL_TEXT);
836 gtk_entry_completion_set_match_func (completion,
837 contact_selector_dialog_match_func,
839 g_signal_connect (completion, "match-selected",
840 G_CALLBACK (contact_selector_dialog_match_selected_cb),
842 gtk_entry_set_completion (GTK_ENTRY (self->priv->add_contact_entry),
844 g_object_unref (completion);
845 g_object_unref (self->priv->completion_contacts);
847 /* add the account chooser */
848 self->priv->account_chooser = empathy_account_chooser_new ();
849 contact_blocking_dialog_refilter_account_chooser (self);
850 g_signal_connect (self->priv->account_chooser, "changed",
851 G_CALLBACK (contact_blocking_dialog_account_changed), self);
853 gtk_box_pack_start (GTK_BOX (account_hbox), self->priv->account_chooser,
855 gtk_widget_show (self->priv->account_chooser);
857 /* add an error warning info bar */
858 self->priv->info_bar = gtk_info_bar_new ();
859 gtk_box_pack_start (GTK_BOX (contents), self->priv->info_bar, FALSE, TRUE, 0);
860 gtk_info_bar_set_message_type (GTK_INFO_BAR (self->priv->info_bar),
863 self->priv->info_bar_label = gtk_label_new ("");
864 gtk_container_add (GTK_CONTAINER (
865 gtk_info_bar_get_content_area (GTK_INFO_BAR (self->priv->info_bar))),
866 self->priv->info_bar_label);
867 gtk_widget_show (self->priv->info_bar_label);
869 /* prepare the account manager */
870 am = tp_account_manager_dup ();
871 tp_proxy_prepare_async (am, NULL, contact_blocking_dialog_am_prepared, self);
875 g_object_unref (gui);
879 empathy_contact_blocking_dialog_new (GtkWindow *parent)
881 GtkWidget *self = g_object_new (EMPATHY_TYPE_CONTACT_BLOCKING_DIALOG,
886 gtk_window_set_transient_for (GTK_WINDOW (self), parent);