#include "empathy-avatar-chooser.h"
#include "empathy-avatar-image.h"
#include "empathy-ui-utils.h"
+#include "empathy-string-parser.h"
#include "empathy-kludge-label.h"
#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
EmpathyContact *contact;
EmpathyContactWidgetFlags flags;
guint widget_id_timeout;
+ gulong fav_sig_id;
GtkWidget *vbox_contact_widget;
GtkWidget *label_status;
GtkWidget *table_contact;
GtkWidget *vbox_avatar;
+ GtkWidget *favourite_checkbox;
/* Location */
GtkWidget *vbox_location;
{
if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_GROUPS)
{
- information->manager = empathy_contact_manager_dup_singleton ();
contact_widget_model_setup (information);
}
}
};
int i;
const gchar *skey;
+ gboolean display_map = FALSE;
if (!(information->flags & EMPATHY_CONTACT_WIDGET_SHOW_LOCATION))
{
row++;
}
- if (row == 0)
+#if HAVE_LIBCHAMPLAIN
+ if (has_position &&
+ !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
+ {
+ /* Cannot be displayed in tooltips until Clutter-Gtk can deal with such
+ * windows */
+ display_map = TRUE;
+ }
+#endif
+
+ if (row > 0)
{
+ /* We can display some fields */
+ gtk_widget_show (information->table_location);
+ }
+ else if (!display_map)
+ {
+ /* Can't display either fields or map */
gtk_widget_hide (information->vbox_location);
return;
}
- gtk_widget_show (information->table_location);
-
#if HAVE_LIBCHAMPLAIN
- /* Cannot be displayed in tooltips until Clutter-Gtk can deal with such
- * windows
- */
- if (has_position &&
- !(information->flags & EMPATHY_CONTACT_WIDGET_FOR_TOOLTIP))
+ if (display_map)
{
ClutterActor *marker;
ChamplainLayer *layer;
gtk_container_add (GTK_CONTAINER (information->viewport_map),
information->map_view_embed);
- g_object_set (G_OBJECT (information->map_view), "show-license", FALSE,
+ g_object_set (G_OBJECT (information->map_view),
+ "show-license", TRUE,
"scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
+ "zoom-level", 10,
NULL);
layer = champlain_layer_new ();
static void
contact_widget_presence_notify_cb (EmpathyContactWidget *information)
{
- gtk_label_set_text (GTK_LABEL (information->label_status),
- empathy_contact_get_status (information->contact));
+ const gchar *status;
+ gchar *markup_text = NULL;
+
+ status = empathy_contact_get_status (information->contact);
+ if (status != NULL)
+ markup_text = empathy_add_link_markup (status);
+ gtk_label_set_markup (GTK_LABEL (information->label_status), markup_text);
+ g_free (markup_text);
+
gtk_image_set_from_icon_name (GTK_IMAGE (information->image_state),
empathy_icon_name_for_contact (information->contact),
GTK_ICON_SIZE_BUTTON);
gtk_widget_show (information->image_state);
}
+#if HAVE_FAVOURITE_CONTACTS
+static void
+contact_widget_favourites_changed_cb (EmpathyContactManager *manager,
+ EmpathyContact *contact,
+ gboolean is_favourite,
+ EmpathyContactWidget *information)
+{
+ if (contact != information->contact)
+ return;
+
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (
+ information->favourite_checkbox), is_favourite);
+}
+#endif
+
static void
contact_widget_remove_contact (EmpathyContactWidget *information)
{
contact_widget_presence_notify_cb (information);
contact_widget_avatar_notify_cb (information);
+#if HAVE_FAVOURITE_CONTACTS
+ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE)
+ {
+ gboolean is_favourite;
+
+ is_favourite = empathy_contact_list_is_favourite (
+ EMPATHY_CONTACT_LIST (information->manager),
+ information->contact);
+
+ contact_widget_favourites_changed_cb (information->manager,
+ information->contact, is_favourite, information);
+ }
+#endif
+
gtk_widget_show (information->label_alias);
gtk_widget_show (information->widget_alias);
gtk_widget_show (information->hbox_presence);
return FALSE;
}
+#if HAVE_FAVOURITE_CONTACTS
+static void
+favourite_toggled_cb (GtkToggleButton *button,
+ EmpathyContactWidget *information)
+{
+ gboolean active;
+
+ active = gtk_toggle_button_get_active (button);
+
+ if (active)
+ {
+ empathy_contact_list_add_to_favourites (
+ EMPATHY_CONTACT_LIST (information->manager), information->contact);
+ }
+ else
+ {
+ empathy_contact_list_remove_from_favourites (
+ EMPATHY_CONTACT_LIST (information->manager), information->contact);
+ }
+}
+#endif
+
static void
contact_widget_contact_setup (EmpathyContactWidget *information)
{
gtk_label_set_selectable (GTK_LABEL (information->label_status), FALSE);
}
gtk_widget_show (information->widget_alias);
+
+#if HAVE_FAVOURITE_CONTACTS
+ /* Favorite */
+ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_FAVOURITE)
+ {
+ information->favourite_checkbox = gtk_check_button_new_with_label (
+ _("Favorite"));
+
+ g_signal_connect (information->favourite_checkbox, "toggled",
+ G_CALLBACK (favourite_toggled_cb), information);
+
+ gtk_table_attach_defaults (GTK_TABLE (information->table_contact),
+ information->favourite_checkbox, 0, 2, 3, 4);
+
+ information->fav_sig_id = g_signal_connect (information->manager,
+ "favourites-changed",
+ G_CALLBACK (contact_widget_favourites_changed_cb), information);
+
+ gtk_widget_show (information->favourite_checkbox);
+ }
+#endif
}
static void
{
g_source_remove (information->widget_id_timeout);
}
- if (information->manager)
- {
- g_object_unref (information->manager);
- }
+
+ if (information->fav_sig_id != 0)
+ g_signal_handler_disconnect (information->manager, information->fav_sig_id);
+
+ g_object_unref (information->manager);
g_slice_free (EmpathyContactWidget, information);
}
"EmpathyContactWidget",
information);
+ information->manager = empathy_contact_manager_dup_singleton ();
+
/* Create widgets */
contact_widget_contact_setup (information);
contact_widget_groups_setup (information);