Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add settings to center buttons-grid #426

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion man/swaync.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ config file to be able to detect config errors
type: bool ++
default: true ++
description: Display notification timestamps relative to now e.g. \"26 minutes ago\". ++
If false, a local iso8601-formatted absolute timestamp is displayed.
If false, a local iso8601-formatted absolute timestamp is displayed.

*control-center-height* ++
type: integer ++
Expand Down Expand Up @@ -442,6 +442,21 @@ config file to be able to detect config errors
type: object ++
css class: widget-buttons (access buttons with >flowbox>flowboxchild>button) ++
properties: ++
center: ++
type: bool ++
optional: true ++
default: false ++
description: set buttons-grid halign to center ++
column-min: ++
type: integer ++
optional: true ++
default: 0 ++
description: minimum number of buttons per line ++
column-max: ++
type: integer ++
optional: true ++
default: 0 ++
description: maximum number of buttons per line ++
actions: ++
type: array ++
Default values: [] ++
Expand Down
15 changes: 15 additions & 0 deletions src/configSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,21 @@
"description": "A widget to add a grid of buttons that execute shell commands",
"additionalProperties": false,
"properties": {
"center": {
"type": "boolean",
"description": "set buttons-grid halign to center",
"default": false
},
"column-min": {
"type": "integer",
"description": "minimum number of buttons per line",
"default": 0
},
"column-max": {
"type": "integer",
"description": "maximum number of buttons per line",
"default": 0
},
"actions": {
"type": "array",
"description": "A list of actions containing a label and a command",
Expand Down
20 changes: 16 additions & 4 deletions src/controlCenter/widgets/buttonsGrid/buttonsGrid.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,27 @@ namespace SwayNotificationCenter.Widgets {
public ButtonsGrid (string suffix, SwayncDaemon swaync_daemon, NotiDaemon noti_daemon) {
base (suffix, swaync_daemon, noti_daemon);

Gtk.FlowBox container = new Gtk.FlowBox ();
container.set_selection_mode (Gtk.SelectionMode.NONE);
pack_start (container, true, true, 0);

Json.Object ? config = get_config (this);
if (config != null) {
Json.Array a = get_prop_array (config, "actions");
if (a != null) actions = parse_actions (a);
}

Gtk.FlowBox container = new Gtk.FlowBox ();
container.set_selection_mode (Gtk.SelectionMode.NONE);
pack_start (container, true, true, 0);
bool? center = get_prop<bool> (config, "center");
if (center != null && center)
container.set_halign(Gtk.Align.CENTER);

int? col_min = get_prop<int> (config, "column-min");
if (col_min != null && col_min > 0)
container.set_min_children_per_line(col_min);

int? col_max = get_prop<int> (config, "column-max");
if (col_max != null && col_max > 0)
container.set_max_children_per_line(col_max);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter requires spaces between the function name and the parenthesis. Also, I'd prefer if you use brackets on small if-statments.

Not sure why GitHub isn't allowing me to run my GitHub Linting Actions…

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vala dev settings on my laptop not seems to be stable enough, reformat with uncrustify, feel free to adjust the code on merge if you like ;)

}

// add action to container
foreach (var act in actions) {
Expand Down