mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Fix enter fullscreen and popover buttons
This commit is contained in:
@@ -1,41 +1,51 @@
|
||||
const { GObject, Gtk } = imports.gi;
|
||||
|
||||
var BoxedIconButton = GObject.registerClass(
|
||||
class BoxedIconButton extends Gtk.Button
|
||||
var IconButton = GObject.registerClass(
|
||||
class ClapperIconButton extends Gtk.Button
|
||||
{
|
||||
_init(icon, size, isFullscreen)
|
||||
_init(icon)
|
||||
{
|
||||
super._init({
|
||||
margin_top: 4,
|
||||
margin_bottom: 4,
|
||||
margin_start: 1,
|
||||
margin_end: 1,
|
||||
can_focus: false,
|
||||
//can_default: false,
|
||||
icon_name: icon,
|
||||
});
|
||||
|
||||
this.isFullscreen = isFullscreen || false;
|
||||
|
||||
size = size || Gtk.IconSize.SMALL_TOOLBAR;
|
||||
let image = Gtk.Image.new_from_icon_name(icon);
|
||||
|
||||
//if(image)
|
||||
//this.set_image(image);
|
||||
/*
|
||||
this.image.defaultSize = size;
|
||||
this.image.fullscreenSize = (size === Gtk.IconSize.SMALL_TOOLBAR)
|
||||
? Gtk.IconSize.LARGE_TOOLBAR
|
||||
: Gtk.IconSize.DND;
|
||||
*/
|
||||
this.isFullscreen = false;
|
||||
this.add_css_class('flat');
|
||||
|
||||
this.box = new Gtk.Box();
|
||||
this.box.append(this);
|
||||
|
||||
super.show();
|
||||
}
|
||||
|
||||
get visible()
|
||||
setFullscreenMode(isFullscreen)
|
||||
{
|
||||
return this.box.visible;
|
||||
this.isFullscreen = isFullscreen;
|
||||
}
|
||||
});
|
||||
|
||||
var PopoverButton = GObject.registerClass(
|
||||
class ClapperPopoverButton extends IconButton
|
||||
{
|
||||
_init(icon)
|
||||
{
|
||||
super._init(icon);
|
||||
|
||||
this.popover = new Gtk.Popover({
|
||||
position: Gtk.PositionType.TOP,
|
||||
});
|
||||
this.popoverBox = new Gtk.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
});
|
||||
|
||||
this.popover.set_parent(this);
|
||||
this.popover.set_child(this.popoverBox);
|
||||
this.popover.set_offset(0, -this.margin_top);
|
||||
|
||||
if(this.isFullscreen)
|
||||
this.popover.add_css_class('osd');
|
||||
|
||||
this.destroySignal = this.connect('destroy', this._onDestroy.bind(this));
|
||||
}
|
||||
|
||||
setFullscreenMode(isFullscreen)
|
||||
@@ -43,62 +53,30 @@ class BoxedIconButton extends Gtk.Button
|
||||
if(this.isFullscreen === isFullscreen)
|
||||
return;
|
||||
|
||||
this.image.icon_size = (isFullscreen)
|
||||
? this.image.fullscreenSize
|
||||
: this.image.defaultSize;
|
||||
this.margin_top = (isFullscreen) ? 6 : 4;
|
||||
this.popover.set_offset(0, -this.margin_top);
|
||||
|
||||
this.isFullscreen = isFullscreen;
|
||||
}
|
||||
/*
|
||||
show_all()
|
||||
{
|
||||
this.box.show_all();
|
||||
}
|
||||
*/
|
||||
show()
|
||||
{
|
||||
this.box.show();
|
||||
}
|
||||
|
||||
hide()
|
||||
{
|
||||
this.box.hide();
|
||||
}
|
||||
});
|
||||
|
||||
var BoxedPopoverButton = GObject.registerClass(
|
||||
class BoxedPopoverButton extends BoxedIconButton
|
||||
{
|
||||
_init(icon, size, isFullscreen)
|
||||
{
|
||||
super._init(icon, size, isFullscreen);
|
||||
|
||||
this.popover = new Gtk.Popover({
|
||||
default_widget: this.box
|
||||
});
|
||||
this.popoverBox = new Gtk.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL
|
||||
});
|
||||
this.popover.set_child(this.popoverBox);
|
||||
this.popoverBox.show();
|
||||
|
||||
if(this.isFullscreen)
|
||||
this.popover.add_css_class('osd');
|
||||
}
|
||||
|
||||
setFullscreenMode(isEnabled)
|
||||
{
|
||||
if(this.isFullscreen === isEnabled)
|
||||
let cssClass = 'osd';
|
||||
if(isFullscreen == this.popover.has_css_class(cssClass))
|
||||
return;
|
||||
|
||||
let action = (isEnabled) ? 'add' : 'remove';
|
||||
this.popover[action + '_css_class']('osd');
|
||||
let action = (isFullscreen) ? 'add' : 'remove';
|
||||
this.popover[action + '_css_class'](cssClass);
|
||||
|
||||
super.setFullscreenMode(isEnabled);
|
||||
super.setFullscreenMode(isFullscreen);
|
||||
}
|
||||
|
||||
vfunc_clicked()
|
||||
{
|
||||
this.popover.popup();
|
||||
}
|
||||
|
||||
_onDestroy()
|
||||
{
|
||||
this.disconnect(this.destroySignal);
|
||||
|
||||
this.popover.unparent();
|
||||
this.popoverBox.emit('destroy');
|
||||
this.popover.emit('destroy');
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user