summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStéphane Maniaci <stephane.maniaci@gmail.com>2011-07-22 20:21:08 +0200
committerStéphane Maniaci <stephane.maniaci@gmail.com>2011-07-22 20:21:08 +0200
commitfd4d344466567a2e7177c2b983722fac23956ded (patch)
treec256d0ab4889efbb5a00656e17919fb20f49a317
parent30cc7383add53457186af51117df4a7aafb07f00 (diff)
downloadgnome-control-center-gsoc2011/location.tar.gz
Solve a week of headbanging with g_variant_ref_sink ()gsoc2011/location
-rw-r--r--panels/location/cc-location-panel.c11
-rw-r--r--panels/location/location-utils.c41
2 files changed, 10 insertions, 42 deletions
diff --git a/panels/location/cc-location-panel.c b/panels/location/cc-location-panel.c
index 01f110208..63bc82287 100644
--- a/panels/location/cc-location-panel.c
+++ b/panels/location/cc-location-panel.c
@@ -61,7 +61,6 @@ static void
populate_locations (GtkListStore *store,
GVariant *locations)
{
- g_debug ("Updating liststore with new locations");
GtkTreeIter iter;
GVariantIter viter;
GVariant *dict;
@@ -94,15 +93,16 @@ populate_locations (GtkListStore *store,
gtk_list_store_set (store, &iter, 3, "20:00", -1);
- value = g_variant_lookup_value (dict,
+ /*value = g_variant_lookup_value (dict,
"longitude",
G_VARIANT_TYPE_DOUBLE);
- // gtk_list_store_set (store, &iter, 1, g_variant_get_double (value), -1);
+ gtk_list_store_set (store, &iter, 1, g_variant_get_double (value), -1);
value = g_variant_lookup_value (dict,
"latitude",
G_VARIANT_TYPE_DOUBLE);
- // gtk_list_store_set (store, &iter, 1, g_variant_get_double (value), -1);
+ gtk_list_store_set (store, &iter, 1, g_variant_get_double (value), -1);
+ */
}
}
@@ -121,7 +121,7 @@ _on_add_location (GtkToolButton *bt,
switch (res) {
case GTK_RESPONSE_OK:
- printf ("s");
+ printf ("Dialog response OK\n");
// FIXME: column ids
const char *city = gtk_entry_get_text (GTK_ENTRY (WID ("city-entry")));
const char *ctry = gtk_entry_get_text (GTK_ENTRY (WID ("country-entry")));
@@ -134,6 +134,7 @@ _on_add_location (GtkToolButton *bt,
g_assert (g_settings_set_value (priv->location_settings,
"locations",
priv->locations));
+
gtk_list_store_clear (priv->location_store);
populate_locations (priv->location_store,
priv->locations);
diff --git a/panels/location/location-utils.c b/panels/location/location-utils.c
index 0a93c01d2..e48aaf7ef 100644
--- a/panels/location/location-utils.c
+++ b/panels/location/location-utils.c
@@ -40,7 +40,6 @@ g_variant_location_new (const char *city,
g_variant_builder_add_parsed (builder, "{'latitude', <%d>}", latitude);
GVariant *val = g_variant_builder_end (builder);
- g_variant_location_print (val);
return val;
}
@@ -48,51 +47,19 @@ GVariant *
g_variant_array_add_value (GVariant *container,
GVariant *value)
{
- g_debug ("Adding value to the locations array");
-
GVariantBuilder *builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
GVariantIter iter;
GVariant *val;
g_variant_iter_init (&iter, container);
- g_debug ("About to loop in the previous locations");
while ((val = g_variant_iter_next_value (&iter))) {
- g_debug ("In the loop\n");
- g_variant_location_print (val);
g_variant_builder_add_value (builder, val);
}
- g_debug ("Added the previous locations");
g_variant_builder_add_value (builder, value);
- return g_variant_builder_end (builder);
-}
-
-void
-g_variant_location_print (GVariant *location)
-{
- g_print("Location:\n");
- g_print ("\tcity:%s\n"
- "\tcountry: %s\n"
- "\ttimezone: %i\n"
- "\tlong: %f\n"
- "\tlat: %f\n",
- g_variant_get_string (g_variant_lookup_value (location,
- "city",
- G_VARIANT_TYPE_STRING),
- NULL),
- g_variant_get_string (g_variant_lookup_value (location,
- "country",
- G_VARIANT_TYPE_STRING),
- NULL),
- g_variant_get_int16 (g_variant_lookup_value (location,
- "timezone",
- G_VARIANT_TYPE_INT16)),
- g_variant_get_double (g_variant_lookup_value (location,
- "latitude",
- G_VARIANT_TYPE_DOUBLE)),
- g_variant_get_double (g_variant_lookup_value (location,
- "longitude",
- G_VARIANT_TYPE_DOUBLE))
- );
+ GVariant *res = g_variant_builder_end (builder);
+ g_variant_builder_unref (builder);
+ g_variant_ref_sink (res);
+ return res;
}