]> err.no Git - mapper/commitdiff
MapWidget: Some more properties, free mutex and condition variables on free.
authorKaj-Michael Lang <milang@tal.org>
Wed, 20 Aug 2008 13:53:14 +0000 (16:53 +0300)
committerKaj-Michael Lang <milang@tal.org>
Wed, 20 Aug 2008 13:53:14 +0000 (16:53 +0300)
libs/libgtkmap/tilerepo.c
libs/libgtkmap/tilerepo.h

index 0a2ed9a47501db80f180ca3e7c0dc2b7f7ea6972..c7441f2afff3d7624f8ae99f4aeb6ffb58894bff 100644 (file)
@@ -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);
 }
index aa3fc29f5ebeec5869a092881dda506d3a399b87..59580b55e6b566f6466e9d65a731b80b90306e70 100644 (file)
@@ -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;