initial commit

This commit is contained in:
2022-01-12 14:55:33 -03:00
commit c968bf909f
330 changed files with 61257 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
const Meta = imports.gi.Meta;
const Main = imports.ui.main;
const Shell = imports.gi.Shell;
const SHORTCUT_KEY = 'shortcut-key';
let settings = imports.misc.extensionUtils.getSettings();
var currentWorkspace = -1;
var lastWorkspace = -1;
function goToLastWorkspace() {
if (lastWorkspace < 0) {
return;
}
// keep global.screen for backwards compatibility
let ws = (global.screen || global.workspace_manager).get_workspace_by_index(lastWorkspace);
ws.activate(global.get_current_time());
}
function init() {
}
let signals = [];
function enable() {
var ModeType = Shell.hasOwnProperty('ActionMode') ? Shell.ActionMode : Shell.KeyBindingMode;
Main.wm.addKeybinding(SHORTCUT_KEY, settings, Meta.KeyBindingFlags.NONE, ModeType.NORMAL | ModeType.OVERVIEW, goToLastWorkspace);
signals.push((global.screen || global.workspace_manager).connect('workspace-switched', function(display, prev, current, direction) {
lastWorkspace = currentWorkspace;
currentWorkspace = current;
}));
}
function disable() {
// clean up
Main.wm.removeKeybinding(SHORTCUT_KEY);
let i = signals.length;
while (i--) {
(global.screen || global.workspace_manager).disconnect(signals.pop());
}
}

View File

@@ -0,0 +1,18 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"description": "Quickly toggle between two workspaces with one key",
"name": "Go To Last Workspace",
"settings-schema": "org.gnome.shell.extensions.go-to-last-workspace",
"shell-version": [
"3.28",
"3.30",
"3.34",
"3.32",
"3.36",
"3.38",
"40"
],
"url": "https://github.com/arjan/gnome-shell-go-to-last-workspace",
"uuid": "gnome-shell-go-to-last-workspace@github.com",
"version": 7
}

View File

@@ -0,0 +1,82 @@
// Library imports
const GObject = imports.gi.GObject;
const Gdk = imports.gi.Gdk;
const Gtk = imports.gi.Gtk;
const ExtensionUtils = imports.misc.extensionUtils;
// Globals
const pretty_names = {
"shortcut-key": "Go to last workspace",
};
function init() {}
function buildPrefsWidget() {
let model = new Gtk.ListStore();
model.set_column_types([
GObject.TYPE_STRING,
GObject.TYPE_STRING,
GObject.TYPE_INT,
GObject.TYPE_INT,
]);
let settings = ExtensionUtils.getSettings();
for (key in pretty_names) {
append_hotkey(model, settings, key, pretty_names[key]);
}
let treeview = new Gtk.TreeView({
model: model,
});
let col;
let cellrend;
cellrend = new Gtk.CellRendererText();
col = new Gtk.TreeViewColumn({
title: "Keybinding",
});
col.pack_start(cellrend, true);
col.add_attribute(cellrend, "text", 1);
treeview.append_column(col);
cellrend = new Gtk.CellRendererAccel({
editable: true,
"accel-mode": Gtk.CellRendererAccelMode.GTK,
});
cellrend.connect("accel-edited", function (rend, iter, key, mods) {
let value = Gtk.accelerator_name(key, mods);
log("change");
log(value);
log(key);
log(mods);
let [success, iter1] = model.get_iter_from_string(iter);
if (!success) {
throw new Error("Something be broken, yo.");
}
let name = model.get_value(iter1, 0);
model.set(iter1, [2, 3], [mods, key]);
settings.set_strv(name, [value]);
});
col = new Gtk.TreeViewColumn({
title: "Accel",
});
col.pack_end(cellrend, false);
col.add_attribute(cellrend, "accel-mods", 2);
col.add_attribute(cellrend, "accel-key", 3);
treeview.append_column(col);
treeview.expand_all();
return treeview;
}
function append_hotkey(model, settings, name, pretty_name) {
let [_something, key, mods] = Gtk.accelerator_parse(
settings.get_strv(name)[0]
);
let row = model.insert(-1);
model.set(row, [0, 1, 2, 3], [name, pretty_name, mods, key]);
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="gnome-shell-extensions">
<schema path="/org/gnome/shell/extensions/go-to-last-workspace/" id="org.gnome.shell.extensions.go-to-last-workspace">
<key name="shortcut-key" type="as">
<default><![CDATA[['<Super>escape']]]></default>
<summary>Keybinding switch to last workspace</summary>
<description>
The keybinding used to switch to the last used workspace.
</description>
</key>
</schema>
</schemalist>

View File

@@ -0,0 +1,46 @@
const Gio = imports.gi.Gio;
const Config = imports.misc.config;
const ExtensionUtils = imports.misc.extensionUtils;
/**
* getSettings:
* @schema: (optional): the GSettings schema id
*
* Builds and return a GSettings schema for @schema, using schema files
* in extensionsdir/schemas. If @schema is not provided, it is taken from
* metadata['settings-schema'].
*/
function getSettings(schema) {
let extension = ExtensionUtils.getCurrentExtension();
schema = schema || extension.metadata["settings-schema"];
const GioSSS = Gio.SettingsSchemaSource;
// check if this extension was built with "make zip-file", and thus
// has the schema files in a subfolder
// otherwise assume that extension has been installed in the
// same prefix as gnome-shell (and therefore schemas are available
// in the standard folders)
let schemaDir = extension.dir.get_child("schemas");
let schemaSource;
if (schemaDir.query_exists(null))
schemaSource = GioSSS.new_from_directory(
schemaDir.get_path(),
GioSSS.get_default(),
false
);
else schemaSource = GioSSS.get_default();
let schemaObj = schemaSource.lookup(schema, true);
if (!schemaObj)
throw new Error(
"Schema " +
schema +
" could not be found for extension " +
extension.metadata.uuid +
". Please check your installation."
);
return new Gio.Settings({ settings_schema: schemaObj });
}