[libchamplain] Remove the dependency on a default rules file.
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain] Remove the dependency on a default rules file.
- Date: Sun, 24 Jan 2010 20:13:36 +0000 (UTC)
commit b9320c6a3a6c9b7444fc63e1498d4a244fcc465d
Author: Simon Wenner <simon wenner ch>
Date: Sat Aug 15 14:55:52 2009 +0200
Remove the dependency on a default rules file.
The default rule is now hardcoded. All highway types are drawn as thin black lines.
champlain/champlain-memphis-map-source.c | 20 +++++++++++++++-----
demos/local-rendering.c | 5 +++++
2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/champlain/champlain-memphis-map-source.c b/champlain/champlain-memphis-map-source.c
index 90ba638..c48cbf5 100644
--- a/champlain/champlain-memphis-map-source.c
+++ b/champlain/champlain-memphis-map-source.c
@@ -51,17 +51,26 @@
#include "champlain-private.h"
#include <errno.h>
+#include <string.h>
#include <glib/gstdio.h>
#include <clutter-cairo.h>
#include <gdk/gdk.h>
/* Tuning parameters */
#define MAX_THREADS 4
-#define DEFAULT_TILE_SIZE 256 // FIXME find the bug
-#define DEFAULT_RULES_PATH "default-rules.xml"
+#define DEFAULT_TILE_SIZE 256 // FIXME: switching between map sources
+ // with different tile size crashes champlain.
/* 0: Be quiet, 1: Normal output, 2: Be verbose */
#define MEMPHIS_INTERNAL_DEBUG_LEVEL 0
+const gchar default_rules[] =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\
+ <rules version=\"0.1\" background=\"#ffffff\">\
+ <rule e=\"way\" k=\"highway\" v=\"*\">\
+ <line color=\"#000000\" width=\"1.0\"/>\
+ </rule>\
+ </rules>";
+
enum
{
PROP_0,
@@ -530,8 +539,8 @@ champlain_memphis_map_source_new_full (ChamplainMapSourceDesc *desc,
memphis_renderer_set_debug_level (priv->renderer,
MEMPHIS_INTERNAL_DEBUG_LEVEL);
- memphis_rule_set_load_from_file (priv->rules, DEFAULT_RULES_PATH);
- // TODO: Do we want to ship a default rule-set?
+ memphis_rule_set_load_from_data (priv->rules, default_rules,
+ strlen (default_rules));
priv->thpool = g_thread_pool_new (memphis_worker_thread, source,
MAX_THREADS, FALSE, NULL);
@@ -561,7 +570,8 @@ champlain_memphis_map_source_load_rules (
if (rules_path)
memphis_rule_set_load_from_file (priv->rules, rules_path);
else
- memphis_rule_set_load_from_file (priv->rules, DEFAULT_RULES_PATH);
+ memphis_rule_set_load_from_data (priv->rules, default_rules,
+ strlen (default_rules));
g_static_rw_lock_writer_unlock (&MemphisLock);
if (!priv->persistent_cache)
diff --git a/demos/local-rendering.c b/demos/local-rendering.c
index 06c75d0..6e93daa 100644
--- a/demos/local-rendering.c
+++ b/demos/local-rendering.c
@@ -27,6 +27,7 @@
#define COL_NAME 1
guint map_index = 0;
+guint rules_index = 0;
static const char *maps[] = { "schaffhausen.osm", "las_palmas.osm" };
static const char *rules[] = { "default-rules.xml", "high-contrast.xml" };
@@ -428,6 +429,8 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
{
if (g_strcmp0 (id, "memphis-local") == 0)
{
+ champlain_memphis_map_source_load_rules (
+ CHAMPLAIN_MEMPHIS_MAP_SOURCE (source), rules[rules_index]);
load_local_map_data (source);
gtk_widget_hide_all (memphis_box);
gtk_widget_set_no_show_all (memphis_box, FALSE);
@@ -437,6 +440,8 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
}
else if (g_strcmp0 (id, "memphis-network") == 0)
{
+ champlain_memphis_map_source_load_rules (
+ CHAMPLAIN_MEMPHIS_MAP_SOURCE (source), rules[rules_index]);
load_network_map_data (source, view);
gtk_widget_hide_all (memphis_box);
gtk_widget_set_no_show_all (memphis_box, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]