From 0513f2521e2bed5451053d8dcf2fbe89f97f41c5 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 26 Mar 2010 16:14:56 +0100 Subject: map-view: display position of contacts added after the map has been created (#614012) --- src/empathy-map-view.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src') diff --git a/src/empathy-map-view.c b/src/empathy-map-view.c index 11e0f0485..30c123b26 100644 --- a/src/empathy-map-view.c +++ b/src/empathy-map-view.c @@ -58,6 +58,7 @@ typedef struct { guint timeout_id; /* reffed (EmpathyContact *) => borrowed (ChamplainMarker *) */ GHashTable *markers; + gulong members_changed_id; } EmpathyMapView; static void @@ -327,6 +328,7 @@ map_view_destroy_cb (GtkWidget *widget, { GHashTableIter iter; gpointer contact; + EmpathyContactList *list_iface; g_source_remove (window->timeout_id); @@ -335,6 +337,9 @@ map_view_destroy_cb (GtkWidget *widget, g_signal_handlers_disconnect_by_func (contact, map_view_contact_location_notify, window); + list_iface = empathy_contact_list_store_get_list_iface (window->list_store); + g_signal_handler_disconnect (list_iface, window->members_changed_id); + g_hash_table_destroy (window->markers); g_object_unref (window->list_store); g_object_unref (window->layer); @@ -369,6 +374,39 @@ map_view_tick (EmpathyMapView *window) return TRUE; } +static void +contact_removed (EmpathyMapView *self, + EmpathyContact *contact) +{ + ClutterActor *marker; + + marker = g_hash_table_lookup (self->markers, contact); + if (marker == NULL) + return; + + clutter_actor_destroy (marker); + g_hash_table_remove (self->markers, contact); +} + +static void +members_changed_cb (EmpathyContactList *list, + EmpathyContact *contact, + EmpathyContact *actor, + guint reason, + gchar *message, + gboolean is_member, + EmpathyMapView *self) +{ + if (is_member) + { + contact_added (self, contact); + } + else + { + contact_removed (self, contact); + } +} + GtkWidget * empathy_map_view_show (void) { @@ -420,6 +458,9 @@ empathy_map_view_show (void) empathy_contact_list_store_set_show_avatars (list_store, TRUE); g_object_unref (list_iface); + window->members_changed_id = g_signal_connect (list_iface, "members-changed", + G_CALLBACK (members_changed_cb), window); + window->throbber = ephy_spinner_new (); ephy_spinner_set_size (EPHY_SPINNER (window->throbber), GTK_ICON_SIZE_LARGE_TOOLBAR); -- cgit v1.2.3