Skip to content

Commit

Permalink
Merge branch 'release/version-27'
Browse files Browse the repository at this point in the history
  • Loading branch information
BigE committed Apr 15, 2018
2 parents 8e09498 + 7b085a2 commit e0cdf06
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [email protected]/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const DBusInterface = '<node>\
</node>';
const DBusProxy = Gio.DBusProxy.makeProxyWrapper(DBusInterface);

const DeskChangerDaemon = new Lang.Class({
var DeskChangerDaemon = new Lang.Class({
Name: 'DeskChangerDaemon',

_init: function (settings) {
Expand Down
9 changes: 6 additions & 3 deletions [email protected]/deskchanger/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import random
from . import logger

ACCEPTED = ['application/xml', 'image/jpeg', 'image/png']
MAX_QUEUE_LENGTH = 100


Expand Down Expand Up @@ -35,6 +34,7 @@ def __init__(self, name):
self._wallpapers = []
self._settings = Gio.Settings.new('org.gnome.shell.extensions.desk-changer')
self._handler_profiles = self._settings.connect('changed::profiles', self._changed_profile)
self._handler_mime_types = self._settings.connect('changed::allowed-mime-types', self._changed_profile)
self._handler_random = self._settings.connect('changed::random', self._changed_random)
logger.debug('successfully created %s', self)

Expand All @@ -47,6 +47,7 @@ def destroy(self):
"""
self._remove_monitors()
self._settings.disconnect(self._handler_profiles)
self._settings.disconnect(self._handler_mime_types)
self._settings.disconnect(self._handler_random)
del self._settings

Expand Down Expand Up @@ -120,9 +121,11 @@ def save_state(self):
logger.info('saving state of %s is disabled while type %s', self.name, self)

def _changed_profile(self, obj, key):
if self._hash == sha256(str(self._settings.get_value(key).unpack().get(self.name)).encode('utf-8')):
if key == 'current-profile' and self._hash == sha256(str(self._settings.get_value('current-profile').unpack().get(self.name)).encode('utf-8')):
logger.info('not reloading profile, hashes match')
return
elif key == 'allowed-mime-types':
logger.info('reloading profile since mime types changed')
self.load()

def _changed_random(self, obj, key):
Expand Down Expand Up @@ -211,7 +214,7 @@ def _load_uri(self, uri, recursive, top_level=False):
self._monitors.append(monitor)
logger.debug('descending into %s to find wallpapers', location.get_uri())
self._load_children(location, recursive)
elif info.get_file_type() == Gio.FileType.REGULAR and info.get_content_type() in ACCEPTED:
elif info.get_file_type() == Gio.FileType.REGULAR and info.get_content_type() in self._settings.get_value('allowed-mime-types'):
logger.debug('adding wallpaper %s', location.get_uri())
if location.get_uri() in self._wallpapers:
logger.warning('%s already loaded, skipping duplicate', location.get_uri())
Expand Down
26 changes: 13 additions & 13 deletions [email protected]/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const debug = Me.imports.utils.debug;
const error = Me.imports.utils.error;
const Ui = Me.imports.ui;

const DeskChangerControls = new Lang.Class({
var DeskChangerControls = new Lang.Class({
Name: 'DeskChangerControls',
Extends: PopupMenu.PopupBaseMenuItem,

Expand Down Expand Up @@ -152,7 +152,7 @@ const DeskChangerControls = new Lang.Class({
},
});

const DeskChangerDaemonControls = new Lang.Class({
var DeskChangerDaemonControls = new Lang.Class({
Name: 'DeskChangerDaemonControls',
Extends: PopupMenu.PopupSwitchMenuItem,

Expand All @@ -179,7 +179,7 @@ const DeskChangerDaemonControls = new Lang.Class({
}
});

const DeskChangerOpenCurrent = new Lang.Class({
var DeskChangerOpenCurrent = new Lang.Class({
Name: 'DeskChangerOpenCurrent',
Extends: PopupMenu.PopupMenuItem,

Expand All @@ -202,7 +202,7 @@ const DeskChangerOpenCurrent = new Lang.Class({
}
});

const DeskChangerPreviewMenuItem = new Lang.Class({
var DeskChangerPreviewMenuItem = new Lang.Class({
Name: 'DeskChangerPreviewMenuItem',
Extends: PopupMenu.PopupBaseMenuItem,

Expand All @@ -212,7 +212,7 @@ const DeskChangerPreviewMenuItem = new Lang.Class({
try {
this.addActor(this._box, {align: St.Align.MIDDLE, span: -1});
} catch (e) {
this.actor.add_actor(this._box, {align: St.Align.MIDDLE, span: -1});
this.actor.add_actor(this._box);
}
this._prefix = new St.Label({text: _('Open Next Wallpaper')});
this._box.add(this._prefix);
Expand Down Expand Up @@ -241,7 +241,7 @@ const DeskChangerPreviewMenuItem = new Lang.Class({
}
});

const DeskChangerPopupSubMenuMenuItem = new Lang.Class({
var DeskChangerPopupSubMenuMenuItem = new Lang.Class({
Abstract: true,
Name: 'DeskChangerPopupSubMenuItem',
Extends: PopupMenu.PopupSubMenuMenuItem,
Expand All @@ -262,7 +262,7 @@ const DeskChangerPopupSubMenuMenuItem = new Lang.Class({
}
});

const DeskChangerPopupMenuItem = new Lang.Class({
var DeskChangerPopupMenuItem = new Lang.Class({
Name: 'DeskChangerPopupMenuItem',
Extends: PopupMenu.PopupMenuItem,

Expand Down Expand Up @@ -296,7 +296,7 @@ const DeskChangerPopupMenuItem = new Lang.Class({
}
});

const DeskChangerProfileBase = new Lang.Class({
var DeskChangerProfileBase = new Lang.Class({
Abstract: true,
Name: 'DeskChangerProfileBase',
Extends: DeskChangerPopupSubMenuMenuItem,
Expand All @@ -317,7 +317,7 @@ const DeskChangerProfileBase = new Lang.Class({
}
});

const DeskChangerProfileDesktop = new Lang.Class({
var DeskChangerProfileDesktop = new Lang.Class({
Name: 'DeskChangerProfileDesktop',
Extends: DeskChangerProfileBase,

Expand All @@ -326,7 +326,7 @@ const DeskChangerProfileDesktop = new Lang.Class({
},
});

const DeskChangerProfileLockscreen = new Lang.Class({
var DeskChangerProfileLockscreen = new Lang.Class({
Name: 'DeskChangerProfileLockscreen',
Extends: DeskChangerProfileBase,

Expand All @@ -341,7 +341,7 @@ const DeskChangerProfileLockscreen = new Lang.Class({
value = _('(inherited)');
}

this.label.text = _('Lock Screen Profile') + value;
this.label.text = _('Lock Screen Profile') + ': ' + value;
},

_populate_profiles: function () {
Expand All @@ -351,7 +351,7 @@ const DeskChangerProfileLockscreen = new Lang.Class({
}
});

const DeskChangerRotation = new Lang.Class({
var DeskChangerRotation = new Lang.Class({
Name: 'DeskChangerRotation',
Extends: DeskChangerPopupSubMenuMenuItem,

Expand All @@ -363,7 +363,7 @@ const DeskChangerRotation = new Lang.Class({
}
});

const DeskChangerSwitch = new Lang.Class({
var DeskChangerSwitch = new Lang.Class({
Name: 'DeskChangerSwitch',
Extends: PopupMenu.PopupSwitchMenuItem,

Expand Down
5 changes: 3 additions & 2 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"3.21.91",
"3.22",
"3.24",
"3.26"
"3.26",
"3.28"
],
"url": "https://github.com/BigE/desk-changer/",
"uuid": "[email protected]",
"version": "26"
"version": "27"
}
22 changes: 21 additions & 1 deletion [email protected]/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const DeskChangerPrefs = new Lang.Class({
this._initExtension();
this._initDaemon();
this._load_profiles();
this._update_rotation();
this.box.pack_start(this.notebook, true, true, 0);
this.box.show_all();
this._is_init = false;
Expand Down Expand Up @@ -83,6 +82,7 @@ const DeskChangerPrefs = new Lang.Class({
this._rotation_combo_box.insert_text(0, 'interval');
this._rotation_combo_box.insert_text(1, 'hourly');
this._rotation_combo_box.insert_text(2, 'disabled');
this._update_rotation();
this._rotation_combo_box.connect('changed', Lang.bind(this, function (object) {
this._settings.rotation = object.get_active_text();
}));
Expand Down Expand Up @@ -159,6 +159,26 @@ const DeskChangerPrefs = new Lang.Class({
}));
box.pack_end(button, false, false, 5);
daemon_box.pack_start(box, false, false, 5);
// Allowed Mime Types
box = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL});
label = new Gtk.Label({label: _('Allowed Mime Types')});
box.pack_start(label, false, true, 5);
label = new Gtk.Label({label: ' '});
box.pack_start(label, true, true, 5);
this._allowed_mime_types = new Gtk.TextBuffer({text: this._settings.allowed_mime_types.join("\n")});
let textview = new Gtk.TextView({
buffer: this._allowed_mime_types,
justification: Gtk.Justification.RIGHT,
});
box.pack_end(textview, false, true, 5);
daemon_box.pack_start(box, false, false, 5);
box = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL});
button = new Gtk.Button({label: 'Save'});
button.connect('clicked', Lang.bind(this, function () {
this._settings.allowed_mime_types = this._allowed_mime_types.text.split("\n");
}));
box.pack_end(button, false, true, 5);
daemon_box.pack_start(box, false, false, 5);
this.notebook.append_page(daemon_box, new Gtk.Label({label: _('Daemon')}));
},

Expand Down
Binary file modified [email protected]/schemas/gschemas.compiled
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<schemalist>
<schema id="org.gnome.shell.extensions.desk-changer" path="/org/gnome/shell/extensions/desk-changer/">
<key name="allowed-mime-types" type="as">
<default><![CDATA[['application/xml', 'image/jpeg', 'image/png']]]></default>
<description>
These are the mime types that the daemon will recognise as valid files to load and use for backgrounds.
</description>
<summary>Allowed mime types for loading backgrounds</summary>
</key>
<key name="auto-rotate" type="b">
<default>true</default>
<description>
Expand Down
12 changes: 11 additions & 1 deletion [email protected]/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const GLib = imports.gi.GLib;
const Lang = imports.lang;
const Me = imports.misc.extensionUtils.getCurrentExtension();

const DeskChangerSettings = new Lang.Class({
var DeskChangerSettings = new Lang.Class({
Name: 'DeskChangerSettings',

_init: function () {
Expand All @@ -38,6 +38,16 @@ const DeskChangerSettings = new Lang.Class({
this._handlers = [];
},

get allowed_mime_types()
{
return this.schema.get_value('allowed-mime-types').deep_unpack();
},

set allowed_mime_types(value)
{
this.schema.set_value('allowed-mime-types', new GLib.Variant('as', value));
},

get auto_rotate() {
return this.schema.get_boolean('auto-rotate');
},
Expand Down
8 changes: 4 additions & 4 deletions [email protected]/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const _ = Gettext.gettext;
const debug = Me.imports.utils.debug;
const error = Me.imports.utils.error;

const DeskChangerButton = new Lang.Class({
var DeskChangerButton = new Lang.Class({
Name: 'DeskChangerButton',
Extends: St.Button,

Expand All @@ -59,7 +59,7 @@ const DeskChangerButton = new Lang.Class({
}
});

const DeskChangerIcon = new Lang.Class({
var DeskChangerIcon = new Lang.Class({
Name: 'DeskChangerIcon',
Extends: St.Bin,

Expand Down Expand Up @@ -137,7 +137,7 @@ const DeskChangerIcon = new Lang.Class({
}
});

const DeskChangerPreview = new Lang.Class({
var DeskChangerPreview = new Lang.Class({
Name: 'DeskChangerPreview',
Extends: St.Bin,

Expand Down Expand Up @@ -222,7 +222,7 @@ const DeskChangerPreview = new Lang.Class({
}
});

const DeskChangerStateButton = new Lang.Class({
var DeskChangerStateButton = new Lang.Class({
Name: 'DeskChangerStateButton',
Extends: DeskChangerButton,

Expand Down

0 comments on commit e0cdf06

Please sign in to comment.