mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Add "BoxedIconButton" class
This commit is contained in:
38
clapper_src/buttons.js
Normal file
38
clapper_src/buttons.js
Normal file
@@ -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();
|
||||
}
|
||||
});
|
12
clapper_src/controls.js
vendored
12
clapper_src/controls.js
vendored
@@ -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;
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user