diff --git a/clapper_src/buttons.js b/clapper_src/buttons.js new file mode 100644 index 00000000..24949869 --- /dev/null +++ b/clapper_src/buttons.js @@ -0,0 +1,38 @@ +const { GObject, Gtk } = imports.gi; + +var BoxedIconButton = GObject.registerClass( +class BoxedIconButton extends Gtk.Button +{ + _init(icon, size) + { + super._init(); + + let image = Gtk.Image.new_from_icon_name(icon, size); + + if(image) + this.set_image(image); + + this.box = new Gtk.Box(); + this.box.pack_start(this, false, false, 0); + } + + get visible() + { + return this.box.visible; + } + + show_all() + { + this.box.show_all(); + } + + show() + { + this.box.show(); + } + + hide() + { + this.box.hide(); + } +}); diff --git a/clapper_src/controls.js b/clapper_src/controls.js index dc568ec8..a4e9f48a 100644 --- a/clapper_src/controls.js +++ b/clapper_src/controls.js @@ -1,4 +1,5 @@ const { GObject, Gtk } = imports.gi; +const Buttons = imports.clapper_src.buttons; const Debug = imports.clapper_src.debug; const CONTROLS_MARGIN = 4; @@ -94,9 +95,7 @@ var Controls = GObject.registerClass({ { size = size || Gtk.IconSize.SMALL_TOOLBAR; - let button = Gtk.Button.new_from_icon_name(iconName, size); - let box = new Gtk.Box(); - + let button = new Buttons.BoxedIconButton(iconName, size); button.margin_top = CONTROLS_MARGIN; button.margin_bottom = CONTROLS_MARGIN; button.image.defaultSize = size; @@ -107,11 +106,8 @@ var Controls = GObject.registerClass({ this.setDefaultWidgetBehaviour(button); button.get_style_context().add_class('flat'); - if(!noPack) { - box.pack_start(button, false, false, 0); - this.pack_start(box, false, false, 0); - box.show_all(); - } + if(!noPack) + this.pack_start(button.box, false, false, 0); this.buttonImages.push(button.image); return button; diff --git a/clapper_src/interface.js b/clapper_src/interface.js index d5aebf05..91b5a157 100644 --- a/clapper_src/interface.js +++ b/clapper_src/interface.js @@ -101,7 +101,7 @@ class ClapperInterface extends Gtk.Grid if(isOnVideo) { this.remove(this.controls); - this.controls.pack_start(this.controls.unfullscreenButton, false, false, 0); + this.controls.pack_start(this.controls.unfullscreenButton.box, false, false, 0); this.overlay.add_overlay(this.revealer); this.revealerBox.pack_start(this.controls, false, true, 0); this.revealer.show(); @@ -109,7 +109,7 @@ class ClapperInterface extends Gtk.Grid } else { this.revealerBox.remove(this.controls); - this.controls.remove(this.controls.unfullscreenButton); + this.controls.remove(this.controls.unfullscreenButton.box); this.overlay.remove(this.revealer); this.attach(this.controls, 0, 1, 1, 1); this.controls.show();