int main(int argc, char **argv)
{
- gdk_threads_init();
gtk_init(&argc, &argv);
prefs = grits_prefs_new(NULL, NULL);
plugins = grits_plugins_new(g_getenv("GRITS_PLUGIN_PATH"), prefs);
viewer = grits_opengl_new(plugins, prefs);
- gdk_threads_enter();
-
GtkWidget *notebook = NULL;
GtkUIManager *manager = setup_actions();
GtkWidget *window = setup_window(manager, ¬ebook);
grits_plugins_free(plugins);
g_object_unref(prefs);
- gdk_threads_leave();
-
g_debug("GritsDemo: main - refs=%d,%d",
G_OBJECT(manager)->ref_count,
G_OBJECT(window)->ref_count);
plugins = NULL;
viewer = NULL;
- gdk_display_close(gdk_display_get_default());
+ //gdk_display_close(gdk_display_get_default());
return 0;
}
***********/
int main(int argc, char **argv)
{
- gdk_threads_init();
gtk_init(&argc, &argv);
prefs = grits_prefs_new(NULL, NULL);
plugins = grits_plugins_new(g_getenv("GRITS_PLUGIN_PATH"), prefs);
viewer = grits_opengl_new(plugins, prefs);
- gdk_threads_enter();
GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
GtkWidget *config = gtk_notebook_new();
gtk_widget_show_all(config);
gtk_main();
- gdk_threads_leave();
gdk_display_close(gdk_display_get_default());
GtkWidget *progress;
};
+struct LoadData {
+ GtkImage *image;
+ GdkPixbuf *pixbuf;
+};
void chunk_callback(gsize cur, gsize total, gpointer _state)
{
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(state->progress), (gdouble)cur/total);
}
+gboolean load_callback(gpointer _data)
+{
+ struct LoadData *data = _data;
+ gtk_image_set_from_pixbuf(GTK_IMAGE(data->image), data->pixbuf);
+ g_free(data);
+ return FALSE;
+}
+
+void load_image(GtkImage *image, GdkPixbuf *pixbuf)
+{
+ struct LoadData *data = g_new0(struct LoadData, 1);
+ data->image = image;
+ data->pixbuf = pixbuf;
+ g_idle_add(load_callback, data);
+}
+
gpointer do_bmng_cache(gpointer _image)
{
GtkImage *image = _image;
g_message("Loading bmng image: [%s]", path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL);
- gdk_threads_enter();
- gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
- gdk_threads_leave();
+ load_image(GTK_IMAGE(image), pixbuf);
g_message("Cleaning bmng up");
grits_wms_free(bmng_wms);
g_message("Loading osm image: [%s]", path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL);
- gdk_threads_enter();
- gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
- gdk_threads_leave();
+ load_image(GTK_IMAGE(image), pixbuf);
g_message("Cleaning osm up");
grits_wms_free(osm_wms);
g_message("Loading osm2 image: [%s]", path);
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(path, NULL);
- gdk_threads_enter();
- gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
- gdk_threads_leave();
+ load_image(GTK_IMAGE(image), pixbuf);
g_message("Cleaning osm2 up");
grits_tms_free(osm2_tms);
int main(int argc, char **argv)
{
- gdk_threads_init();
gtk_init(&argc, &argv);
GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL);