[libgweather] [libgweather] Make gweather_location_entry_set_city() return a boolean



commit bb66d9a29ebbfc0e406e3ac158b61f10e35bae13
Author: Vincent Untz <vuntz gnome org>
Date:   Wed Aug 12 03:23:14 2009 +0200

    [libgweather] Make gweather_location_entry_set_city() return a boolean
    
    The caller might need to know if the call is successful or not.
    
    Part of http://bugzilla.gnome.org/show_bug.cgi?id=591516

 libgweather/location-entry.c |   13 +++++++++----
 libgweather/location-entry.h |    2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/libgweather/location-entry.c b/libgweather/location-entry.c
index 6ecc351..331fdaa 100644
--- a/libgweather/location-entry.c
+++ b/libgweather/location-entry.c
@@ -254,8 +254,11 @@ gweather_location_entry_get_location (GWeatherLocationEntry *entry)
  * Sets @entry's location to a city with the given @code, and given
  * @city_name, if non-%NULL. If there is no matching city, sets
  * @entry's location to %NULL.
+ *
+ * Return value: %TRUE if @entry's location could be set to a matching city,
+ * %FALSE otherwise.
  **/
-void
+gboolean
 gweather_location_entry_set_city (GWeatherLocationEntry *entry,
 				  const char            *city_name,
 				  const char            *code)
@@ -267,8 +270,8 @@ gweather_location_entry_set_city (GWeatherLocationEntry *entry,
     const char *cmpcode;
     char *cmpname;
 
-    g_return_if_fail (GWEATHER_IS_LOCATION_ENTRY (entry));
-    g_return_if_fail (code != NULL);
+    g_return_val_if_fail (GWEATHER_IS_LOCATION_ENTRY (entry), FALSE);
+    g_return_val_if_fail (code != NULL, FALSE);
 
     completion = gtk_entry_get_completion (GTK_ENTRY (entry));
     model = gtk_entry_completion_get_model (completion);
@@ -293,10 +296,12 @@ gweather_location_entry_set_city (GWeatherLocationEntry *entry,
 	}
 
 	set_location_internal (entry, model, &iter);
-	return;
+	return TRUE;
     } while (gtk_tree_model_iter_next (model, &iter));
 
     set_location_internal (entry, model, NULL);
+
+    return FALSE;
 }
 
 static void
diff --git a/libgweather/location-entry.h b/libgweather/location-entry.h
index c1eddb3..e628383 100644
--- a/libgweather/location-entry.h
+++ b/libgweather/location-entry.h
@@ -51,7 +51,7 @@ void              gweather_location_entry_set_location (GWeatherLocationEntry *e
 							GWeatherLocation      *loc);
 GWeatherLocation *gweather_location_entry_get_location (GWeatherLocationEntry *entry);
 
-void              gweather_location_entry_set_city     (GWeatherLocationEntry *entry,
+gboolean          gweather_location_entry_set_city     (GWeatherLocationEntry *entry,
 							const char            *city_name,
 							const char            *code);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]