libgweather r187 - in trunk: . libgweather
- From: vuntz svn gnome org
- To: svn-commits-list gnome org
- Subject: libgweather r187 - in trunk: . libgweather
- Date: Sat, 19 Apr 2008 18:38:48 +0100 (BST)
Author: vuntz
Date: Sat Apr 19 17:38:48 2008
New Revision: 187
URL: http://svn.gnome.org/viewvc/libgweather?rev=187&view=rev
Log:
2008-04-19 Vincent Untz <vuntz gnome org>
* libgweather/gweather-xml.c: (gweather_xml_parse_node):
Remove useless entries (region/country/state/city without any
location).
When there's only one location in a city, merge the two items since
it's kind of useless to display the child in this case.
Fix bug #527594.
Modified:
trunk/ChangeLog
trunk/libgweather/gweather-xml.c
Modified: trunk/libgweather/gweather-xml.c
==============================================================================
--- trunk/libgweather/gweather-xml.c (original)
+++ trunk/libgweather/gweather-xml.c Sat Apr 19 17:38:48 2008
@@ -326,11 +326,6 @@
if( self )
gtk_tree_store_set( store, self, GWEATHER_XML_COL_LOC, name, -1 );
- /* absorb the end tag. in the case of processing a <gweather> then 'self'
- is NULL. In this case, we let this fail since we might be at EOF */
- if( xmlTextReaderRead( xml ) != 1 && self )
- goto error_out;
-
/* if this is an actual location, setup the WeatherLocation for it */
if( is_location )
{
@@ -351,8 +346,37 @@
gtk_tree_store_set( store, &iter, GWEATHER_XML_COL_POINTER, new_loc, -1 );
}
+ /* if this is not a location and there's no child, then it's useless */
+ else if ( !gtk_tree_model_iter_has_child( GTK_TREE_MODEL (store), &iter ) )
+ {
+ gtk_tree_store_remove( store, &iter );
+ }
+
+ /* if this is a city with only one location, then we merge the location and
+ * the city */
+ if (*city)
+ {
+ int n_children;
- ret = TRUE;
+ n_children = gtk_tree_model_iter_n_children( GTK_TREE_MODEL (store),
+ &iter );
+ if ( n_children == 1 )
+ {
+ GtkTreeIter child;
+ WeatherLocation *loc;
+
+ gtk_tree_model_iter_children( GTK_TREE_MODEL (store), &child, &iter );
+ gtk_tree_model_get( GTK_TREE_MODEL (store), &child,
+ GWEATHER_XML_COL_POINTER, &loc, -1 );
+ gtk_tree_store_remove( store, &child );
+ gtk_tree_store_set( store, &iter, GWEATHER_XML_COL_POINTER, loc, -1 );
+ }
+ }
+
+ /* absorb the end tag. in the case of processing a <gweather> then 'self'
+ is NULL. In this case, we let this fail since we might be at EOF */
+ if( xmlTextReaderRead( xml ) == 1 || !self )
+ ret = TRUE;
error_out:
xmlFree( name );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]