create_marker_layer ()
{
ClutterActor *layer, *marker;
-
+
layer = champlain_layer_new();
-
+
ClutterColor orange = { 0xf3, 0x94, 0x07, 0xbb };
ClutterColor white = { 0xff, 0xff, 0xff, 0xff };
marker = champlain_marker_new_with_label("Montréal", "Airmole 14", NULL, NULL);
champlain_marker_set_position(CHAMPLAIN_MARKER(marker), 45.528178, -73.563788);
clutter_container_add(CLUTTER_CONTAINER(layer), marker, NULL);
-
+
marker = champlain_marker_new_with_label("New York", "Sans 25", &white, NULL);
champlain_marker_set_position(CHAMPLAIN_MARKER(marker), 40.77, -73.98);
clutter_container_add(CLUTTER_CONTAINER(layer), marker, NULL);
-
+
marker = champlain_marker_new_with_label("Saint-Tite-des-Caps", "Serif 12", NULL, &orange);
champlain_marker_set_position(CHAMPLAIN_MARKER(marker), 47.130885, -70.764141);
clutter_container_add(CLUTTER_CONTAINER(layer), marker, NULL);
-
+
clutter_actor_hide(layer);
return layer;
}
static void
-toggle_layer (GtkToggleButton *widget, ClutterActor *layer)
+toggle_layer (GtkToggleButton *widget,
+ ClutterActor *layer)
{
if(gtk_toggle_button_get_active(widget))
clutter_actor_show_all(layer);
}
static void
-map_source_changed (GtkWidget *widget, ChamplainView *view)
+map_source_changed (GtkWidget *widget,
+ ChamplainView *view)
{
gchar* selection = gtk_combo_box_get_active_text(GTK_COMBO_BOX(widget));
if (g_strcmp0(selection, OSM_MAP) == 0)
}
static void
-zoom_changed (GtkSpinButton *spinbutton, ChamplainView *view)
+zoom_changed (GtkSpinButton *spinbutton,
+ ChamplainView *view)
{
gint zoom = gtk_spin_button_get_value_as_int(spinbutton);
g_object_set(G_OBJECT(view), "zoom-level", zoom, NULL);
}
static void
-map_zoom_changed (ChamplainView *view, GParamSpec *gobject, GtkSpinButton *spinbutton)
+map_zoom_changed (ChamplainView *view,
+ GParamSpec *gobject,
+ GtkSpinButton *spinbutton)
{
gint zoom;
g_object_get(G_OBJECT(view), "zoom-level", &zoom, NULL);
}
static void
-zoom_in (GtkWidget *widget, ChamplainView *view)
+zoom_in (GtkWidget *widget,
+ ChamplainView *view)
{
champlain_view_zoom_in(view);
}
static void
-zoom_out (GtkWidget *widget, ChamplainView *view)
+zoom_out (GtkWidget *widget,
+ ChamplainView *view)
{
champlain_view_zoom_out(view);
}
int
-main (int argc, char *argv[])
+main (int argc,
+ char *argv[])
{
GtkWidget *window;
GtkWidget *widget, *vbox, *bbox, *button, *viewport;
ClutterActor *layer, *view;
-
+
g_thread_init (NULL);
gtk_clutter_init (&argc, &argv);
* 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);
+ g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (on_destroy),
+ NULL);
vbox = gtk_vbox_new(FALSE, 10);
-
- view = champlain_view_new (CHAMPLAIN_VIEW_MODE_KINETIC);
+
+ view = champlain_view_new ();
widget = champlain_view_embed_new(CHAMPLAIN_VIEW (view));
- g_object_set(G_OBJECT(view), "zoom-level", 5, NULL);
+ g_object_set(G_OBJECT(view), "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
+ "zoom-level", 5, NULL);
layer = create_marker_layer();
champlain_view_add_layer(CHAMPLAIN_VIEW (view), layer);
-
+
gtk_widget_set_size_request(widget, 640, 480);
-
+
bbox = gtk_hbox_new (FALSE, 10);
button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_IN);
- g_signal_connect (button,
- "clicked",
- G_CALLBACK (zoom_in),
- view);
+ g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), view);
gtk_container_add (GTK_CONTAINER (bbox), button);
+
button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_OUT);
- g_signal_connect (button,
- "clicked",
- G_CALLBACK (zoom_out),
- view);
+ 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");
- g_signal_connect (button,
- "toggled",
- G_CALLBACK (toggle_layer),
- layer);
+ g_signal_connect (button, "toggled", G_CALLBACK (toggle_layer), layer);
gtk_container_add (GTK_CONTAINER (bbox), button);
-
+
button = gtk_combo_box_new_text();
gtk_combo_box_append_text(GTK_COMBO_BOX(button), OSM_MAP);
gtk_combo_box_append_text(GTK_COMBO_BOX(button), OAM_MAP);
gtk_combo_box_append_text(GTK_COMBO_BOX(button), MFF_MAP);
gtk_combo_box_set_active(GTK_COMBO_BOX(button), 0);
- g_signal_connect (button,
- "changed",
- G_CALLBACK (map_source_changed),
- view);
+ 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);
- g_signal_connect (button,
- "changed",
- G_CALLBACK (zoom_changed),
- view);
- g_signal_connect (view,
- "notify::zoom-level",
- G_CALLBACK (map_zoom_changed),
- button);
+ 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);
-
+
viewport = gtk_viewport_new (NULL, NULL);
gtk_viewport_set_shadow_type (GTK_VIEWPORT(viewport), GTK_SHADOW_ETCHED_IN);
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);