void gourmap_ui_update_map (GourmapUi *ui, const double my_lat, const double my_lng, const double center_lat, const double center_lng, GList *poi_list) { GourmapUiPrivate *priv = GET_PRIVATE (ui); ClutterActor *marker; ClutterColor *color; Restaurant *rest; GList *list_i; /* remove previous markers */ champlain_marker_layer_remove_all (priv->marker_layer); champlain_view_set_zoom_level (priv->champ_view, priv->zoom); champlain_view_go_to (priv->champ_view, my_lat, my_lng); color = clutter_color_new (0xff, 0x20, 0x15, 0xbb); marker = champlain_label_new_with_text (_("I'm here"), "Serif 14", NULL, color); clutter_color_free (color); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), my_lat, my_lng); champlain_marker_layer_add_marker (priv->marker_layer, CHAMPLAIN_MARKER (marker)); /* Put restaurant markers */ list_i = poi_list; color = clutter_color_new (0xff, 0x20, 0xff, 0xbb); while (list_i != NULL) { rest = (Restaurant *)list_i->data; marker = champlain_label_new_with_text (rest->name, "Serif 10", NULL, color); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), rest->latitude, rest->longitude); champlain_marker_layer_add_marker (priv->marker_layer, CHAMPLAIN_MARKER (marker)); list_i = g_list_next (list_i); } clutter_color_free (color); champlain_marker_layer_show_all_markers (priv->marker_layer); }
static void create_marker (EogImage *image, EogMapPlugin *plugin) { gdouble lon, lat; if (!image) return; if (!eog_image_has_data (image, EOG_IMAGE_DATA_EXIF) && !eog_image_load (image, EOG_IMAGE_DATA_EXIF, NULL, NULL)) return; if (get_coordinates (image, &lat, &lon)) { ChamplainLabel *marker; marker = CHAMPLAIN_LABEL (champlain_label_new ()); champlain_label_set_draw_background (CHAMPLAIN_LABEL (marker), FALSE); update_marker_image (marker, GTK_ICON_SIZE_MENU); g_object_set_data_full (G_OBJECT (image), "marker", marker, (GDestroyNotify) clutter_actor_destroy); g_object_set_data (G_OBJECT (marker), "image", image); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), lat, lon); champlain_marker_layer_add_marker (plugin->layer, CHAMPLAIN_MARKER (marker)); g_signal_connect (marker, "button-release-event", G_CALLBACK (change_image), plugin); } }
static void draw_background (BixiMarker *marker, gint radius) { BixiMarkerPrivate *priv = marker->priv; ClutterActor *bg = NULL; ClutterColor color; ClutterColor darker_color; gboolean highlighted = FALSE; guint line_width = 1; cairo_t *cr; bg = clutter_cairo_texture_new (radius * 2, radius * 2); cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg)); color = *champlain_marker_get_color (CHAMPLAIN_MARKER (marker)); if (priv->value == 0) color.alpha = 128; g_object_get (marker, "highlighted", &highlighted, NULL); if (highlighted) { #if CHAMPLAIN_CHECK_VERSION(0, 4, 1) color = *champlain_marker_get_highlight_color (); #else line_width *= 3; #endif } clutter_color_darken (&color, &darker_color); draw_box (cr, radius); cairo_set_source_rgba (cr, color.red / 255.0, color.green / 255.0, color.blue / 255.0, color.alpha / 255.0); cairo_fill_preserve (cr); cairo_set_line_width (cr, line_width); cairo_set_source_rgba (cr, darker_color.red / 255.0, darker_color.green / 255.0, darker_color.blue / 255.0, darker_color.alpha / 255.0); cairo_stroke (cr); cairo_destroy (cr); clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg); if (priv->background != NULL) { clutter_container_remove_actor (CLUTTER_CONTAINER (marker), priv->background); g_object_unref (priv->background); } priv->background = g_object_ref (bg); }
static gboolean remove_marker (gpointer key, gpointer value, gpointer user_data) { ChamplainMarkerLayer *layer; layer = user_data; champlain_marker_layer_remove_marker (layer, CHAMPLAIN_MARKER (value)); return TRUE; }
int main (int argc, char *argv[]) { ClutterActor *actor, *marker, *stage; ChamplainMarkerLayer *layer; GpsCallbackData callback_data; if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; stage = clutter_stage_new (); clutter_actor_set_size (stage, 800, 600); g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL); /* Create the map view */ actor = champlain_view_new (); clutter_actor_set_size (CLUTTER_ACTOR (actor), 800, 600); clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor); /* Create the marker layer */ layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_SINGLE); clutter_actor_show (CLUTTER_ACTOR (layer)); champlain_view_add_layer (CHAMPLAIN_VIEW (actor), CHAMPLAIN_LAYER (layer)); /* Create a marker */ marker = create_marker (); champlain_marker_layer_add_marker (layer, CHAMPLAIN_MARKER (marker)); /* Finish initialising the map view */ g_object_set (G_OBJECT (actor), "zoom-level", 12, "kinetic-mode", TRUE, NULL); champlain_view_center_on (CHAMPLAIN_VIEW (actor), lat, lon); /* Create callback that updates the map periodically */ callback_data.view = CHAMPLAIN_VIEW (actor); callback_data.marker = CHAMPLAIN_MARKER (marker); g_timeout_add (1000, (GSourceFunc) gps_callback, &callback_data); clutter_actor_show (stage); clutter_main (); return 0; }
static void gth_map_view_init (GthMapView *self) { ClutterActor *scale; self->priv = GTH_MAP_VIEW_GET_PRIVATE (self); gtk_box_set_spacing (GTK_BOX (self), 6); gtk_container_set_border_width (GTK_CONTAINER (self), 2); gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL); /* No GPS label */ self->priv->no_gps_label = gtk_label_new (_("The geographical position information is not available for this image.")); g_object_set (G_OBJECT (self->priv->no_gps_label), "wrap", TRUE, "wrap-mode", PANGO_WRAP_WORD_CHAR, "single-line-mode", FALSE, "justify", GTK_JUSTIFY_CENTER, "width-request", LABEL_MAX_WIDTH, NULL); gtk_widget_show (self->priv->no_gps_label); gtk_box_pack_start (GTK_BOX (self), self->priv->no_gps_label, TRUE, TRUE, 0); /* The map widget */ self->priv->embed = gtk_champlain_embed_new (); self->priv->map_view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (self->priv->embed)); g_object_set (G_OBJECT (self->priv->map_view), "reactive", TRUE, "zoom-level", 5, "zoom-on-double-click", TRUE, "kinetic-mode", TRUE, NULL); scale = champlain_scale_new (); champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), self->priv->map_view); champlain_view_bin_layout_add (self->priv->map_view, scale, CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END); self->priv->marker_layer = champlain_marker_layer_new (); champlain_view_add_layer (self->priv->map_view, CHAMPLAIN_LAYER (self->priv->marker_layer)); clutter_actor_show (CLUTTER_ACTOR (self->priv->marker_layer)); self->priv->marker = champlain_label_new_with_text ("", "Sans 10", NULL, NULL); clutter_actor_show (self->priv->marker); champlain_marker_layer_add_marker (self->priv->marker_layer, CHAMPLAIN_MARKER (self->priv->marker)); gtk_widget_show_all (self->priv->embed); gtk_widget_hide (self->priv->embed); gtk_box_pack_start (GTK_BOX (self), self->priv->embed, TRUE, TRUE, 0); }
static ChamplainMarker * add_marker(PlacemarksPlugin *plugin, const gchar *name, gdouble lat, gdouble lon) { PlacemarksPluginPrivate *priv; priv = PLACEMARKS_PLUGIN (plugin)->priv; ChamplainMarker *marker; ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb }; marker = CHAMPLAIN_MARKER ( champlain_label_new_with_text (name, "Serif 14", NULL, NULL)); champlain_label_set_use_markup (CHAMPLAIN_LABEL (marker), TRUE); champlain_label_set_alignment (CHAMPLAIN_LABEL (marker), PANGO_ALIGN_RIGHT); champlain_label_set_color (CHAMPLAIN_LABEL (marker), &orange); champlain_location_set_location (CHAMPLAIN_LOCATION(marker), lat, lon); champlain_marker_layer_add_marker (priv->markers_layer, CHAMPLAIN_MARKER (marker)); return marker; }
static void item_deleted_cb (GtkTreeModel *tree_model, GtkTreePath *path, PhidiasItemsGeo *item) { gchar *str; ClutterActor *marker; str = gtk_tree_path_to_string (path); marker = g_hash_table_lookup (item->priv->markers, str); if (marker != NULL) { champlain_marker_layer_remove_marker (item->priv->current_layer, CHAMPLAIN_MARKER (marker)); g_hash_table_remove (item->priv->markers, str); } g_free (str); }
static void bar_pane_gps_thumb_done_cb(ThumbLoader *tl, gpointer data) { FileData *fd; ClutterActor *marker; ClutterActor *actor; marker = CLUTTER_ACTOR(data); fd = g_object_get_data(G_OBJECT(marker), "file_fd"); if (fd->thumb_pixbuf != NULL) { actor = clutter_texture_new(); gtk_clutter_texture_set_from_pixbuf(CLUTTER_TEXTURE(actor), fd->thumb_pixbuf, NULL); champlain_marker_set_image(CHAMPLAIN_MARKER(marker), actor); } thumb_loader_free(tl); }
static void draw (ClutterCanvas *canvas, cairo_t *cr, gint width, gint height, ChamplainPoint *point) { ChamplainPointPrivate *priv = point->priv; gdouble size = priv->size; gdouble radius = size / 2.0; const ClutterColor *color; set_surface (CHAMPLAIN_EXPORTABLE (point), cairo_get_target (cr)); cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); cairo_paint (cr); cairo_set_operator (cr, CAIRO_OPERATOR_OVER); if (champlain_marker_get_selected (CHAMPLAIN_MARKER (point))) color = champlain_marker_get_selection_color (); else color = priv->color; cairo_set_source_rgba (cr, color->red / 255.0, color->green / 255.0, color->blue / 255.0, color->alpha / 255.0); cairo_arc (cr, radius, radius, radius, 0, 2 * M_PI); cairo_fill (cr); cairo_fill_preserve (cr); cairo_set_line_width (cr, 1.0); cairo_stroke (cr); }
static gboolean bar_pane_gps_marker_keypress_cb(GtkWidget *widget, ClutterButtonEvent *bevent, gpointer data) { //PaneGPSData *pgd = data; FileData *fd; ClutterActor *marker; ClutterColor marker_colour = { MARKER_COLOUR }; ClutterColor text_colour = { TEXT_COLOUR }; ClutterColor thumb_colour = { THUMB_COLOUR }; gchar *current_text; ClutterActor *actor; ClutterActor *current_image; GString *text; gint height, width, rotate; gchar *altitude = NULL; ThumbLoader *tl; if (bevent->button == MOUSE_BUTTON_LEFT) { marker = CLUTTER_ACTOR(widget); fd = g_object_get_data(G_OBJECT(marker), "file_fd"); /* If the marker is showing a thumbnail, delete it */ current_image = champlain_marker_get_image(CHAMPLAIN_MARKER(marker)); if (current_image != NULL) { clutter_actor_destroy(CLUTTER_ACTOR(current_image)); champlain_marker_set_image(CHAMPLAIN_MARKER(marker), NULL); } current_text = g_strdup(champlain_marker_get_text(CHAMPLAIN_MARKER(marker))); /* If the marker is showing only the text character, replace it with a * thumbnail and date and altitude */ if (g_strcmp0(current_text, "i") == 0) { /* If a thumbail has already been generated, use that. If not try the pixbuf of the full image. * If not, call the thumb_loader to generate a thumbnail and update the marker later in the * thumb_loader callback */ if (fd->thumb_pixbuf != NULL) { actor = clutter_texture_new(); gtk_clutter_texture_set_from_pixbuf(CLUTTER_TEXTURE(actor), fd->thumb_pixbuf, NULL); champlain_marker_set_image(CHAMPLAIN_MARKER(marker), actor); } else if (fd->pixbuf != NULL) { actor = clutter_texture_new(); width = gdk_pixbuf_get_width (fd->pixbuf); height = gdk_pixbuf_get_height (fd->pixbuf); switch (fd->exif_orientation) { case 8: rotate = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE; break; case 3: rotate = GDK_PIXBUF_ROTATE_UPSIDEDOWN; break; case 6: rotate = GDK_PIXBUF_ROTATE_CLOCKWISE; break; default: rotate = GDK_PIXBUF_ROTATE_NONE; } gtk_clutter_texture_set_from_pixbuf(CLUTTER_TEXTURE(actor), gdk_pixbuf_rotate_simple(gdk_pixbuf_scale_simple(fd->pixbuf, THUMB_SIZE, height * THUMB_SIZE / width, GDK_INTERP_NEAREST), rotate), NULL); champlain_marker_set_image(CHAMPLAIN_MARKER(marker), actor); } else { tl = thumb_loader_new(THUMB_SIZE, THUMB_SIZE); thumb_loader_set_callbacks(tl, bar_pane_gps_thumb_done_cb, bar_pane_gps_thumb_error_cb, NULL, marker); thumb_loader_start(tl, fd); } text = g_string_new(fd->name); g_string_append(text, "\n"); g_string_append(text, text_from_time(fd->date)); g_string_append(text, "\n"); altitude = metadata_read_string(fd, "formatted.GPSAltitude", METADATA_FORMATTED); if (altitude != NULL) { g_string_append(text, altitude); } champlain_marker_set_text(CHAMPLAIN_MARKER(marker), text->str); champlain_marker_set_color(CHAMPLAIN_MARKER(marker), &thumb_colour); champlain_marker_set_text_color(CHAMPLAIN_MARKER(marker), &text_colour); champlain_marker_set_font_name(CHAMPLAIN_MARKER(marker), "sans 8"); g_free(altitude); g_string_free(text, TRUE); } /* otherwise, revert to the hidden text marker */ else { champlain_marker_set_text(CHAMPLAIN_MARKER(marker), "i"); champlain_marker_set_color(CHAMPLAIN_MARKER(marker), &marker_colour); champlain_marker_set_text_color(CHAMPLAIN_MARKER(marker), &marker_colour); champlain_marker_set_font_name(CHAMPLAIN_MARKER(marker), "courier 5"); } g_free(current_text); return TRUE; } return TRUE; }
static gboolean add_marker (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { int latitude_offset; int longitude_offset; double lat; double lon; gchar *title; gchar *latitude_str; gchar *longitude_str; gchar *check; ClutterActor *marker; ClutterActor *icon; PhidiasItemsGeo *item; item = data; latitude_offset = phidias_extra_column_get_index ((PhidiasExtraColumn*) g_ptr_array_index (item->priv->extras, 0)); longitude_offset = phidias_extra_column_get_index ((PhidiasExtraColumn*) g_ptr_array_index (item->priv->extras, 1)); gtk_tree_model_get (model, iter, ITEM_INFO_TITLE, &title, latitude_offset, &latitude_str, longitude_offset, &longitude_str, -1); if (latitude_str == NULL || longitude_str == NULL) goto end; check = NULL; lat = strtod (latitude_str, &check); if (*check != '\0') goto end; check = NULL; lon = strtod (longitude_str, &check); if (*check != '\0') goto end; check = g_markup_escape_text (title, -1); g_free (title); title = check; /* TODO Provide a proper ChamplainMarker implementation, able to store the icon, the title, the description, and able to react to clicks */ icon = do_marker_icon ("go-jump", 22); if (item->priv->show_text) { marker = champlain_label_new_with_text (title, "Serif 9", NULL, NULL); } else { marker = champlain_label_new_with_text (title, "Serif 0", NULL, NULL); champlain_label_set_image (CHAMPLAIN_LABEL (marker), icon); } g_object_set_data (G_OBJECT (marker), "icon", icon); champlain_location_set_location (CHAMPLAIN_LOCATION (marker), lat, lon); champlain_marker_layer_add_marker (item->priv->current_layer, CHAMPLAIN_MARKER (marker)); g_hash_table_insert (item->priv->markers, gtk_tree_path_to_string (path), marker); end: if (title != NULL) g_free (title); if (latitude_str != NULL) g_free (latitude_str); if (longitude_str != NULL) g_free (longitude_str); return FALSE; }