[libchamplain] Build memphis demo in meson and move its resources to separate directory



commit 7096f1a5bfccf73b17281325f7a97e89f68916c8
Author: Jiří Techet <techet gmail com>
Date:   Wed Feb 6 14:27:53 2019 +0100

    Build memphis demo in meson and move its resources to separate directory

 configure.ac                          |  1 +
 demos/Makefile.am                     |  4 ++--
 demos/local-rendering.c               | 22 +++++++++++++++++-----
 demos/memphis/Makefile.am             |  1 +
 demos/{ => memphis}/default-rules.xml |  0
 demos/{ => memphis}/high-contrast.xml |  0
 demos/{ => memphis}/las_palmas.osm    |  0
 demos/memphis/meson.build             | 14 ++++++++++++++
 demos/{ => memphis}/schaffhausen.osm  |  0
 demos/meson.build                     | 22 ++++++++++++++++++++++
 10 files changed, 57 insertions(+), 7 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cfb3a78..90824ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -196,6 +196,7 @@ AC_CONFIG_FILES([Makefile
                  champlain/champlain-version.h
                  demos/Makefile
                  demos/icons/Makefile
+                 demos/memphis/Makefile
                  docs/Makefile
                  docs/reference/Makefile
                  docs/reference/version.xml
diff --git a/demos/Makefile.am b/demos/Makefile.am
index bc210a1..b74823a 100644
--- a/demos/Makefile.am
+++ b/demos/Makefile.am
@@ -1,6 +1,6 @@
 noinst_PROGRAMS = minimal launcher animated-marker polygons url-marker create-destroy-test
 
-SUBDIRS = icons
+SUBDIRS = icons memphis
 
 AM_CPPFLAGS = $(DEPS_CFLAGS) $(WARN_CFLAGS) -I$(top_srcdir)
 
@@ -58,5 +58,5 @@ launcher_vala_LDADD = \
        $(top_builddir)/champlain/libchamplain-@CHAMPLAIN_API_VERSION@.la
 endif
 
-EXTRA_DIST = markers.h launcher.js minimal.py launcher-gtk.py polygons.py keyboard-mapping.py 
default-rules.xml high-contrast.xml las_palmas.osm schaffhausen.osm
+EXTRA_DIST = markers.h launcher.js minimal.py launcher-gtk.py polygons.py keyboard-mapping.py
 
diff --git a/demos/local-rendering.c b/demos/local-rendering.c
index d6d3058..8dd3c99 100644
--- a/demos/local-rendering.c
+++ b/demos/local-rendering.c
@@ -462,11 +462,15 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
       ChamplainMapSource *src;
       ChamplainRenderer *image_renderer;
       guint tile_size;
+      gchar *rules_path, *map_path;
+
+      rules_path = g_build_path(G_DIR_SEPARATOR_S, "memphis", rules[rules_index], NULL);
+      map_path = g_build_path(G_DIR_SEPARATOR_S, "memphis", maps[map_index], NULL);
 
       if (g_strcmp0 (id, "memphis-local") == 0)
         {
-          champlain_memphis_renderer_load_rules (CHAMPLAIN_MEMPHIS_RENDERER (renderer), rules[rules_index]);
-          champlain_file_tile_source_load_map_data (CHAMPLAIN_FILE_TILE_SOURCE (source), maps[map_index]);
+          champlain_memphis_renderer_load_rules (CHAMPLAIN_MEMPHIS_RENDERER (renderer), rules_path);
+          champlain_file_tile_source_load_map_data (CHAMPLAIN_FILE_TILE_SOURCE (source), map_path);
           gtk_widget_hide (memphis_box);
           gtk_widget_set_no_show_all (memphis_box, FALSE);
           gtk_widget_set_no_show_all (memphis_local_box, FALSE);
@@ -475,7 +479,7 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
         }
       else if (g_strcmp0 (id, "memphis-network") == 0)
         {
-          champlain_memphis_renderer_load_rules (CHAMPLAIN_MEMPHIS_RENDERER (renderer), rules[rules_index]);
+          champlain_memphis_renderer_load_rules (CHAMPLAIN_MEMPHIS_RENDERER (renderer), rules_path);
           load_network_map_data (CHAMPLAIN_NETWORK_BBOX_TILE_SOURCE (source), view);
           gtk_widget_hide (memphis_box);
           gtk_widget_set_no_show_all (memphis_box, FALSE);
@@ -489,6 +493,9 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
           gtk_widget_set_no_show_all (memphis_box, TRUE);
         }
 
+      g_free (rules_path);
+      g_free (map_path);
+
       tile_source = CHAMPLAIN_MAP_SOURCE (source);
 
       source_chain = champlain_map_source_chain_new ();
@@ -540,8 +547,11 @@ map_data_changed (GtkWidget *widget, ChamplainView *view)
 
   if (g_strcmp0 (champlain_map_source_get_id (tile_source), "memphis-local") == 0)
     {
-      champlain_file_tile_source_load_map_data (CHAMPLAIN_FILE_TILE_SOURCE (tile_source), maps[map_index]);
+      gchar *map_path = g_build_path(G_DIR_SEPARATOR_S, "memphis", maps[map_index], NULL);
+
+      champlain_file_tile_source_load_map_data (CHAMPLAIN_FILE_TILE_SOURCE (tile_source), map_path);
       reload_tiles ();
+      g_free (map_path);
     }
 }
 
@@ -562,11 +572,13 @@ rules_changed (GtkWidget *widget, ChamplainView *view)
   if (strncmp (champlain_map_source_get_id (tile_source), "memphis", 7) == 0)
     {
       ChamplainMemphisRenderer *renderer;
+      gchar *rules_path = g_build_path(G_DIR_SEPARATOR_S, "memphis", file, NULL);
 
       renderer = CHAMPLAIN_MEMPHIS_RENDERER (champlain_map_source_get_renderer (CHAMPLAIN_MAP_SOURCE 
(tile_source)));
-      champlain_memphis_renderer_load_rules (renderer, file);
+      champlain_memphis_renderer_load_rules (renderer, rules_path);
       load_rules_into_gui (view);
       reload_tiles ();
+      g_free (rules_path);
     }
 }
 
diff --git a/demos/memphis/Makefile.am b/demos/memphis/Makefile.am
new file mode 100644
index 0000000..73cc545
--- /dev/null
+++ b/demos/memphis/Makefile.am
@@ -0,0 +1 @@
+EXTRA_DIST = default-rules.xml high-contrast.xml las_palmas.osm schaffhausen.osm
diff --git a/demos/default-rules.xml b/demos/memphis/default-rules.xml
similarity index 100%
rename from demos/default-rules.xml
rename to demos/memphis/default-rules.xml
diff --git a/demos/high-contrast.xml b/demos/memphis/high-contrast.xml
similarity index 100%
rename from demos/high-contrast.xml
rename to demos/memphis/high-contrast.xml
diff --git a/demos/las_palmas.osm b/demos/memphis/las_palmas.osm
similarity index 100%
rename from demos/las_palmas.osm
rename to demos/memphis/las_palmas.osm
diff --git a/demos/memphis/meson.build b/demos/memphis/meson.build
new file mode 100644
index 0000000..aa24ee1
--- /dev/null
+++ b/demos/memphis/meson.build
@@ -0,0 +1,14 @@
+libchamplain_memphis_data = [
+  'default-rules.xml',
+  'high-contrast.xml',
+  'las_palmas.osm',
+  'schaffhausen.osm',
+]
+
+custom_target(
+  'libchamplain_memphis_data',
+  input: libchamplain_memphis_data,
+  output: libchamplain_memphis_data,
+  command: ['cp', '@INPUT@', '@OUTDIR@'],
+  build_by_default: true,
+)
diff --git a/demos/schaffhausen.osm b/demos/memphis/schaffhausen.osm
similarity index 100%
rename from demos/schaffhausen.osm
rename to demos/memphis/schaffhausen.osm
diff --git a/demos/meson.build b/demos/meson.build
index 0f49e5f..47c9979 100644
--- a/demos/meson.build
+++ b/demos/meson.build
@@ -22,6 +22,7 @@ foreach demo: libchamplain_demos
 endforeach
 
 subdir('icons')
+subdir('memphis')
 
 if build_gtk_widgetry == true
   libchamplain_gtk_demos = [
@@ -68,3 +69,24 @@ if generate_vapi == true and build_gtk_widgetry == true
     )
   endforeach
 endif
+
+if build_with_memphis == true and build_gtk_widgetry == true
+  libchamplain_memphis_demos = [
+    ['local-rendering', 'local-rendering.c'],
+  ]
+
+  foreach demo: libchamplain_memphis_demos
+    demo_name = demo.get(0)
+    demo_sources = demo.get(1)
+
+    executable(
+      demo_name,
+      demo_sources,
+      install: false,
+      dependencies: [
+        libchamplain_dep,
+        libchamplain_gtk_dep,
+      ]
+    )
+  endforeach
+endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]