summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-02-17 15:29:03 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-02-21 10:17:49 +0100
commit1629b3b04f38eb748ae8385e407e01bfaf312a63 (patch)
tree612502aee7dfeecd1a5419416f3bd4ee7b920297
parent932d46f051bbfbf144dcb063849e4f285daa8586 (diff)
downloadempathy-1629b3b04f38eb748ae8385e407e01bfaf312a63.tar.gz
Port to champlain 0.10 (#642010)
-rw-r--r--configure.ac9
-rw-r--r--libempathy-gtk/empathy-contact-widget.c15
-rw-r--r--libempathy-gtk/empathy-individual-widget.c29
-rw-r--r--src/empathy-map-view.c96
4 files changed, 68 insertions, 81 deletions
diff --git a/configure.ac b/configure.ac
index b1234b068..c7d18a0ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,7 +49,7 @@ ENCHANT_REQUIRED=1.2.0
GEOCLUE_REQUIRED=0.11
ISO_CODES_REQUIRED=0.35
LIBCHAMPLAIN_GTK_REQUIRED=0.7.1
-LIBCHAMPLAIN_REQUIRED=0.7.1
+LIBCHAMPLAIN_REQUIRED=0.9
NAUTILUS_SENDTO_REQUIRED=2.90.0
NETWORK_MANAGER_REQUIRED=0.7.0
WEBKIT_REQUIRED=1.3.2
@@ -328,10 +328,9 @@ if test "x$enable_map" != "xno"; then
PKG_CHECK_MODULES(LIBCHAMPLAIN,
[
- champlain-0.8 >= $LIBCHAMPLAIN_REQUIRED,
-# champplain-gtk3 doesn't exist. Fix the name once bgo #631009
- champlain-gtk3-0.8 >= $LIBCHAMPLAIN_GTK_REQUIRED
- clutter-gtk >= $CLUTTER_GTK_REQUIRED
+ champlain-0.10
+ champlain-gtk-0.10
+ clutter-gtk-1.0
], have_libchamplain="yes", have_libchamplain="no")
if test "x$have_libchamplain" = "xyes"; then
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 3e4dc845a..410b59f00 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -946,7 +946,7 @@ contact_widget_location_update (EmpathyContactWidget *information)
if (display_map)
{
ClutterActor *marker;
- ChamplainLayer *layer;
+ ChamplainMarkerLayer *layer;
information->map_view_embed = gtk_champlain_embed_new ();
information->map_view = gtk_champlain_embed_get_view (
@@ -955,18 +955,17 @@ contact_widget_location_update (EmpathyContactWidget *information)
gtk_container_add (GTK_CONTAINER (information->viewport_map),
information->map_view_embed);
g_object_set (G_OBJECT (information->map_view),
- "show-license", TRUE,
- "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
+ "kinetic-mode", TRUE,
"zoom-level", 10,
NULL);
- layer = champlain_layer_new ();
- champlain_view_add_layer (information->map_view, layer);
+ layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_NONE);
+ champlain_view_add_layer (information->map_view, CHAMPLAIN_LAYER (layer));
- marker = champlain_marker_new_with_text (
+ marker = champlain_label_new_with_text (
empathy_contact_get_alias (information->contact), NULL, NULL, NULL);
- champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), lat, lon);
- clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
+ champlain_location_set_location (CHAMPLAIN_LOCATION (marker), lat, lon);
+ champlain_marker_layer_add_marker (layer, CHAMPLAIN_MARKER (marker));
champlain_view_center_on (information->map_view, lat, lon);
gtk_widget_show_all (information->viewport_map);
diff --git a/libempathy-gtk/empathy-individual-widget.c b/libempathy-gtk/empathy-individual-widget.c
index 35e12dbe2..8ca5c0f73 100644
--- a/libempathy-gtk/empathy-individual-widget.c
+++ b/libempathy-gtk/empathy-individual-widget.c
@@ -728,8 +728,8 @@ location_update (EmpathyIndividualWidget *self)
#ifdef HAVE_LIBCHAMPLAIN
if (display_map == TRUE)
{
- GPtrArray *markers;
- ChamplainLayer *layer;
+ ChamplainMarkerLayer *layer;
+ ChamplainBoundingBox *bbox;
priv->map_view_embed = gtk_champlain_embed_new ();
priv->map_view = gtk_champlain_embed_get_view (
@@ -738,14 +738,12 @@ location_update (EmpathyIndividualWidget *self)
gtk_container_add (GTK_CONTAINER (priv->viewport_map),
priv->map_view_embed);
g_object_set (G_OBJECT (priv->map_view),
- "show-license", TRUE,
- "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
+ "kinetic-mode", TRUE,
"zoom-level", 10,
NULL);
- layer = champlain_layer_new ();
- champlain_view_add_layer (priv->map_view, layer);
- markers = g_ptr_array_new ();
+ layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_NONE);
+ champlain_view_add_layer (priv->map_view, CHAMPLAIN_LAYER (layer));
/* FIXME: For now, we have to do this manually. Once libfolks grows a
* location interface, we can use that. (bgo#627400) */
@@ -793,24 +791,21 @@ location_update (EmpathyIndividualWidget *self)
lon = g_value_get_double (value);
/* Add a marker to the map */
- marker = champlain_marker_new_with_text (
+ marker = champlain_label_new_with_text (
folks_aliasable_get_alias (FOLKS_ALIASABLE (persona)), NULL,
NULL, NULL);
- champlain_base_marker_set_position (
- CHAMPLAIN_BASE_MARKER (marker), lat, lon);
- clutter_container_add (CLUTTER_CONTAINER (layer), marker, NULL);
-
- g_ptr_array_add (markers, marker);
+ champlain_location_set_location (CHAMPLAIN_LOCATION (marker),
+ lat, lon);
+ champlain_marker_layer_add_marker (layer,
+ CHAMPLAIN_MARKER (marker));
g_object_unref (contact);
}
}
/* Zoom to show all of the markers */
- g_ptr_array_add (markers, NULL); /* NULL-terminate the array */
- champlain_view_ensure_markers_visible (priv->map_view,
- (ChamplainBaseMarker **) markers->pdata, FALSE);
- g_ptr_array_free (markers, TRUE);
+ bbox = champlain_layer_get_bounding_box (CHAMPLAIN_LAYER (layer));
+ champlain_view_ensure_visible (priv->map_view, bbox, FALSE);
gtk_widget_show_all (priv->viewport_map);
}
diff --git a/src/empathy-map-view.c b/src/empathy-map-view.c
index 9aa8108ba..626d83067 100644
--- a/src/empathy-map-view.c
+++ b/src/empathy-map-view.c
@@ -54,7 +54,7 @@ struct _EmpathyMapViewPriv {
GtkWidget *zoom_out;
GtkWidget *throbber;
ChamplainView *map_view;
- ChamplainLayer *layer;
+ ChamplainMarkerLayer *layer;
guint timeout_id;
/* reffed (EmpathyContact *) => borrowed (ChamplainMarker *) */
GHashTable *markers;
@@ -95,7 +95,7 @@ contact_has_location (EmpathyContact *contact)
return TRUE;
}
-static ChamplainMarker * create_marker (EmpathyMapView *window,
+static ClutterActor * create_marker (EmpathyMapView *window,
EmpathyContact *contact);
static void
@@ -106,7 +106,7 @@ map_view_update_contact_position (EmpathyMapView *self,
gdouble lon, lat;
GValue *value;
GHashTable *location;
- ChamplainMarker *marker;
+ ClutterActor *marker;
gboolean has_location;
has_location = contact_has_location (contact);
@@ -121,7 +121,7 @@ map_view_update_contact_position (EmpathyMapView *self,
}
else if (!has_location)
{
- champlain_base_marker_animate_out (CHAMPLAIN_BASE_MARKER (marker));
+ champlain_marker_animate_out (CHAMPLAIN_MARKER (marker));
return;
}
@@ -130,7 +130,7 @@ map_view_update_contact_position (EmpathyMapView *self,
value = g_hash_table_lookup (location, EMPATHY_LOCATION_LAT);
if (value == NULL)
{
- clutter_actor_hide (CLUTTER_ACTOR (marker));
+ clutter_actor_hide (marker);
return;
}
lat = g_value_get_double (value);
@@ -138,13 +138,13 @@ map_view_update_contact_position (EmpathyMapView *self,
value = g_hash_table_lookup (location, EMPATHY_LOCATION_LON);
if (value == NULL)
{
- clutter_actor_hide (CLUTTER_ACTOR (marker));
+ clutter_actor_hide (marker);
return;
}
lon = g_value_get_double (value);
- champlain_base_marker_set_position (CHAMPLAIN_BASE_MARKER (marker), lat, lon);
- champlain_base_marker_animate_in (CHAMPLAIN_BASE_MARKER (marker));
+ champlain_location_set_location (CHAMPLAIN_LOCATION (marker), lat, lon);
+ champlain_marker_animate_in (CHAMPLAIN_MARKER (marker));
}
static void
@@ -178,34 +178,25 @@ map_view_zoom_fit_cb (GtkWidget *widget,
EmpathyMapView *self)
{
EmpathyMapViewPriv *priv = GET_PRIV (self);
- GList *item, *children;
- GPtrArray *markers;
-
- children = clutter_container_get_children (CLUTTER_CONTAINER (priv->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 (priv->map_view,
- (ChamplainBaseMarker **) markers->pdata,
- TRUE);
+ ChamplainBoundingBox *bbox;
- g_ptr_array_free (markers, TRUE);
- g_list_free (children);
+ bbox = champlain_layer_get_bounding_box (CHAMPLAIN_LAYER (priv->layer));
+ champlain_view_ensure_visible (priv->map_view, bbox, TRUE);
}
static gboolean
marker_clicked_cb (ChamplainMarker *marker,
ClutterButtonEvent *event,
- EmpathyContact *contact)
+ EmpathyMapView *self)
{
GtkWidget *menu;
+ EmpathyContact *contact;
if (event->button != 3)
return FALSE;
+ contact = g_object_get_data (G_OBJECT (marker), "contact");
+
menu = empathy_contact_menu_new (contact,
EMPATHY_CONTACT_FEATURE_CHAT |
EMPATHY_CONTACT_FEATURE_CALL |
@@ -216,17 +207,17 @@ marker_clicked_cb (ChamplainMarker *marker,
if (menu == NULL)
return FALSE;
+ gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (self), NULL);
+
gtk_widget_show (menu);
gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL,
event->button, event->time);
- g_object_ref_sink (menu);
- g_object_unref (menu);
return FALSE;
}
static void
-map_view_contacts_update_label (ChamplainMarker *marker)
+map_view_contacts_update_label (ClutterActor *marker)
{
const gchar *name;
gchar *date;
@@ -254,58 +245,58 @@ map_view_contacts_update_label (ChamplainMarker *marker)
/* if location is older than a week */
if (now - loctime > (60 * 60 * 24 * 7))
- clutter_actor_set_opacity (CLUTTER_ACTOR (marker), 0.75 * 255);
+ clutter_actor_set_opacity (marker, 0.75 * 255);
}
else
{
label = g_strconcat ("<b>", name, "</b>\n", NULL);
}
- champlain_marker_set_use_markup (CHAMPLAIN_MARKER (marker), TRUE);
- champlain_marker_set_text (CHAMPLAIN_MARKER (marker), label);
+ champlain_label_set_use_markup (CHAMPLAIN_LABEL (marker), TRUE);
+ champlain_label_set_text (CHAMPLAIN_LABEL (marker), label);
g_free (label);
}
-static ChamplainMarker *
+static ClutterActor *
create_marker (EmpathyMapView *self,
EmpathyContact *contact)
{
EmpathyMapViewPriv *priv = GET_PRIV (self);
ClutterActor *marker;
- ClutterActor *texture;
GdkPixbuf *avatar;
-
- marker = champlain_marker_new ();
+ ClutterActor *texture = NULL;
avatar = empathy_pixbuf_avatar_from_contact_scaled (contact, 32, 32);
if (avatar != NULL)
{
- texture = clutter_texture_new ();
- gtk_clutter_texture_set_from_pixbuf (CLUTTER_TEXTURE (texture), avatar,
- NULL);
- champlain_marker_set_image (CHAMPLAIN_MARKER (marker), texture);
+ texture = gtk_clutter_texture_new ();
+
+ gtk_clutter_texture_set_from_pixbuf (GTK_CLUTTER_TEXTURE (texture),
+ avatar, NULL);
+
g_object_unref (avatar);
}
- else
- champlain_marker_set_image (CHAMPLAIN_MARKER (marker), NULL);
+
+ marker = champlain_label_new_with_image (texture);
g_object_set_data_full (G_OBJECT (marker), "contact",
g_object_ref (contact), g_object_unref);
g_hash_table_insert (priv->markers, g_object_ref (contact), marker);
- map_view_contacts_update_label (CHAMPLAIN_MARKER (marker));
+ map_view_contacts_update_label (marker);
clutter_actor_set_reactive (CLUTTER_ACTOR (marker), TRUE);
g_signal_connect (marker, "button-release-event",
- G_CALLBACK (marker_clicked_cb), contact);
+ G_CALLBACK (marker_clicked_cb), self);
- clutter_container_add (CLUTTER_CONTAINER (priv->layer), marker, NULL);
+ champlain_marker_layer_add_marker (priv->layer, CHAMPLAIN_MARKER (marker));
DEBUG ("Create marker for %s", empathy_contact_get_id (contact));
- return CHAMPLAIN_MARKER (marker);
+ tp_clear_object (&texture);
+ return marker;
}
static void
@@ -323,8 +314,8 @@ map_view_key_press_cb (GtkWidget *widget,
GdkEventKey *event,
gpointer user_data)
{
- if ((event->state & GDK_CONTROL_MASK && event->keyval == GDK_w)
- || event->keyval == GDK_Escape)
+ if ((event->state & GDK_CONTROL_MASK && event->keyval == GDK_KEY_w)
+ || event->keyval == GDK_KEY_Escape)
{
gtk_widget_destroy (widget);
return TRUE;
@@ -339,7 +330,7 @@ map_view_tick (EmpathyMapView *self)
EmpathyMapViewPriv *priv = GET_PRIV (self);
GList *marker, *l;
- marker = clutter_container_get_children (CLUTTER_CONTAINER (priv->layer));
+ marker = champlain_marker_layer_get_markers (priv->layer);
for (l = marker; l != NULL; l = g_list_next (l))
map_view_contacts_update_label (l->data);
@@ -492,15 +483,18 @@ empathy_map_view_init (EmpathyMapView *self)
/* Set up map view */
embed = gtk_champlain_embed_new ();
priv->map_view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (embed));
- g_object_set (G_OBJECT (priv->map_view), "zoom-level", 1,
- "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC, NULL);
+ g_object_set (G_OBJECT (priv->map_view),
+ "zoom-level", 1,
+ "kinetic-mode", TRUE,
+ NULL);
champlain_view_center_on (priv->map_view, 36, 0);
gtk_container_add (GTK_CONTAINER (sw), embed);
gtk_widget_show_all (embed);
- priv->layer = g_object_ref (champlain_layer_new ());
- champlain_view_add_layer (priv->map_view, priv->layer);
+ priv->layer = g_object_ref (champlain_marker_layer_new_full (
+ CHAMPLAIN_SELECTION_NONE));
+ champlain_view_add_layer (priv->map_view, CHAMPLAIN_LAYER (priv->layer));
g_signal_connect (priv->map_view, "notify::state",
G_CALLBACK (map_view_state_changed), self);