Make notification center width and height configurable (#38)
This commit is contained in:
@@ -87,6 +87,22 @@ config file to be able to detect config errors
|
|||||||
default: true ++
|
default: true ++
|
||||||
description: Hides the control center when clicking on notification action
|
description: Hides the control center when clicking on notification action
|
||||||
|
|
||||||
|
*fit-to-screen* ++
|
||||||
|
type: bool ++
|
||||||
|
default: true ++
|
||||||
|
description: Whether the control center should expand vertically to fill the screen
|
||||||
|
|
||||||
|
*control-center-height* ++
|
||||||
|
type: integer ++
|
||||||
|
default: 500 ++
|
||||||
|
description: The control centers height in pixels.
|
||||||
|
This setting is ignored when _fit-to-screen_ it set to "true"
|
||||||
|
|
||||||
|
*control-center-width* ++
|
||||||
|
type: integer ++
|
||||||
|
default: 500 ++
|
||||||
|
description: The control centers width in pixels
|
||||||
|
|
||||||
*notification-visibility* ++
|
*notification-visibility* ++
|
||||||
type: object ++
|
type: object ++
|
||||||
visibility object properties: ++
|
visibility object properties: ++
|
||||||
|
@@ -9,6 +9,8 @@
|
|||||||
"timeout": 10,
|
"timeout": 10,
|
||||||
"timeout-low": 5,
|
"timeout-low": 5,
|
||||||
"timeout-critical": 0,
|
"timeout-critical": 0,
|
||||||
|
"fit-to-screen": true,
|
||||||
|
"control-center-width": 500,
|
||||||
"notification-window-width": 500,
|
"notification-window-width": 500,
|
||||||
"keyboard-shortcuts": true,
|
"keyboard-shortcuts": true,
|
||||||
"image-visibility": "always",
|
"image-visibility": "always",
|
||||||
|
@@ -413,6 +413,38 @@ namespace SwayNotificationCenter {
|
|||||||
public bool script_fail_notify { get; set; default = true; }
|
public bool script_fail_notify { get; set; default = true; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Whether to expand the notification center across both edges of the screen */
|
||||||
|
public bool fit_to_screen { get; set; default = true; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notification center's height, in pixels.
|
||||||
|
* Set `fit_to_screen` to true to ignore the height setting.
|
||||||
|
*/
|
||||||
|
private const int control_center_minimum_height = 300;
|
||||||
|
private int _control_center_height = control_center_minimum_height;
|
||||||
|
public int control_center_height {
|
||||||
|
get {
|
||||||
|
return _control_center_height;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_control_center_height = value > control_center_minimum_height ? value : control_center_minimum_height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notification center's width, in pixels.
|
||||||
|
*/
|
||||||
|
private const int control_center_minimum_width = 300;
|
||||||
|
private int _control_center_width = control_center_minimum_width;
|
||||||
|
public int control_center_width {
|
||||||
|
get {
|
||||||
|
return _control_center_width;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_control_center_width = value > control_center_minimum_width ? value : control_center_minimum_width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "Horizontal position of control center and notification window",
|
"description": "Horizontal position of control center and notification window",
|
||||||
"default": "right",
|
"default": "right",
|
||||||
"enum": ["right", "left"]
|
"enum": ["right", "left", "center"]
|
||||||
},
|
},
|
||||||
"positionY": {
|
"positionY": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -59,6 +59,23 @@
|
|||||||
"description": "Width of the notification in pixels",
|
"description": "Width of the notification in pixels",
|
||||||
"default": 500
|
"default": 500
|
||||||
},
|
},
|
||||||
|
"fit-to-screen": {
|
||||||
|
"type": "boolean",
|
||||||
|
"description": "If the control center should expand to both edges of the screen",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
|
"control-center-height": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Height of the control center in pixels. Ignored when 'fit-to-screen' is set to 'true'",
|
||||||
|
"default": 600,
|
||||||
|
"minimum": 300
|
||||||
|
},
|
||||||
|
"control-center-width": {
|
||||||
|
"type": "integer",
|
||||||
|
"description": "Width of the control center in pixels",
|
||||||
|
"default": 500,
|
||||||
|
"minimum": 300
|
||||||
|
},
|
||||||
"keyboard-shortcuts": {
|
"keyboard-shortcuts": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If control center should use keyboard shortcuts",
|
"description": "If control center should use keyboard shortcuts",
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
<template class="SwayNotificationCenterControlCenter" parent="GtkApplicationWindow">
|
<template class="SwayNotificationCenterControlCenter" parent="GtkApplicationWindow">
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="resizable">False</property>
|
<property name="resizable">False</property>
|
||||||
<property name="default-width">500</property>
|
|
||||||
<property name="skip-taskbar-hint">True</property>
|
<property name="skip-taskbar-hint">True</property>
|
||||||
<property name="skip-pager-hint">True</property>
|
<property name="skip-pager-hint">True</property>
|
||||||
<property name="urgency-hint">True</property>
|
<property name="urgency-hint">True</property>
|
||||||
|
@@ -36,6 +36,7 @@ namespace SwayNotificationCenter {
|
|||||||
this.set_anchor ();
|
this.set_anchor ();
|
||||||
|
|
||||||
viewport.size_allocate.connect (size_alloc);
|
viewport.size_allocate.connect (size_alloc);
|
||||||
|
this.map.connect (set_anchor);
|
||||||
|
|
||||||
// Only use release for closing notifications due to Escape key
|
// Only use release for closing notifications due to Escape key
|
||||||
// sometimes being passed through to unfucused application
|
// sometimes being passed through to unfucused application
|
||||||
@@ -147,39 +148,37 @@ namespace SwayNotificationCenter {
|
|||||||
#endif
|
#endif
|
||||||
GtkLayerShell.set_layer (this, GtkLayerShell.Layer.TOP);
|
GtkLayerShell.set_layer (this, GtkLayerShell.Layer.TOP);
|
||||||
|
|
||||||
GtkLayerShell.set_margin (this, GtkLayerShell.Edge.TOP, ConfigModel.instance.control_center_margin_top);
|
GtkLayerShell.set_margin (this,
|
||||||
GtkLayerShell.set_margin (this, GtkLayerShell.Edge.BOTTOM, ConfigModel.instance.control_center_margin_bottom);
|
GtkLayerShell.Edge.TOP,
|
||||||
GtkLayerShell.set_margin (this, GtkLayerShell.Edge.RIGHT, ConfigModel.instance.control_center_margin_right);
|
ConfigModel.instance.control_center_margin_top);
|
||||||
GtkLayerShell.set_margin (this, GtkLayerShell.Edge.LEFT, ConfigModel.instance.control_center_margin_left);
|
GtkLayerShell.set_margin (this,
|
||||||
|
GtkLayerShell.Edge.BOTTOM,
|
||||||
|
ConfigModel.instance.control_center_margin_bottom);
|
||||||
|
GtkLayerShell.set_margin (this,
|
||||||
|
GtkLayerShell.Edge.RIGHT,
|
||||||
|
ConfigModel.instance.control_center_margin_right);
|
||||||
|
GtkLayerShell.set_margin (this,
|
||||||
|
GtkLayerShell.Edge.LEFT,
|
||||||
|
ConfigModel.instance.control_center_margin_left);
|
||||||
|
|
||||||
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.TOP, true);
|
// Anchor to north/south edges as needed
|
||||||
GtkLayerShell.set_anchor (this, GtkLayerShell.Edge.BOTTOM, true);
|
bool anchorTop = ConfigModel.instance.positionY == PositionY.TOP;
|
||||||
switch (ConfigModel.instance.positionX) {
|
GtkLayerShell.set_anchor (this,
|
||||||
case PositionX.LEFT:
|
GtkLayerShell.Edge.TOP,
|
||||||
|
ConfigModel.instance.fit_to_screen || anchorTop);
|
||||||
|
GtkLayerShell.set_anchor (this,
|
||||||
|
GtkLayerShell.Edge.BOTTOM,
|
||||||
|
ConfigModel.instance.fit_to_screen || !anchorTop);
|
||||||
|
|
||||||
|
bool anchorLeft = ConfigModel.instance.positionX == PositionX.LEFT;
|
||||||
|
bool anchorRight = ConfigModel.instance.positionX == PositionX.RIGHT;
|
||||||
GtkLayerShell.set_anchor (this,
|
GtkLayerShell.set_anchor (this,
|
||||||
GtkLayerShell.Edge.RIGHT,
|
GtkLayerShell.Edge.RIGHT,
|
||||||
false);
|
anchorRight);
|
||||||
GtkLayerShell.set_anchor (this,
|
GtkLayerShell.set_anchor (this,
|
||||||
GtkLayerShell.Edge.LEFT,
|
GtkLayerShell.Edge.LEFT,
|
||||||
true);
|
anchorLeft);
|
||||||
break;
|
|
||||||
case PositionX.CENTER:
|
|
||||||
GtkLayerShell.set_anchor (this,
|
|
||||||
GtkLayerShell.Edge.RIGHT,
|
|
||||||
false);
|
|
||||||
GtkLayerShell.set_anchor (this,
|
|
||||||
GtkLayerShell.Edge.LEFT,
|
|
||||||
false);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
GtkLayerShell.set_anchor (this,
|
|
||||||
GtkLayerShell.Edge.LEFT,
|
|
||||||
false);
|
|
||||||
GtkLayerShell.set_anchor (this,
|
|
||||||
GtkLayerShell.Edge.RIGHT,
|
|
||||||
true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (ConfigModel.instance.positionY) {
|
switch (ConfigModel.instance.positionY) {
|
||||||
case PositionY.BOTTOM:
|
case PositionY.BOTTOM:
|
||||||
list_reverse = true;
|
list_reverse = true;
|
||||||
@@ -205,6 +204,11 @@ namespace SwayNotificationCenter {
|
|||||||
int val = list_reverse ? 1 : -1;
|
int val = list_reverse ? 1 : -1;
|
||||||
return a.param.time > b.param.time ? val : val * -1;
|
return a.param.time > b.param.time ? val : val * -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Always set the size request in all events.
|
||||||
|
int configuredWidth = ConfigModel.instance.control_center_width;
|
||||||
|
int configuredHeight = ConfigModel.instance.control_center_height;
|
||||||
|
this.set_size_request (configuredWidth, configuredHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void size_alloc () {
|
private void size_alloc () {
|
||||||
|
@@ -37,7 +37,6 @@
|
|||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkOverlay" id="overlay">
|
<object class="GtkOverlay" id="overlay">
|
||||||
<property name="width-request">500</property>
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
|
Reference in New Issue
Block a user