[geocode-glib] Add icon from nominatim as place GIcon property
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib] Add icon from nominatim as place GIcon property
- Date: Mon, 26 Aug 2013 16:29:26 +0000 (UTC)
commit dfd51c5ec21a07fb94d8d8d307925d56349f60f6
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Mon Aug 19 11:24:20 2013 +0200
Add icon from nominatim as place GIcon property
https://bugzilla.gnome.org/show_bug.cgi?id=706291
geocode-glib/geocode-forward.c | 8 +++++
geocode-glib/geocode-glib-private.h | 2 +
geocode-glib/geocode-glib.symbols | 2 +
geocode-glib/geocode-place.c | 51 +++++++++++++++++++++++++++++++++++
geocode-glib/geocode-place.h | 3 ++
5 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/geocode-glib/geocode-forward.c b/geocode-glib/geocode-forward.c
index acb8945..534ba72 100644
--- a/geocode-glib/geocode-forward.c
+++ b/geocode-glib/geocode-forward.c
@@ -508,6 +508,14 @@ fill_place_from_entry (const char *key,
NULL);
break;
}
+ /* special case for icon, convert to GIcon */
+ if (g_str_equal (key, "icon")) {
+ GFile *file = g_file_new_for_uri (value);
+ GIcon *icon = g_file_icon_new (file);
+
+ g_object_set (G_OBJECT (place), "icon", icon, NULL);
+ g_object_unref (icon);
+ }
}
}
diff --git a/geocode-glib/geocode-glib-private.h b/geocode-glib/geocode-glib-private.h
index c725d27..6ce232c 100644
--- a/geocode-glib/geocode-glib-private.h
+++ b/geocode-glib/geocode-glib-private.h
@@ -58,6 +58,8 @@ gboolean _geocode_glib_cache_load (SoupMessage *query,
char **contents);
GHashTable *_geocode_glib_dup_hash_table (GHashTable *ht);
+void _geocode_place_set_icon (GeocodePlace *place,
+ GIcon *icon);
G_END_DECLS
diff --git a/geocode-glib/geocode-glib.symbols b/geocode-glib/geocode-glib.symbols
index f779f03..12d045e 100644
--- a/geocode-glib/geocode-glib.symbols
+++ b/geocode-glib/geocode-glib.symbols
@@ -27,6 +27,7 @@ _geocode_parse_resolve_json
_geocode_read_nominatim_attributes
_geocode_ip_json_to_location
_geocode_create_place_from_attributes
+_geocode_place_set_icon
geocode_ipclient_get_type
geocode_ipclient_new
geocode_ipclient_new_for_ip
@@ -66,3 +67,4 @@ geocode_place_set_country
geocode_place_get_country
geocode_place_set_continent
geocode_place_get_continent
+geocode_place_get_icon
diff --git a/geocode-glib/geocode-place.c b/geocode-glib/geocode-place.c
index d4e3886..fc7e782 100644
--- a/geocode-glib/geocode-place.c
+++ b/geocode-glib/geocode-place.c
@@ -23,6 +23,7 @@
#include <geocode-glib/geocode-place.h>
#include <geocode-glib/geocode-enum-types.h>
+#include <geocode-glib/geocode-glib-private.h>
/**
* SECTION:geocode-place
@@ -52,6 +53,7 @@ struct _GeocodePlacePrivate {
char *country_code;
char *country;
char *continent;
+ GIcon *icon;
};
enum {
@@ -72,6 +74,7 @@ enum {
PROP_COUNTRY_CODE,
PROP_COUNTRY,
PROP_CONTINENT,
+ PROP_ICON,
};
G_DEFINE_TYPE (GeocodePlace, geocode_place, G_TYPE_OBJECT)
@@ -160,6 +163,11 @@ geocode_place_get_property (GObject *object,
geocode_place_get_continent (place));
break;
+ case PROP_ICON:
+ g_value_set_object (value,
+ geocode_place_get_icon (place));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -240,6 +248,10 @@ geocode_place_set_property(GObject *object,
geocode_place_set_continent (place, g_value_get_string (value));
break;
+ case PROP_ICON:
+ _geocode_place_set_icon (place, g_value_get_object (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -252,6 +264,7 @@ geocode_place_dispose (GObject *gplace)
GeocodePlace *place = (GeocodePlace *) gplace;
g_clear_object (&place->priv->location);
+ g_clear_object (&place->priv->icon);
g_clear_pointer (&place->priv->name, g_free);
g_clear_pointer (&place->priv->street_address, g_free);
@@ -478,6 +491,19 @@ geocode_place_class_init (GeocodePlaceClass *klass)
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS);
g_object_class_install_property (gplace_class, PROP_CONTINENT, pspec);
+
+ /**
+ * GeocodePlace:icon:
+ *
+ * #GIcon representing the @GeocodePlace.
+ */
+ pspec = g_param_spec_object ("icon",
+ "Icon",
+ "An icon representing the the place",
+ G_TYPE_ICON,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (gplace_class, PROP_ICON, pspec);
}
static void
@@ -990,3 +1016,28 @@ geocode_place_get_continent (GeocodePlace *place)
return place->priv->continent;
}
+
+/**
+ * geocode_place_get_icon:
+ * @place: A place
+ *
+ * Gets the #GIcon representing the @place.
+ **/
+GIcon *
+geocode_place_get_icon (GeocodePlace *place)
+{
+ g_return_val_if_fail (GEOCODE_IS_PLACE (place), NULL);
+
+ return place->priv->icon;
+}
+
+void
+_geocode_place_set_icon (GeocodePlace *place,
+ GIcon *icon)
+{
+ g_return_if_fail (GEOCODE_IS_PLACE (place));
+ g_return_if_fail (icon != NULL);
+
+ g_clear_object (&place->priv->icon);
+ place->priv->icon = g_object_ref (icon);
+}
diff --git a/geocode-glib/geocode-place.h b/geocode-glib/geocode-place.h
index e8b1fc1..1aba478 100644
--- a/geocode-glib/geocode-place.h
+++ b/geocode-glib/geocode-place.h
@@ -25,6 +25,7 @@
#define GEOCODE_PLACE_H
#include <glib-object.h>
+#include <gio/gio.h>
#include <geocode-glib/geocode-location.h>
G_BEGIN_DECLS
@@ -197,6 +198,8 @@ void geocode_place_set_continent (GeocodePlace *place,
const char *continent);
const char *geocode_place_get_continent (GeocodePlace *place);
+GIcon *geocode_place_get_icon (GeocodePlace *place);
+
G_END_DECLS
#endif /* GEOCODE_PLACE_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]