[gnome-weather] World: fix regression after libgd update



commit b92de3ba5071a708df5a41562c7bd57d316fa953
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Jan 19 15:04:27 2014 +0100

    World: fix regression after libgd update
    
    New libgd has more columns, so we need to update our enumeration.
    Let's make sure this doesn't happen anymore with an assert.

 src/util.js  |    5 +++++
 src/world.js |   30 ++++++++++++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/src/util.js b/src/util.js
index 2c7feb3..6f61fe7 100644
--- a/src/util.js
+++ b/src/util.js
@@ -146,3 +146,8 @@ function normalizeCasefoldAndUnaccent(str) {
      */
     return str.replace(/[\u0300-\u036f]|[\u1dc0-\u1dff]|[\u20d0-\u20ff]|[\ufe20-\ufe2f]/, '');
 }
+
+function assertEqual(one, two) {
+    if (one != two)
+        throw Error('Assertion failed: ' + one + ' != ' + two);
+}
diff --git a/src/world.js b/src/world.js
index 38e4bb3..b56305b 100644
--- a/src/world.js
+++ b/src/world.js
@@ -35,9 +35,24 @@ const Columns = {
     ICON: Gd.MainColumns.ICON,
     MTIME: Gd.MainColumns.MTIME,
     SELECTED: Gd.MainColumns.SELECTED,
-    LOCATION: 7,
-    INFO: 8
+    PULSE: Gd.MainColumns.PULSE,
+    LOCATION: Gd.MainColumns.LAST,
+    INFO: Gd.MainColumns.LAST+1
 };
+const ColumnTypes = {
+    ID: GObject.TYPE_STRING,
+    URI: GObject.TYPE_STRING,
+    PRIMARY_TEXT: GObject.TYPE_STRING,
+    SECONDARY_TEXT: GObject.TYPE_STRING,
+    ICON: GdkPixbuf.Pixbuf,
+    MTIME: GObject.TYPE_INT,
+    SELECTED: GObject.TYPE_BOOLEAN,
+    PULSE: GObject.TYPE_UINT,
+    LOCATION: GWeather.Location,
+    INFO: GWeather.Info
+};
+Util.assertEqual(Object.keys(Columns).length, Object.keys(ColumnTypes).length);
+Util.assertEqual(Gd.MainColumns.LAST+2, Object.keys(ColumnTypes).length);
 
 const ICON_SIZE = 128;
 
@@ -53,16 +68,7 @@ const WorldModel = new Lang.Class({
 
     _init: function(world) {
         this.parent();
-        this.set_column_types([GObject.TYPE_STRING,
-                               GObject.TYPE_STRING,
-                               GObject.TYPE_STRING,
-                               GObject.TYPE_STRING,
-                               GdkPixbuf.Pixbuf,
-                               GObject.TYPE_INT,
-                               GObject.TYPE_BOOLEAN,
-                               GWeather.Location,
-                               GWeather.Info]);
-
+        this.set_column_types([ColumnTypes[c] for (c in ColumnTypes)]);
         this._world = world;
 
         this._settings = Util.getSettings('org.gnome.Weather.Application');


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