summaryrefslogtreecommitdiff
path: root/wikipedia/widgets
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2014-01-20 17:51:02 -0200
committerPhilip Chimento <philip@endlessm.com>2014-01-22 22:33:34 -0200
commit46b36cd29f5dd4fe7aefce1e2edb668c3254cee6 (patch)
tree2d058f9667f968548545611249f757bc9df8d016 /wikipedia/widgets
parent4d7b0cb396f5a1992aacf077bcd893758cbc9b1f (diff)
Move category back button to its own class
For better code organization and cleaner CSS; add style classes. [endlessm/eos-sdk#504]
Diffstat (limited to 'wikipedia/widgets')
-rw-r--r--wikipedia/widgets/category_back_button.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/wikipedia/widgets/category_back_button.js b/wikipedia/widgets/category_back_button.js
new file mode 100644
index 0000000..d358601
--- /dev/null
+++ b/wikipedia/widgets/category_back_button.js
@@ -0,0 +1,47 @@
+// Copyright 2014 Endless Mobile, Inc.
+
+const Gettext = imports.gettext;
+const GLib = imports.gi.GLib;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+
+const CompositeButton = imports.wikipedia.widgets.composite_button;
+const Config = imports.wikipedia.config;
+
+const _ = function (string) { return GLib.dgettext('eos-sdk', string); };
+Gettext.bindtextdomain('eos-sdk', Config.DATADIR + '/locale');
+
+const CATEGORY_BACK_BUTTON_RESOURCE_URI = 'resource:///com/endlessm/wikipedia-domain/assets/wikipedia-category-back-symbolic.svg';
+const CATEGORY_BACK_BUTTON_SIZE_PIXELS = 68;
+const STYLE_CONTEXT_LABEL = 'label';
+const STYLE_CONTEXT_BACK = 'back';
+
+const CategoryBackButton = new Lang.Class({
+ Name: 'CategoryBackButton',
+ GTypeName: 'CategoryBackButton',
+ Extends: CompositeButton.CompositeButton,
+
+ _init: function(props) {
+ this.parent(props);
+
+ let gicon = new Gio.FileIcon({
+ file: Gio.File.new_for_uri(CATEGORY_BACK_BUTTON_RESOURCE_URI)
+ });
+ let icon = Gtk.Image.new_from_gicon(gicon, Gtk.IconSize.DIALOG);
+ icon.pixel_size = CATEGORY_BACK_BUTTON_SIZE_PIXELS;
+ let label = new Gtk.Label({
+ label: _("OTHER CATEGORIES")
+ });
+ let innerGrid = new Gtk.Grid();
+
+ innerGrid.add(icon);
+ innerGrid.add(label);
+ this.add(innerGrid);
+ this.setSensitiveChildren([icon, label]);
+
+ // Define style classes for CSS
+ icon.get_style_context().add_class(Gtk.STYLE_CLASS_IMAGE);
+ label.get_style_context().add_class(STYLE_CONTEXT_LABEL);
+ this.get_style_context().add_class(STYLE_CONTEXT_BACK);
+ }
+});