[libchamplain] Add state property to ChamplainMapDataSource
- From: Pierre-Luc Beaudoin <plbeaudoin src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libchamplain] Add state property to ChamplainMapDataSource
- Date: Sun, 24 Jan 2010 20:11:51 +0000 (UTC)
commit 10b7a1627b22ed5b5e8a7848ec9e563d8ed24e7c
Author: Simon Wenner <simon wenner ch>
Date: Mon Jul 27 22:58:29 2009 +0200
Add state property to ChamplainMapDataSource
This allows a client to know if new data is currently loading
champlain/champlain-local-map-data-source.c | 3 ++
champlain/champlain-map-data-source.c | 31 ++++++++++++++++++++++++-
champlain/champlain-network-map-data-source.c | 5 ++++
3 files changed, 38 insertions(+), 1 deletions(-)
---
diff --git a/champlain/champlain-local-map-data-source.c b/champlain/champlain-local-map-data-source.c
index fd6027d..a108ecb 100644
--- a/champlain/champlain-local-map-data-source.c
+++ b/champlain/champlain-local-map-data-source.c
@@ -21,6 +21,7 @@
#define DEBUG_FLAG CHAMPLAIN_DEBUG_MEMPHIS
#include "champlain-debug.h"
#include "champlain-bounding-box.h"
+#include "champlain-enum-types.h"
#include <memphis/memphis.h>
@@ -144,6 +145,8 @@ champlain_local_map_data_source_load_map_data (ChamplainLocalMapDataSource *self
g_object_set (G_OBJECT (self), "bounding-box", bbox, NULL);
champlain_bounding_box_free (bbox);
+ g_object_set (G_OBJECT (self), "state", CHAMPLAIN_STATE_DONE, NULL);
+
g_signal_emit_by_name (CHAMPLAIN_MAP_DATA_SOURCE (self),
"map-data-changed", NULL);
}
diff --git a/champlain/champlain-map-data-source.c b/champlain/champlain-map-data-source.c
index 7009a76..774af0d 100644
--- a/champlain/champlain-map-data-source.c
+++ b/champlain/champlain-map-data-source.c
@@ -21,6 +21,7 @@
#define DEBUG_FLAG CHAMPLAIN_DEBUG_MEMPHIS
#include "champlain-debug.h"
#include "champlain-bounding-box.h"
+#include "champlain-enum-types.h"
G_DEFINE_TYPE (ChamplainMapDataSource, champlain_map_data_source, G_TYPE_OBJECT)
@@ -36,7 +37,8 @@ enum
enum
{
PROP_0,
- PROP_BOUNDING_BOX
+ PROP_BOUNDING_BOX,
+ PROP_STATE
};
static guint signals[LAST_SIGNAL] = { 0, };
@@ -46,6 +48,7 @@ typedef struct _ChamplainMapDataSourcePrivate ChamplainMapDataSourcePrivate;
struct _ChamplainMapDataSourcePrivate {
ChamplainBoundingBox *bounding_box;
/* the area that is covered by this data source */
+ ChamplainState state;
};
static void
@@ -62,6 +65,9 @@ champlain_map_data_source_get_property (GObject *object,
case PROP_BOUNDING_BOX:
g_value_set_boxed (value, priv->bounding_box);
break;
+ case PROP_STATE:
+ g_value_set_enum (value, priv->state);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -82,6 +88,10 @@ champlain_map_data_source_set_property (GObject *object,
champlain_bounding_box_free (priv->bounding_box);
priv->bounding_box = g_value_dup_boxed (value);
break;
+ case PROP_STATE:
+ priv->state = g_value_get_enum (value);
+ g_object_notify (G_OBJECT (self), "state");
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -140,6 +150,23 @@ champlain_map_data_source_class_init (ChamplainMapDataSourceClass *klass)
G_PARAM_READWRITE));
/**
+ * ChamplainMapDataSource:state
+ *
+ * The map data source's state. Useful to know if the data source is loading
+ * or not.
+ *
+ * Since: 0.6
+ */
+ g_object_class_install_property (object_class,
+ PROP_STATE,
+ g_param_spec_enum ("state",
+ "map data source's state",
+ "The state of the map data source",
+ CHAMPLAIN_TYPE_STATE,
+ CHAMPLAIN_STATE_INIT,
+ G_PARAM_READWRITE));
+
+ /**
* ChamplainMapDataSource::map-data-changed:
* @map_data_source: the #ChamplainMapDataSource that received the signal
*
@@ -165,6 +192,8 @@ champlain_map_data_source_init (ChamplainMapDataSource *self)
priv->bounding_box->bottom = 0.0;
priv->bounding_box->right = 0.0;
priv->bounding_box->top = 0.0;
+
+ priv->state = CHAMPLAIN_STATE_INIT;
}
ChamplainMapDataSource *
diff --git a/champlain/champlain-network-map-data-source.c b/champlain/champlain-network-map-data-source.c
index 1810722..c48f926 100644
--- a/champlain/champlain-network-map-data-source.c
+++ b/champlain/champlain-network-map-data-source.c
@@ -22,6 +22,7 @@
#define DEBUG_FLAG CHAMPLAIN_DEBUG_MEMPHIS
#include "champlain-debug.h"
#include "champlain-bounding-box.h"
+#include "champlain-enum-types.h"
#include <memphis/memphis.h>
#ifdef HAVE_LIBSOUP_GNOME
@@ -247,6 +248,8 @@ load_map_data_cb (SoupSession *session, SoupMessage *msg,
g_object_set (G_OBJECT (self), "bounding-box", bbox, NULL);
champlain_bounding_box_free (bbox);
+ g_object_set (G_OBJECT (self), "state", CHAMPLAIN_STATE_DONE, NULL);
+
g_signal_emit_by_name (CHAMPLAIN_MAP_DATA_SOURCE (self),
"map-data-changed", NULL);
}
@@ -272,6 +275,8 @@ champlain_network_map_data_source_load_map_data (
SoupMessage *msg;
gchar *url;
+ g_object_set (G_OBJECT (self), "state", CHAMPLAIN_STATE_LOADING, NULL);
+
if (!soup_session)
{
soup_session = soup_session_async_new_with_options (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]