Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* @sonnyp
/src/langs/javascript/ @sonnyp
*.js @sonnyp

/src/langs/vala/ @lw64
*.vala @lw64
Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,3 @@ __pycache__

# IDEs / editors
.idea

# Project files - sync with Makefile
src/Library/**/settings
src/Library/**/workbench.vala
src/Library/**/main.ui
src/Library/**/libworkbenchcode.so
src/Library/**/__pycache__
2 changes: 1 addition & 1 deletion data/app.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name translatable="no">Workbench</name>
<!-- developer_name tag deprecated with Appstream 1.0 -->
<developer_name translatable="no">Sonny Piers</developer_name>
<developer id="gitlab.com">
<developer>
<name translatable="no">Sonny Piers</name>
</developer>
<update_contact>sonnyp@gnome.org</update_contact>
Expand Down
8 changes: 7 additions & 1 deletion src/langs/rust/Compiler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import Gio from "gi://Gio";
import GLib from "gi://GLib";
import dbus_previewer from "../../Previewer/DBusPreviewer.js";
import { decode, encode } from "../../util.js";
import { copyDirectory, decode, encode } from "../../util.js";

const rust_template_dir = Gio.File.new_for_path(
pkg.pkgdatadir,
).resolve_relative_path("langs/rust/template");

export default function Compiler({ session }) {
const { file } = session;
Expand All @@ -15,6 +19,8 @@ export default function Compiler({ session }) {
let savedRustcVersion;

async function compile() {
copyDirectory(rust_template_dir, file);

rustcVersion ||= await getRustcVersion();
savedRustcVersion ||= await getSavedRustcVersion({ rustcVersionFile });

Expand Down
21 changes: 1 addition & 20 deletions src/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
ensureDir,
getNowForFilename,
demos_dir,
rust_template_dir,
settings as global_settings,
encode,
languages,
settings,
copyDirectory,
} from "./util.js";

export const sessions_dir = data_dir.get_child("sessions");
Expand Down Expand Up @@ -64,7 +64,6 @@ export function createSessionFromDemo(demo) {

const { file, settings } = session;
copyDirectory(demo_dir, file);
copyDirectory(rust_template_dir, file);

settings.set_string("name", name);
settings.set_boolean("show-code", panels.includes("code"));
Expand All @@ -79,24 +78,6 @@ export function createSessionFromDemo(demo) {
return session;
}

// There is no copy directory function
function copyDirectory(source, destination) {
for (const file_info of source.enumerate_children(
"",
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
null,
)) {
if (file_info.get_file_type() === Gio.FileType.DIRECTORY) continue;
const child = source.get_child(file_info.get_name());
child.copy(
destination.get_child(child.get_basename()),
Gio.FileCopyFlags.NONE,
null,
null,
);
}
}

export async function deleteSession(session) {
// There is no method to recursively delete a folder so we trash instead
// https://github.com/flatpak/xdg-desktop-portal/issues/630 :/
Expand Down
27 changes: 24 additions & 3 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,30 @@ export const demos_dir = Gio.File.new_for_path(
pkg.pkgdatadir,
).resolve_relative_path("demos");

export const rust_template_dir = Gio.File.new_for_path(
pkg.pkgdatadir,
).resolve_relative_path("langs/rust/template");
// There is no copy directory function
export function copyDirectory(source, destination) {
for (const file_info of source.enumerate_children(
"",
Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,
null,
)) {
if (file_info.get_file_type() === Gio.FileType.DIRECTORY) continue;
const child = source.get_child(file_info.get_name());

try {
child.copy(
destination.get_child(child.get_basename()),
Gio.FileCopyFlags.NONE,
null,
null,
);
} catch (err) {
if (!err.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS)) {
throw err;
}
}
}
}

export function getNowForFilename() {
return new GLib.DateTime().format("%Y-%m-%d %H-%M-%S");
Expand Down