[libchamplain] Remove the reload-tiles signal



commit 04a1b4b287daffbeaa5ae1a5ebed13fcf19dd329
Author: JiÅ?í Techet <techet gmail com>
Date:   Mon Aug 2 22:41:23 2010 +0200

    Remove the reload-tiles signal
    
    The reload-tiles signal complicates a lot of things in
    libchamplain. In addition, it causes double-(or more)-reload
    when multiple rendering properties change. Instead
    invoke reload manually from local rendering demo, which
    adds just a few extra lines.
    
    Signed-off-by: JiÅ?í Techet <techet gmail com>

 champlain/champlain-map-source-chain.c |   53 +++++++---------------
 champlain/champlain-map-source.c       |   77 +-------------------------------
 champlain/champlain-map-source.h       |    4 --
 champlain/champlain-memory-cache.c     |   12 -----
 champlain/champlain-memphis-renderer.c |   15 ------
 champlain/champlain-renderer.c         |   15 ------
 champlain/champlain-view.c             |   13 +-----
 champlain/champlain-view.h             |    2 +
 demos/local-rendering.c                |   68 ++++++++++++++++++----------
 9 files changed, 64 insertions(+), 195 deletions(-)
---
diff --git a/champlain/champlain-map-source-chain.c b/champlain/champlain-map-source-chain.c
index ea291b5..c3a6536 100644
--- a/champlain/champlain-map-source-chain.c
+++ b/champlain/champlain-map-source-chain.c
@@ -43,7 +43,6 @@ struct _ChamplainMapSourceChainPrivate
 {
   ChamplainMapSource *stack_top;
   ChamplainMapSource *stack_bottom;
-  gulong sig_handler_id;
 };
 
 static const gchar *get_id (ChamplainMapSource *map_source);
@@ -56,9 +55,8 @@ static guint get_tile_size (ChamplainMapSource *map_source);
 
 static void fill_tile (ChamplainMapSource *map_source,
     ChamplainTile *tile);
-static void on_set_next_source (ChamplainMapSource *map_source,
-    ChamplainMapSource *old_next_source,
-    ChamplainMapSource *new_next_source);
+static void on_set_next_source_cb (ChamplainMapSourceChain *source_chain,
+    G_GNUC_UNUSED gpointer user_data);
 
 
 static void
@@ -101,7 +99,6 @@ champlain_map_source_chain_class_init (ChamplainMapSourceChainClass *klass)
   map_source_class->get_tile_size = get_tile_size;
 
   map_source_class->fill_tile = fill_tile;
-  map_source_class->on_set_next_source = on_set_next_source;
 }
 
 
@@ -114,6 +111,9 @@ champlain_map_source_chain_init (ChamplainMapSourceChain *source_chain)
 
   priv->stack_top = NULL;
   priv->stack_bottom = NULL;
+  
+  g_signal_connect (source_chain, "notify::next-source",
+      G_CALLBACK (on_set_next_source_cb), NULL);
 }
 
 
@@ -247,17 +247,19 @@ fill_tile (ChamplainMapSource *map_source,
 
 
 static void
-on_set_next_source (ChamplainMapSource *map_source,
-    G_GNUC_UNUSED ChamplainMapSource *old_next_source,
-    ChamplainMapSource *new_next_source)
+on_set_next_source_cb (ChamplainMapSourceChain *source_chain,
+    G_GNUC_UNUSED gpointer user_data)
 {
-  ChamplainMapSourceChain *source_chain = CHAMPLAIN_MAP_SOURCE_CHAIN (map_source);
-  ChamplainMapSourceChainPrivate *priv = source_chain->priv;
-
   g_return_if_fail (source_chain);
 
+  ChamplainMapSourceChainPrivate *priv = source_chain->priv;
+  ChamplainMapSource *map_source = CHAMPLAIN_MAP_SOURCE (source_chain);
+  ChamplainMapSource *next_source;
+  
+  next_source = champlain_map_source_get_next_source (map_source);
+
   if (priv->stack_bottom)
-    champlain_map_source_set_next_source (priv->stack_bottom, new_next_source);
+    champlain_map_source_set_next_source (priv->stack_bottom, next_source);
 }
 
 
@@ -272,7 +274,8 @@ assign_cache_of_next_source_sequence (ChamplainMapSourceChain *source_chain,
   do
     {
       map_source = champlain_map_source_get_next_source (map_source);
-    } while (CHAMPLAIN_IS_TILE_CACHE (map_source));
+    } 
+  while (CHAMPLAIN_IS_TILE_CACHE (map_source));
 
   while (CHAMPLAIN_IS_TILE_SOURCE (map_source) && map_source != chain_next_source)
     {
@@ -282,15 +285,6 @@ assign_cache_of_next_source_sequence (ChamplainMapSourceChain *source_chain,
 }
 
 
-static void
-reload_tiles_cb (G_GNUC_UNUSED ChamplainMapSource *map_source,
-    ChamplainMapSourceChain *source_chain)
-{
-  /* propagate the signal from the chain that is inside champlain_map_source_chain */
-  g_signal_emit_by_name (source_chain, "reload-tiles", NULL);
-}
-
-
 /**
  * champlain_map_source_chain_push:
  * @source_chain: a #ChamplainMapSourceChain
@@ -328,9 +322,6 @@ champlain_map_source_chain_push (ChamplainMapSourceChain *source_chain,
     }
   else
     {
-      if (g_signal_handler_is_connected (priv->stack_top, priv->sig_handler_id))
-        g_signal_handler_disconnect (priv->stack_top, priv->sig_handler_id);
-
       champlain_map_source_set_next_source (map_source, priv->stack_top);
       priv->stack_top = map_source;
 
@@ -340,9 +331,6 @@ champlain_map_source_chain_push (ChamplainMapSourceChain *source_chain,
           assign_cache_of_next_source_sequence (source_chain, priv->stack_top, tile_cache);
         }
     }
-
-  priv->sig_handler_id = g_signal_connect (priv->stack_top, "reload-tiles",
-      G_CALLBACK (reload_tiles_cb), source_chain);
 }
 
 
@@ -363,9 +351,6 @@ champlain_map_source_chain_pop (ChamplainMapSourceChain *source_chain)
 
   g_return_if_fail (priv->stack_top);
 
-  if (g_signal_handler_is_connected (priv->stack_top, priv->sig_handler_id))
-    g_signal_handler_disconnect (priv->stack_top, priv->sig_handler_id);
-
   if (CHAMPLAIN_IS_TILE_CACHE (priv->stack_top))
     {
       ChamplainTileCache *tile_cache = NULL;
@@ -386,11 +371,5 @@ champlain_map_source_chain_pop (ChamplainMapSourceChain *source_chain)
   else
     priv->stack_top = next_source;
 
-  if (priv->stack_top)
-    {
-      priv->sig_handler_id = g_signal_connect (priv->stack_top, "reload-tiles",
-          G_CALLBACK (reload_tiles_cb), source_chain);
-    }
-
   g_object_unref (old_stack_top);
 }
diff --git a/champlain/champlain-map-source.c b/champlain/champlain-map-source.c
index c1783ea..6be9944 100644
--- a/champlain/champlain-map-source.c
+++ b/champlain/champlain-map-source.c
@@ -61,35 +61,17 @@ G_DEFINE_TYPE (ChamplainMapSource, champlain_map_source, G_TYPE_INITIALLY_UNOWNE
 
 enum
 {
-  /* normal signals */
-  RELOAD_TILES,
-  LAST_SIGNAL
-};
-
-enum
-{
   PROP_0,
   PROP_NEXT_SOURCE,
   PROP_RENDERER,
 };
 
-static guint champlain_map_source_signals[LAST_SIGNAL] = { 0, };
-
 struct _ChamplainMapSourcePrivate
 {
   ChamplainMapSource *next_source;
   ChamplainRenderer *renderer;
-
-  gulong sig_handler_id;
-  gulong renderer_sig_handler_id;
 };
 
-static void reload_tiles_cb (ChamplainMapSource *orig,
-    ChamplainMapSource *self);
-static void on_set_next_source (ChamplainMapSource *map_source,
-    ChamplainMapSource *old_next_source,
-    ChamplainMapSource *new_next_source);
-
 static void
 champlain_map_source_get_property (GObject *object,
     guint prop_id,
@@ -202,7 +184,6 @@ champlain_map_source_class_init (ChamplainMapSourceClass *klass)
   klass->get_projection = NULL;
 
   klass->fill_tile = NULL;
-  klass->on_set_next_source = on_set_next_source;
 
   /**
    * ChamplainMapSource:next-source:
@@ -231,21 +212,6 @@ champlain_map_source_class_init (ChamplainMapSourceClass *klass)
       CHAMPLAIN_TYPE_RENDERER,
       G_PARAM_READWRITE);
   g_object_class_install_property (object_class, PROP_RENDERER, pspec);
-
-  /**
-   * ChamplainMapSource::reload-tiles:
-   * @map_source: the #ChamplainMapSource that received the signal
-   *
-   * The ChamplainMapSource::reload-tiles signal is emitted when the map source
-   * changed its style or data
-   *
-   * Since: 0.6
-   */
-  champlain_map_source_signals[RELOAD_TILES] =
-    g_signal_new ("reload-tiles", G_OBJECT_CLASS_TYPE (object_class),
-        G_SIGNAL_RUN_LAST, 0, NULL, NULL,
-        g_cclosure_marshal_VOID__VOID, G_TYPE_NONE,
-        0, NULL);
 }
 
 
@@ -258,8 +224,6 @@ champlain_map_source_init (ChamplainMapSource *map_source)
 
   priv->next_source = NULL;
   priv->renderer = NULL;
-  priv->sig_handler_id = 0;
-  priv->renderer_sig_handler_id = 0;
 }
 
 
@@ -301,35 +265,6 @@ champlain_map_source_get_renderer (ChamplainMapSource *map_source)
 }
 
 
-static void
-reload_tiles_cb (G_GNUC_UNUSED ChamplainMapSource *orig, ChamplainMapSource *self)
-{
-  /* propagate the signal up the chain */
-  g_signal_emit_by_name (self, "reload-tiles", NULL);
-}
-
-
-static void
-on_set_next_source (ChamplainMapSource *map_source,
-    ChamplainMapSource *old_next_source,
-    ChamplainMapSource *new_next_source)
-{
-  ChamplainMapSourcePrivate *priv = map_source->priv;
-
-  if (old_next_source)
-    {
-      if (g_signal_handler_is_connected (old_next_source, priv->sig_handler_id))
-        g_signal_handler_disconnect (old_next_source, priv->sig_handler_id);
-    }
-
-  if (new_next_source)
-    {
-      priv->sig_handler_id = g_signal_connect (new_next_source, "reload-tiles",
-          G_CALLBACK (reload_tiles_cb), map_source);
-    }
-}
-
-
 /**
  * champlain_map_source_set_next_source:
  * @map_source: a #ChamplainMapSource
@@ -347,8 +282,6 @@ champlain_map_source_set_next_source (ChamplainMapSource *map_source,
 
   ChamplainMapSourcePrivate *priv = map_source->priv;
 
-  CHAMPLAIN_MAP_SOURCE_GET_CLASS (map_source)->on_set_next_source (map_source, priv->next_source, next_source);
-
   if (priv->next_source != NULL)
     g_object_unref (priv->next_source);
 
@@ -384,19 +317,11 @@ champlain_map_source_set_renderer (ChamplainMapSource *map_source,
   ChamplainMapSourcePrivate *priv = map_source->priv;
 
   if (priv->renderer != NULL)
-    {
-      if (g_signal_handler_is_connected (priv->renderer, priv->renderer_sig_handler_id))
-        g_signal_handler_disconnect (priv->renderer, priv->renderer_sig_handler_id);
-
-      g_object_unref (priv->renderer);
-    }
+    g_object_unref (priv->renderer);
 
   g_object_ref_sink (renderer);
   priv->renderer = renderer;
 
-  priv->renderer_sig_handler_id = g_signal_connect (renderer, "reload-tiles",
-      G_CALLBACK (reload_tiles_cb), map_source);
-
   g_object_notify (G_OBJECT (map_source), "renderer");
 }
 
diff --git a/champlain/champlain-map-source.h b/champlain/champlain-map-source.h
index 26cc10e..eb69ce0 100644
--- a/champlain/champlain-map-source.h
+++ b/champlain/champlain-map-source.h
@@ -83,10 +83,6 @@ struct _ChamplainMapSourceClass
 
   void (*fill_tile)(ChamplainMapSource *map_source,
       ChamplainTile *tile);
-
-  void (*on_set_next_source)(ChamplainMapSource *map_source,
-      ChamplainMapSource *next_source,
-      ChamplainMapSource *new_next_source);
 };
 
 GType champlain_map_source_get_type (void);
diff --git a/champlain/champlain-memory-cache.c b/champlain/champlain-memory-cache.c
index be7ee6d..f464d86 100644
--- a/champlain/champlain-memory-cache.c
+++ b/champlain/champlain-memory-cache.c
@@ -177,24 +177,12 @@ champlain_memory_cache_new_full (guint size_limit,
 
 
 static void
-reload_tiles_cb (ChamplainMemoryCache *memory_cache, G_GNUC_UNUSED gpointer data)
-{
-  g_return_if_fail (CHAMPLAIN_IS_MEMORY_CACHE (memory_cache));
-
-  champlain_memory_cache_clean (memory_cache);
-}
-
-
-static void
 champlain_memory_cache_init (ChamplainMemoryCache *memory_cache)
 {
   ChamplainMemoryCachePrivate *priv = GET_PRIVATE (memory_cache);
 
   memory_cache->priv = priv;
 
-  g_signal_connect (memory_cache, "reload-tiles",
-      G_CALLBACK (reload_tiles_cb), NULL);
-
   priv->queue = g_queue_new ();
 }
 
diff --git a/champlain/champlain-memphis-renderer.c b/champlain/champlain-memphis-renderer.c
index 2c6a69f..6bd16dd 100644
--- a/champlain/champlain-memphis-renderer.c
+++ b/champlain/champlain-memphis-renderer.c
@@ -471,9 +471,6 @@ set_data (ChamplainRenderer *renderer,
       &bbox->right, &bbox->bottom);
   g_object_set (G_OBJECT (renderer), "bounding-box", bbox, NULL);
   champlain_bounding_box_free (bbox);
-
-  g_signal_emit_by_name (CHAMPLAIN_RENDERER (renderer),
-      "reload-tiles", NULL);
 }
 
 
@@ -522,9 +519,6 @@ champlain_memphis_renderer_load_rules (
         strlen (default_rules), NULL);
 
   g_static_rw_lock_writer_unlock (&MemphisLock);
-
-  g_signal_emit_by_name (CHAMPLAIN_RENDERER (renderer),
-      "reload-tiles", NULL);
 }
 
 
@@ -580,9 +574,6 @@ champlain_memphis_renderer_set_background_color (
   memphis_rule_set_set_bg_color (renderer->priv->rules, color->red,
       color->green, color->blue, color->alpha);
   g_static_rw_lock_writer_unlock (&MemphisLock);
-
-  g_signal_emit_by_name (CHAMPLAIN_RENDERER (renderer),
-      "reload-tiles", NULL);
 }
 
 
@@ -606,9 +597,6 @@ champlain_memphis_renderer_set_rule (ChamplainMemphisRenderer *renderer,
   g_static_rw_lock_writer_lock (&MemphisLock);
   memphis_rule_set_set_rule (renderer->priv->rules, (MemphisRule *) rule);
   g_static_rw_lock_writer_unlock (&MemphisLock);
-
-  g_signal_emit_by_name (CHAMPLAIN_RENDERER (renderer),
-      "reload-tiles", NULL);
 }
 
 
@@ -687,9 +675,6 @@ champlain_memphis_renderer_remove_rule (
   g_static_rw_lock_writer_lock (&MemphisLock);
   memphis_rule_set_remove_rule (renderer->priv->rules, id);
   g_static_rw_lock_writer_unlock (&MemphisLock);
-
-  g_signal_emit_by_name (CHAMPLAIN_RENDERER (renderer),
-      "reload-tiles", NULL);
 }
 
 
diff --git a/champlain/champlain-renderer.c b/champlain/champlain-renderer.c
index 9c2efe8..e1fad8e 100644
--- a/champlain/champlain-renderer.c
+++ b/champlain/champlain-renderer.c
@@ -20,15 +20,6 @@
 
 G_DEFINE_TYPE (ChamplainRenderer, champlain_renderer, G_TYPE_OBJECT)
 
-enum
-{
-  /* normal signals */
-  RELOAD_TILES,
-  LAST_SIGNAL
-};
-
-static guint champlain_renderer_signals[LAST_SIGNAL] = { 0, };
-
 static void
 champlain_renderer_dispose (GObject *object)
 {
@@ -53,12 +44,6 @@ champlain_renderer_class_init (ChamplainRendererClass *klass)
 
   klass->set_data = NULL;
   klass->render = NULL;
-
-  champlain_renderer_signals[RELOAD_TILES] =
-    g_signal_new ("reload-tiles", G_OBJECT_CLASS_TYPE (object_class),
-        G_SIGNAL_RUN_LAST, 0, NULL, NULL,
-        g_cclosure_marshal_VOID__VOID, G_TYPE_NONE,
-        0, NULL);
 }
 
 
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 470ae52..fd27dcd 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -251,8 +251,6 @@ static void update_scale (ChamplainView *view);
 static void view_load_visible_tiles (ChamplainView *view);
 static void view_position_tile (ChamplainView *view,
     ChamplainTile *tile);
-static void view_reload_tiles_cb (ChamplainMapSource *map_source,
-    ChamplainView *view);
 static void view_update_state (ChamplainView *view,
     ChamplainTile *tile);
 static void view_update_anchor (ChamplainView *view,
@@ -1650,9 +1648,6 @@ champlain_view_init (ChamplainView *view)
 
   priv->state = CHAMPLAIN_STATE_DONE;
   g_object_notify (G_OBJECT (view), "state");
-
-  g_signal_connect (priv->map_source, "reload-tiles",
-      G_CALLBACK (view_reload_tiles_cb), view);
 }
 
 
@@ -2651,9 +2646,8 @@ view_position_tile (ChamplainView *view,
 }
 
 
-static void
-view_reload_tiles_cb (G_GNUC_UNUSED ChamplainMapSource *map_source,
-    ChamplainView *view)
+void
+champlain_view_reload_tiles (ChamplainView *view)
 {
   DEBUG_LOG ()
 
@@ -2773,9 +2767,6 @@ champlain_view_set_map_source (ChamplainView *view,
   update_license (view);
   champlain_view_center_on (view, priv->latitude, priv->longitude);
 
-  g_signal_connect (priv->map_source, "reload-tiles",
-      G_CALLBACK (view_reload_tiles_cb), view);
-
   g_object_notify (G_OBJECT (view), "map-source");
 }
 
diff --git a/champlain/champlain-view.h b/champlain/champlain-view.h
index 9f93795..88a031d 100644
--- a/champlain/champlain-view.h
+++ b/champlain/champlain-view.h
@@ -184,6 +184,8 @@ void champlain_view_add_polygon (ChamplainView *view,
 void champlain_view_remove_polygon (ChamplainView *view,
     ChamplainPolygon *polygon);
 
+void champlain_view_reload_tiles (ChamplainView *view);
+
 G_END_DECLS
 
 #endif
diff --git a/demos/local-rendering.c b/demos/local-rendering.c
index e6a1e35..2284f21 100644
--- a/demos/local-rendering.c
+++ b/demos/local-rendering.c
@@ -48,6 +48,9 @@ static GtkWidget *textcolor, *textsize, *textminz, *textmaxz;
 static ChamplainMemphisRule *current_rule = NULL;
 
 static ChamplainMapSource *tile_source = NULL;
+static ChamplainMemoryCache *memory_cache = NULL;
+
+static ChamplainView *champlain_view;
 
 /*
  * Terminate the main loop.
@@ -81,10 +84,19 @@ color_clutter_to_gdk (const ClutterColor *clutter_color,
 
 
 static void
+reload_tiles ()
+{
+  champlain_memory_cache_clean (memory_cache);
+  champlain_view_reload_tiles (champlain_view);
+}
+
+
+static void
 data_source_state_changed (ChamplainNetworkBboxTileSource *source,
     GtkImage *image)
 {
   gtk_image_clear (image);
+  reload_tiles ();
   g_print ("NET DATA SOURCE STATE: done\n");
   g_signal_handlers_disconnect_by_func (source,
       data_source_state_changed,
@@ -201,6 +213,7 @@ rule_apply_cb (GtkWidget *widget, ChamplainMemphisRenderer *renderer)
     }
 
   champlain_memphis_renderer_set_rule (renderer, rule);
+  reload_tiles ();
 }
 
 
@@ -393,6 +406,7 @@ bg_color_set_cb (GtkColorButton *widget, ChamplainView *view)
       renderer = CHAMPLAIN_MEMPHIS_RENDERER (champlain_map_source_get_renderer (CHAMPLAIN_MAP_SOURCE (tile_source)));
 
       champlain_memphis_renderer_set_background_color (renderer, &clutter_color);
+      reload_tiles ();
     }
 }
 
@@ -404,7 +418,7 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
   ChamplainMapSource *source;
   GtkTreeIter iter;
   GtkTreeModel *model;
-  ChamplainMemphisRenderer *renderer;
+  ChamplainRenderer *renderer;
 
   if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
     return;
@@ -415,17 +429,18 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
 
   ChamplainMapSourceFactory *factory = champlain_map_source_factory_dup_default ();
   source = champlain_map_source_factory_create (factory, id);
-  renderer = CHAMPLAIN_MEMPHIS_RENDERER (champlain_map_source_get_renderer (CHAMPLAIN_MAP_SOURCE (source)));
+  renderer = champlain_map_source_get_renderer (CHAMPLAIN_MAP_SOURCE (source));
 
   if (source != NULL)
     {
       ChamplainMapSourceChain *source_chain;
       ChamplainMapSource *src;
+      ChamplainRenderer *image_renderer;
       guint tile_size;
 
       if (g_strcmp0 (id, "memphis-local") == 0)
         {
-          champlain_memphis_renderer_load_rules (renderer, rules[rules_index]);
+          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]);
           gtk_widget_hide_all (memphis_box);
           gtk_widget_set_no_show_all (memphis_box, FALSE);
@@ -435,7 +450,7 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
         }
       else if (g_strcmp0 (id, "memphis-network") == 0)
         {
-          champlain_memphis_renderer_load_rules (renderer, rules[rules_index]);
+          champlain_memphis_renderer_load_rules (CHAMPLAIN_MEMPHIS_RENDERER (renderer), rules[rules_index]);
           load_network_map_data (CHAMPLAIN_NETWORK_BBOX_TILE_SOURCE (source), view);
           gtk_widget_hide_all (memphis_box);
           gtk_widget_set_no_show_all (memphis_box, FALSE);
@@ -459,10 +474,10 @@ map_source_changed (GtkWidget *widget, ChamplainView *view)
       champlain_map_source_chain_push (source_chain, src);
       champlain_map_source_chain_push (source_chain, tile_source);
 
-      src = CHAMPLAIN_MAP_SOURCE (champlain_memory_cache_new_full (100, CHAMPLAIN_RENDERER (champlain_image_renderer_new ())));
-      champlain_map_source_set_renderer (src, CHAMPLAIN_RENDERER (champlain_image_renderer_new ()));
-
-      champlain_map_source_chain_push (source_chain, src);
+      image_renderer = CHAMPLAIN_RENDERER (champlain_image_renderer_new ());
+      memory_cache = champlain_memory_cache_new_full (100, image_renderer);
+      
+      champlain_map_source_chain_push (source_chain, CHAMPLAIN_MAP_SOURCE (memory_cache));
 
       g_object_set (G_OBJECT (view), "map-source", source_chain, NULL);
       if (strncmp (id, "memphis", 7) == 0)
@@ -489,7 +504,10 @@ map_data_changed (GtkWidget *widget, ChamplainView *view)
   map_index = index;
 
   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]);
+    {
+      champlain_file_tile_source_load_map_data (CHAMPLAIN_FILE_TILE_SOURCE (tile_source), maps[map_index]);
+      reload_tiles ();
+    }
 }
 
 
@@ -513,6 +531,7 @@ rules_changed (GtkWidget *widget, ChamplainView *view)
       renderer = CHAMPLAIN_MEMPHIS_RENDERER (champlain_map_source_get_renderer (CHAMPLAIN_MAP_SOURCE (tile_source)));
       champlain_memphis_renderer_load_rules (renderer, file);
       load_rules_into_gui (view);
+      reload_tiles ();
     }
 }
 
@@ -686,7 +705,6 @@ main (int argc,
     char *argv[])
 {
   GtkWidget *widget, *hbox, *bbox, *menubox, *button, *viewport, *label;
-  ChamplainView *view;
 
   g_thread_init (NULL);
   gtk_clutter_init (&argc, &argv);
@@ -717,9 +735,9 @@ main (int argc,
   gtk_widget_set_no_show_all (memphis_local_box, TRUE);
 
   widget = gtk_champlain_embed_new ();
-  view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (widget));
+  champlain_view = gtk_champlain_embed_get_view (GTK_CHAMPLAIN_EMBED (widget));
 
-  g_object_set (G_OBJECT (view), "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
+  g_object_set (G_OBJECT (champlain_view), "scroll-mode", CHAMPLAIN_SCROLL_MODE_KINETIC,
       "zoom-level", 9, NULL);
 
   gtk_widget_set_size_request (widget, 640, 480);
@@ -727,18 +745,18 @@ main (int argc,
   /* first line of buttons */
   bbox = gtk_hbox_new (FALSE, 10);
   button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_IN);
-  g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), view);
+  g_signal_connect (button, "clicked", G_CALLBACK (zoom_in), champlain_view);
   gtk_container_add (GTK_CONTAINER (bbox), button);
 
   button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_OUT);
-  g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), view);
+  g_signal_connect (button, "clicked", G_CALLBACK (zoom_out), champlain_view);
   gtk_container_add (GTK_CONTAINER (bbox), button);
 
   button = gtk_spin_button_new_with_range (0, 20, 1);
   gtk_spin_button_set_value (GTK_SPIN_BUTTON (button),
-      champlain_view_get_zoom_level (view));
-  g_signal_connect (button, "changed", G_CALLBACK (zoom_changed), view);
-  g_signal_connect (view, "notify::zoom-level", G_CALLBACK (map_zoom_changed),
+      champlain_view_get_zoom_level (champlain_view));
+  g_signal_connect (button, "changed", G_CALLBACK (zoom_changed), champlain_view);
+  g_signal_connect (champlain_view, "notify::zoom-level", G_CALLBACK (map_zoom_changed),
       button);
   gtk_container_add (GTK_CONTAINER (bbox), button);
 
@@ -748,7 +766,7 @@ main (int argc,
   button = gtk_combo_box_new ();
   build_source_combo_box (GTK_COMBO_BOX (button));
   gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0);
-  g_signal_connect (button, "changed", G_CALLBACK (map_source_changed), view);
+  g_signal_connect (button, "changed", G_CALLBACK (map_source_changed), champlain_view);
   gtk_box_pack_start (GTK_BOX (menubox), button, FALSE, FALSE, 0);
 
   /* Memphis options */
@@ -760,18 +778,18 @@ main (int argc,
   button = gtk_combo_box_new ();
   build_data_combo_box (GTK_COMBO_BOX (button));
   gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0);
-  g_signal_connect (button, "changed", G_CALLBACK (map_data_changed), view);
+  g_signal_connect (button, "changed", G_CALLBACK (map_data_changed), champlain_view);
   gtk_box_pack_start (GTK_BOX (memphis_local_box), button, FALSE, FALSE, 0);
 
   button = gtk_button_new_from_stock (GTK_STOCK_ZOOM_FIT);
-  g_signal_connect (button, "clicked", G_CALLBACK (zoom_to_map_data), view);
+  g_signal_connect (button, "clicked", G_CALLBACK (zoom_to_map_data), champlain_view);
   gtk_container_add (GTK_CONTAINER (memphis_local_box), button);
 
   gtk_box_pack_start (GTK_BOX (memphis_box), memphis_local_box, FALSE, FALSE, 0);
 
   /* network source panel */
   button = gtk_button_new_with_label ("Request OSM data");
-  g_signal_connect (button, "clicked", G_CALLBACK (request_osm_data_cb), view);
+  g_signal_connect (button, "clicked", G_CALLBACK (request_osm_data_cb), champlain_view);
   gtk_box_pack_start (GTK_BOX (memphis_net_box), button, FALSE, FALSE, 0);
 
   map_data_state_img = gtk_image_new ();
@@ -783,7 +801,7 @@ main (int argc,
   button = gtk_combo_box_new ();
   build_rules_combo_box (GTK_COMBO_BOX (button));
   gtk_combo_box_set_active (GTK_COMBO_BOX (button), 0);
-  g_signal_connect (button, "changed", G_CALLBACK (rules_changed), view);
+  g_signal_connect (button, "changed", G_CALLBACK (rules_changed), champlain_view);
   gtk_box_pack_start (GTK_BOX (memphis_box), button, FALSE, FALSE, 0);
 
   /* bg chooser */
@@ -795,7 +813,7 @@ main (int argc,
 
   bg_button = gtk_color_button_new ();
   gtk_color_button_set_title (GTK_COLOR_BUTTON (bg_button), "Background");
-  g_signal_connect (bg_button, "color-set", G_CALLBACK (bg_color_set_cb), view);
+  g_signal_connect (bg_button, "color-set", G_CALLBACK (bg_color_set_cb), champlain_view);
   gtk_box_pack_start (GTK_BOX (bbox), bg_button, FALSE, FALSE, 0);
 
   gtk_box_pack_start (GTK_BOX (memphis_box), bbox, FALSE, FALSE, 0);
@@ -823,7 +841,7 @@ main (int argc,
   gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
 
   gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
-  g_signal_connect (tree_view, "row-activated", G_CALLBACK (list_item_selected_cb), view);
+  g_signal_connect (tree_view, "row-activated", G_CALLBACK (list_item_selected_cb), champlain_view);
 
   scrolled = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
@@ -845,7 +863,7 @@ main (int argc,
 
   /* make sure that everything, window and label, are visible */
   gtk_widget_show_all (window);
-  champlain_view_center_on (CHAMPLAIN_VIEW (view), 28.13476, -15.43814);
+  champlain_view_center_on (CHAMPLAIN_VIEW (champlain_view), 28.13476, -15.43814);
   /* start the main loop */
   gtk_main ();
 



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