mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Make remote app minimize, maximize and close buttons affect Clapper
This commit is contained in:
@@ -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();
|
||||
|
@@ -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()
|
||||
|
@@ -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
20
src/headerbarRemote.js
Normal 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);
|
||||
}
|
||||
});
|
@@ -252,8 +252,23 @@ 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:
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user