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 { 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();
|
||||||
|
@@ -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()
|
||||||
|
@@ -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
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':
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
|
Reference in New Issue
Block a user