Skip to content

Commit

Permalink
Merge branch 'main' into wip/vixalien/typechecking
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Jul 3, 2024
2 parents a06b0ec + bdf7bed commit 6aad42a
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 86 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name: CI
on:
pull_request:
branches: [main]
workflow_dispatch:

jobs:
CI:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Deploy

on:
push:
branches: [main]
name: Deploy
workflow_dispatch:

jobs:
flatpak:
name: "Flatpak"
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ We provide a couple of tools to make the development process pleasant.
# sudo dnf install flatpak flatpak-builder nodejs make gcc gcc-c++

cd Workbench
make setup
make
```

Before submitting a PR, we recommend running tests locally with
Expand Down
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
SHELL:=/bin/bash -O globstar
.PHONY: setup build lint unit test ci sandbox flatpak
.DEFAULT_GOAL := test
.DEFAULT_GOAL := setup

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//46 org.flatpak.Builder org.freedesktop.Sdk.Extension.rust-stable//23.08 org.freedesktop.Sdk.Extension.vala//23.08 org.freedesktop.Sdk.Extension.llvm16//23.08 org.freedesktop.Sdk.Extension.node18//23.08 org.freedesktop.Sdk.Extension.typescript//23.08
# flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
flatpak remote-add --user --if-not-exists flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
flatpak install --or-update --user --noninteractive flathub-beta org.freedesktop.Sdk.Extension.rust-stable//24.08beta org.freedesktop.Sdk.Extension.vala//24.08beta org.freedesktop.Sdk.Extension.llvm18//24.08beta
# org.freedesktop.Sdk.Extension.node18//24.08beta org.freedesktop.Sdk.Extension.typescript//24.08beta
flatpak remote-add --user --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
flatpak install --or-update --user --noninteractive gnome-nightly org.gnome.Sdk//master
npm install
make build
git submodule update --init
npm install --no-fund
@echo " ✅ You can use make stable or make devel to build Workbench"

build:
stable:
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.json

devel:
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json

build: devel

cli:
./troll/gjspack/bin/gjspack src/cli/main.js --appid=re.sonny.Workbench.cli --prefix=/re/sonny/Workbench --resource-root=src/ --no-executable flatpak/files/share/re.sonny.Workbench.cli/
cp src/cli/bin.js flatpak/files/bin/workbench-cli
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ Among other things, Workbench comes with

| | Formatter | Linter | Library demos[1] |
| ---------- | --------- | ------ | ---------------- |
| JavaScript ||| 100 |
| JavaScript ||| 99 |
| Python ||| 92 |
| Vala ||| 67 |
| Vala ||| 92 |
| Rust ||| 45 |
| Blueprint ||| |
| CSS ||| |

[1] As of 2024-04-28 <!--counted with `~/go/bin/scc demos/src`-->
[1] As of 2024-06-16 <!--counted with `~/go/bin/scc demos/src`-->

## Tips and tricks

Expand Down
2 changes: 1 addition & 1 deletion demos
22 changes: 11 additions & 11 deletions src/Library/EntryRow.blp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using Gtk 4.0;
using Adw 1;

template $EntryRow: Adw.PreferencesRow {
template $EntryRow: Adw.ActionRow {
activatable: true;

accessibility {
labelled-by: title_label;
described-by: description_label;
}

title: bind title_label.label;

[prefix]
Box contents {
orientation: horizontal;

Box labels_box {
margin-top: 6;
margin-start: 12;
margin-bottom: 6;
spacing: 3;
orientation: vertical;
Expand Down Expand Up @@ -43,13 +43,13 @@ template $EntryRow: Adw.PreferencesRow {
margin-top: 3;
}
}
}

Image {
icon-name: "go-next-symbolic";
margin-end: 12;
margin-start: 6;
hexpand: true;
halign: end;
}
[suffix]
Image {
icon-name: "go-next-symbolic";
margin-start: 6;
hexpand: true;
halign: end;
}
}
8 changes: 4 additions & 4 deletions src/Library/EntryRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import GObject from "gi://GObject";
import { getLanguage } from "../util.js";
import Template from "./EntryRow.blp" with { type: "uri" };

class EntryRow extends Adw.PreferencesRow {
class EntryRow extends Adw.ActionRow {
constructor({ demo, ...params } = {}) {
super(params);

Expand All @@ -22,7 +22,7 @@ class EntryRow extends Adw.PreferencesRow {
});

activate_action.connect("activate", () => {
this.emit("activated", null);
this.emit("triggered", null);
});
action_group.add_action(activate_action);

Expand All @@ -47,7 +47,7 @@ class EntryRow extends Adw.PreferencesRow {
});

button.connect("clicked", () => {
this.emit("activated", language);
this.emit("triggered", language);
});

return button;
Expand All @@ -68,7 +68,7 @@ export default GObject.registerClass(
),
},
Signals: {
activated: {
triggered: {
param_types: [GObject.TYPE_JSOBJECT],
},
},
Expand Down
120 changes: 71 additions & 49 deletions src/Library/Library.blp
Original file line number Diff line number Diff line change
@@ -1,75 +1,97 @@
using Gtk 4.0;
using Adw 1;

Adw.PreferencesWindow window {
Adw.Window window {
hide-on-close: true;
modal: false;
title: _("Workbench — Library");
default-height: 700;
default-width: 700;

Adw.PreferencesPage {
Adw.PreferencesGroup {
Picture picture_illustration {
can-shrink: false;
margin-bottom: 32;
}

Label {
label: _("Learn, Test, Remix");
Adw.ToolbarView toolbar_view {
[top]
Adw.HeaderBar header_bar {
title-widget: Adw.WindowTitle {
title: _("Workbench — Library");
};
}

styles [
"title-1"
]
content: Adw.PreferencesPage {
Adw.PreferencesGroup {
Box {
halign: center;
vexpand: false;

Picture picture_illustration {
can-shrink: false;
margin-bottom: 32;
}
}

Label {
label: _("Learn, Test, Remix");

styles [
"title-1"
]
}

SearchEntry search_entry {
search-delay: 100;
placeholder-text: _("Search demos");
activates-default: true;
width-request: 400;
margin-top: 32;
}
}
}

Adw.PreferencesGroup library_uncategorized {}
Adw.PreferencesGroup library_uncategorized {}

Adw.PreferencesGroup library_tools {
title: _("Tools");
}
Adw.PreferencesGroup library_tools {
title: _("Tools");
}

Adw.PreferencesGroup library_network {
title: _("Network");
}
Adw.PreferencesGroup library_network {
title: _("Network");
}

Adw.PreferencesGroup library_controls {
title: _("Controls");
}
Adw.PreferencesGroup library_controls {
title: _("Controls");
}

Adw.PreferencesGroup library_layout {
title: _("Layout");
}
Adw.PreferencesGroup library_layout {
title: _("Layout");
}

Adw.PreferencesGroup library_feedback {
title: _("Feedback");
}
Adw.PreferencesGroup library_feedback {
title: _("Feedback");
}

Adw.PreferencesGroup library_navigation {
title: _("Navigation");
}
Adw.PreferencesGroup library_navigation {
title: _("Navigation");
}

Adw.PreferencesGroup library_user_interface {
title: _("User Interface");
}
Adw.PreferencesGroup library_user_interface {
title: _("User Interface");
}

Adw.PreferencesGroup library_platform {
title: _("Platform APIs");
}
Adw.PreferencesGroup library_platform {
title: _("Platform APIs");
}

Adw.PreferencesGroup {
vexpand: true;
valign: end;
Adw.PreferencesGroup {
vexpand: true;
valign: end;

Label {
label: _('All examples are dedicated to the public domain\nand <b>can be used freely</b> under the terms of <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0 1.0</a>');
use-markup: true;
Label {
label: _("All examples are dedicated to the public domain\nand <b>can be used freely</b> under the terms of <a href=\"https://creativecommons.org/publicdomain/zero/1.0/\">CC0 1.0</a>");
use-markup: true;

styles [
"caption"
]
styles [
"caption"
]
}
}
}
};
}
}
41 changes: 30 additions & 11 deletions src/Library/Library.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,62 @@ import { build } from "../../troll/src/builder.js";

export default function Library({ application }) {
const objects = build(resource);
const { window, picture_illustration } = objects;
const { window, picture_illustration, search_entry } = objects;
window.application = application;
picture_illustration.set_resource(illustration);

if (__DEV__) {
window.add_css_class("devel");
}

let last_selected;
let last_triggered;

window.connect("close-request", quitOnLastWindowClose);

const demos = getDemos();
const widgets_map = new Map();
const category_map = new Map();
demos.forEach((demo) => {
const widget = new EntryRow({ demo: demo });
if (demo.name === "Welcome") last_selected = widget;
const entry_row = new EntryRow({ demo: demo });
if (demo.name === "Welcome") last_triggered = entry_row;

widget.connect("activated", (_self, language) => {
last_selected = widget;
entry_row.connect("triggered", (_self, language) => {
last_triggered = entry_row;

openDemo({
application,
demo_name: demo.name,
language,
}).catch(console.error);
});

objects[`library_${demo.category}`].add(widget);
if (!category_map.has(demo.category)) {
category_map.set(demo.category, objects[`library_${demo.category}`]);
}
objects[`library_${demo.category}`].add(entry_row);
widgets_map.set(demo.name, { entry_row, category: demo.category });
});

search_entry.connect("search-changed", () => {
const search_term = search_entry.get_text().toLowerCase();
const visible_categories = new Set();

widgets_map.forEach(({ entry_row, category }, demo_name) => {
const is_match = demo_name.toLowerCase().includes(search_term);
entry_row.visible = is_match;
if (is_match) visible_categories.add(category);
});

category_map.forEach((category_widget, category_name) => {
category_widget.visible = visible_categories.has(category_name);
});
});
const action_library = new Gio.SimpleAction({
name: "library",
parameter_type: null,
});
action_library.connect("activate", () => {
window.present();
last_selected?.grab_focus();
last_triggered?.grab_focus();
});
application.add_action(action_library);
application.set_accels_for_action("app.library", ["<Control><Shift>O"]);
Expand Down Expand Up @@ -86,9 +105,9 @@ async function openDemo({ application, demo_name, language }) {
session.settings.set_int("code-language", language.index);
global_settings.set_int("recent-code-language", language.index);

// If the user explictely requested to open the demo
// If the user explicitly requested to open the demo
// in a specific language then that's probably what they are interested in
// therefor override the demo default and force show the code panel
// therefore override the demo default and force show the code panel
session.settings.set_boolean("show-code", true);
}

Expand Down

0 comments on commit 6aad42a

Please sign in to comment.