Make remote app minimize, maximize and close buttons affect Clapper

This commit is contained in:
Rafał Dzięgiel
2021-02-23 11:56:02 +01:00
parent 6950cf1bbb
commit a309ef6099
6 changed files with 46 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
const { GObject } = imports.gi;
const { AppBase } = imports.src.appBase;
const { HeaderBarBase } = imports.src.headerbarBase;
const { HeaderBarRemote } = imports.src.headerbarRemote;
const { WidgetRemote } = imports.src.widgetRemote;
var AppRemote = GObject.registerClass(
@@ -13,7 +13,7 @@ class ClapperAppRemote extends AppBase
const clapperWidget = new WidgetRemote();
this.active_window.set_child(clapperWidget);
const headerBar = new HeaderBarBase(this.active_window);
const headerBar = new HeaderBarRemote();
this.active_window.set_titlebar(headerBar);
this.active_window.maximize();

View File

@@ -1,19 +1,12 @@
const { GObject, Gtk } = imports.gi;
const { GObject } = imports.gi;
const { HeaderBarBase } = imports.src.headerbarBase;
var HeaderBar = GObject.registerClass(
class ClapperHeaderBar extends HeaderBarBase
{
_init()
{
super._init();
this.add_css_class('osd');
this.add_css_class('osdheaderbar');
}
_onWindowButtonActivate(action)
{
this.activate_action(action, null);
this.activate_action(`window.${action}`, null);
}
_onFloatButtonClicked()

View File

@@ -17,6 +17,8 @@ class ClapperHeaderBarBase extends Gtk.Box
margin_start: 6,
margin_end: 6,
});
this.add_css_class('osd');
this.add_css_class('osdheaderbar');
this.isMaximized = false;
this.isMenuOnLeft = true;
@@ -197,12 +199,11 @@ class ClapperHeaderBarBase extends Gtk.Box
});
button.add_css_class('circular');
const action = (name === 'maximize')
? 'window.toggle-maximized'
: 'window.' + name;
if(name === 'maximize')
name = 'toggle-maximized';
button.connect('clicked',
this._onWindowButtonActivate.bind(this, action)
this._onWindowButtonActivate.bind(this, name)
);
return button;

20
src/headerbarRemote.js Normal file
View File

@@ -0,0 +1,20 @@
const { GObject } = imports.gi;
const { HeaderBarBase } = imports.src.headerbarBase;
var HeaderBarRemote = GObject.registerClass(
class ClapperHeaderBarRemote extends HeaderBarBase
{
_init()
{
super._init();
this.extraButtonsBox.visible = false;
}
_onWindowButtonActivate(action)
{
if(action === 'toggle-maximized')
action = 'toggle_maximized';
this.root.child.sendWs(action);
}
});

View File

@@ -252,10 +252,25 @@ class ClapperPlayer extends PlayerBase
case 'set_playlist':
this[action](value);
break;
case 'toggle_maximized':
action = 'toggle-maximized';
case 'minimize':
case 'close':
this.widget.activate_action(`window.${action}`, null);
break;
default:
const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
switch(action) {
case 'toggle_fullscreen':
clapperWidget.toggleFullscreen();
break;
default:
super.receiveWs(action, value);
break;
}
break;
}
}
_performCloseCleanup(window)

View File

@@ -62,8 +62,7 @@ class ClapperWidgetRemote extends Gtk.Grid
}
break;
case 'close':
const root = this.get_root();
root.run_dispose();
this.root.run_dispose();
break;
default:
break;