From: Kaj-Michael Lang Date: Tue, 12 Aug 2008 14:36:13 +0000 (+0300) Subject: TileRepo: Add properties handlers X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8657f91f057dcf9607a57b65dd9911043b3fe23;p=mapper TileRepo: Add properties handlers --- diff --git a/libs/libgtkmap/tilerepo.c b/libs/libgtkmap/tilerepo.c index 7c2ad34..d3d85c0 100644 --- a/libs/libgtkmap/tilerepo.c +++ b/libs/libgtkmap/tilerepo.c @@ -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 diff --git a/libs/libgtkmap/tilerepo.h b/libs/libgtkmap/tilerepo.h index 5478349..ec4e5c4 100644 --- a/libs/libgtkmap/tilerepo.h +++ b/libs/libgtkmap/tilerepo.h @@ -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