Add ControlCenter positioning config option (#213)
This commit is contained in:
@@ -1,30 +1,10 @@
|
|||||||
namespace SwayNotificationCenter {
|
namespace SwayNotificationCenter {
|
||||||
public enum PositionX {
|
public enum PositionX {
|
||||||
RIGHT, LEFT, CENTER;
|
RIGHT, LEFT, CENTER, NONE;
|
||||||
|
|
||||||
public string parse () {
|
|
||||||
switch (this) {
|
|
||||||
default:
|
|
||||||
return "right";
|
|
||||||
case LEFT:
|
|
||||||
return "left";
|
|
||||||
case CENTER:
|
|
||||||
return "center";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PositionY {
|
public enum PositionY {
|
||||||
TOP, BOTTOM;
|
TOP, BOTTOM, NONE;
|
||||||
|
|
||||||
public string parse () {
|
|
||||||
switch (this) {
|
|
||||||
default:
|
|
||||||
return "top";
|
|
||||||
case BOTTOM:
|
|
||||||
return "bottom";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ImageVisibility {
|
public enum ImageVisibility {
|
||||||
@@ -432,6 +412,15 @@ namespace SwayNotificationCenter {
|
|||||||
/** Hides the control center when clicking on notification action */
|
/** Hides the control center when clicking on notification action */
|
||||||
public bool hide_on_action { get; set; default = true; }
|
public bool hide_on_action { get; set; default = true; }
|
||||||
|
|
||||||
|
/** The controlcenters horizontal alignment. Supersedes `positionX` if not `NONE` */
|
||||||
|
public PositionX control_center_positionX { // vala-lint=naming-convention
|
||||||
|
get; set; default = PositionX.NONE;
|
||||||
|
}
|
||||||
|
/** The controlcenters vertical alignment. Supersedes `positionY` if not `NONE` */
|
||||||
|
public PositionY control_center_positionY { // vala-lint=naming-convention
|
||||||
|
get; set; default = PositionY.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
/** GtkLayerShell margins around the notification center */
|
/** GtkLayerShell margins around the notification center */
|
||||||
private int control_center_margin_top_ = 0;
|
private int control_center_margin_top_ = 0;
|
||||||
public int control_center_margin_top {
|
public int control_center_margin_top {
|
||||||
|
@@ -32,6 +32,18 @@
|
|||||||
"default": "top",
|
"default": "top",
|
||||||
"enum": ["top", "bottom"]
|
"enum": ["top", "bottom"]
|
||||||
},
|
},
|
||||||
|
"control-center-positionX": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Optional: Horizontal position of the control center. Supersedes positionX if not set to `none`",
|
||||||
|
"default": "none",
|
||||||
|
"enum": ["right", "left", "center", "none"]
|
||||||
|
},
|
||||||
|
"control-center-positionY": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Optional: Vertical position of the control center. Supersedes positionY if not set to `none`",
|
||||||
|
"default": "none",
|
||||||
|
"enum": ["top", "bottom", "none"]
|
||||||
|
},
|
||||||
"control-center-margin-top": {
|
"control-center-margin-top": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"description": "The margin (in pixels) at the top of the notification center. 0 to disable",
|
"description": "The margin (in pixels) at the top of the notification center. 0 to disable",
|
||||||
|
@@ -254,19 +254,25 @@ namespace SwayNotificationCenter {
|
|||||||
|
|
||||||
// Anchor box to north/south edges as needed
|
// Anchor box to north/south edges as needed
|
||||||
Gtk.Align align_x = Gtk.Align.END;
|
Gtk.Align align_x = Gtk.Align.END;
|
||||||
switch (ConfigModel.instance.positionX) {
|
PositionX pos_x = ConfigModel.instance.control_center_positionX;
|
||||||
|
if (pos_x == PositionX.NONE) pos_x = ConfigModel.instance.positionX;
|
||||||
|
switch (pos_x) {
|
||||||
case PositionX.LEFT:
|
case PositionX.LEFT:
|
||||||
align_x = Gtk.Align.START;
|
align_x = Gtk.Align.START;
|
||||||
break;
|
break;
|
||||||
case PositionX.CENTER:
|
case PositionX.CENTER:
|
||||||
align_x = Gtk.Align.CENTER;
|
align_x = Gtk.Align.CENTER;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
case PositionX.RIGHT:
|
case PositionX.RIGHT:
|
||||||
align_x = Gtk.Align.END;
|
align_x = Gtk.Align.END;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Gtk.Align align_y = Gtk.Align.START;
|
Gtk.Align align_y = Gtk.Align.START;
|
||||||
switch (ConfigModel.instance.positionY) {
|
PositionY pos_y = ConfigModel.instance.control_center_positionY;
|
||||||
|
if (pos_y == PositionY.NONE) pos_y = ConfigModel.instance.positionY;
|
||||||
|
switch (pos_y) {
|
||||||
|
default:
|
||||||
case PositionY.TOP:
|
case PositionY.TOP:
|
||||||
align_y = Gtk.Align.START;
|
align_y = Gtk.Align.START;
|
||||||
// Set cc widget position
|
// Set cc widget position
|
||||||
|
Reference in New Issue
Block a user