diff options
Diffstat (limited to 'wikipedia/widgets/composite_button.js')
-rw-r--r-- | wikipedia/widgets/composite_button.js | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/wikipedia/widgets/composite_button.js b/wikipedia/widgets/composite_button.js deleted file mode 100644 index 2fb0666..0000000 --- a/wikipedia/widgets/composite_button.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 Endless Mobile, Inc. - -const Gtk = imports.gi.Gtk; -const Lang = imports.lang; - -// Class for buttons whose :hover and :active CSS pseudoclass states should be -// inherited by some of their child widgets, since as of GTK 3.10 these flags no -// longer propagate from a widget to its children. Widgets in sensitiveChildren -// will listen to this widget's state-flags-changed event and inherit all flag -// values listed in _INHERITED_FLAGS. - -const CompositeButton = new Lang.Class({ - Name: 'CompositeButton', - GTypeName: 'CompositeButton', - Extends: Gtk.Button, - - _INHERITED_FLAGS: [Gtk.StateFlags.PRELIGHT, Gtk.StateFlags.ACTIVE], - - _init: function (props) { - this._handlerSet = false; - this._sensitiveChildren = []; - this.parent(props); - }, - - // Set the list of child widgets which will inherit the CompositeButton's - // hover/active state flags. - setSensitiveChildren: function (children) { - this._sensitiveChildren = children; - // If the handlers for mouse events aren't already set, connect them - if (!this._handlerSet) { - this._connectStateChangedHandler(); - } - }, - - _connectStateChangedHandler: function () { - this.connect('state-flags-changed', - Lang.bind(this, this._stateChangedHandler)); - this._handlerSet = true; - }, - - _stateChangedHandler: function (widget, flags) { - let myFlags = this.get_state_flags(); - this._sensitiveChildren.forEach(function (child) { - this._INHERITED_FLAGS.forEach(function (flag) { - // for each flag we want the children to inherit, grab this - // widget's flag value, and set the child's matching flag - // accordingly - let myFlag = myFlags & flag; - if (myFlag !== 0) - child.set_state_flags(flag, false); - else - child.unset_state_flags(flag); - - }); - }, this); - } -}); |