From cf5784fe3e77bedfe25f3b31dff6eb92e7a580ee Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Thu, 3 Sep 2009 16:18:39 +0200 Subject: Add a Best fit button to the map view (#584034) Add a button to the contact map view which show all the contacts at once. --- src/empathy-map-view.c | 23 +++++++++++++++++++++++ src/empathy-map-view.ui | 10 ++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/empathy-map-view.c b/src/empathy-map-view.c index 9eadee756..95fdabd44 100644 --- a/src/empathy-map-view.c +++ b/src/empathy-map-view.c @@ -130,6 +130,28 @@ map_view_zoom_out_cb (GtkWidget *widget, champlain_view_zoom_out (window->map_view); } +static void +map_view_zoom_fit_cb (GtkWidget *widget, + EmpathyMapView *window) +{ + GList *item, *children; + GPtrArray *markers; + + children = clutter_container_get_children (CLUTTER_CONTAINER (window->layer)); + markers = g_ptr_array_sized_new (g_list_length (children) + 1); + + for (item = children; item != NULL; item = g_list_next (item)) + g_ptr_array_add (markers, (gpointer) item->data); + + g_ptr_array_add (markers, (gpointer) NULL); + champlain_view_ensure_markers_visible (window->map_view, + (ChamplainBaseMarker **) markers->pdata, + TRUE); + + g_ptr_array_free (markers, TRUE); + g_list_free (children); +} + static gboolean marker_clicked_cb (ChamplainMarker *marker, ClutterButtonEvent *event, @@ -332,6 +354,7 @@ empathy_map_view_show (void) "map_view", "destroy", map_view_destroy_cb, "zoom_in", "clicked", map_view_zoom_in_cb, "zoom_out", "clicked", map_view_zoom_out_cb, + "zoom_fit", "clicked", map_view_zoom_fit_cb, NULL); g_object_unref (gui); diff --git a/src/empathy-map-view.ui b/src/empathy-map-view.ui index 7d3e3cefc..a56090e0e 100644 --- a/src/empathy-map-view.ui +++ b/src/empathy-map-view.ui @@ -34,6 +34,16 @@ True + + + True + gtk-zoom-fit + + + False + True + + True -- cgit v1.2.3