summaryrefslogtreecommitdiff
path: root/wikipedia
diff options
context:
space:
mode:
authorP. F. Chimento <philip.chimento@gmail.com>2013-08-07 14:35:40 -0700
committerP. F. Chimento <philip.chimento@gmail.com>2013-08-07 14:35:40 -0700
commit55e6b5a443085fac920766c173cd77154c66e6e7 (patch)
treec110e0d514bde81d29f8c0801e1c08ea29f72153 /wikipedia
parent4219eeedfc62e9160eb464f24bf0b161487e43bb (diff)
parent8c8fe4fb9dc3eeb8b042fbf7a31e95aadc34d41f (diff)
Merge pull request #235 from endlessm/issues/234
#234 Fixed the sizing of pixbufs in the wikipedia first page
Diffstat (limited to 'wikipedia')
-rw-r--r--wikipedia/views/title_label_view.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/wikipedia/views/title_label_view.js b/wikipedia/views/title_label_view.js
index 15b3085..ccedc8e 100644
--- a/wikipedia/views/title_label_view.js
+++ b/wikipedia/views/title_label_view.js
@@ -91,17 +91,25 @@ const TitleLabelView = new Lang.Class({
// PRIVATE
- _updateImage: function(res_path, width, height) {
- let [source_width, source_height] = [width, height];
- if(width > height)
+ _updateImage: function(res_path, dest_width, dest_height) {
+ let [source_width, source_height] = [dest_width, dest_height];
+ // TODO: We need to get the size of the source image, so right now we
+ // are loading the image twice, once to get the size, and the again at
+ // the proper size. We should eventually use a GdkPixbuf.Loader and
+ // connect to the size-prepared signal, as described in the
+ // documentation
+ let temp_pixbuf = GdkPixbuf.Pixbuf.new_from_resource(res_path);
+ let source_aspect = temp_pixbuf.width / temp_pixbuf.height;
+ let dest_aspect = dest_width / dest_height;
+ if(dest_aspect > source_aspect)
source_height = -1;
else
source_width = -1;
let source_pixbuf = GdkPixbuf.Pixbuf.new_from_resource_at_scale(res_path,
source_width, source_height, true);
let cropped_pixbuf = source_pixbuf;
- if(width < source_pixbuf.width || height < source_pixbuf.height)
- cropped_pixbuf = source_pixbuf.new_subpixbuf(0, 0, width, height);
+ if(dest_width < source_pixbuf.width || dest_height < source_pixbuf.height)
+ cropped_pixbuf = source_pixbuf.new_subpixbuf(0, 0, dest_width, dest_height);
this._image.set_from_pixbuf(cropped_pixbuf);
}
});