Skip to content

Commit

Permalink
prepared for release, bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
MattByName committed Dec 6, 2023
1 parent 7edcdb3 commit 7810b7c
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 103 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ settings.json
*.zip
bin/
tmp/
*.log
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
- New overlay code to fix [Issue 20](https://github.com/MattByName/color-tint/issues/20)
- No longer shipping compiled schemas, once Gnome 44 becomes oldest supported release

## 2.3.2

### Fixed

- GNOME 45 support

## 2.3.1

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ install: build
# Uncomment below line once Gnome 44 is oldest supported version
# glib-compile-schemas $(INSTALL_DIR)/schemas/
.PHONY:install

test: install
./nested-session.sh
.PHONY:install
# end
59 changes: 38 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,60 @@

## About

ColorTint is a Gnome extension that draws a translucent coloured overlay over your desktop. This is to help people with dyslexia, visual stress, scopic sensitivity, and related conditions.
ColorTint is a Gnome extension that draws a translucent coloured overlay over your desktop. This is
to help people with dyslexia, visual stress, scopic sensitivity, and related conditions.

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/E1E1CFXTK)

### Links

- [GitHub Repository](https://github.com/MattByName/color-tint)
- [Gnome Extensions Page](https://extensions.gnome.org/extension/1789/colortint/)

- [GNOME Extensions Page](https://extensions.gnome.org/extension/1789/colortint/)
- [GitHub Releases](https://github.com/MattByName/color-tint/releases)

## Installation

The easiest way to install is using the Gnome Extensions website. You can find ColorTint [here](https://extensions.gnome.org/extension/1789/colortint/)
The easiest way to install is using the Gnome Extensions website. You can find ColorTint
[here](https://extensions.gnome.org/extension/1789/colortint/)

You can also install ColorTint manually by downloading the [latest release](https://github.com/MattByName/color-tint/releases) and unzipping it into the Gnome extensions folder on your desktop. You can find a guide on how to do that [here](https://www.ubuntubuzz.com/2017/11/how-to-install-manually-gnome-shell-extension.html). You can also clone this repository and use the terminal command `make install` from the repo root directory.
You can also install ColorTint manually by downloading the [latest
release](https://github.com/MattByName/color-tint/releases) and unzipping it into the Gnome
extensions folder on your desktop. You can find a guide on how to do that
[here](https://www.ubuntubuzz.com/2017/11/how-to-install-manually-gnome-shell-extension.html). You
can also clone this repository and use the terminal command `make install` from the repo root
directory.

## Support for GNOME versions

I attempt to maintain backwards compatibility, but if an upgrade breaks support for a release that has reached end of
life, I will update the table below to show which version of ColorTint was last verified to work with it.

| GNOME Version | ColorTint Version | GNOME Extensions Site Version |
| :------------ | :--------------------------------------------------------------------- | :---------------------------- |
| 44 | [latest](https://github.com/MattByName/color-tint/releases/latest) | 19 |
| 43 | [latest](https://github.com/MattByName/color-tint/releases/latest) | 19 |
| 42 | [latest](https://github.com/MattByName/color-tint/releases/latest) | 19 |
| 41 | [v2.2.2](https://github.com/MattByName/color-tint/releases/tag/v2.2.2) | 14 |
| 40 | [v2.2.2](https://github.com/MattByName/color-tint/releases/tag/v2.2.2) | 14 |
| 3.38 | [v2.2.2](https://github.com/MattByName/color-tint/releases/tag/v2.2.2) | 14 |
| 3.36 | [v2.2.2](https://github.com/MattByName/color-tint/releases/tag/v2.2.2) | 14 |
| 3.34 | [v1.1.1](https://github.com/MattByName/color-tint/releases/tag/v1.1.1) | 4 |
| 3.32 | [v1.1.1](https://github.com/MattByName/color-tint/releases/tag/v1.1.1) | 4 |
I attempt to maintain backwards compatibility, but if an upgrade breaks support for a release that
has reached end of life, I will update the table below to show which version of ColorTint was last
verified to work with it.

The version of this table in the package available through the GNOME Extensions website will be
slightly out of date compared to github.

| GNOME Releases | ColorTint Releases | Extension Site version |
| :------------- | :--------------------------------------------------------------------- | :--------------------- |
| 45 | [latest](https://github.com/MattByName/color-tint/releases/latest) | TBC |
| 44 | [v2.3.1](https://github.com/MattByName/color-tint/releases/tag/v2.3.1) | 19 |
| 43 | [v2.3.1](https://github.com/MattByName/color-tint/releases/tag/v2.3.1) | 19 |
| 42 | [v2.3.1](https://github.com/MattByName/color-tint/releases/tag/v2.3.1) | 19 |
| 41 | [v2.2.2](https://github.com/MattByName/color-tint/releases/tag/v2.2.2) | 14 |
| 40 | [v2.2.2](https://github.com/MattByName/color-tint/releases/tag/v2.2.2) | 14 |
| 3.38 | [v2.2.2](https://github.com/MattByName/color-tint/releases/tag/v2.2.2) | 14 |
| 3.36 | [v2.2.2](https://github.com/MattByName/color-tint/releases/tag/v2.2.2) | 14 |
| 3.34 | [v1.1.1](https://github.com/MattByName/color-tint/releases/tag/v1.1.1) | 4 |
| 3.32 | [v1.1.1](https://github.com/MattByName/color-tint/releases/tag/v1.1.1) | 4 |

## Features

- Set any colour using RGB sliders
- Custom translucency through alpha slider
- ColorTint remembers your chosen color, automatically saving it when you change it, and loading on launch
- The tint is on by default. Click the colortint icon and toggle "Tint" to enable. Go to settings in the Gnome Extensions app to change the default behaviour
- ColorTint remembers your chosen color, automatically saving it when you change it, and loading on
launch
- The tint is on by default. Click the colortint icon and toggle "Tint" to enable. Go to settings in
the Gnome Extensions app to change the default behaviour
- Supports multiple monitor setup

## Contributing
Expand All @@ -51,4 +66,6 @@ Please do contribute if you want to change something or help out with one of the

## Support, Feature Requests and Bug Reports

Please [raise an issue](https://github.com/MattByName/color-tint/issues/new) or raise a pull request. Alternatively, you can contact me via matrix at [@mattbyname:matrix.org](https://matrix.to/#/@mattbyname:matrix.org)
Please [raise an issue](https://github.com/MattByName/color-tint/issues/new) or raise a pull
request. Alternatively, you can contact me via matrix at
[@mattbyname:matrix.org](https://matrix.to/#/@mattbyname:matrix.org)
7 changes: 7 additions & 0 deletions nested-session.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#!/bin/sh -e

export G_MESSAGES_DEBUG=all
export MUTTER_DEBUG_DUMMY_MODE_SPECS=1366x768
export SHELL_DEBUG=backtrace-segfaults
dbus-run-session -- gnome-shell --nested --wayland > nested.log
63 changes: 20 additions & 43 deletions src/extension.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,45 @@
import * as St from "gi://St";
import * as Clutter from "gi://Clutter";
import * as Gio from "gi://Gio";
import * as GObject from "gi://GObject";
import St from "gi://St";
import Clutter from "gi://Clutter";
import Gio from "gi://Gio";
import GObject from "gi://GObject";
import * as Main from "resource:///org/gnome/shell/ui/main.js";
import * as PopupMenu from "resource:///org/gnome/shell/ui/popupMenu.js";
import * as PanelMenu from "resource:///org/gnome/shell/ui/panelMenu.js";
import * as Slider from "resource:///org/gnome/shell/ui/slider.js";

import { Extension } from "resource:///org/gnome/shell/extensions/extension.js";
let overlay_active = false;
let menu = null;
let overlay = null;

let settings = null;
let metadata = null;
let tinter = null;
let overlay_color = {
red: 20,
green: 20,
blue: 20,
alpha: 80,
};
import { Extension } from "resource:///org/gnome/shell/extensions/extension.js";
export default class ColorTinter extends Extension {
/**
* This class is constructed once when your extension is loaded, not
* enabled. This is a good time to setup translations or anything else you
* only do once.
*
* You MUST NOT make any changes to GNOME Shell, connect any signals or add
* any event sources here.
*
* @param {ExtensionMeta} metadata - An extension meta object
*/
constructor(metadata) {
super(metadata);

console.debug(`constructing ${this.metadata.name}`);
}

/**
* This function is called when your extension is enabled, which could be
* done in GNOME Extensions, when you log in or when the screen is unlocked.
*
* This is when you should setup any UI for your extension, change existing
* widgets, connect signals or modify GNOME Shell's behavior.
*/
enable() {
console.debug(`enabling ${this.metadata.name}`);
tinter = this;
settings = this.getSettings();
metadata = this.metadata;
this.start_up();
menu = new MenuButton();
Main.panel.addToStatusArea("Tint", menu, 0, "right");
this._settings = this.getSettings();
}

/**
* This function is called when your extension is uninstalled, disabled in
* GNOME Extensions or when the screen locks.
*
* Anything you created, modified or setup in enable() MUST be undone here.
* Not doing so is the most common reason extensions are rejected in review!
*/
disable() {
console.debug(`disabling ${this.metadata.name}`);
this.stop_now();
menu.destroy();
menu = null;
this._settings = null;
settings = null;
metadata = null;
tinter = null;
}

createOverlay() {
Expand Down Expand Up @@ -112,7 +89,7 @@ export default class ColorTinter extends Extension {
loadColor() {
// Load last from json

this._file = Gio.file_new_for_path(`${this.metadata.path}/settings.json`);
this._file = Gio.file_new_for_path(`${metadata.path}/settings.json`);
if (this._file.query_exists(null)) {
var flag;
var data;
Expand All @@ -131,7 +108,7 @@ export default class ColorTinter extends Extension {

// Save Color
saveColor() {
this._file = Gio.file_new_for_path(`${this.metadata.path}/settings.json`);
this._file = Gio.file_new_for_path(`${metadata.path}/settings.json`);
this._file.replace_contents(
JSON.stringify(overlay_color),
null,
Expand All @@ -145,7 +122,7 @@ export default class ColorTinter extends Extension {
overlay_active = false;
this.loadColor();
this.createOverlay();
if (this._settings.get_boolean("autostart")) this.show();
if (settings.get_boolean("autostart")) this.show();
}

stop_now() {
Expand All @@ -170,11 +147,11 @@ const MenuButton = GObject.registerClass(

// We add the icon
let iconName = "";
if (this._settings.get_boolean("monochrome-icon"))
iconName = "icon_mono.svg";

if (settings.get_boolean("monochrome-icon")) iconName = "icon_mono.svg";
else iconName = "icon.svg";

icon.gicon = Gio.icon_new_for_string(`${this.metadata.path}/${iconName}`);
icon.gicon = Gio.icon_new_for_string(`${metadata.path}/${iconName}`);
icon.set_icon_size(20);
box.add(icon);

Expand Down
71 changes: 32 additions & 39 deletions src/prefs.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,63 @@
'use strict';

const {Adw, Gio, Gtk} = imports.gi;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();


/**
*
*/
function init() {
}

/**
*
* @param window
*/
function fillPreferencesWindow(window) {
// Use the same GSettings schema as in `extension.js`
const settings = ExtensionUtils.getSettings(
'org.gnome.shell.extensions.colortint');

import Gio from "gi://Gio";
import Adw from "gi://Adw";
import Gtk from "gi://Gtk";

import {
ExtensionPreferences,
gettext as _,
} from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";

export default class ColorTintPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
window._settings = this.getSettings("org.gnome.shell.extensions.colortint");
// Create a preferences page and group
const page = new Adw.PreferencesPage();
const group = new Adw.PreferencesGroup();
page.add(group);

// Create a new preferences row
const row = new Adw.ActionRow({title: 'Overlay active on start'});
const row = new Adw.ActionRow({ title: "Overlay active on start" });
group.add(row);

// Create the switch and bind its value to the `autostart` key
const toggle = new Gtk.Switch({
active: settings.get_boolean('autostart'),
valign: Gtk.Align.CENTER,
active: window._settings.get_boolean("autostart"),
valign: Gtk.Align.CENTER,
});
settings.bind(
'autostart',
toggle,
'active',
Gio.SettingsBindFlags.DEFAULT
window._settings.bind(
"autostart",
toggle,
"active",
Gio.SettingsBindFlags.DEFAULT
);

// Add the switch to the row
row.add_suffix(toggle);
row.activatable_widget = toggle;

// Create a new preferences row
const row2 = new Adw.ActionRow({title: 'Use monochrome system tray icon', subtitle: 'Changes take effect on restart of extension'});
const row2 = new Adw.ActionRow({
title: "Use monochrome system tray icon",
subtitle: "Changes take effect on restart of extension",
});
group.add(row2);

// Create the switch and bind its value to the `monochrome` key
const toggle2 = new Gtk.Switch({
active: settings.get_boolean('monochrome-icon'),
valign: Gtk.Align.CENTER,
active: window._settings.get_boolean("monochrome-icon"),
valign: Gtk.Align.CENTER,
});
settings.bind(
'monochrome-icon',
toggle2,
'active',
Gio.SettingsBindFlags.DEFAULT
window._settings.bind(
"monochrome-icon",
toggle2,
"active",
Gio.SettingsBindFlags.DEFAULT
);

// Add the switch to the row
row2.add_suffix(toggle2);
row2.activatable_widget = toggle2;
// Add our page to the window
window.add(page);
}
}

0 comments on commit 7810b7c

Please sign in to comment.