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

View File

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

View File

@@ -17,6 +17,8 @@ class ClapperHeaderBarBase extends Gtk.Box
margin_start: 6, margin_start: 6,
margin_end: 6, margin_end: 6,
}); });
this.add_css_class('osd');
this.add_css_class('osdheaderbar');
this.isMaximized = false; this.isMaximized = false;
this.isMenuOnLeft = true; this.isMenuOnLeft = true;
@@ -197,12 +199,11 @@ class ClapperHeaderBarBase extends Gtk.Box
}); });
button.add_css_class('circular'); button.add_css_class('circular');
const action = (name === 'maximize') if(name === 'maximize')
? 'window.toggle-maximized' name = 'toggle-maximized';
: 'window.' + name;
button.connect('clicked', button.connect('clicked',
this._onWindowButtonActivate.bind(this, action) this._onWindowButtonActivate.bind(this, name)
); );
return button; 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,8 +252,23 @@ class ClapperPlayer extends PlayerBase
case 'set_playlist': case 'set_playlist':
this[action](value); this[action](value);
break; break;
case 'toggle_maximized':
action = 'toggle-maximized';
case 'minimize':
case 'close':
this.widget.activate_action(`window.${action}`, null);
break;
default: default:
super.receiveWs(action, value); const clapperWidget = this.widget.get_ancestor(Gtk.Grid);
switch(action) {
case 'toggle_fullscreen':
clapperWidget.toggleFullscreen();
break;
default:
super.receiveWs(action, value);
break;
}
break; break;
} }
} }

View File

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