Skip to content

Commit

Permalink
Merge branch 'main' into gamepads-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Sep 26, 2024
2 parents 5e4d85c + cda16c2 commit 7a6e1f9
Show file tree
Hide file tree
Showing 194 changed files with 2,590 additions and 741 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ on:

jobs:
CI:
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # required for make test
submodules: "recursive"

- name: Install host dependencies
Expand All @@ -25,13 +26,6 @@ jobs:
key: ${{ runner.os }}-flatpak-dependencies-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-flatpak-dependencies-
- name: Restore .flatpak-builder
uses: actions/cache/restore@v3
with:
path: Workbench/.flatpak-builder
key: ${{ runner.os }}-flatpak-builder-${{ github.run_id }}
restore-keys: |
${{ runner.os }}-flatpak-builder-
- run: mutter --wayland --no-x11 --headless --wayland-display=wayland-0 --virtual-monitor 1280x720 > /tmp/mutter.log 2>&1 &
- run: make ci
Expand All @@ -44,9 +38,3 @@ jobs:
with:
path: ~/.local/share/flatpak
key: ${{ runner.os }}-flatpak-dependencies-${{ github.run_id }}
- name: Save .flatpak-builder
uses: actions/cache/save@v3
if: always()
with:
path: Workbench/.flatpak-builder
key: ${{ runner.os }}-flatpak-builder-${{ github.run_id }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ src/*/Cargo.toml
src/*/lib.rs
src/*/workbench.rs
src/*/target
src/*/*.gresource
src/*/*.gresource.xml
src/*/jsconfig.json
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,7 @@ Here is a compilation of resources to learn more about the GNOME platform.
- [Valadoc.org](https://valadoc.org)
- [Vala tutorial](https://wiki.gnome.org/Projects/Vala/Tutorial)
- [Vala examples](https://wiki.gnome.org/Projects/Vala/Examples)

### Python

- [PyGObject Docs](https://pygobject.gnome.org)
35 changes: 19 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
SHELL:=/bin/bash -O globstar
.PHONY: setup lint test ci
.PHONY: setup test ci
.DEFAULT_GOAL := ci

setup:
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install --or-update --user --noninteractive flathub org.freedesktop.Sdk.Extension.rust-stable//24.08 org.freedesktop.Sdk.Extension.vala//24.08 org.freedesktop.Sdk.Extension.node20//24.08 #org.freedesktop.Sdk.Extension.typescript//24.08
# flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
flatpak install --or-update --user --noninteractive flathub re.sonny.Workbench org.freedesktop.Sdk.Extension.rust-stable//23.08 org.freedesktop.Sdk.Extension.vala//23.08

lint:
# Rust
flatpak run --command="/usr/lib/sdk/rust-stable/bin/rustfmt" --filesystem=host re.sonny.Workbench --check --edition 2021 src/*/*.rs
# Python
# flatpak run --command="ruff" --filesystem=host re.sonny.Workbench check --config=../src/langs/python/ruff.toml src/*/*.py
flatpak remote-add --user --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
flatpak install --or-update --user --noninteractive gnome-nightly re.sonny.Workbench.Devel

format:
# npx prettier --write src/*/*.json
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench format javascript src/*/*.js
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench format css src/*/*.css
# flatpak run --command="ruff" --filesystem=host re.sonny.Workbench format --config=../src/langs/python/ruff.toml src/**/*.py
flatpak run --command="/usr/lib/sdk/rust-stable/bin/rustfmt" --filesystem=host re.sonny.Workbench --edition 2021 src/*/*.rs
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench format blueprint src/*/*.blp
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench format vala src/*/*.vala
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench.Devel format javascript src/*/*.js
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench.Devel format css src/*/*.css
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench.Devel format python src/*/*.py
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench.Devel format rust src/*/*.rs
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench.Devel format blueprint src/*/*.blp
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench.Devel format vala src/*/*.vala

test:
# list folders that have changed and run workbench-cli ci on them
git diff --dirstat=files,0 origin/main src | sed 's/^[ 0-9.]\+% //g' | uniq | xargs -d '\n' flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench.Devel ci

test: lint
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench ci src/*
all:
flatpak run --command="workbench-cli" --filesystem=host re.sonny.Workbench.Devel ci src/*

ci: setup test

Expand All @@ -37,5 +37,8 @@ clean:
rm -f src/*/Cargo.lockfile
rm -f src/*/lib.rs
rm -f src/*/workbench.rs
rm -f src/*/jsconfig.json
rm -f src/*/*.gresource
rm -f src/*/*.gresource.xml
rm -rf src/*/target
rm -rf src/*/__pycache__
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,6 @@ flatpak override --user --filesystem=$PWD re.sonny.Workbench

For more details see [CONTRIBUTING.md](./CONTRIBUTING.md).

## Testing

Please make sure to test your changes manually.

You can run automated tests for a specific demo locally with

```sh
flatpak run --command="workbench-cli" --filesystem=$PWD/src re.sonny.Workbench ci src/Welcome
```

Or run all the tests locally with

```sh
make ci
```

## Code of conduct

Workbench follows the [GNOME Code of Conduct](https://conduct.gnome.org/).
Expand Down
3 changes: 2 additions & 1 deletion STYLEGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Prefer properties like `Gtk.Box:spacing` to `Gtk.Widget:margin-top` for layout
- Avoid hard-coded height and width, except for e.g. images with fixed geometry
- Prefer HIG terms (Radio Groups, Checkboxes) over technical ones (Checkbuttons)
- If you need icons, it is possible to use custom icons but prefer included [Adwaita icons set](ttps://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/master/Adwaita/symbolic/actions?ref_type=heads).

## CSS

Expand Down Expand Up @@ -130,4 +131,4 @@ button.add_css_class ("pill");
### Logging

- Use `message ()`, `warning ()` and `critical ()` for debug messages (depending on the severity)
- Use `print ()`/`stdout.printf ()` for messages that are intended to be seen by the user
- Use `print ()`/`stdout.printf ()` for messages that are intended to be seen by the user
2 changes: 1 addition & 1 deletion src/About Dialog/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn on_button_clicked() {

dialog.add_link(
"Documentation",
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.AboutDialog.html",
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.AboutDialog.html",
);

dialog.add_legal_section(
Expand Down
2 changes: 1 addition & 1 deletion src/About Dialog/main.blp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Adw.StatusPage {

LinkButton {
label: _("API Reference");
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.AboutDialog.html";
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.AboutDialog.html";
}
}
}
4 changes: 2 additions & 2 deletions src/About Dialog/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gettext as _ } from "gettext";
import Adw from "gi://Adw";
import Gtk from "gi://Gtk";
import Gtk from "gi://Gtk?version=4.0";

const button = workbench.builder.get_object("button");

Expand All @@ -25,7 +25,7 @@ function openAboutDialog() {

dialog.add_link(
_("Documentation"),
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.AboutDialog.html",
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.AboutDialog.html",
);

dialog.add_legal_section(
Expand Down
2 changes: 1 addition & 1 deletion src/About Dialog/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def open_about_window(_widget):

dialog.add_link(
_("Documentation"),
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.AboutDialog.html",
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.AboutDialog.html",
)

dialog.add_legal_section(
Expand Down
2 changes: 1 addition & 1 deletion src/About Dialog/main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void on_button_clicked () {
};
dialog.add_link (
"Documentation",
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.AboutDialog.html"
"https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.AboutDialog.html"
);
dialog.add_legal_section (
"Fonts",
Expand Down
7 changes: 5 additions & 2 deletions src/Accessibility/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import GObject from "gi://GObject";
import Gdk from "gi://Gdk";
import Gtk from "gi://Gtk";
import Gdk from "gi://Gdk?version=4.0";
import Gtk from "gi://Gtk?version=4.0";

const button = workbench.builder.get_object("custom_button");

Expand All @@ -22,6 +22,9 @@ key_controller.connect("key-released", (_controller, keyval) => {
});
button.add_controller(key_controller);

/**
* @param {Gtk.Button} button
*/
function toggleButton(button) {
let checked = (button.get_state_flags() & Gtk.StateFlags.CHECKED) !== 0;
let pressed;
Expand Down
4 changes: 2 additions & 2 deletions src/Account/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Gdk from "gi://Gdk";
import Gdk from "gi://Gdk?version=4.0";
import Gio from "gi://Gio";
import Xdp from "gi://Xdp";
import Xdp from "gi://Xdp?version=1.0";
import XdpGtk from "gi://XdpGtk4";

Gio._promisify(
Expand Down
2 changes: 1 addition & 1 deletion src/Action Bar/main.blp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Box {

[end]
Button end_widget {
icon-name: "padlock2-symbolic";
icon-name: "input-keyboard-symbolic";
}
}
}
44 changes: 44 additions & 0 deletions src/Actions/main.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! /usr/bin/env -S vala workbench.vala --pkg libadwaita-1

public void main () {
var demo = (Adw.StatusPage) workbench.builder.get_object ("demo");

var demo_group = new SimpleActionGroup ();
demo.insert_action_group ("demo", demo_group);

// Action with no state or parameters
var simple_action = new SimpleAction ("simple", null);
simple_action.activate.connect (() => {
message (@"$(simple_action.name) action activated");
});
demo_group.add_action (simple_action);

// Action with parameter
var bookmarks_action = new SimpleAction ("open-bookmarks", new GLib.VariantType ("s"));
bookmarks_action.activate.connect ((action, parameter) => {
message (@"$(action.name) activated with $(parameter.get_string())");
});
demo_group.add_action (bookmarks_action);

// Action with state
var toggle_action = new SimpleAction.stateful ("toggle", null, new Variant.boolean (false));
toggle_action.notify.connect ((action, state) => {
bool b = toggle_action.state.get_boolean ();
message (@"$(toggle_action.name) action set to " + (b ? "true" : "false"));
});

demo_group.add_action (toggle_action);

// Action with state and parameter
var scale_action = new SimpleAction.stateful ("scale", new VariantType ("s"), new Variant.string ("100%"));

scale_action.notify.connect ((action) => {
message (@"$(scale_action.name) action set to $(scale_action.state.get_string())");
});

demo_group.add_action (scale_action);

var text = (Gtk.Label) workbench.builder.get_object ("text");
var alignment_action = new PropertyAction ("text-align", text, "halign");
demo_group.add_action (alignment_action);
}
14 changes: 7 additions & 7 deletions src/Advanced Buttons/main.blp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Adw.StatusPage {

Adw.SplitButton {
halign: center;
icon-name: "execute-from-symbolic";
icon-name: "media-playback-start-symbolic";
menu-model: button_run_menu;
}

Expand Down Expand Up @@ -71,7 +71,7 @@ Adw.StatusPage {
LinkButton {
margin-bottom: 36;
label: _("API Reference");
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.SplitButton.html";
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.SplitButton.html";
}

Box {
Expand Down Expand Up @@ -126,7 +126,7 @@ Adw.StatusPage {

Adw.ButtonContent {
label: _("New");
icon-name: "plus-symbolic";
icon-name: "list-add-symbolic";
}
}

Expand All @@ -143,8 +143,8 @@ Adw.StatusPage {

ToggleButton {
Adw.ButtonContent {
label: _("Alerts");
icon-name: "bell-outline-symbolic";
label: _("Bluetooth");
icon-name: "bluetooth-active-symbolic";
}
}

Expand All @@ -157,7 +157,7 @@ Adw.StatusPage {

LinkButton {
label: _("API Reference");
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.ButtonContent.html";
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.ButtonContent.html";
}
}
}
Expand All @@ -172,7 +172,7 @@ Popover button_popover {

Adw.StatusPage {
title: _("No Recent Documents");
icon-name: "clock-symbolic";
icon-name: "document-open-recent-symbolic";
width-request: 300;
height-request: 300;

Expand Down
8 changes: 4 additions & 4 deletions src/Animation/main.blp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Adw.Clamp {
hexpand: true;
halign: end;
valign: center;
icon-name: "play-large-symbolic";
icon-name: "media-playback-start-symbolic";

styles [
"circular"
Expand Down Expand Up @@ -115,7 +115,7 @@ Adw.Clamp {
hexpand: true;
halign: end;
valign: center;
icon-name: "play-large-symbolic";
icon-name: "media-playback-start-symbolic";

styles [
"circular"
Expand Down Expand Up @@ -163,12 +163,12 @@ Adw.Clamp {

LinkButton {
label: _("Timed Animation");
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.TimedAnimation.html";
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.TimedAnimation.html";
}

LinkButton {
label: _("Spring Animation");
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.5/class.SpringAnimation.html";
uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.6/class.SpringAnimation.html";
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/Animation/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ const animation_spring = new Adw.SpringAnimation({
value_to: 1,
spring_params: params,
target: target_spring,
initial_velocity: 1.0, // If amplitude of oscillation < epsilon, animation stops
epsilon: 0.001,
clamp: false,
});
animation_spring.initial_velocity = 1.0;
// If amplitude of oscillation < epsilon, animation stops
animation_spring.epsilon = 0.001;
animation_spring.clamp = false;

button_spring.connect("clicked", () => {
animation_spring.play();
Expand Down
Loading

0 comments on commit 7a6e1f9

Please sign in to comment.