Skip to content

Commit

Permalink
Format Vala code
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Dec 17, 2023
1 parent b787136 commit 8680b50
Show file tree
Hide file tree
Showing 493 changed files with 266 additions and 243 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ indent_style = tab

[*.py]
indent_size = 4

[*.rs]
indent_size = 4

[*.vala]
indent_size = 4
20 changes: 10 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ __pycache__
.vscode

# Project files - sync with Makefile
demos/**/settings
demos/**/workbench.vala
demos/**/main.ui
demos/**/libworkbenchcode.so
demos/**/__pycache__
demos/**/Cargo.lock
demos/**/Cargo.toml
demos/**/lib.rs
demos/**/workbench.rs
demos/**/biome.json
src/**/settings
src/**/workbench.vala
src/**/main.ui
src/**/libworkbenchcode.so
src/**/__pycache__
src/**/Cargo.lock
src/**/Cargo.toml
src/**/lib.rs
src/**/workbench.rs
src/**/biome.json
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ flatpak override --user --filesystem=$PWD re.sonny.Workbench
To create a new Library entry, duplicate an existing one and proceed to the next section.

```sh
cp -r demos/Button demos/Something
cp -r src/Button src/Something
```

### Update Library entry
Expand All @@ -97,7 +97,7 @@ To update or port an existing Library entry

1. Open Workbench
2. Select "Open Project…" in the menu
3. Select the corresponding demo folder, for example `demos/Something`
3. Select the corresponding demo folder, for example `src/Something`
4. Make the changes

## Submitting a contribution
Expand Down
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@ SHELL:=/bin/bash -O globstar

setup:
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//45 org.freedesktop.Sdk.Extension.rust-stable//23.08
flatpak install --or-update --user --noninteractive flathub org.gnome.Sdk//45 org.freedesktop.Sdk.Extension.rust-stable//23.08 org.freedesktop.Sdk.Extension.vala//23.08
npm install
flatpak-builder --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Demos.json

lint:
# JavaScript
# ./node_modules/.bin/eslint --max-warnings=0 src
./build-aux/fun biome ci demos/
# rustfmt
./build-aux/fun rustfmt --check --edition 2021 demos/**/*.rs
# black
./build-aux/fun black --check demos/**/*.py
./build-aux/fun biome ci src/
# Vala
./build-aux/fun uncrustify -c - --check --set indent_with_tabs=0 --set nl_end_of_file=force --set nl_end_of_file_min=1 --set indent_columns=4 src/**/*.vala
# Rust
./build-aux/fun rustfmt --check --edition 2021 src/**/*.rs
# Python
./build-aux/fun black --check src/**/*.py
# Blueprint
find demos/ -type f -name "*blp" -print0 | xargs -0 ./build-aux/fun blueprint-compiler format
./build-aux/fun blueprint-compiler format src/**/*.blp

test: lint

ci: setup lint

# Sync with .gitignore
clean:
rm -f demos/**/settings
rm -f demos/**/workbench.vala
rm -f demos/**/main.ui
rm -f demos/**/libworkbenchcode.so
rm -rf demos/**/__pycache__
rm -f src/**/settings
rm -f src/**/workbench.vala
rm -f src/**/main.ui
rm -f src/**/libworkbenchcode.so
rm -rf src/**/__pycache__
rm -rf _build
rm -rf .flatpak
rm -rf .flatpak-builder
Expand Down
6 changes: 2 additions & 4 deletions build-aux/re.sonny.Workbench.Demos.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
"runtime": "org.gnome.Sdk",
"runtime-version": "45",
"sdk": "org.gnome.Sdk",
"sdk-extensions": [
"org.freedesktop.Sdk.Extension.rust-stable"
],
"sdk-extensions": ["org.freedesktop.Sdk.Extension.rust-stable"],
"build-options": {
"append-path": "/usr/lib/sdk/rust-stable/bin"
"append-path": "/usr/lib/sdk/vala/bin:/usr/lib/sdk/rust-stable/bin"
},
"modules": [
"modules/python-black.json",
Expand Down
42 changes: 0 additions & 42 deletions demos/About Window/main.vala

This file was deleted.

23 changes: 0 additions & 23 deletions demos/Source View/main.vala

This file was deleted.

32 changes: 0 additions & 32 deletions demos/Welcome/main.vala

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
],
"*.py": "./build-aux/fun black",
"*.rs": "./build-aux/fun rustfmt --edition 2021",
"*.blp": "./build-aux/fun blueprint-compiler format --fix"
"*.blp": "./build-aux/fun blueprint-compiler format --fix",
"*.{vala}": "./build-aux/fun uncrustify -c - --replace --no-backup --set indent_with_tabs=0 --set nl_end_of_file=force --set nl_end_of_file_min=1 --set indent_columns=2"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
42 changes: 42 additions & 0 deletions src/About Window/main.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#! /usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1

public void main () {
Gtk.init ();

var button = workbench.builder.get_object ("button") as Gtk.Button;
button.clicked.connect(on_button_clicked);
}

public void on_button_clicked () {
// https://valadoc.org/libadwaita-1/Adw.AboutWindow.html
var dialog = new Adw.AboutWindow() {
transient_for = workbench.window,
application_icon = "application-x-executable",
application_name = "Typeset",
developer_name = "Angela Avery",
version = "1.2.3",
comments = "Typeset is an app that doesn’t exist and is used as an example content for About Window.",
website = "https://example.org",
issue_url = "https://example.org",
support_url = "https://example.org",
copyright = "© 2023 Angela Avery",
license_type = Gtk.License.GPL_3_0_ONLY,
developers = { "Angela Avery <[email protected]>" },
artists = { "GNOME Design Team" },
translator_credits = "translator-credits",
};
dialog.add_link (
"Documentation",
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.4/class.AboutWindow.html"
);
dialog.add_legal_section (
"Fonts",
null,
Gtk.License.CUSTOM,
"This application uses font data from <a href='https://example.org'>somewhere</a>."
);

dialog.add_acknowledgement_section ("Special thanks to", { "My cat" } );

dialog.present();
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions demos/Account/main.vala → src/Account/main.vala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S vala workbench.vala --pkg libadwaita-1 --pkg libportal-gtk4
#! /usr/bin/env -S vala workbench.vala --pkg libadwaita-1 --pkg libportal-gtk4

private Gtk.Revealer revealer;
private Adw.EntryRow entry;
Expand Down Expand Up @@ -28,11 +28,11 @@ private async void on_button_clicked () {
Variant result = yield portal.get_user_information (parent, reason, NONE, null);

/*
* result is a Variant dictionary containing the following fields:
* id (s): the user id
* name (s): the users real name
* image (s): the uri of an image file for the users avatar picture
*/
* result is a Variant dictionary containing the following fields:
* id (s): the user id
* name (s): the users real name
* image (s): the uri of an image file for the users avatar picture
*/

var id = (string) result.lookup_value ("id", VariantType.STRING);
var name = (string) result.lookup_value ("name", VariantType.STRING);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions demos/Animation/main.vala → src/Animation/main.vala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S vala workbench.vala --pkg libadwaita-1
#! /usr/bin/env -S vala workbench.vala --pkg libadwaita-1

private Adw.Bin ball;

Expand All @@ -12,7 +12,7 @@ public void main () {
0, 1, // Initial value, final value
1500, // Duration (in milliseconds)
target_timed // Animation target
) {
) {
easing = EASE_IN_OUT_CUBIC
};

Expand All @@ -27,14 +27,14 @@ public void main () {
0.5, // Damping Ratio
1.0, // Mass
50.0 // Stiffness
);
);

var spring_animation = new Adw.SpringAnimation (
ball, // Widget
0, 1, // Initial value, final value
spring_params, // Spring params
spring_target // Animation target
) {
) {
initial_velocity = 1.0,
epsilon = 0.001,
clamp = false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion demos/Audio/main.vala → src/Audio/main.vala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S vala workbench.vala --pkg libadwaita-1
#! /usr/bin/env -S vala workbench.vala --pkg libadwaita-1

public void main () {
var controls = (Gtk.MediaControls) workbench.builder.get_object ("controls");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion demos/Avatar/main.vala → src/Avatar/main.vala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S vala workbench.vala --pkg libadwaita-1
#! /usr/bin/env -S vala workbench.vala --pkg libadwaita-1

private Adw.Avatar avatar_image;

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions demos/Box/main.vala → src/Box/main.vala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S vala workbench.vala --pkg libadwaita-1
#! /usr/bin/env -S vala workbench.vala --pkg libadwaita-1

private Gtk.Box interactive_box;
private int count = 0;
Expand All @@ -15,7 +15,7 @@ public void main () {

var toggle_orientation_horizontal = (Gtk.ToggleButton) workbench.builder.get_object (
"toggle_orientation_horizontal"
);
);

toggle_orientation_horizontal.toggled.connect (() => {
if (toggle_orientation_horizontal.active) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion demos/Button/main.vala → src/Button/main.vala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1
#! /usr/bin/env -S vala workbench.vala --pkg gtk4 --pkg libadwaita-1

public void main () {
string[] button_ids = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 12 additions & 5 deletions demos/Carousel/main.vala → src/Carousel/main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,32 @@ public void main() {
});

if (indicator_row.get_selected() == 0) {
dots = new Adw.CarouselIndicatorDots() { carousel = carousel };
dots = new Adw.CarouselIndicatorDots() {
carousel = carousel
};
dots.orientation = carousel.orientation;
root_box.append(dots);
} else {
lines = new Adw.CarouselIndicatorLines() { carousel = carousel };
lines = new Adw.CarouselIndicatorLines() {
carousel = carousel
};
lines.orientation = carousel.orientation;
root_box.append(lines);
}

indicator_row.notify["selected-item"].connect(() => {
if (indicator_row.get_selected() == 0) {
root_box.remove(lines);
dots = new Adw.CarouselIndicatorDots() { carousel = carousel };
dots = new Adw.CarouselIndicatorDots() {
carousel = carousel
};
dots.orientation = carousel.orientation;
root_box.append(dots);
} else {
root_box.remove(dots);
lines = new Adw.CarouselIndicatorLines() { carousel = carousel };
lines = new Adw.CarouselIndicatorLines() {
carousel = carousel
};
lines.orientation = carousel.orientation;
root_box.append(lines);
}
Expand All @@ -64,4 +72,3 @@ public void main() {
}
});
}

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 8680b50

Please sign in to comment.