Skip to content

Commit

Permalink
Merge pull request #36 from Jomik/polish-settings-widget
Browse files Browse the repository at this point in the history
Polish settings widget
  • Loading branch information
swsnr authored Oct 3, 2020
2 parents 7a765a2 + 553fb41 commit 9ec3cf7
Show file tree
Hide file tree
Showing 18 changed files with 850 additions and 201 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
sudo apt-get install --no-install-recommends -qq -y libglib2.0-bin gnome-shell
- run: yarn install
- run: yarn compile
- run: yarn compile:schemas
- run: yarn lint --max-warnings 0
- run: yarn format --check
- run: yarn package
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Node libraries
/node_modules/

# Compiled JS extension
/extension.js
# Compiled JS files
*.js

# Compiled schema file
/schemas/*.compiled
Expand Down
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2017 Jonas Damtoft
Copyright (c) 2017-2020 Jonas Damtoft
Copyright (c) 2019-2020 Sebastian Wiesner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/parser": "^4.1.1",
"concurrently": "^5.3.0",
"eslint": "^7.9.0",
"eslint-plugin-immutable": "^1.0.0",
"prettier": "^2.1.2",
"typescript": "^4.0.3"
},
"scripts": {
"lint": "eslint *.ts prefs.js",
"compile": "tsc",
"lint": "eslint *.ts",
"compile:prefs": "tsc --build tsconfig.prefs.json",
"compile:extension": "tsc --build tsconfig.extension.json",
"compile:schemas": "glib-compile-schemas --strict schemas/",
"format": "prettier *.ts *.json prefs.js .eslintrc.json",
"package": "gnome-extensions pack --extra-source utils.js --extra-source prefs.xml",
"compile": "concurrently yarn:compile:prefs yarn:compile:extension yarn:compile:schemas",
"format": "prettier **/*.ts *.json .eslintrc.json",
"package": "gnome-extensions pack --extra-source prefs.xml --extra-source LICENSE",
"nested": "dbus-run-session -- gnome-shell --nested --wayland"
}
}
45 changes: 30 additions & 15 deletions prefs.js → prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,55 @@
// top-level, because typescript considers all files as single project with one
// common top scope. Hence we can't redefine imports, etc.

const Gtk = imports.gi.Gtk;
const Gio = imports.gi.Gio;
import ByteArray = imports.byteArray;
import Gtk = imports.gi.Gtk;
import Gio = imports.gi.Gio;

const ExtensionUtils = imports.misc.extensionUtils;
const Self = ExtensionUtils.getCurrentExtension();
import ExtensionUtils = imports.misc.extensionUtils;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const Self = ExtensionUtils.getCurrentExtension()!;

// eslint-disable-next-line no-unused-vars
function init() {}
// eslint-disable-next-line @typescript-eslint/no-unused-vars,@typescript-eslint/no-empty-function
function init(): void {}

// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function buildPrefsWidget() {
const ui = Self.dir.get_child("prefs.xml").get_path();
if (!ui) {
throw new Error("Fatal error, failed to find prefs.xml");
}
const buildable = Gtk.Builder.new_from_file(ui);
const box = buildable.get_object<Gtk.Widget>("prefs_widget");

const settings = ExtensionUtils.getSettings();
const buildable = new Gtk.Builder();
buildable.add_from_file(Self.dir.get_child("prefs.xml").get_path());
const box = buildable.get_object("prefs_widget");
const license = ByteArray.toString(
Self.dir.get_child("LICENSE").load_contents(null)[1]
);
const about_license_buffer = buildable.get_object<Gtk.TextBuffer>(
"about_license_buffer"
);
about_license_buffer.set_text(license, -1);

const version_label = buildable.get_object("version_info");
version_label.set_text(`[VSCode-Search-Provider v${Self.metadata.version}]`);
const about_version_label = buildable.get_object<Gtk.Label>(
"about_version_label"
);
about_version_label.set_text(`Version ${Self.metadata.version}`);

settings.bind(
"show-workspaces",
buildable.get_object("field_workspaces"),
buildable.get_object("show_workspaces_switch"),
"active",
Gio.SettingsBindFlags.DEFAULT
);
settings.bind(
"show-files",
buildable.get_object("field_files"),
buildable.get_object("show_files_switch"),
"active",
Gio.SettingsBindFlags.DEFAULT
);
settings.bind(
"search-prefix",
buildable.get_object("search_prefix"),
buildable.get_object("search_prefix_entry"),
"text",
Gio.SettingsBindFlags.DEFAULT
);
Expand Down
Loading

0 comments on commit 9ec3cf7

Please sign in to comment.