added map to utility window
This commit is contained in:
parent
680069d98f
commit
297160fd0f
|
@ -1,15 +1,29 @@
|
||||||
#include<gtk/gtk.h>
|
#include<gtk/gtk.h>
|
||||||
#include<stdio.h>
|
#include "osm-gps-map.h"
|
||||||
|
|
||||||
|
#define UI_fILE "./utility_tools.ui"
|
||||||
|
|
||||||
void utility_tools(GtkButton *but, gpointer udata)
|
void utility_tools(GtkButton *but, gpointer udata)
|
||||||
{
|
{
|
||||||
GtkWidget *new_window;
|
GtkBuilder *builder;
|
||||||
new_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
GError *error = NULL;
|
||||||
gtk_window_set_title(GTK_WINDOW(new_window), "Utility Tools");
|
builder = gtk_builder_new();
|
||||||
gtk_window_set_default_size(GTK_WINDOW(new_window), 600, 400);
|
if(!gtk_builder_add_from_file(builder, UI_fILE, &error))
|
||||||
gtk_window_set_position(GTK_WINDOW(new_window), GTK_WIN_POS_CENTER);
|
{
|
||||||
gtk_container_set_border_width(GTK_CONTAINER(new_window), 10);
|
g_warning("%s", error->message);
|
||||||
g_signal_connect (new_window, "destroy", G_CALLBACK(gtk_widget_destroy), new_window);
|
g_free(error);
|
||||||
|
}
|
||||||
gtk_widget_show_all(new_window);
|
GtkWidget *window = GTK_WIDGET(gtk_builder_get_object(builder, "util_window"));
|
||||||
|
GtkContainer *map_container = GTK_CONTAINER(gtk_builder_get_object(builder, "map_layout"));
|
||||||
|
|
||||||
|
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();
|
||||||
}
|
}
|
|
@ -1,2 +1,9 @@
|
||||||
#include<gtk/gtk.h>
|
#include<gtk/gtk.h>
|
||||||
|
|
||||||
|
/* 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);
|
void utility_tools(GtkButton *but, gpointer udata);
|
|
@ -16,7 +16,7 @@ main (int argc,
|
||||||
|
|
||||||
|
|
||||||
map = g_object_new (OSM_TYPE_GPS_MAP,
|
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/",
|
"tile-cache", "/tmp/",
|
||||||
NULL);
|
NULL);
|
||||||
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(map));
|
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(map));
|
||||||
|
|
Loading…
Reference in New Issue