From 297160fd0fd1a2e9b9235d73ac32771c73a577e3 Mon Sep 17 00:00:00 2001 From: karthikmv Date: Tue, 23 Aug 2022 22:04:29 +0530 Subject: [PATCH] added map to utility window --- iPDC/utility_tools.c | 32 +++++++++++++++++++++++--------- iPDC/utility_tools.h | 7 +++++++ test-examples/editable_track.c | 2 +- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/iPDC/utility_tools.c b/iPDC/utility_tools.c index e7dae6b..1071c33 100644 --- a/iPDC/utility_tools.c +++ b/iPDC/utility_tools.c @@ -1,15 +1,29 @@ #include -#include +#include "osm-gps-map.h" + +#define UI_fILE "./utility_tools.ui" void utility_tools(GtkButton *but, gpointer udata) { - GtkWidget *new_window; - new_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(new_window), "Utility Tools"); - gtk_window_set_default_size(GTK_WINDOW(new_window), 600, 400); - gtk_window_set_position(GTK_WINDOW(new_window), GTK_WIN_POS_CENTER); - gtk_container_set_border_width(GTK_CONTAINER(new_window), 10); - g_signal_connect (new_window, "destroy", G_CALLBACK(gtk_widget_destroy), new_window); + GtkBuilder *builder; + GError *error = NULL; + builder = gtk_builder_new(); + if(!gtk_builder_add_from_file(builder, UI_fILE, &error)) + { + g_warning("%s", error->message); + g_free(error); + } + GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "util_window")); + GtkContainer *map_container = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout")); - gtk_widget_show_all(new_window); + OsmGpsMap *map = g_object_new (OSM_TYPE_GPS_MAP, + "map-source", OSM_GPS_MAP_SOURCE_OPENSTREETMAP, + "tile-cache", "/tmp/", + NULL); + gtk_widget_set_size_request(GTK_WIDGET(map), 800, 600); + + gtk_container_add(map_container, GTK_WIDGET(map)); + + gtk_widget_show_all(window); + gtk_main(); } \ No newline at end of file diff --git a/iPDC/utility_tools.h b/iPDC/utility_tools.h index c5c224c..d583201 100644 --- a/iPDC/utility_tools.h +++ b/iPDC/utility_tools.h @@ -1,2 +1,9 @@ #include + +/* Convenience macros for obtaining objects from UI file */ +#define CH_GET_OBJECT(builder, name, type, data) \ + data->name = type(gtk_builder_get_object (builder, #name) ) +#define CH_GET_WIDGET(builder, name, data) \ + CH_GET_OBJECT(builder, name, GTK_WIDGET, data) + void utility_tools(GtkButton *but, gpointer udata); \ No newline at end of file diff --git a/test-examples/editable_track.c b/test-examples/editable_track.c index d51eef3..d5ce24c 100644 --- a/test-examples/editable_track.c +++ b/test-examples/editable_track.c @@ -16,7 +16,7 @@ main (int argc, map = g_object_new (OSM_TYPE_GPS_MAP, - "map-source", OSM_GPS_MAP_SOURCE_OPENSTREETMAP, + "map-source", OSM_GPS_MAP_SOURCE_GOOGLE_STREET, "tile-cache", "/tmp/", NULL); gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(map));