From 395771099269d017e9be2a0f4198adb0186f0cd0 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Wed, 20 Aug 2008 16:53:14 +0300 Subject: [PATCH] MapWidget: Some more properties, free mutex and condition variables on free. --- libs/libgtkmap/tilerepo.c | 33 +++++++++++++++++++++++++++++++++ libs/libgtkmap/tilerepo.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/libs/libgtkmap/tilerepo.c b/libs/libgtkmap/tilerepo.c index 0a2ed9a..c7441f2 100644 --- a/libs/libgtkmap/tilerepo.c +++ b/libs/libgtkmap/tilerepo.c @@ -40,6 +40,9 @@ enum { PROP_NAME=1, PROP_URL, PROP_CACHE_DIR, + PROP_AUTO_DOWNLOAD, + PROP_AUTO_UPDATE, + PROP_MAX_AGE, }; typedef struct _ProgressUpdateInfo ProgressUpdateInfo; @@ -91,6 +94,12 @@ switch (prop_id) { g_free(tr->cache_dir); tr->cache_dir=g_value_dup_string(value); break; + case PROP_AUTO_DOWNLOAD: + break; + case PROP_AUTO_UPDATE: + break; + case PROP_MAX_AGE: + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -112,6 +121,15 @@ switch (prop_id) { case PROP_CACHE_DIR: g_value_set_string(value, tr->cache_dir); break; + case PROP_AUTO_DOWNLOAD: + g_value_set_boolean(value, tr->auto_download); + break; + case PROP_AUTO_UPDATE: + g_value_set_boolean(value, tr->auto_update); + break; + case PROP_MAX_AGE: + g_value_set_long(value, tr->max_age); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -121,12 +139,22 @@ switch (prop_id) { static void tile_repo_class_init(TileRepoClass *klass) { +GParamSpec *pspec; 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; + +pspec=g_param_spec_uint("max-age","Tile max age","Redownload if tile is over max-age and auto-update is true", 0, 2, 1, G_PARAM_READWRITE); +g_object_class_install_property (object_class, PROP_MAX_AGE, pspec); + +pspec=g_param_spec_boolean("auto-download","Auto download tiles","Automaticaly download map tiles when needed", FALSE, G_PARAM_READWRITE); +g_object_class_install_property(object_class, PROP_AUTO_DOWNLOAD, pspec); + +pspec=g_param_spec_boolean("auto-update","Refresh tiles","Automaticaly refresh old tiles", FALSE, G_PARAM_READWRITE); +g_object_class_install_property(object_class, PROP_AUTO_UPDATE, pspec); } static gboolean @@ -197,6 +225,9 @@ tr->cache_dir=NULL; tr->dl_zoom_steps=1; tr->double_size=0; tr->nextable=FALSE; +tr->auto_download=FALSE; +tr->auto_update=FALSE; +tr->max_age=604800; tr->download.cond=g_cond_new(); tr->download.mutex=g_mutex_new(); @@ -333,6 +364,8 @@ if (tr->download.pui_by_easy) g_hash_table_destroy(tr->download.pui_by_easy); if (tr->download.curl_easy_queue) g_queue_free(tr->download.curl_easy_queue); +g_cond_free(tr->download.cond); +g_mutex_free(tr->download.mutex); g_object_unref(tr); } diff --git a/libs/libgtkmap/tilerepo.h b/libs/libgtkmap/tilerepo.h index aa3fc29..59580b5 100644 --- a/libs/libgtkmap/tilerepo.h +++ b/libs/libgtkmap/tilerepo.h @@ -76,6 +76,9 @@ struct _TileRepo { guint max_zoom; gboolean double_size; gboolean nextable; + gboolean auto_download; + gboolean auto_update; + guint max_age; ImageCache *icache; RepoType type; TileDownload download; -- 2.39.5