diff options
author | Will Greenberg <ifnspifn@gmail.com> | 2014-02-04 17:34:43 -0800 |
---|---|---|
committer | Will Greenberg <ifnspifn@gmail.com> | 2014-02-04 17:34:43 -0800 |
commit | 0a9ddc9d424e6695f1fb480c7f796da269d19059 (patch) | |
tree | 28b20632a84433a08fea702d97246ff0fd00c2e7 /wikipedia | |
parent | 9131ccb56266d770fbfaae71f1b43c0e69a3078f (diff) | |
parent | 80f9003e067a4aad9b3c28a063423bba78a4142e (diff) |
Merge pull request #543 from endlessm/issues/540
Fix for making arrow hover states correct in NUC
Diffstat (limited to 'wikipedia')
-rw-r--r-- | wikipedia/widgets/category_button.js | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/wikipedia/widgets/category_button.js b/wikipedia/widgets/category_button.js index 08ce2ed..cafa7a6 100644 --- a/wikipedia/widgets/category_button.js +++ b/wikipedia/widgets/category_button.js @@ -96,6 +96,26 @@ const CategoryButton = new Lang.Class({ this._inner_grid.add(this._arrow); this.add(this._inner_grid); this.show_all(); + + // For some reason, on the NUC, setting opacity in CSS for this button does not work. + // So we have to set it in Gtk code. Also, we have to set the opacity + // to zero upfront. I am putting that here instead of in the initialisation + // of the arrow since it is part of this NUC-specific hack + this._arrow.connect('state-flags-changed', Lang.bind(this, this._update_appearance)); + this._arrow.set_opacity(0) + }, + + _update_appearance: function(widget) { + // If button is hovered over and/or pressed, then show the arrow icon + if ((widget.get_state_flags() & Gtk.StateFlags.ACTIVE || + widget.get_state_flags() & Gtk.StateFlags.PRELIGHT) && + this._clickable_category) { + this._arrow.set_opacity(1); + return false; + } + // If no hover or press, then hide the arrow icon + this._arrow.set_opacity(0); + return false; }, get image_uri() { @@ -122,11 +142,7 @@ const CategoryButton = new Lang.Class({ set clickable_category(value) { this._clickable_category = value; - if(this._clickable_category) { - this.get_style_context().add_class(EndlessWikipedia.STYLE_CLASS_CATEGORY_CLICKABLE); - } else { - this.get_style_context().remove_class(EndlessWikipedia.STYLE_CLASS_CATEGORY_CLICKABLE); - } + this._update_appearance(this._arrow); }, get is_main_category() { |