Skip to content

Commit

Permalink
prefs.js: don't show 'Adaptive' option for Gnome < 3.26.
Browse files Browse the repository at this point in the history
  • Loading branch information
franglais125 committed Sep 21, 2017
1 parent b8ce545 commit 1421b49
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
const Config = imports.misc.config;

// Use __ () and N__() for the extension gettext domain, and reuse
// the shell domain with the default _() and N_()
Expand Down Expand Up @@ -73,6 +74,42 @@ function setShortcut(settings) {
}
}

/** Compare two dotted version strings (like '10.2.3').
* @returns {Integer} 0: v1 == v2, -1: v1 < v2, 1: v1 > v2
* Copied from https://github.com/paradoxxxzero/gnome-shell-system-monitor-applet/, compat.js.
*/
function versionCompare(v1, v2) {
let v1parts = ('' + v1).split('.')
let v2parts = ('' + v2).split('.')
let minLength = Math.min(v1parts.length, v2parts.length)
let p1, p2;
// Compare tuple pair-by-pair.
for (let i = 0; i < minLength; i++) {
// Convert to integer if possible, because "8" > "10".
p1 = parseInt(v1parts[i], 10);
p2 = parseInt(v2parts[i], 10);

if (isNaN(p1))
p1 = v1parts[i];
if (isNaN(p2))
p2 = v2parts[i];

if (p1 === p2)
continue;
else if (p1 > p2)
return 1;
else if (p1 < p2)
return -1;

// one operand is NaN
return NaN;
}
// The longer tuple is always considered 'greater'
if (v1parts.length === v2parts.length)
return 0;
return (v1parts.length < v2parts.length) ? -1 : 1;
}

const Settings = new Lang.Class({
Name: 'DashToDock.Settings',

Expand Down Expand Up @@ -628,6 +665,10 @@ const Settings = new Lang.Class({
}
}));

// We need to hide the 'Adaptive' option for < Gnome 3.26
if (versionCompare(Config.PACKAGE_VERSION, '3.26') === -1)
this._builder.get_object('customize_opacity_combo').remove(2);

// Create dialog for transparency advanced settings
this._builder.get_object('dynamic_opacity_button').connect('clicked', Lang.bind(this, function() {

Expand Down

0 comments on commit 1421b49

Please sign in to comment.