#define TESTREPO "/home/milang/MyDocs/.documents/Maps/OpenStreet"
+#define WITH_THREADS 1
+
GtkWidget *map;
static gboolean
int
main (int argc, char **args)
{
-GtkDialog *dialog;
+GtkWidget *window, *wvbox;
GtkWidget *hbox, *zoomer, *btn_left, *btn_right, *btn_up, *btn_down, *vbox;
GtkWidget *rotate;
RepoData *rd;
-gtk_init (&argc, &args);
+#if WITH_THREADS
+if (!g_thread_supported ()) {
+ g_thread_init(NULL);
+}
+gdk_threads_init();
+gdk_threads_enter();
+#endif
+
+gtk_init(&argc, &args);
+
+window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
+gtk_window_set_title(GTK_WINDOW(window), "MapWidget Test");
+gtk_window_resize(GTK_WINDOW(window), 800, 600);
+wvbox=gtk_vbox_new(FALSE, 3);
+gtk_container_add(GTK_CONTAINER(window), wvbox);
rd=map_tile_repo_new();
rd->view_zoom_steps=1;
rd->cache_dir=TESTREPO;
-dialog=GTK_DIALOG(gtk_dialog_new ());
-gtk_window_set_title(GTK_WINDOW(dialog), "Map test");
-gtk_window_resize(GTK_WINDOW(dialog), 800, 600);
-gtk_dialog_add_button (dialog, "Close", GTK_RESPONSE_CLOSE);
-
hbox=gtk_hbox_new(FALSE, 3);
vbox=gtk_vbox_new(FALSE, 3);
map=gtk_map_new();
gtk_map_set_tile_repository(map, rd);
+
gtk_box_pack_start(GTK_BOX(hbox), map, TRUE, TRUE, 0);
zoomer=gtk_vscale_new_with_range(0,17,1);
gtk_box_pack_start(GTK_BOX(vbox), btn_down, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
-gtk_box_pack_start(GTK_BOX(dialog->vbox), hbox, TRUE, TRUE, 0);
-gtk_box_pack_start(GTK_BOX(dialog->vbox), rotate, FALSE, FALSE, 0);
+gtk_box_pack_start(GTK_BOX(wvbox), hbox, TRUE, TRUE, 0);
+gtk_box_pack_start(GTK_BOX(wvbox), rotate, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(zoomer), "value-changed", G_CALLBACK(map_zoom), NULL);
g_signal_connect(G_OBJECT(rotate), "value-changed", G_CALLBACK(map_rotate), NULL);
g_signal_connect(G_OBJECT(btn_left), "clicked", G_CALLBACK(map_pan_left), NULL);
g_signal_connect(G_OBJECT(btn_right), "clicked", G_CALLBACK(map_pan_right), NULL);
-gtk_widget_show_all(GTK_WIDGET(dialog));
+g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
+
+gtk_widget_show_all(GTK_WIDGET(window));
gtk_map_set_center_latlon(map, 60.45, 22.25);
gtk_map_set_zoom(map, 8);
-gtk_dialog_run(dialog);
+gtk_main();
+
+#ifdef WITH_THREADS
+gdk_threads_leave();
+#endif
return 0;
}