Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[horizontal-osd@berk-karaal] v0.0.3 - Improves compatibility with Cinnamon 6.4 #791

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,48 @@ const Tweener = imports.ui.tweener;
const Gio = imports.gi.Gio;
const Gdk = imports.gi.Gdk;
const Meta = imports.gi.Meta;
const GLib = imports.gi.GLib;

const CINNAMON_VERSION = GLib.getenv('CINNAMON_VERSION');

const LEVEL_ANIMATION_TIME = 0.1;
const FADE_TIME = 0.1;
let HIDE_TIMEOUT = 1500;

function version_exceeds(version, min_version) {
let our_version = version.split(".");
let cmp_version = min_version.split(".");
let i;

for (i = 0; i < our_version.length && i < cmp_version.length; i++) {
let our_part = parseInt(our_version[i]);
let cmp_part = parseInt(cmp_version[i]);

if (isNaN(our_part) || isNaN(cmp_part)) {
return false;
}

if (our_part < cmp_part) {
return false;
} else
if (our_part > cmp_part) {
return true;
}
}

if (our_version.length < cmp_version.length) {
return false;
} else {
return true;
}
}

// Removal of the percentage in the Cinnamon media OSD, from Cinnamon 6.4.
// See https://github.com/linuxmint/mint22.1-beta/issues/4#issuecomment-2535973291
let PERCENT_SYMBOL = " %";
if (version_exceeds(CINNAMON_VERSION, "6.4"))
PERCENT_SYMBOL = "";

const OSD_SIZE = 110;

let extension_settings = null;
Expand Down Expand Up @@ -139,7 +176,7 @@ OsdWindow.prototype = {

setLevel: function (level) {
if (level != undefined) {
this._label.set_text(String(level) + " %");
this._label.set_text(""+ level + PERCENT_SYMBOL);
this._label.visible = this._level.actor.visible = true;

if (this.actor.visible)
Expand Down Expand Up @@ -316,23 +353,31 @@ OsdWindow.prototype = {
},

_onOsdSettingsChanged: function () {
let currentSize = this._osdSettings.get_string("show-media-keys-osd");

switch (currentSize) {
case "disabled":
this._osdBaseSize = null;
break;
case "small":
this._sizeMultiplier = 0.7;
this._osdBaseSize = Math.floor(OSD_SIZE * this._sizeMultiplier);
break;
case "large":
this._sizeMultiplier = 1.0;
this._osdBaseSize = OSD_SIZE;
break;
default:
let currentSize = this._osdSettings.get_value("show-media-keys-osd");
if (typeof(currentSize) == "boolean") { // Cinnamon 6+
if (currentSize) {
this._sizeMultiplier = 0.85;
this._osdBaseSize = Math.floor(OSD_SIZE * this._sizeMultiplier);
} else {
this._osdBaseSize = null;
}
} else {
switch (currentSize) {
case "disabled":
this._osdBaseSize = null;
break;
case "small":
this._sizeMultiplier = 0.7;
this._osdBaseSize = Math.floor(OSD_SIZE * this._sizeMultiplier);
break;
case "large":
this._sizeMultiplier = 1.0;
this._osdBaseSize = OSD_SIZE;
break;
default:
this._sizeMultiplier = 0.85;
this._osdBaseSize = Math.floor(OSD_SIZE * this._sizeMultiplier);
}
}

this._monitorsChanged();
Expand Down Expand Up @@ -402,4 +447,4 @@ OsdWindowManager.prototype = {
for (let i = 0; i < this._osdWindows.length; i++)
this._osdWindows[i].cancel();
}
};
};
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"uuid": "horizontal-osd@berk-karaal",
"name": "Horizontal OSD",
"author": "Berk Karaal",
"version": "0.0.2",
"author": "berk-karaal",
"version": "0.0.3",
"description": "Horizontal and customizable OSDs",
"url": "https://github.com/berk-karaal/cinnamon-horizontal-osd",
"website": "https://github.com/berk-karaal/cinnamon-horizontal-osd",
"cinnamon-version": [
"5.2",
"5.4"
]
}
}
Loading