control-center: add dynamic height option

parent f4ddf0fc
......@@ -186,10 +186,17 @@ config file to be able to detect config errors
type: integer ++
default: 500 ++
description: Height of the control center in pixels. ++
When 'control-center-dynamic-height' is true, ++
this acts as maximum height. ++
A value of -1 means that it will fit to the content. ++
Ignored when 'fit-to-screen' is set to 'true'. ++
Also limited to the height of the monitor, unless ++
'layer-shell-cover-screen' is set to false.
Ignored when 'fit-to-screen' is set to 'true'.
*control-center-dynamic-height* ++
type: bool ++
default: true ++
description: If true, the control center height adjusts ++
to its content, up to 'control-center-height' as ++
maximum. If false, height is fixed.
*control-center-width* ++
type: integer ++
......
......@@ -7,6 +7,7 @@
"cssPriority": "user",
"control-center-width": 400,
"control-center-height": 740,
"control-center-dynamic-height": true,
"control-center-margin-top": 8,
"control-center-margin-bottom": 8,
"control-center-margin-right": 8,
......
......@@ -669,6 +669,14 @@ namespace XimperShellNotificationCenter {
}
/**
* If true, the control center height adjusts to content,
* up to control-center-height as maximum.
*/
public bool control_center_dynamic_height {
get; set; default = true;
}
/**
* Notification center's width, in pixels.
*/
private const int CONTROL_CENTER_MINIMUM_WIDTH = 300;
......
......@@ -153,10 +153,15 @@
},
"control-center-height": {
"type": "integer",
"description": "Height of the control center in pixels. A value of -1 means that it will fit to the content. Ignored when 'fit-to-screen' is set to 'true'. Also limited to the height of the monitor, unless 'layer-shell-cover-screen' is set to false.",
"description": "Height of the control center in pixels. When 'control-center-dynamic-height' is true, this acts as maximum height. A value of -1 means that it will fit to the content. Ignored when 'fit-to-screen' is set to 'true'.",
"default": 500,
"minimum": -1
},
"control-center-dynamic-height": {
"type": "boolean",
"description": "If true, the control center height adjusts to its content, up to 'control-center-height' as maximum. If false, height is fixed.",
"default": true
},
"control-center-width": {
"type": "integer",
"description": "Width of the control center in pixels",
......
......@@ -365,14 +365,28 @@ namespace XimperShellNotificationCenter {
window.set_halign (align_x);
window.set_valign (align_y);
// Re-set the minimum size
window.set_propagate_natural_height (
ConfigModel.instance.control_center_height < 1
|| ConfigModel.instance.fit_to_screen);
window.set_size_request (ConfigModel.instance.control_center_width,
ConfigModel.instance.control_center_height);
box.set_size_request (ConfigModel.instance.control_center_width,
ConfigModel.instance.control_center_height);
// Re-set the size
int cc_width =
ConfigModel.instance.control_center_width;
int cc_height =
ConfigModel.instance.control_center_height;
bool dynamic =
ConfigModel.instance
.control_center_dynamic_height;
if (dynamic && cc_height > 0) {
window.set_propagate_natural_height (true);
window.set_max_content_height (cc_height);
window.set_size_request (cc_width, -1);
box.set_size_request (cc_width, -1);
} else {
window.set_propagate_natural_height (
cc_height < 1
|| ConfigModel.instance.fit_to_screen);
window.set_max_content_height (-1);
window.set_size_request (cc_width, cc_height);
box.set_size_request (cc_width, cc_height);
}
}
public bool toggle_visibility () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment