1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2007-2009 Collabora Ltd.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 * Authors: Xavier Claessens <xclaesse@gmail.com>
28 #include <glib/gi18n-lib.h>
30 #ifdef HAVE_LIBCHAMPLAIN
31 #include <champlain/champlain.h>
32 #include <champlain-gtk/champlain-gtk.h>
35 #include <telepathy-glib/account.h>
36 #include <telepathy-glib/util.h>
37 #include <telepathy-glib/interfaces.h>
39 #include <libempathy/empathy-tp-contact-factory.h>
40 #include <libempathy/empathy-contact-manager.h>
41 #include <libempathy/empathy-contact-list.h>
42 #include <libempathy/empathy-location.h>
43 #include <libempathy/empathy-time.h>
44 #include <libempathy/empathy-utils.h>
46 #include "empathy-contact-widget.h"
47 #include "empathy-account-chooser.h"
48 #include "empathy-avatar-chooser.h"
49 #include "empathy-avatar-image.h"
50 #include "empathy-groups-widget.h"
51 #include "empathy-ui-utils.h"
52 #include "empathy-string-parser.h"
53 #include "empathy-kludge-label.h"
55 #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
56 #include <libempathy/empathy-debug.h>
59 * SECTION:empathy-contact-widget
60 * @title:EmpathyContactWidget
61 * @short_description: A widget used to display and edit details about a contact
62 * @include: libempathy-empathy-contact-widget.h
64 * #EmpathyContactWidget is a widget which displays appropriate widgets
65 * with details about a contact, also allowing changing these details,
70 * EmpathyContactWidget:
71 * @parent: parent object
73 * Widget which displays appropriate widgets with details about a contact,
74 * also allowing changing these details, if desired.
77 /* Delay before updating the widget when the id entry changed (seconds) */
78 #define ID_CHANGED_TIMEOUT 1
82 EmpathyContactManager *manager;
83 EmpathyContact *contact;
84 EmpathyContactWidgetFlags flags;
85 guint widget_id_timeout;
88 GtkWidget *vbox_contact_widget;
91 GtkWidget *hbox_contact;
92 GtkWidget *widget_avatar;
93 GtkWidget *widget_account;
94 GtkWidget *image_account;
95 GtkWidget *label_account;
97 GtkWidget *widget_alias;
98 GtkWidget *label_alias;
99 GtkWidget *hbox_presence;
100 GtkWidget *image_state;
101 GtkWidget *label_status;
102 GtkWidget *table_contact;
103 GtkWidget *vbox_avatar;
104 GtkWidget *favourite_checkbox;
107 GtkWidget *vbox_location;
108 GtkWidget *subvbox_location;
109 GtkWidget *table_location;
110 GtkWidget *label_location;
111 #ifdef HAVE_LIBCHAMPLAIN
112 GtkWidget *viewport_map;
113 GtkWidget *map_view_embed;
114 ChamplainView *map_view;
118 GtkWidget *groups_widget;
121 GtkWidget *vbox_details;
122 GtkWidget *table_details;
123 GtkWidget *hbox_details_requested;
124 GtkWidget *spinner_details;
125 GList *details_to_set;
126 GCancellable *details_cancellable;
129 GtkWidget *vbox_client;
130 GtkWidget *table_client;
131 GtkWidget *hbox_client_requested;
132 } EmpathyContactWidget;
136 EmpathyContactWidget *information;
139 GtkTreeIter found_iter;
151 contact_widget_save (EmpathyContactWidget *information)
153 TpConnection *connection;
156 connection = empathy_contact_get_connection (information->contact);
158 /* Remove empty fields */
159 for (l = information->details_to_set; l != NULL; l = next)
161 TpContactInfoField *field = l->data;
164 if (field->field_value == NULL || EMP_STR_EMPTY (field->field_value[0]))
166 DEBUG ("Drop empty field: %s", field->field_name);
167 tp_contact_info_field_free (field);
168 information->details_to_set =
169 g_list_delete_link (information->details_to_set, l);
173 if (information->details_to_set != NULL)
175 tp_connection_set_contact_info_async (connection,
176 information->details_to_set, NULL, NULL);
177 tp_contact_info_list_free (information->details_to_set);
178 information->details_to_set = NULL;
183 contact_widget_details_setup (EmpathyContactWidget *information)
185 gtk_widget_hide (information->vbox_details);
187 information->spinner_details = gtk_spinner_new ();
188 gtk_box_pack_end (GTK_BOX (information->hbox_details_requested),
189 information->spinner_details, TRUE, TRUE, 0);
190 gtk_widget_show (information->spinner_details);
194 contact_widget_details_changed_cb (GtkEntry *entry,
195 TpContactInfoField *field)
197 const gchar *strv[] = { NULL, NULL };
199 strv[0] = gtk_entry_get_text (entry);
201 if (field->field_value != NULL)
202 g_strfreev (field->field_value);
203 field->field_value = g_strdupv ((GStrv) strv);
206 static void contact_widget_details_notify_cb (EmpathyContactWidget *information);
210 const gchar *field_name;
215 static InfoFieldData info_field_datas[] =
217 { "fn", N_("Full name:"), FALSE },
218 { "tel", N_("Phone number:"), FALSE },
219 { "email", N_("E-mail address:"), TRUE },
220 { "url", N_("Website:"), TRUE },
221 { "bday", N_("Birthday:"), FALSE },
225 static InfoFieldData *
226 find_info_field_data (const gchar *field_name)
230 for (i = 0; info_field_datas[i].field_name != NULL; i++)
232 if (!tp_strdiff (info_field_datas[i].field_name, field_name))
233 return info_field_datas + i;
239 contact_info_field_name_cmp (const gchar *name1,
244 if (!tp_strdiff (name1, name2))
247 /* We use the order of info_field_datas */
248 for (i = 0; info_field_datas[i].field_name != NULL; i++)
250 if (!tp_strdiff (info_field_datas[i].field_name, name1))
252 if (!tp_strdiff (info_field_datas[i].field_name, name2))
256 return g_strcmp0 (name1, name2);
260 contact_info_field_cmp (TpContactInfoField *field1,
261 TpContactInfoField *field2)
263 return contact_info_field_name_cmp (field1->field_name, field2->field_name);
267 contact_info_field_spec_cmp (TpContactInfoFieldSpec *spec1,
268 TpContactInfoFieldSpec *spec2)
270 return contact_info_field_name_cmp (spec1->name, spec2->name);
274 contact_widget_details_update_edit (EmpathyContactWidget *information)
277 TpConnection *connection;
281 g_assert (information->details_to_set == NULL);
283 contact = empathy_contact_get_tp_contact (information->contact);
284 connection = tp_contact_get_connection (contact);
286 specs = tp_connection_get_contact_info_supported_fields (connection);
287 specs = g_list_sort (specs, (GCompareFunc) contact_info_field_spec_cmp);
288 for (l = specs; l != NULL; l = l->next)
290 TpContactInfoFieldSpec *spec = l->data;
291 TpContactInfoField *field;
292 InfoFieldData *field_data;
297 field_data = find_info_field_data (spec->name);
298 if (field_data == NULL)
300 DEBUG ("Unhandled ContactInfo field spec: %s", spec->name);
304 /* Search initial value */
305 info = tp_contact_get_contact_info (contact);
306 for (ll = info; ll != NULL; ll = ll->next)
309 if (!tp_strdiff (field->field_name, spec->name))
311 value = field->field_value;
316 field = tp_contact_info_field_new (spec->name, spec->parameters, value);
317 information->details_to_set = g_list_prepend (information->details_to_set,
321 w = gtk_label_new (_(field_data->title));
322 gtk_table_attach (GTK_TABLE (information->table_details),
323 w, 0, 1, n_rows, n_rows + 1, GTK_FILL, 0, 0, 0);
324 gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
328 w = gtk_entry_new ();
329 gtk_entry_set_text (GTK_ENTRY (w),
330 field->field_value[0] ? field->field_value[0] : "");
331 gtk_table_attach_defaults (GTK_TABLE (information->table_details),
332 w, 1, 2, n_rows, n_rows + 1);
335 g_signal_connect (w, "changed",
336 G_CALLBACK (contact_widget_details_changed_cb), field);
346 contact_widget_details_update_show (EmpathyContactWidget *information)
352 contact = empathy_contact_get_tp_contact (information->contact);
353 info = tp_contact_get_contact_info (contact);
354 info = g_list_sort (info, (GCompareFunc) contact_info_field_cmp);
355 for (l = info; l != NULL; l = l->next)
357 TpContactInfoField *field = l->data;
358 InfoFieldData *field_data;
362 if (field->field_value == NULL || field->field_value[0] == NULL)
365 value = field->field_value[0];
367 field_data = find_info_field_data (field->field_name);
368 if (field_data == NULL)
370 DEBUG ("Unhandled ContactInfo field: %s", field->field_name);
375 w = gtk_label_new (_(field_data->title));
376 gtk_table_attach (GTK_TABLE (information->table_details),
377 w, 0, 1, n_rows, n_rows + 1, GTK_FILL, 0, 0, 0);
378 gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
382 w = gtk_label_new (value);
383 if (field_data->linkify)
387 markup = empathy_add_link_markup (value);
388 gtk_label_set_markup (GTK_LABEL (w), markup);
392 if ((information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) == 0)
393 gtk_label_set_selectable (GTK_LABEL (w), TRUE);
395 gtk_table_attach_defaults (GTK_TABLE (information->table_details),
396 w, 1, 2, n_rows, n_rows + 1);
397 gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
408 contact_widget_details_notify_cb (EmpathyContactWidget *information)
412 gtk_container_foreach (GTK_CONTAINER (information->table_details),
413 (GtkCallback) gtk_widget_destroy, NULL);
415 if ((information->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) != 0)
416 n_rows = contact_widget_details_update_edit (information);
418 n_rows = contact_widget_details_update_show (information);
422 gtk_widget_show (information->vbox_details);
423 gtk_widget_show (information->table_details);
427 gtk_widget_hide (information->vbox_details);
430 gtk_widget_hide (information->hbox_details_requested);
431 gtk_spinner_stop (GTK_SPINNER (information->spinner_details));
435 contact_widget_details_request_cb (GObject *object,
439 TpContact *contact = TP_CONTACT (object);
440 EmpathyContactWidget *information = user_data;
441 GError *error = NULL;
443 if (!tp_contact_request_contact_info_finish (contact, res, &error))
445 /* If the request got cancelled it could mean the contact widget is
446 * destroyed, so we should not dereference information */
447 if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
449 g_clear_error (&error);
453 gtk_widget_hide (information->vbox_details);
454 g_clear_error (&error);
458 contact_widget_details_notify_cb (information);
461 /* If we are going to edit ContactInfo, we don't want live updates */
462 if ((information->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) == 0)
464 g_signal_connect_swapped (contact, "notify::contact-info",
465 G_CALLBACK (contact_widget_details_notify_cb), information);
468 g_object_unref (information->details_cancellable);
469 information->details_cancellable = NULL;
473 contact_widget_details_feature_prepared_cb (GObject *object,
477 TpConnection *connection = TP_CONNECTION (object);
478 EmpathyContactWidget *information = user_data;
480 TpContactInfoFlags flags;
482 if (!tp_proxy_prepare_finish (connection, res, NULL))
484 gtk_widget_hide (information->vbox_details);
488 /* If we want to edit info, but connection does not support that, stop */
489 flags = tp_connection_get_contact_info_flags (connection);
490 if ((flags & TP_CONTACT_INFO_FLAG_CAN_SET) == 0 &&
491 (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) != 0)
493 gtk_widget_hide (information->vbox_details);
497 /* Request the contact's info */
498 gtk_widget_show (information->vbox_details);
499 gtk_widget_show (information->hbox_details_requested);
500 gtk_widget_hide (information->table_details);
501 gtk_spinner_start (GTK_SPINNER (information->spinner_details));
503 contact = empathy_contact_get_tp_contact (information->contact);
504 g_assert (information->details_cancellable == NULL);
505 information->details_cancellable = g_cancellable_new ();
506 tp_contact_request_contact_info_async (contact,
507 information->details_cancellable, contact_widget_details_request_cb,
512 contact_widget_details_update (EmpathyContactWidget *information)
514 TpContact *tp_contact = NULL;
516 if ((information->flags & EMPATHY_CONTACT_WIDGET_SHOW_DETAILS) == 0 &&
517 (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_DETAILS) == 0)
520 gtk_widget_hide (information->vbox_details);
522 if (information->contact != NULL)
523 tp_contact = empathy_contact_get_tp_contact (information->contact);
525 if (tp_contact != NULL)
527 GQuark features[] = { TP_CONNECTION_FEATURE_CONTACT_INFO, 0 };
528 TpConnection *connection;
530 /* First, make sure the CONTACT_INFO feature is ready on the connection */
531 connection = tp_contact_get_connection (tp_contact);
532 tp_proxy_prepare_async (connection, features,
533 contact_widget_details_feature_prepared_cb, information);
538 contact_widget_client_update (EmpathyContactWidget *information)
540 /* FIXME: Needs new telepathy spec */
544 contact_widget_client_setup (EmpathyContactWidget *information)
546 /* FIXME: Needs new telepathy spec */
547 gtk_widget_hide (information->vbox_client);
551 contact_widget_groups_update (EmpathyContactWidget *information)
553 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS &&
554 information->contact != NULL)
556 FolksPersona *persona =
557 empathy_contact_get_persona (information->contact);
559 if (FOLKS_IS_GROUPS (persona))
561 empathy_groups_widget_set_groupable (
562 EMPATHY_GROUPS_WIDGET (information->groups_widget),
563 FOLKS_GROUPS (persona));
564 gtk_widget_show (information->groups_widget);
570 /* In case of failure */
571 gtk_widget_hide (information->groups_widget);
574 /* Converts the Location's GHashTable's key to a user readable string */
576 location_key_to_label (const gchar *key)
578 if (tp_strdiff (key, EMPATHY_LOCATION_COUNTRY_CODE) == FALSE)
579 return _("Country ISO Code:");
580 else if (tp_strdiff (key, EMPATHY_LOCATION_COUNTRY) == FALSE)
581 return _("Country:");
582 else if (tp_strdiff (key, EMPATHY_LOCATION_REGION) == FALSE)
584 else if (tp_strdiff (key, EMPATHY_LOCATION_LOCALITY) == FALSE)
586 else if (tp_strdiff (key, EMPATHY_LOCATION_AREA) == FALSE)
588 else if (tp_strdiff (key, EMPATHY_LOCATION_POSTAL_CODE) == FALSE)
589 return _("Postal Code:");
590 else if (tp_strdiff (key, EMPATHY_LOCATION_STREET) == FALSE)
592 else if (tp_strdiff (key, EMPATHY_LOCATION_BUILDING) == FALSE)
593 return _("Building:");
594 else if (tp_strdiff (key, EMPATHY_LOCATION_FLOOR) == FALSE)
596 else if (tp_strdiff (key, EMPATHY_LOCATION_ROOM) == FALSE)
598 else if (tp_strdiff (key, EMPATHY_LOCATION_TEXT) == FALSE)
600 else if (tp_strdiff (key, EMPATHY_LOCATION_DESCRIPTION) == FALSE)
601 return _("Description:");
602 else if (tp_strdiff (key, EMPATHY_LOCATION_URI) == FALSE)
604 else if (tp_strdiff (key, EMPATHY_LOCATION_ACCURACY_LEVEL) == FALSE)
605 return _("Accuracy Level:");
606 else if (tp_strdiff (key, EMPATHY_LOCATION_ERROR) == FALSE)
608 else if (tp_strdiff (key, EMPATHY_LOCATION_VERTICAL_ERROR_M) == FALSE)
609 return _("Vertical Error (meters):");
610 else if (tp_strdiff (key, EMPATHY_LOCATION_HORIZONTAL_ERROR_M) == FALSE)
611 return _("Horizontal Error (meters):");
612 else if (tp_strdiff (key, EMPATHY_LOCATION_SPEED) == FALSE)
614 else if (tp_strdiff (key, EMPATHY_LOCATION_BEARING) == FALSE)
615 return _("Bearing:");
616 else if (tp_strdiff (key, EMPATHY_LOCATION_CLIMB) == FALSE)
617 return _("Climb Speed:");
618 else if (tp_strdiff (key, EMPATHY_LOCATION_TIMESTAMP) == FALSE)
619 return _("Last Updated on:");
620 else if (tp_strdiff (key, EMPATHY_LOCATION_LON) == FALSE)
621 return _("Longitude:");
622 else if (tp_strdiff (key, EMPATHY_LOCATION_LAT) == FALSE)
623 return _("Latitude:");
624 else if (tp_strdiff (key, EMPATHY_LOCATION_ALT) == FALSE)
625 return _("Altitude:");
628 DEBUG ("Unexpected Location key: %s", key);
634 contact_widget_location_update (EmpathyContactWidget *information)
636 GHashTable *location;
638 gdouble lat = 0.0, lon = 0.0;
639 gboolean has_position = TRUE;
642 static const gchar* ordered_geolocation_keys[] = {
643 EMPATHY_LOCATION_TEXT,
644 EMPATHY_LOCATION_URI,
645 EMPATHY_LOCATION_DESCRIPTION,
646 EMPATHY_LOCATION_BUILDING,
647 EMPATHY_LOCATION_FLOOR,
648 EMPATHY_LOCATION_ROOM,
649 EMPATHY_LOCATION_STREET,
650 EMPATHY_LOCATION_AREA,
651 EMPATHY_LOCATION_LOCALITY,
652 EMPATHY_LOCATION_REGION,
653 EMPATHY_LOCATION_COUNTRY,
658 gboolean display_map = FALSE;
660 if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION))
662 gtk_widget_hide (information->vbox_location);
666 location = empathy_contact_get_location (information->contact);
667 if (location == NULL || g_hash_table_size (location) == 0)
669 gtk_widget_hide (information->vbox_location);
673 value = g_hash_table_lookup (location, EMPATHY_LOCATION_LAT);
675 has_position = FALSE;
677 lat = g_value_get_double (value);
679 value = g_hash_table_lookup (location, EMPATHY_LOCATION_LON);
681 has_position = FALSE;
683 lon = g_value_get_double (value);
685 value = g_hash_table_lookup (location, EMPATHY_LOCATION_TIMESTAMP);
688 gchar *loc = g_strdup_printf ("<b>%s</b>", _("Location"));
689 gtk_label_set_markup (GTK_LABEL (information->label_location), loc);
699 stamp = g_value_get_int64 (value);
702 user_date = empathy_time_to_string_relative (time_);
704 text = g_strconcat ( _("<b>Location</b>, "), user_date, NULL);
705 gtk_label_set_markup (GTK_LABEL (information->label_location), text);
711 /* Prepare the location information table */
712 if (information->table_location != NULL)
714 gtk_widget_destroy (information->table_location);
717 information->table_location = gtk_table_new (1, 2, FALSE);
718 gtk_box_pack_start (GTK_BOX (information->subvbox_location),
719 information->table_location, FALSE, FALSE, 5);
722 for (i = 0; (skey = ordered_geolocation_keys[i]); i++)
724 const gchar* user_label;
728 gvalue = g_hash_table_lookup (location, (gpointer) skey);
732 user_label = location_key_to_label (skey);
734 label = gtk_label_new (user_label);
735 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
736 gtk_table_attach (GTK_TABLE (information->table_location),
737 label, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 10, 0);
738 gtk_widget_show (label);
740 if (G_VALUE_TYPE (gvalue) == G_TYPE_DOUBLE)
743 dvalue = g_value_get_double (gvalue);
744 svalue = g_strdup_printf ("%f", dvalue);
746 else if (G_VALUE_TYPE (gvalue) == G_TYPE_STRING)
748 svalue = g_value_dup_string (gvalue);
750 else if (G_VALUE_TYPE (gvalue) == G_TYPE_INT64)
754 time_ = g_value_get_int64 (value);
755 svalue = empathy_time_to_string_utc (time_, _("%B %e, %Y at %R UTC"));
760 label = gtk_label_new (svalue);
761 gtk_table_attach_defaults (GTK_TABLE (information->table_location),
762 label, 1, 2, row, row + 1);
763 gtk_misc_set_alignment (GTK_MISC (label), 0, 0);
764 gtk_widget_show (label);
766 if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
767 gtk_label_set_selectable (GTK_LABEL (label), TRUE);
774 #ifdef HAVE_LIBCHAMPLAIN
776 !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
778 /* Cannot be displayed in tooltips until Clutter-Gtk can deal with such
786 /* We can display some fields */
787 gtk_widget_show (information->table_location);
789 else if (!display_map)
791 /* Can't display either fields or map */
792 gtk_widget_hide (information->vbox_location);
796 #ifdef HAVE_LIBCHAMPLAIN
799 ClutterActor *marker;
800 ChamplainLayer *layer;
802 information->map_view_embed = gtk_champlain_embed_new ();
803 information->map_view = gtk_champlain_embed_get_view (
804 GTK_CHAMPLAIN_EMBED (information->map_view_embed));
806 gtk_container_add (GTK_CONTAINER (information->viewport_map),
807 information->map_view_embed);
808 g_object_set (G_OBJECT (information->map_view),
809 "show-license", TRUE,
810 "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
814 layer = champlain_layer_new ();
815 champlain_view_add_layer (information->map_view, layer);
817 marker = champlain_marker_new_with_text (
818 empathy_contact_get_alias (information->contact), NULL, NULL, NULL);
819 champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), lat, lon);
820 clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
822 champlain_view_center_on (information->map_view, lat, lon);
823 gtk_widget_show_all (information->viewport_map);
827 gtk_widget_show (information->vbox_location);
831 save_avatar_menu_activate_cb (GtkWidget *widget,
832 EmpathyContactWidget *information)
835 EmpathyAvatar *avatar;
836 gchar *ext = NULL, *filename;
838 dialog = gtk_file_chooser_dialog_new (_("Save Avatar"),
840 GTK_FILE_CHOOSER_ACTION_SAVE,
841 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
842 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
845 gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
848 /* look for the avatar extension */
849 avatar = empathy_contact_get_avatar (information->contact);
850 if (avatar->format != NULL)
854 splitted = g_strsplit (avatar->format, "/", 2);
855 if (splitted[0] != NULL && splitted[1] != NULL)
856 ext = g_strdup (splitted[1]);
858 g_strfreev (splitted);
862 /* Avatar was loaded from the cache so was converted to PNG */
863 ext = g_strdup ("png");
870 id = tp_escape_as_identifier (empathy_contact_get_id (
871 information->contact));
873 filename = g_strdup_printf ("%s.%s", id, ext);
874 gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);
881 if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
883 GError *error = NULL;
885 filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
887 if (!empathy_avatar_save_to_file (avatar, filename, &error))
890 GtkWidget *error_dialog;
892 error_dialog = gtk_message_dialog_new (NULL, 0,
893 GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
894 _("Unable to save avatar"));
896 gtk_message_dialog_format_secondary_text (
897 GTK_MESSAGE_DIALOG (error_dialog), "%s", error->message);
899 g_signal_connect (error_dialog, "response",
900 G_CALLBACK (gtk_widget_destroy), NULL);
902 gtk_window_present (GTK_WINDOW (error_dialog));
904 g_clear_error (&error);
910 gtk_widget_destroy (dialog);
914 popup_avatar_menu (EmpathyContactWidget *information,
916 GdkEventButton *event)
918 GtkWidget *menu, *item;
919 gint button, event_time;
921 if (information->contact == NULL ||
922 empathy_contact_get_avatar (information->contact) == NULL)
925 menu = gtk_menu_new ();
927 /* Add "Save as..." entry */
928 item = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE_AS, NULL);
929 gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
930 gtk_widget_show (item);
932 g_signal_connect (item, "activate",
933 G_CALLBACK (save_avatar_menu_activate_cb), information);
937 button = event->button;
938 event_time = event->time;
943 event_time = gtk_get_current_event_time ();
946 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
948 g_object_ref_sink (menu);
949 g_object_unref (menu);
953 widget_avatar_popup_menu_cb (GtkWidget *widget,
954 EmpathyContactWidget *information)
956 popup_avatar_menu (information, widget, NULL);
962 widget_avatar_button_press_event_cb (GtkWidget *widget,
963 GdkEventButton *event,
964 EmpathyContactWidget *information)
966 /* Ignore double-clicks and triple-clicks */
967 if (event->button == 3 && event->type == GDK_BUTTON_PRESS)
969 popup_avatar_menu (information, widget, event);
977 set_avatar_cb (GObject *source,
981 GError *error = NULL;
983 if (!tp_account_set_avatar_finish (TP_ACCOUNT (source), res, &error)) {
984 DEBUG ("Failed to set Account.Avatar: %s", error->message);
985 g_error_free (error);
990 set_avatar_on_account (TpAccount *account,
993 const gchar *mime_type)
995 DEBUG ("%s Account.Avatar on %s", size > 0 ? "Set": "Clear",
996 tp_proxy_get_object_path (account));
998 tp_account_set_avatar_async (account, (const guchar *) data, size,
999 mime_type, set_avatar_cb, NULL);
1003 contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser,
1004 EmpathyContactWidget *information)
1008 const gchar *mime_type;
1011 empathy_avatar_chooser_get_image_data (
1012 EMPATHY_AVATAR_CHOOSER (information->widget_avatar),
1013 &data, &size, &mime_type);
1015 account = empathy_contact_get_account (information->contact);
1016 set_avatar_on_account (account, data, size, mime_type);
1020 set_nickname_cb (GObject *source,
1024 GError *error = NULL;
1026 if (!tp_account_set_nickname_finish (TP_ACCOUNT (source), res, &error))
1028 DEBUG ("Failed to set Account.Nickname: %s", error->message);
1029 g_error_free (error);
1034 set_alias_on_account (TpAccount *account,
1037 DEBUG ("Set Account.Nickname to %s", alias);
1039 tp_account_set_nickname_async (account, alias, set_nickname_cb, NULL);
1043 contact_widget_entry_alias_focus_event_cb (GtkEditable *editable,
1044 GdkEventFocus *event,
1045 EmpathyContactWidget *information)
1047 if (information->contact)
1051 alias = gtk_entry_get_text (GTK_ENTRY (editable));
1053 if (empathy_contact_is_user (information->contact))
1055 TpAccount * account;
1057 account = empathy_contact_get_account (information->contact);
1058 set_alias_on_account (account, alias);
1062 empathy_contact_set_alias (information->contact, alias);
1070 update_avatar_chooser_account_cb (EmpathyAccountChooser *account_chooser,
1071 EmpathyAvatarChooser *avatar_chooser)
1075 account = empathy_account_chooser_get_account (account_chooser);
1076 if (account == NULL)
1079 empathy_avatar_chooser_set_account (avatar_chooser, account);
1083 contact_widget_avatar_notify_cb (EmpathyContactWidget *information)
1085 EmpathyAvatar *avatar = NULL;
1087 if (information->contact)
1088 avatar = empathy_contact_get_avatar (information->contact);
1090 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
1092 g_signal_handlers_block_by_func (information->widget_avatar,
1093 contact_widget_avatar_changed_cb,
1095 empathy_avatar_chooser_set (
1096 EMPATHY_AVATAR_CHOOSER (information->widget_avatar), avatar);
1097 g_signal_handlers_unblock_by_func (information->widget_avatar,
1098 contact_widget_avatar_changed_cb, information);
1101 empathy_avatar_image_set (
1102 EMPATHY_AVATAR_IMAGE (information->widget_avatar), avatar);
1106 contact_widget_name_notify_cb (EmpathyContactWidget *information)
1108 if (GTK_IS_ENTRY (information->widget_alias))
1109 gtk_entry_set_text (GTK_ENTRY (information->widget_alias),
1110 empathy_contact_get_alias (information->contact));
1112 gtk_label_set_label (GTK_LABEL (information->widget_alias),
1113 empathy_contact_get_alias (information->contact));
1117 contact_widget_presence_notify_cb (EmpathyContactWidget *information)
1119 const gchar *status;
1120 gchar *markup_text = NULL;
1122 status = empathy_contact_get_status (information->contact);
1124 markup_text = empathy_add_link_markup (status);
1125 gtk_label_set_markup (GTK_LABEL (information->label_status), markup_text);
1126 g_free (markup_text);
1128 gtk_image_set_from_icon_name (GTK_IMAGE (information->image_state),
1129 empathy_icon_name_for_contact (information->contact),
1130 GTK_ICON_SIZE_BUTTON);
1131 gtk_widget_show (information->image_state);
1135 contact_widget_favourites_changed_cb (EmpathyContactManager *manager,
1136 EmpathyContact *contact,
1137 gboolean is_favourite,
1138 EmpathyContactWidget *information)
1140 if (contact != information->contact)
1143 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (
1144 information->favourite_checkbox), is_favourite);
1148 contact_widget_remove_contact (EmpathyContactWidget *information)
1150 if (information->contact)
1152 TpContact *tp_contact;
1154 contact_widget_save (information);
1156 g_signal_handlers_disconnect_by_func (information->contact,
1157 contact_widget_name_notify_cb, information);
1158 g_signal_handlers_disconnect_by_func (information->contact,
1159 contact_widget_presence_notify_cb, information);
1160 g_signal_handlers_disconnect_by_func (information->contact,
1161 contact_widget_avatar_notify_cb, information);
1163 tp_contact = empathy_contact_get_tp_contact (information->contact);
1164 if (tp_contact != NULL)
1166 g_signal_handlers_disconnect_by_func (tp_contact,
1167 contact_widget_details_notify_cb, information);
1170 g_object_unref (information->contact);
1171 information->contact = NULL;
1174 if (information->details_cancellable != NULL)
1176 /* The cancellable will be unreffed and cleared in
1177 * contact_widget_details_request_cb */
1178 g_cancellable_cancel (information->details_cancellable);
1182 static void contact_widget_change_contact (EmpathyContactWidget *information);
1185 contact_widget_contact_update (EmpathyContactWidget *information)
1187 TpAccount *account = NULL;
1188 const gchar *id = NULL;
1190 /* Connect and get info from new contact */
1191 if (information->contact)
1193 g_signal_connect_swapped (information->contact, "notify::name",
1194 G_CALLBACK (contact_widget_name_notify_cb), information);
1195 g_signal_connect_swapped (information->contact, "notify::presence",
1196 G_CALLBACK (contact_widget_presence_notify_cb), information);
1197 g_signal_connect_swapped (information->contact,
1198 "notify::presence-message",
1199 G_CALLBACK (contact_widget_presence_notify_cb), information);
1200 g_signal_connect_swapped (information->contact, "notify::avatar",
1201 G_CALLBACK (contact_widget_avatar_notify_cb), information);
1203 account = empathy_contact_get_account (information->contact);
1204 id = empathy_contact_get_id (information->contact);
1207 /* Update account widget */
1208 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
1212 g_signal_handlers_block_by_func (information->widget_account,
1213 contact_widget_change_contact,
1215 empathy_account_chooser_set_account (
1216 EMPATHY_ACCOUNT_CHOOSER (information->widget_account), account);
1217 g_signal_handlers_unblock_by_func (information->widget_account,
1218 contact_widget_change_contact, information);
1227 name = tp_account_get_display_name (account);
1228 gtk_label_set_label (GTK_LABEL (information->label_account), name);
1230 name = tp_account_get_icon_name (account);
1231 gtk_image_set_from_icon_name (GTK_IMAGE (information->image_account),
1232 name, GTK_ICON_SIZE_MENU);
1236 /* Update id widget */
1237 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
1238 gtk_entry_set_text (GTK_ENTRY (information->widget_id), id ? id : "");
1240 gtk_label_set_label (GTK_LABEL (information->widget_id), id ? id : "");
1242 /* Update other widgets */
1243 if (information->contact)
1245 contact_widget_name_notify_cb (information);
1246 contact_widget_presence_notify_cb (information);
1247 contact_widget_avatar_notify_cb (information);
1249 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE)
1251 FolksPersona *persona = empathy_contact_get_persona (
1252 information->contact);
1254 if (persona != NULL && FOLKS_IS_FAVOURITE (persona))
1256 gboolean is_favourite = folks_favourite_get_is_favourite (
1257 FOLKS_FAVOURITE (persona));
1258 contact_widget_favourites_changed_cb (information->manager,
1259 information->contact, is_favourite, information);
1263 gtk_widget_show (information->label_alias);
1264 gtk_widget_show (information->widget_alias);
1265 gtk_widget_show (information->hbox_presence);
1266 gtk_widget_show (information->widget_avatar);
1270 gtk_widget_hide (information->label_alias);
1271 gtk_widget_hide (information->widget_alias);
1272 gtk_widget_hide (information->hbox_presence);
1273 gtk_widget_hide (information->widget_avatar);
1278 contact_widget_set_contact (EmpathyContactWidget *information,
1279 EmpathyContact *contact)
1281 if (contact == information->contact)
1284 contact_widget_remove_contact (information);
1286 information->contact = g_object_ref (contact);
1288 /* set the selected account to be the account this contact came from */
1289 if (contact && EMPATHY_IS_ACCOUNT_CHOOSER (information->widget_account)) {
1290 empathy_account_chooser_set_account (
1291 EMPATHY_ACCOUNT_CHOOSER (information->widget_account),
1292 empathy_contact_get_account (contact));
1295 /* Update information for widgets */
1296 contact_widget_contact_update (information);
1297 contact_widget_groups_update (information);
1298 contact_widget_details_update (information);
1299 contact_widget_client_update (information);
1300 contact_widget_location_update (information);
1304 contact_widget_got_contact_cb (TpConnection *connection,
1305 EmpathyContact *contact,
1306 const GError *error,
1308 GObject *weak_object)
1310 EmpathyContactWidget *information = user_data;
1314 DEBUG ("Error: %s", error->message);
1318 contact_widget_set_contact (information, contact);
1322 contact_widget_change_contact (EmpathyContactWidget *information)
1324 TpConnection *connection;
1326 connection = empathy_account_chooser_get_connection (
1327 EMPATHY_ACCOUNT_CHOOSER (information->widget_account));
1331 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
1335 id = gtk_entry_get_text (GTK_ENTRY (information->widget_id));
1336 if (!EMP_STR_EMPTY (id))
1338 empathy_tp_contact_factory_get_from_id (connection, id,
1339 contact_widget_got_contact_cb, information, NULL,
1340 G_OBJECT (information->vbox_contact_widget));
1345 empathy_tp_contact_factory_get_from_handle (connection,
1346 tp_connection_get_self_handle (connection),
1347 contact_widget_got_contact_cb, information, NULL,
1348 G_OBJECT (information->vbox_contact_widget));
1353 contact_widget_id_activate_timeout (EmpathyContactWidget *self)
1355 contact_widget_change_contact (self);
1360 contact_widget_id_changed_cb (GtkEntry *entry,
1361 EmpathyContactWidget *self)
1363 if (self->widget_id_timeout != 0)
1365 g_source_remove (self->widget_id_timeout);
1368 self->widget_id_timeout =
1369 g_timeout_add_seconds (ID_CHANGED_TIMEOUT,
1370 (GSourceFunc) contact_widget_id_activate_timeout, self);
1374 contact_widget_id_focus_out_cb (GtkWidget *widget,
1375 GdkEventFocus *event,
1376 EmpathyContactWidget *information)
1378 contact_widget_change_contact (information);
1383 favourite_toggled_cb (GtkToggleButton *button,
1384 EmpathyContactWidget *information)
1386 FolksPersona *persona = empathy_contact_get_persona (information->contact);
1388 if (persona != NULL && FOLKS_IS_FAVOURITE (persona))
1390 gboolean active = gtk_toggle_button_get_active (button);
1391 folks_favourite_set_is_favourite (FOLKS_FAVOURITE (persona), active);
1396 contact_widget_contact_setup (EmpathyContactWidget *information)
1398 /* Setup label_status as a KludgeLabel */
1399 information->label_status = empathy_kludge_label_new ("");
1400 gtk_label_set_line_wrap_mode (GTK_LABEL (information->label_status),
1401 PANGO_WRAP_WORD_CHAR);
1402 gtk_label_set_line_wrap (GTK_LABEL (information->label_status),
1405 if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
1406 gtk_label_set_selectable (GTK_LABEL (information->label_status), TRUE);
1408 gtk_box_pack_start (GTK_BOX (information->hbox_presence),
1409 information->label_status, TRUE, TRUE, 0);
1410 gtk_widget_show (information->label_status);
1412 /* Setup account label/chooser */
1413 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
1415 information->widget_account = empathy_account_chooser_new ();
1417 g_signal_connect_swapped (information->widget_account, "changed",
1418 G_CALLBACK (contact_widget_change_contact),
1423 /* Pack the protocol icon with the account name in an hbox */
1424 information->widget_account = gtk_hbox_new (FALSE, 6);
1426 information->label_account = gtk_label_new (NULL);
1427 if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
1428 gtk_label_set_selectable (GTK_LABEL (information->label_account), TRUE);
1430 gtk_misc_set_alignment (GTK_MISC (information->label_account), 0, 0.5);
1431 gtk_widget_show (information->label_account);
1433 information->image_account = gtk_image_new ();
1434 gtk_widget_show (information->image_account);
1436 gtk_box_pack_start (GTK_BOX (information->widget_account),
1437 information->image_account, FALSE, FALSE, 0);
1438 gtk_box_pack_start (GTK_BOX (information->widget_account),
1439 information->label_account, FALSE, TRUE, 0);
1441 gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
1442 information->widget_account,
1444 gtk_widget_show (information->widget_account);
1446 /* Set up avatar chooser/display */
1447 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_AVATAR)
1449 information->widget_avatar = empathy_avatar_chooser_new ();
1450 g_signal_connect (information->widget_avatar, "changed",
1451 G_CALLBACK (contact_widget_avatar_changed_cb),
1453 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT)
1455 g_signal_connect (information->widget_account, "changed",
1456 G_CALLBACK (update_avatar_chooser_account_cb),
1457 information->widget_avatar);
1458 update_avatar_chooser_account_cb (
1459 EMPATHY_ACCOUNT_CHOOSER (information->widget_account),
1460 EMPATHY_AVATAR_CHOOSER (information->widget_avatar));
1465 information->widget_avatar = empathy_avatar_image_new ();
1467 g_signal_connect (information->widget_avatar, "popup-menu",
1468 G_CALLBACK (widget_avatar_popup_menu_cb), information);
1469 g_signal_connect (information->widget_avatar, "button-press-event",
1470 G_CALLBACK (widget_avatar_button_press_event_cb), information);
1473 gtk_box_pack_start (GTK_BOX (information->vbox_avatar),
1474 information->widget_avatar,
1477 gtk_widget_show (information->widget_avatar);
1479 /* Setup id label/entry */
1480 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
1482 information->widget_id = gtk_entry_new ();
1483 g_signal_connect (information->widget_id, "focus-out-event",
1484 G_CALLBACK (contact_widget_id_focus_out_cb),
1486 g_signal_connect (information->widget_id, "changed",
1487 G_CALLBACK (contact_widget_id_changed_cb),
1492 information->widget_id = gtk_label_new (NULL);
1493 if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
1494 gtk_label_set_selectable (GTK_LABEL (information->widget_id), TRUE);
1496 gtk_misc_set_alignment (GTK_MISC (information->widget_id), 0, 0.5);
1498 gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
1499 information->widget_id,
1501 gtk_widget_show (information->widget_id);
1503 /* Setup alias label/entry */
1504 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ALIAS)
1506 information->widget_alias = gtk_entry_new ();
1508 if (!(information->flags & EMPATHY_CONTACT_WIDGET_NO_SET_ALIAS))
1509 g_signal_connect (information->widget_alias, "focus-out-event",
1510 G_CALLBACK (contact_widget_entry_alias_focus_event_cb),
1513 /* Make return activate the window default (the Close button) */
1514 gtk_entry_set_activates_default (GTK_ENTRY (information->widget_alias),
1519 information->widget_alias = gtk_label_new (NULL);
1520 if (!(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP)) {
1521 gtk_label_set_selectable (GTK_LABEL (information->widget_alias), TRUE);
1523 gtk_misc_set_alignment (GTK_MISC (information->widget_alias), 0, 0.5);
1525 gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
1526 information->widget_alias,
1528 if (information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP) {
1529 gtk_label_set_selectable (GTK_LABEL (information->label_status), FALSE);
1531 gtk_widget_show (information->widget_alias);
1534 if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE)
1536 information->favourite_checkbox = gtk_check_button_new_with_label (
1539 g_signal_connect (information->favourite_checkbox, "toggled",
1540 G_CALLBACK (favourite_toggled_cb), information);
1542 gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
1543 information->favourite_checkbox, 0, 2, 3, 4);
1545 information->fav_sig_id = g_signal_connect (information->manager,
1546 "favourites-changed",
1547 G_CALLBACK (contact_widget_favourites_changed_cb), information);
1549 gtk_widget_show (information->favourite_checkbox);
1554 contact_widget_destroy_cb (GtkWidget *widget,
1555 EmpathyContactWidget *information)
1557 contact_widget_remove_contact (information);
1559 if (information->widget_id_timeout != 0)
1561 g_source_remove (information->widget_id_timeout);
1564 if (information->fav_sig_id != 0)
1565 g_signal_handler_disconnect (information->manager, information->fav_sig_id);
1567 g_object_unref (information->manager);
1569 g_slice_free (EmpathyContactWidget, information);
1573 * empathy_contact_widget_new:
1574 * @contact: an #EmpathyContact
1575 * @flags: #EmpathyContactWidgetFlags for the new contact widget
1577 * Creates a new #EmpathyContactWidget.
1579 * Return value: a new #EmpathyContactWidget
1582 empathy_contact_widget_new (EmpathyContact *contact,
1583 EmpathyContactWidgetFlags flags)
1585 EmpathyContactWidget *information;
1589 g_return_val_if_fail (contact == NULL || EMPATHY_IS_CONTACT (contact), NULL);
1591 information = g_slice_new0 (EmpathyContactWidget);
1592 information->flags = flags;
1594 filename = empathy_file_lookup ("empathy-contact-widget.ui",
1596 gui = empathy_builder_get_file (filename,
1597 "vbox_contact_widget", &information->vbox_contact_widget,
1598 "hbox_contact", &information->hbox_contact,
1599 "hbox_presence", &information->hbox_presence,
1600 "label_alias", &information->label_alias,
1601 "image_state", &information->image_state,
1602 "table_contact", &information->table_contact,
1603 "vbox_avatar", &information->vbox_avatar,
1604 "vbox_location", &information->vbox_location,
1605 "subvbox_location", &information->subvbox_location,
1606 "label_location", &information->label_location,
1607 #ifdef HAVE_LIBCHAMPLAIN
1608 "viewport_map", &information->viewport_map,
1610 "groups_widget", &information->groups_widget,
1611 "vbox_details", &information->vbox_details,
1612 "table_details", &information->table_details,
1613 "hbox_details_requested", &information->hbox_details_requested,
1614 "vbox_client", &information->vbox_client,
1615 "table_client", &information->table_client,
1616 "hbox_client_requested", &information->hbox_client_requested,
1620 empathy_builder_connect (gui, information,
1621 "vbox_contact_widget", "destroy", contact_widget_destroy_cb,
1623 information->table_location = NULL;
1625 g_object_set_data (G_OBJECT (information->vbox_contact_widget),
1626 "EmpathyContactWidget",
1629 information->manager = empathy_contact_manager_dup_singleton ();
1631 /* Create widgets */
1632 contact_widget_contact_setup (information);
1633 contact_widget_details_setup (information);
1634 contact_widget_client_setup (information);
1636 if (contact != NULL)
1637 contact_widget_set_contact (information, contact);
1638 else if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT ||
1639 information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ID)
1640 contact_widget_change_contact (information);
1642 return empathy_builder_unref_and_keep_widget (gui,
1643 information->vbox_contact_widget);
1647 * empathy_contact_widget_get_contact:
1648 * @widget: an #EmpathyContactWidget
1650 * Get the #EmpathyContact related with the #EmpathyContactWidget @widget.
1652 * Returns: the #EmpathyContact associated with @widget
1655 empathy_contact_widget_get_contact (GtkWidget *widget)
1657 EmpathyContactWidget *information;
1659 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
1661 information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
1665 return information->contact;
1669 empathy_contact_widget_get_alias (GtkWidget *widget)
1671 EmpathyContactWidget *information;
1673 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
1675 information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
1679 return gtk_entry_get_text (GTK_ENTRY (information->widget_alias));
1683 * empathy_contact_widget_set_contact:
1684 * @widget: an #EmpathyContactWidget
1685 * @contact: a different #EmpathyContact
1687 * Change the #EmpathyContact related with the #EmpathyContactWidget @widget.
1690 empathy_contact_widget_set_contact (GtkWidget *widget,
1691 EmpathyContact *contact)
1693 EmpathyContactWidget *information;
1695 g_return_if_fail (GTK_IS_WIDGET (widget));
1696 g_return_if_fail (EMPATHY_IS_CONTACT (contact));
1698 information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
1702 contact_widget_set_contact (information, contact);
1706 * empathy_contact_widget_set_account_filter:
1707 * @widget: an #EmpathyContactWidget
1708 * @filter: a #EmpathyAccountChooserFilterFunc
1709 * @user_data: user data to pass to @filter, or %NULL
1711 * Set a filter on the #EmpathyAccountChooser included in the
1712 * #EmpathyContactWidget.
1715 empathy_contact_widget_set_account_filter (
1717 EmpathyAccountChooserFilterFunc filter,
1720 EmpathyContactWidget *information;
1721 EmpathyAccountChooser *chooser;
1723 g_return_if_fail (GTK_IS_WIDGET (widget));
1725 information = g_object_get_data (G_OBJECT (widget), "EmpathyContactWidget");
1729 chooser = EMPATHY_ACCOUNT_CHOOSER (information->widget_account);
1731 empathy_account_chooser_set_filter (chooser, filter, user_data);