void bar_pane_gps_update_from_config(GtkWidget *pane, const gchar **attribute_names, const gchar **attribute_values) { PaneGPSData *pgd; gint zoom; gint int_longitude, int_latitude; gdouble longitude, latitude; pgd = g_object_get_data(G_OBJECT(pane), "pane_data"); if (!pgd) return; gchar *title = NULL; while (*attribute_names) { const gchar *option = *attribute_names++; const gchar *value = *attribute_values++; if (READ_CHAR_FULL("title", title)) continue; if (READ_CHAR_FULL("map-id", pgd->map_source)) continue; if (READ_BOOL_FULL("expanded", pgd->pane.expanded)) continue; if (READ_INT_FULL("height", pgd->height)) continue; if (READ_CHAR_FULL("id", pgd->pane.id)) continue; if (READ_INT_CLAMP_FULL("zoom-level", zoom, 1, 8)) { g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "zoom-level", zoom, NULL); continue; } if (READ_INT_CLAMP_FULL("longitude", int_longitude, -90000000, +90000000)) { longitude = int_longitude / 1000000; g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "longitude", longitude, NULL); continue; } if (READ_INT_CLAMP_FULL("latitude", int_latitude, -90000000, +90000000)) { latitude = int_latitude / 1000000; g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "latitude", latitude, NULL); continue; } log_printf("unknown attribute %s = %s\n", option, value); } if (title) { bar_pane_translate_title(PANE_COMMENT, pgd->pane.id, &title); gtk_label_set_text(GTK_LABEL(pgd->pane.title), title); g_free(title); } gtk_widget_set_size_request(pgd->widget, -1, pgd->height); bar_update_expander(pane); }
void gth_map_view_real_set_file (GthPropertyView *base, GthFileData *file_data) { GthMapView *self = GTH_MAP_VIEW (base); int coordinates_available; double latitude; double longitude; coordinates_available = 0; if (file_data != NULL) { GthMetadata *metadata; metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Exif::GPSInfo::GPSLatitude"); if (metadata != NULL) { latitude = exif_coordinate_to_decimal (gth_metadata_get_raw (metadata)); metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Exif::GPSInfo::GPSLatitudeRef"); if (metadata != NULL) { if (g_strcmp0 (gth_metadata_get_raw (metadata), "S") == 0) latitude = - latitude; } coordinates_available++; } metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Exif::GPSInfo::GPSLongitude"); if (metadata != NULL) { longitude = exif_coordinate_to_decimal (gth_metadata_get_raw (metadata)); metadata = (GthMetadata *) g_file_info_get_attribute_object (file_data->info, "Exif::GPSInfo::GPSLongitudeRef"); if (metadata != NULL) { if (g_strcmp0 (gth_metadata_get_raw (metadata), "W") == 0) longitude = - longitude; } coordinates_available++; } } if (coordinates_available == 2) { char *position; gtk_widget_hide (self->priv->no_gps_label); gtk_widget_show (self->priv->embed); position = decimal_coordinates_to_string (latitude, longitude); champlain_label_set_text (CHAMPLAIN_LABEL (self->priv->marker), position); g_free (position); champlain_location_set_location (CHAMPLAIN_LOCATION (self->priv->marker), latitude, longitude); champlain_view_center_on (CHAMPLAIN_VIEW (self->priv->map_view), latitude, longitude); } else { gtk_widget_hide (self->priv->embed); gtk_widget_show (self->priv->no_gps_label); } }
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 bar_pane_gps_slider_changed_cb(GtkScaleButton *slider, gdouble zoom, gpointer data) { PaneGPSData *pgd = data; GString *message; message = g_string_new(""); g_string_printf(message, _("Zoom %i"), (gint)zoom); g_object_set(G_OBJECT(CHAMPLAIN_VIEW(pgd->gps_view)), "zoom-level", (gint)zoom, NULL); gtk_widget_set_tooltip_text(GTK_WIDGET(slider), message->str); g_string_free(message, TRUE); }
static void selection_changed_cb (EogThumbView *view, EogMapPlugin *plugin) { EogImage *image; ChamplainLabel *marker; if (!eog_thumb_view_get_n_selected (view)) return; image = eog_thumb_view_get_first_selected_image (view); g_return_if_fail (image != NULL); marker = g_object_get_data (G_OBJECT (image), "marker"); if (marker) { gdouble lat, lon; g_object_get (marker, "latitude", &lat, "longitude", &lon, NULL); champlain_view_center_on (CHAMPLAIN_VIEW (plugin->map), lat, lon); /* Reset the previous selection */ if (plugin->marker) update_marker_image (plugin->marker, GTK_ICON_SIZE_MENU); plugin->marker = marker; update_marker_image (plugin->marker, GTK_ICON_SIZE_LARGE_TOOLBAR); gtk_widget_set_sensitive (plugin->jump_to_button, TRUE); } else { gtk_widget_set_sensitive (plugin->jump_to_button, FALSE); /* Reset the previous selection */ if (plugin->marker) update_marker_image (plugin->marker, GTK_ICON_SIZE_MENU); plugin->marker = NULL; } g_object_unref (image); }
static void jump_to (GtkWidget *widget, EogMapPlugin *plugin) { if (!plugin->marker) return; gdouble lat, lon; g_object_get (plugin->marker, "latitude", &lat, "longitude", &lon, NULL); champlain_view_center_on (CHAMPLAIN_VIEW (plugin->map), lat, lon); }
static gboolean bar_pane_gps_create_markers_cb(gpointer data) { PaneGPSData *pgd = data; gdouble latitude; gdouble longitude; GList *work; ClutterActor *marker; FileData *fd; ClutterColor marker_colour = { MARKER_COLOUR }; GString *message; gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pgd->progress), (gdouble)(pgd->selection_count - g_list_length(pgd->selection_list)) / (gdouble)pgd->selection_count); message = g_string_new(""); g_string_printf(message, "%i/%i", (pgd->selection_count - g_list_length(pgd->selection_list)), pgd->selection_count); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pgd->progress), message->str); g_string_free(message, TRUE); work = pgd->selection_list; while (work) { fd = work->data; pgd->selection_list = g_list_remove(pgd->selection_list, work->data); /* If the file has a parent, it must be a sidecar file. Do not process sidecar files */ if (fd != NULL && fd->parent == NULL) { latitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLatitude", 1000); longitude = metadata_read_GPS_coord(fd, "Xmp.exif.GPSLongitude", 1000); if ((latitude != 1000) && (longitude != 1000)) { marker = champlain_marker_new_with_text("i","courier 5", &marker_colour, &marker_colour); champlain_base_marker_set_position(CHAMPLAIN_BASE_MARKER(marker), latitude, longitude); clutter_container_add(CLUTTER_CONTAINER(pgd->icon_layer), marker, NULL); clutter_actor_set_reactive(marker, TRUE); g_signal_connect(G_OBJECT(marker), "button_release_event", G_CALLBACK(bar_pane_gps_marker_keypress_cb), pgd); g_object_set_data(G_OBJECT(marker), "file_fd", fd); g_ptr_array_add(pgd->marker_list, marker); if (pgd->centre_map_checked) { g_ptr_array_add(pgd->marker_list, NULL); champlain_view_ensure_markers_visible(CHAMPLAIN_VIEW(pgd->gps_view), (void *)pgd->marker_list->pdata, FALSE); g_ptr_array_remove(pgd->marker_list, NULL); } } } return TRUE; } if (pgd->marker_list->len >= 1) { g_ptr_array_add(pgd->marker_list, NULL); if (pgd->centre_map_checked) { champlain_view_ensure_markers_visible(CHAMPLAIN_VIEW(pgd->gps_view), (void *)pgd->marker_list->pdata, FALSE); } } gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pgd->progress), 0); gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pgd->progress), NULL); g_list_free(pgd->selection_list); g_ptr_array_free(pgd->marker_list, TRUE); pgd->create_markers_id = 0; return FALSE; }
int main (int argc, char *argv[]) { ClutterActor *actor, *stage, *buttons, *button; ChamplainMarkerLayer *layer; ChamplainPathLayer *path; gfloat width, total_width = 0; 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_actor_add_child (stage, actor); /* Create the buttons */ buttons = clutter_actor_new (); clutter_actor_set_position (buttons, PADDING, PADDING); button = make_button ("Zoom in"); clutter_actor_add_child (buttons, button); clutter_actor_set_reactive (button, TRUE); clutter_actor_get_size (button, &width, NULL); total_width += width + PADDING; g_signal_connect (button, "button-release-event", G_CALLBACK (zoom_in), actor); button = make_button ("Zoom out"); clutter_actor_add_child (buttons, button); clutter_actor_set_reactive (button, TRUE); clutter_actor_set_position (button, total_width, 0); clutter_actor_get_size (button, &width, NULL); g_signal_connect (button, "button-release-event", G_CALLBACK (zoom_out), actor); clutter_actor_add_child (stage, buttons); ClutterContent *canvas; canvas = clutter_canvas_new (); clutter_canvas_set_size (CLUTTER_CANVAS (canvas), 512, 256); g_signal_connect (canvas, "draw", G_CALLBACK (draw_background_tile), NULL); clutter_content_invalidate (canvas); champlain_view_set_background_pattern (CHAMPLAIN_VIEW (actor), canvas); /* Create the markers and marker layer */ layer = create_marker_layer (CHAMPLAIN_VIEW (actor), &path); champlain_view_add_layer (CHAMPLAIN_VIEW (actor), CHAMPLAIN_LAYER (layer)); /* Connect to the click event */ clutter_actor_set_reactive (actor, TRUE); g_signal_connect (actor, "button-release-event", G_CALLBACK (map_view_button_release_cb), actor); /* 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), 45.466, -73.75); clutter_actor_show (stage); clutter_main (); return 0; }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *widget, *vbox, *bbox, *button, *viewport, *image; ChamplainView *view; ChamplainMarkerLayer *layer; ClutterActor *scale; ChamplainLicense *license_actor; if (gtk_clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) return 1; /* create the main, top level, window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* give the window a 10px wide border */ gtk_container_set_border_width (GTK_CONTAINER (window), 10); /* give it the title */ gtk_window_set_title (GTK_WINDOW (window), "libchamplain Gtk+ demo"); /* Connect the destroy event of the window with our on_destroy function * When the window is about to be destroyed we get a notificaiton and * stop the main GTK loop */ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (on_destroy), NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10); widget = gtk_champlain_embed_new (); view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (widget)); clutter_actor_set_reactive (CLUTTER_ACTOR (view), TRUE); g_signal_connect (view, "button-release-event", G_CALLBACK (mouse_click_cb), view); g_object_set (G_OBJECT (view), "kinetic-mode", TRUE, "zoom-level", 5, NULL); g_object_set_data (G_OBJECT (view), "window", window); scale = champlain_scale_new (); champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), view); /* align to the bottom left */ clutter_actor_set_x_expand (scale, TRUE); clutter_actor_set_y_expand (scale, TRUE); clutter_actor_set_x_align (scale, CLUTTER_ACTOR_ALIGN_START); clutter_actor_set_y_align (scale, CLUTTER_ACTOR_ALIGN_END); clutter_actor_add_child (CLUTTER_ACTOR (view), scale); license_actor = champlain_view_get_license_actor (view); champlain_license_set_extra_text (license_actor, "Don't eat cereals with orange juice\nIt tastes bad"); champlain_view_center_on (CHAMPLAIN_VIEW (view), 45.466, -73.75); layer = create_marker_layer (view, &path); champlain_view_add_layer (view, CHAMPLAIN_LAYER (path)); champlain_view_add_layer (view, CHAMPLAIN_LAYER (layer)); path_layer = champlain_path_layer_new (); /* Cheap approx of Highway 10 */ append_point (path_layer, 45.4095, -73.3197); append_point (path_layer, 45.4104, -73.2846); append_point (path_layer, 45.4178, -73.2239); append_point (path_layer, 45.4176, -73.2181); append_point (path_layer, 45.4151, -73.2126); append_point (path_layer, 45.4016, -73.1926); append_point (path_layer, 45.3994, -73.1877); append_point (path_layer, 45.4000, -73.1815); append_point (path_layer, 45.4151, -73.1218); champlain_view_add_layer (view, CHAMPLAIN_LAYER (path_layer)); gtk_widget_set_size_request (widget, 640, 481); bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("zoom-in", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); gtk_button_set_label (GTK_BUTTON (button), "Zoom In"); g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("zoom-out", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); gtk_button_set_label (GTK_BUTTON (button), "Zoom Out"); g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_toggle_button_new_with_label ("Markers"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE); g_signal_connect (button, "toggled", G_CALLBACK (toggle_layer), layer); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_toggle_button_new_with_label ("Toggle wrap"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), champlain_view_get_horizontal_wrap (view)); g_signal_connect (button, "toggled", G_CALLBACK (toggle_wrap), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_combo_box_new (); build_combo_box (GTK_COMBO_BOX (button)); gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0); g_signal_connect (button, "changed", G_CALLBACK (map_source_changed), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_spin_button_new_with_range (0, 20, 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (button), champlain_view_get_zoom_level (view)); g_signal_connect (button, "changed", G_CALLBACK (zoom_changed), view); g_signal_connect (view, "notify::zoom-level", G_CALLBACK (map_zoom_changed), button); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("list-add", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); g_signal_connect (button, "clicked", G_CALLBACK (add_clicked), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_button_new (); image = gtk_image_new_from_icon_name ("camera-photo-symbolic", GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); g_signal_connect (button, "clicked", G_CALLBACK (export_png), view); gtk_container_add (GTK_CONTAINER (bbox), button); button = gtk_image_new (); gtk_widget_set_size_request (button, 22, -1); g_signal_connect (view, "notify::state", G_CALLBACK (view_state_changed), button); gtk_box_pack_end (GTK_BOX (bbox), button, FALSE, FALSE, 0); viewport = gtk_frame_new (NULL); gtk_container_add (GTK_CONTAINER (viewport), widget); gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (vbox), viewport); /* and insert it into the main window */ gtk_container_add (GTK_CONTAINER (window), vbox); /* make sure that everything, window and label, are visible */ gtk_widget_show_all (window); /* start the main loop */ gtk_main (); return 0; }
static void impl_activate (EogWindowActivatable *activatable) { EogMapPlugin *plugin = EOG_MAP_PLUGIN (activatable); GtkWidget *sidebar, *vbox, *bbox, *button, *viewport; GtkWidget *embed; ClutterActor *scale; eog_debug (DEBUG_PLUGINS); /* This is a workaround until bug 590692 is fixed. */ viewport = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (viewport), GTK_SHADOW_ETCHED_IN); /*viewport = gtk_viewport_new (NULL, NULL); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_ETCHED_IN);*/ embed = gtk_champlain_embed_new (); plugin->map = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (embed)); g_object_set (G_OBJECT (plugin->map), "zoom-level", 3, "kinetic-mode", TRUE, NULL); scale = champlain_scale_new (); champlain_scale_connect_view (CHAMPLAIN_SCALE (scale), plugin->map); /* align to the bottom left */ champlain_view_bin_layout_add (plugin->map, scale, CLUTTER_BIN_ALIGNMENT_START, CLUTTER_BIN_ALIGNMENT_END); gtk_container_add (GTK_CONTAINER (viewport), embed); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); bbox = gtk_toolbar_new (); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "go-jump-symbolic"); gtk_widget_set_tooltip_text (button, _("Jump to current image's location")); g_signal_connect (button, "clicked", G_CALLBACK (jump_to), plugin); gtk_container_add (GTK_CONTAINER (bbox), button); plugin->jump_to_button = button; button = GTK_WIDGET (gtk_separator_tool_item_new ()); gtk_container_add (GTK_CONTAINER (bbox), button); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "zoom-in-symbolic"); gtk_widget_set_tooltip_text (button, _("Zoom in")); g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), plugin->map); gtk_container_add (GTK_CONTAINER (bbox), button); button = GTK_WIDGET (gtk_tool_button_new (NULL, NULL)); gtk_tool_button_set_icon_name (GTK_TOOL_BUTTON (button), "zoom-out-symbolic"); gtk_widget_set_tooltip_text (button, _("Zoom out")); g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), plugin->map); gtk_container_add (GTK_CONTAINER (bbox), button); plugin->layer = champlain_marker_layer_new_full (CHAMPLAIN_SELECTION_SINGLE); champlain_view_add_layer (CHAMPLAIN_VIEW (plugin->map), CHAMPLAIN_LAYER (plugin->layer)); sidebar = eog_window_get_sidebar (plugin->window); plugin->viewport = vbox; gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); gtk_widget_set_vexpand (viewport, TRUE); gtk_container_add (GTK_CONTAINER (vbox), viewport); eog_sidebar_add_page (EOG_SIDEBAR (sidebar), _("Map"), vbox); gtk_widget_show_all (vbox); plugin->win_prepared_id = g_signal_connect (G_OBJECT (plugin->window), "prepared", G_CALLBACK (prepared_cb), plugin); /* Call the callback once in case the window is already ready */ prepared_cb (plugin->window, plugin); }