[geocode-glib] forward: make answer_count a property
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib] forward: make answer_count a property
- Date: Thu, 5 Dec 2013 15:07:30 +0000 (UTC)
commit 7d5da035be690b015ee1404e299ce127433c0577
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue Nov 26 13:07:17 2013 +0100
forward: make answer_count a property
https://bugzilla.gnome.org/show_bug.cgi?id=719585
geocode-glib/geocode-forward.c | 83 ++++++++++++++++++++++++++++++++++++-
geocode-glib/geocode-forward.h | 1 +
geocode-glib/geocode-glib.symbols | 1 +
3 files changed, 84 insertions(+), 1 deletions(-)
---
diff --git a/geocode-glib/geocode-forward.c b/geocode-glib/geocode-forward.c
index a23832d..b8b05f6 100644
--- a/geocode-glib/geocode-forward.c
+++ b/geocode-glib/geocode-forward.c
@@ -45,8 +45,57 @@ struct _GeocodeForwardPrivate {
guint answer_count;
};
+enum {
+ PROP_0,
+
+ PROP_ANSWER_COUNT
+};
+
G_DEFINE_TYPE (GeocodeForward, geocode_forward, G_TYPE_OBJECT)
+static void
+geocode_forward_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GeocodeForward *forward = GEOCODE_FORWARD (object);
+
+ switch (property_id) {
+ case PROP_ANSWER_COUNT:
+ g_value_set_uint (value,
+ geocode_forward_get_answer_count (forward));
+ break;
+
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+geocode_forward_set_property(GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GeocodeForward *forward = GEOCODE_FORWARD (object);
+
+ switch (property_id) {
+ case PROP_ANSWER_COUNT:
+ geocode_forward_set_answer_count (forward,
+ g_value_get_uint (value));
+ break;
+
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
static void geocode_forward_add (GeocodeForward *forward,
const char *key,
const char *value);
@@ -66,10 +115,29 @@ static void
geocode_forward_class_init (GeocodeForwardClass *klass)
{
GObjectClass *gforward_class = G_OBJECT_CLASS (klass);
+ GParamSpec *pspec;
gforward_class->finalize = geocode_forward_finalize;
+ gforward_class->get_property = geocode_forward_get_property;
+ gforward_class->set_property = geocode_forward_set_property;
+
g_type_class_add_private (klass, sizeof (GeocodeForwardPrivate));
+
+ /**
+ * GeocodeForward:answer-count:
+ *
+ * The number of requested results to a search query.
+ */
+ pspec = g_param_spec_uint ("answer-count",
+ "Answer count",
+ "The number of requested results",
+ 0,
+ G_MAXINT,
+ DEFAULT_ANSWER_COUNT,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gforward_class, PROP_ANSWER_COUNT, pspec);
}
static void
@@ -913,6 +981,19 @@ geocode_forward_set_answer_count (GeocodeForward *forward,
{
g_return_if_fail (GEOCODE_IS_FORWARD (forward));
- /* FIXME: make a property */
forward->priv->answer_count = count;
}
+
+/**
+ * geocode_forward_get_answer_count:
+ * @forward: a #GeocodeForward representing a query
+ *
+ * Gets the number of requested results for searches.
+ **/
+guint
+geocode_forward_get_answer_count (GeocodeForward *forward)
+{
+ g_return_val_if_fail (GEOCODE_IS_FORWARD (forward), 0);
+
+ return forward->priv->answer_count;
+}
diff --git a/geocode-glib/geocode-forward.h b/geocode-glib/geocode-forward.h
index 62e07cc..022e9e6 100644
--- a/geocode-glib/geocode-forward.h
+++ b/geocode-glib/geocode-forward.h
@@ -65,6 +65,7 @@ struct _GeocodeForwardClass {
GeocodeForward *geocode_forward_new_for_string (const char *str);
GeocodeForward *geocode_forward_new_for_params (GHashTable *params);
+guint geocode_forward_get_answer_count (GeocodeForward *forward);
void geocode_forward_set_answer_count (GeocodeForward *forward,
guint count);
diff --git a/geocode-glib/geocode-glib.symbols b/geocode-glib/geocode-glib.symbols
index d3a9359..b4e7d04 100644
--- a/geocode-glib/geocode-glib.symbols
+++ b/geocode-glib/geocode-glib.symbols
@@ -11,6 +11,7 @@ geocode_location_set_description
geocode_forward_get_type
geocode_forward_new_for_string
geocode_forward_new_for_params
+geocode_forward_get_answer_count
geocode_forward_set_answer_count
geocode_forward_search_async
geocode_forward_search_finish
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]