]> err.no Git - mapper/commitdiff
TileRepo: Add properties handlers
authorKaj-Michael Lang <milang@tal.org>
Tue, 12 Aug 2008 14:36:13 +0000 (17:36 +0300)
committerKaj-Michael Lang <milang@tal.org>
Tue, 12 Aug 2008 14:36:13 +0000 (17:36 +0300)
libs/libgtkmap/tilerepo.c
libs/libgtkmap/tilerepo.h

index 7c2ad3488e36291565804c1f52c8a2b70a9b22aa..d3d85c0bb14e3b770a0386ed428cfb61070e3c29 100644 (file)
@@ -35,6 +35,13 @@ G_DEFINE_TYPE(TileRepo, tile_repo, G_TYPE_OBJECT);
 /* Filename buffer */
 #define BUFFER_SIZE (2048)
 
+/* Property IDs */
+enum {
+       PROP_NAME=1,
+       PROP_URL,
+       PROP_CACHE_DIR,
+};
+
 #if 0
 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TILE_REPO_TYPE, TileRepoPrivate))
 #endif
@@ -51,6 +58,36 @@ tile_repo_finalize(GObject *object)
 TileRepo *tr=TILE_REPO(object);
 }
 
+static void
+tile_repo_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+TileRepo *tr=TILE_REPO(object);
+
+switch (prop_id) {
+       case PROP_NAME:
+       case PROP_URL:
+       case PROP_CACHE_DIR:
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+       break;
+}
+}
+
+static void
+tile_repo_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec   *pspec)
+{
+TileRepo *tr=TILE_REPO(object);
+
+switch (prop_id) {
+       case PROP_NAME:
+       case PROP_URL:
+       case PROP_CACHE_DIR:
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+       break;
+}
+}
+
 static void
 tile_repo_class_init(TileRepoClass *klass)
 {
@@ -58,6 +95,8 @@ GObjectClass *object_class=G_OBJECT_CLASS(klass);
 
 object_class->dispose=tile_repo_dispose;
 object_class->finalize=tile_repo_finalize;
+object_class->set_property=tile_repo_set_property;
+object_class->get_property=tile_repo_get_property;
 }
 
 /**
@@ -79,6 +118,7 @@ tr->min_zoom=0;
 tr->max_zoom=17;
 tr->view_zoom_steps=1;
 tr->icache=image_cache_new(64);
+tr->type=REPOTYPE_NONE;
 }
 
 /**
@@ -108,17 +148,17 @@ g_return_val_if_fail(tr, NULL);
 /* Parse name. */
 token=strsep(&str, "\n\t");
 if (token)
-       tr->name = g_strdup(token);
+       tr->name=g_strdup(token);
 
 /* Parse URL format. */
 token=strsep(&str, "\n\t");
 if (token)
-       tr->url = g_strdup(token);
+       tr->url=g_strdup(token);
 
 /* Parse cache dir. */
 token=strsep(&str, "\n\t");
 if (token)
-       tr->cache_dir=gnome_vfs_expand_initial_tilde(token);
+       tr->cache_dir=token;
 
 /* Parse download zoom steps. */
 token=strsep(&str, "\n\t");
@@ -144,6 +184,21 @@ tile_repo_set_type(tr);
 return tr;
 }
 
+/**
+ * tile_repo_get_string:
+ * 
+ * Returns a string representation of the tile repository. Caller must free the returned string.
+ *
+ */
+gchar *
+tile_repo_get_string(TileRepo *tr)
+{
+return g_strdup_printf("%s\t%s\t%s\t%d\t%d\t%d\t%d",
+       tr->name, tr->url, tr->cache_dir,
+       tr->dl_zoom_steps, tr->view_zoom_steps,
+       tr->double_size, tr->nextable);
+}
+
 /**
  * tile_repo_free:
  * @tr
index 5478349263b1f10565b530e17c4b7c6a03b3d3b8..ec4e5c4d4fc07cd7469f2d8b3235c3ede62f4657 100644 (file)
@@ -74,6 +74,7 @@ TileRepo *tile_repo_new(void);
 TileRepo *tile_repo_new_from_string(gchar *str);
 void tile_repo_free(TileRepo *tr);
 void tile_repo_set_type(TileRepo *tr);
+gchar *tile_repo_get_string(TileRepo *tr);
 GdkPixbuf *tile_repo_load(TileRepo *tr, guint tilex, guint tiley, gint zoom, gint zoff, gboolean fast_fail);
 
 G_END_DECLS