mirror of
https://github.com/Hopiu/RandomWallpaperGnome3.git
synced 2026-05-03 21:04:43 +00:00
reformat code
This commit is contained in:
parent
42d6e663e9
commit
ef7260a179
12 changed files with 315 additions and 303 deletions
220
assets/icon.svg
220
assets/icon.svg
|
|
@ -1,113 +1,113 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="120"
|
||||
height="120"
|
||||
viewBox="0 0 120 120"
|
||||
version="1.1"
|
||||
id="svg4"
|
||||
sodipodi:docname="icon_v2.svg"
|
||||
inkscape:version="0.92.2 2405546, 2018-03-11"
|
||||
style="enable-background:new"
|
||||
inkscape:export-filename="/home/wolfgang/Develop/RandomWallpaperGnome3/assets/icon.svg.png"
|
||||
inkscape:export-xdpi="212"
|
||||
inkscape:export-ydpi="212">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8">
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient4545">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4541" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4543" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4545"
|
||||
id="linearGradient4547"
|
||||
x1="0"
|
||||
y1="12"
|
||||
x2="24"
|
||||
y2="12"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
<filter
|
||||
inkscape:collect="always"
|
||||
style="color-interpolation-filters:sRGB"
|
||||
id="filter852">
|
||||
<feBlend
|
||||
inkscape:collect="always"
|
||||
mode="multiply"
|
||||
in2="BackgroundImage"
|
||||
id="feBlend854" />
|
||||
</filter>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1172"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="2.3350001"
|
||||
inkscape:cx="-73.129975"
|
||||
inkscape:cy="-22.174101"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="28"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4"
|
||||
fit-margin-top="10"
|
||||
fit-margin-left="10"
|
||||
fit-margin-right="10"
|
||||
fit-margin-bottom="10" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
style="display:inline"
|
||||
transform="translate(10,10)" />
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="Layer 2"
|
||||
style="display:inline;opacity:1"
|
||||
transform="translate(10,10)" />
|
||||
<g
|
||||
id="g1257"
|
||||
transform="translate(10,10)">
|
||||
<path
|
||||
id="rect4614"
|
||||
style="fill:#326679;fill-opacity:1;stroke:none;stroke-width:11.24918652;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 22.132812,25.824219 c -0.808185,0.0011 -1.475462,0.668376 -1.476562,1.476562 v 44.121094 c 0.0011,0.808179 0.663704,1.481322 1.476562,1.482422 h 55.734376 c 0.812856,-0.0011 1.475462,-0.674239 1.476562,-1.482422 V 27.300781 c -0.0011,-0.808189 -0.668375,-1.475462 -1.476562,-1.476562 z m 31.785157,10.628906 8.666015,2.931641 -6.039062,6.871093 -0.986328,-3.675781 c -5.578248,1.494688 -6.167418,4.933346 -6.847656,8.914063 -0.730238,4.264682 -1.553892,9.098413 -8.81836,11.044921 l -2.451172,0.65625 -0.65625,-2.451171 2.451172,-0.65625 c 5.69344,-1.525554 6.285112,-4.999405 6.972656,-9.021485 0.724069,-4.22888 1.54409,-9.021858 8.69336,-10.9375 z m -14.376953,8.412109 c 2.06771,0.104266 3.689143,0.799733 5.052734,1.777344 -0.288344,0.93362 -0.494193,1.855058 -0.65625,2.720703 -1.873113,-1.657387 -4.148218,-2.557714 -7.986328,-1.529297 l -2.449219,0.65625 -0.658203,-2.451172 2.451172,-0.65625 c 1.603807,-0.429738 3.005467,-0.580137 4.246094,-0.517578 z m 18.316406,6.292969 8.666016,2.931641 -6.039063,6.871094 L 59.5,57.285156 c -4.227803,1.132836 -7.032531,0.283284 -9.193359,-1.28125 0.290797,-0.934276 0.498041,-1.853122 0.660156,-2.71875 1.856434,1.653971 4.095715,2.561486 7.875,1.548828 z M 42.101562,74.59375 c -0.429336,0.0011 -0.835273,0.190404 -1.113281,0.511719 l -6.039062,4.630859 c -0.397699,0.463058 -0.447658,1.093346 -0.226563,1.578125 0.221095,0.484777 0.729383,0.858528 1.339844,0.861328 h 27.875 c 0.610478,-0.0029 1.11875,-0.376541 1.339844,-0.861328 0.221092,-0.484788 0.171144,-1.115063 -0.226563,-1.578125 L 59.011719,75.105469 C 58.733714,74.784146 58.327809,74.59485 57.898438,74.59375 Z M 50,0 A 50,50 0 0 0 0,50 50,50 0 0 0 50,100 50,50 0 0 0 100,50 50,50 0 0 0 50,0 Z m 0,6.1328125 A 43.867611,43.867611 0 0 1 93.867188,50 43.867611,43.867611 0 0 1 50,93.867188 43.867611,43.867611 0 0 1 6.1328125,50 43.867611,43.867611 0 0 1 50,6.1328125 Z"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="120"
|
||||
height="120"
|
||||
viewBox="0 0 120 120"
|
||||
version="1.1"
|
||||
id="svg4"
|
||||
sodipodi:docname="icon_v2.svg"
|
||||
inkscape:version="0.92.2 2405546, 2018-03-11"
|
||||
style="enable-background:new"
|
||||
inkscape:export-filename="/home/wolfgang/Develop/RandomWallpaperGnome3/assets/icon.svg.png"
|
||||
inkscape:export-xdpi="212"
|
||||
inkscape:export-ydpi="212">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8">
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
id="linearGradient4545">
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop4541"/>
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop4543"/>
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient4545"
|
||||
id="linearGradient4547"
|
||||
x1="0"
|
||||
y1="12"
|
||||
x2="24"
|
||||
y2="12"
|
||||
gradientUnits="userSpaceOnUse"/>
|
||||
<filter
|
||||
inkscape:collect="always"
|
||||
style="color-interpolation-filters:sRGB"
|
||||
id="filter852">
|
||||
<feBlend
|
||||
inkscape:collect="always"
|
||||
mode="multiply"
|
||||
in2="BackgroundImage"
|
||||
id="feBlend854"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1172"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="2.3350001"
|
||||
inkscape:cx="-73.129975"
|
||||
inkscape:cy="-22.174101"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="28"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg4"
|
||||
fit-margin-top="10"
|
||||
fit-margin-left="10"
|
||||
fit-margin-right="10"
|
||||
fit-margin-bottom="10"/>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
style="display:inline"
|
||||
transform="translate(10,10)"/>
|
||||
<g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer2"
|
||||
inkscape:label="Layer 2"
|
||||
style="display:inline;opacity:1"
|
||||
transform="translate(10,10)"/>
|
||||
<g
|
||||
id="g1257"
|
||||
transform="translate(10,10)">
|
||||
<path
|
||||
id="rect4614"
|
||||
style="fill:#326679;fill-opacity:1;stroke:none;stroke-width:11.24918652;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:stroke fill markers"
|
||||
d="m 22.132812,25.824219 c -0.808185,0.0011 -1.475462,0.668376 -1.476562,1.476562 v 44.121094 c 0.0011,0.808179 0.663704,1.481322 1.476562,1.482422 h 55.734376 c 0.812856,-0.0011 1.475462,-0.674239 1.476562,-1.482422 V 27.300781 c -0.0011,-0.808189 -0.668375,-1.475462 -1.476562,-1.476562 z m 31.785157,10.628906 8.666015,2.931641 -6.039062,6.871093 -0.986328,-3.675781 c -5.578248,1.494688 -6.167418,4.933346 -6.847656,8.914063 -0.730238,4.264682 -1.553892,9.098413 -8.81836,11.044921 l -2.451172,0.65625 -0.65625,-2.451171 2.451172,-0.65625 c 5.69344,-1.525554 6.285112,-4.999405 6.972656,-9.021485 0.724069,-4.22888 1.54409,-9.021858 8.69336,-10.9375 z m -14.376953,8.412109 c 2.06771,0.104266 3.689143,0.799733 5.052734,1.777344 -0.288344,0.93362 -0.494193,1.855058 -0.65625,2.720703 -1.873113,-1.657387 -4.148218,-2.557714 -7.986328,-1.529297 l -2.449219,0.65625 -0.658203,-2.451172 2.451172,-0.65625 c 1.603807,-0.429738 3.005467,-0.580137 4.246094,-0.517578 z m 18.316406,6.292969 8.666016,2.931641 -6.039063,6.871094 L 59.5,57.285156 c -4.227803,1.132836 -7.032531,0.283284 -9.193359,-1.28125 0.290797,-0.934276 0.498041,-1.853122 0.660156,-2.71875 1.856434,1.653971 4.095715,2.561486 7.875,1.548828 z M 42.101562,74.59375 c -0.429336,0.0011 -0.835273,0.190404 -1.113281,0.511719 l -6.039062,4.630859 c -0.397699,0.463058 -0.447658,1.093346 -0.226563,1.578125 0.221095,0.484777 0.729383,0.858528 1.339844,0.861328 h 27.875 c 0.610478,-0.0029 1.11875,-0.376541 1.339844,-0.861328 0.221092,-0.484788 0.171144,-1.115063 -0.226563,-1.578125 L 59.011719,75.105469 C 58.733714,74.784146 58.327809,74.59485 57.898438,74.59375 Z M 50,0 A 50,50 0 0 0 0,50 50,50 0 0 0 50,100 50,50 0 0 0 100,50 50,50 0 0 0 50,0 Z m 0,6.1328125 A 43.867611,43.867611 0 0 1 93.867188,50 43.867611,43.867611 0 0 1 50,93.867188 43.867611,43.867611 0 0 1 6.1328125,50 43.867611,43.867611 0 0 1 50,6.1328125 Z"
|
||||
inkscape:connector-curvature="0"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.8 KiB |
|
|
@ -38,19 +38,19 @@ const ExtensionUtils = imports.misc.extensionUtils;
|
|||
* If @domain is not provided, it will be taken from metadata['gettext-domain']
|
||||
*/
|
||||
function initTranslations(domain) {
|
||||
let extension = ExtensionUtils.getCurrentExtension();
|
||||
let extension = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
domain = domain || extension.metadata['gettext-domain'];
|
||||
domain = domain || extension.metadata['gettext-domain'];
|
||||
|
||||
// check if this extension was built with "make zip-file", and thus
|
||||
// has the locale files in a subfolder
|
||||
// otherwise assume that extension has been installed in the
|
||||
// same prefix as gnome-shell
|
||||
let localeDir = extension.dir.get_child('locale');
|
||||
if (localeDir.query_exists(null))
|
||||
Gettext.bindtextdomain(domain, localeDir.get_path());
|
||||
else
|
||||
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
|
||||
// check if this extension was built with "make zip-file", and thus
|
||||
// has the locale files in a subfolder
|
||||
// otherwise assume that extension has been installed in the
|
||||
// same prefix as gnome-shell
|
||||
let localeDir = extension.dir.get_child('locale');
|
||||
if (localeDir.query_exists(null))
|
||||
Gettext.bindtextdomain(domain, localeDir.get_path());
|
||||
else
|
||||
Gettext.bindtextdomain(domain, Config.LOCALEDIR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -62,31 +62,31 @@ function initTranslations(domain) {
|
|||
* metadata['settings-schema'].
|
||||
*/
|
||||
function getSettings(schema) {
|
||||
let extension = ExtensionUtils.getCurrentExtension();
|
||||
let extension = ExtensionUtils.getCurrentExtension();
|
||||
|
||||
schema = schema || extension.metadata['settings-schema'];
|
||||
schema = schema || extension.metadata['settings-schema'];
|
||||
|
||||
const GioSSS = Gio.SettingsSchemaSource;
|
||||
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();
|
||||
// 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.');
|
||||
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 });
|
||||
return new Gio.Settings({settings_schema: schemaObj});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ var HistoryElement = new Lang.Class({
|
|||
this.actor.insert_child_above(this._container, this.prefixLabel);
|
||||
}
|
||||
|
||||
this.menu.addMenuItem( new PopupMenu.PopupBaseMenuItem({can_focus: false, reactive: false})); // theme independent spacing
|
||||
this.menu.addMenuItem(new PopupMenu.PopupBaseMenuItem({can_focus: false, reactive: false})); // theme independent spacing
|
||||
|
||||
if (this.historyEntry.source && this.historyEntry.source !== null) {
|
||||
if (this.historyEntry.source.author !== null
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ var RandomWallpaperEntry = new Lang.Class({
|
|||
Name: "RandomWallpaperEntry",
|
||||
logger: null,
|
||||
|
||||
_init: function(menuAlignment, nameText) {
|
||||
_init: function (menuAlignment, nameText) {
|
||||
this.parent(menuAlignment, nameText);
|
||||
this.logger = new LoggerModule.Logger('RWG3', 'RandomWallpaperEntry');
|
||||
|
||||
|
|
@ -104,25 +104,25 @@ var RandomWallpaperEntry = new Lang.Class({
|
|||
wallpaperController.registerStopLoadingHook(this.setHistoryList.bind(this));
|
||||
|
||||
// new wallpaper event
|
||||
this.newWallpaperItem.connect('activate', function() {
|
||||
this.newWallpaperItem.connect('activate', function () {
|
||||
wallpaperController.fetchNewWallpaper();
|
||||
});
|
||||
|
||||
// clear history event
|
||||
this.clearHistoryItem.connect('activate', function() {
|
||||
this.clearHistoryItem.connect('activate', function () {
|
||||
wallpaperController.deleteHistory();
|
||||
});
|
||||
|
||||
// Open Wallpaper Folder
|
||||
this.openFolder.connect('activate', function(event) {
|
||||
this.openFolder.connect('activate', function (event) {
|
||||
let uri = GLib.filename_to_uri(wallpaperController.wallpaperlocation, "");
|
||||
Gio.AppInfo.launch_default_for_uri(uri, global.create_app_launch_context(0, -1))
|
||||
});
|
||||
|
||||
this.openSettings.connect("activate", function(){
|
||||
this.openSettings.connect("activate", function () {
|
||||
// call gnome settings tool for this extension
|
||||
let app = Shell.AppSystem.get_default().lookup_app("gnome-shell-extension-prefs.desktop");
|
||||
if( app!=null ) {
|
||||
if (app != null) {
|
||||
// only works in Gnome >= 3.12
|
||||
let info = app.get_app_info();
|
||||
let timestamp = global.display.get_current_time_roundtrip();
|
||||
|
|
@ -130,7 +130,7 @@ var RandomWallpaperEntry = new Lang.Class({
|
|||
}
|
||||
});
|
||||
|
||||
this.menu.actor.connect('show', function() {
|
||||
this.menu.actor.connect('show', function () {
|
||||
this.newWallpaperItem.show();
|
||||
wallpaperController.menuShowHook();
|
||||
}.bind(this));
|
||||
|
|
@ -160,7 +160,7 @@ var RandomWallpaperEntry = new Lang.Class({
|
|||
}
|
||||
},
|
||||
|
||||
setHistoryList: function() {
|
||||
setHistoryList: function () {
|
||||
this.setCurrentBackgroundElement();
|
||||
|
||||
this.historySection.removeAll();
|
||||
|
|
@ -193,13 +193,14 @@ var RandomWallpaperEntry = new Lang.Class({
|
|||
function onEnter(actor) {
|
||||
wallpaperController.previewWallpaper(actor.historyId);
|
||||
}
|
||||
|
||||
function onSelect(actor) {
|
||||
wallpaperController.setWallpaper(actor.historyEntry.id);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
clearHistoryList: function() {
|
||||
clearHistoryList: function () {
|
||||
this.historySection.removeAll();
|
||||
|
||||
let empty = new PopupMenu.PopupMenuItem('No recent wallpaper ...', {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ var HistoryEntry = new Lang.Class({
|
|||
path: null,
|
||||
source: null,
|
||||
|
||||
_init: function(author, source, url) {
|
||||
_init: function (author, source, url) {
|
||||
this.timestamp = new Date().getTime();
|
||||
|
||||
this.source = {
|
||||
|
|
@ -39,7 +39,7 @@ var HistoryController = new Lang.Class({
|
|||
size: 10,
|
||||
history: [],
|
||||
|
||||
_init: function(wallpaperlocation) {
|
||||
_init: function (wallpaperlocation) {
|
||||
this.logger = new LoggerModule.Logger('RWG3', 'HistoryController');
|
||||
|
||||
this._settings = new Prefs.Settings();
|
||||
|
|
@ -48,7 +48,7 @@ var HistoryController = new Lang.Class({
|
|||
this.load();
|
||||
},
|
||||
|
||||
insert: function(historyElement) {
|
||||
insert: function (historyElement) {
|
||||
this.history.unshift(historyElement);
|
||||
this._deleteOldPictures();
|
||||
this.save();
|
||||
|
|
@ -59,14 +59,16 @@ var HistoryController = new Lang.Class({
|
|||
* @param id
|
||||
* @returns {boolean}
|
||||
*/
|
||||
promoteToActive: function(id) {
|
||||
promoteToActive: function (id) {
|
||||
let element = this.get(id);
|
||||
if (element === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
element.timestamp = new Date().getTime();
|
||||
this.history = this.history.sort((elem1, elem2) => { return elem1.timestamp < elem2.timestamp });
|
||||
this.history = this.history.sort((elem1, elem2) => {
|
||||
return elem1.timestamp < elem2.timestamp
|
||||
});
|
||||
this.save();
|
||||
|
||||
return true;
|
||||
|
|
@ -77,7 +79,7 @@ var HistoryController = new Lang.Class({
|
|||
* @param id
|
||||
* @returns {*}
|
||||
*/
|
||||
get: function(id) {
|
||||
get: function (id) {
|
||||
for (let elem of this.history) {
|
||||
if (elem.id == id) {
|
||||
return elem;
|
||||
|
|
@ -90,7 +92,7 @@ var HistoryController = new Lang.Class({
|
|||
/**
|
||||
* Load the history from the gschema
|
||||
*/
|
||||
load: function() {
|
||||
load: function () {
|
||||
this.size = this._settings.get('history-length', 'int');
|
||||
let stringHistory = this._settings.get('history', 'strv');
|
||||
this.history = stringHistory.map(elem => {
|
||||
|
|
@ -101,8 +103,10 @@ var HistoryController = new Lang.Class({
|
|||
/**
|
||||
* Save the history to the gschema
|
||||
*/
|
||||
save: function() {
|
||||
let stringHistory = this.history.map(elem => { return JSON.stringify(elem) });
|
||||
save: function () {
|
||||
let stringHistory = this.history.map(elem => {
|
||||
return JSON.stringify(elem)
|
||||
});
|
||||
this._settings.set('history', 'strv', stringHistory);
|
||||
},
|
||||
|
||||
|
|
@ -110,7 +114,7 @@ var HistoryController = new Lang.Class({
|
|||
* Clear the history and delete all photos except the current one.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
clear: function() {
|
||||
clear: function () {
|
||||
let firstHistoryElement = this.history[0];
|
||||
|
||||
if (firstHistoryElement)
|
||||
|
|
@ -138,7 +142,7 @@ var HistoryController = new Lang.Class({
|
|||
deleteFile.delete(null);
|
||||
}
|
||||
|
||||
} while(fileinfo);
|
||||
} while (fileinfo);
|
||||
|
||||
this.save();
|
||||
return true;
|
||||
|
|
@ -148,10 +152,10 @@ var HistoryController = new Lang.Class({
|
|||
* Delete all pictures that have no slot in the history.
|
||||
* @private
|
||||
*/
|
||||
_deleteOldPictures: function() {
|
||||
_deleteOldPictures: function () {
|
||||
this.size = this._settings.get('history-length', 'int');
|
||||
let deleteFile;
|
||||
while(this.history.length > this.size) {
|
||||
while (this.history.length > this.size) {
|
||||
deleteFile = Gio.file_new_for_path(this.history.pop().path);
|
||||
deleteFile.delete(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ var JSONPathParser = function () {
|
|||
* @param inputString the json path expression
|
||||
* @returns {*}
|
||||
*/
|
||||
this.access = function(inputObject, inputString) {
|
||||
this.access = function (inputObject, inputString) {
|
||||
if (inputObject === null || inputObject === undefined) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ var JSONPathParser = function () {
|
|||
}
|
||||
|
||||
let keyString = inputString.slice(0, startDot);
|
||||
let inputStringTail = inputString.slice(startDot+1);
|
||||
let inputStringTail = inputString.slice(startDot + 1);
|
||||
|
||||
let startParentheses = keyString.indexOf('[');
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ var JSONPathParser = function () {
|
|||
|
||||
} else {
|
||||
|
||||
let indexString = keyString.slice(startParentheses+1, keyString.length-1);
|
||||
let indexString = keyString.slice(startParentheses + 1, keyString.length - 1);
|
||||
keyString = keyString.slice(0, startParentheses);
|
||||
|
||||
let targetObject = this._getTargetObject(inputObject, keyString);
|
||||
|
|
@ -47,12 +47,12 @@ var JSONPathParser = function () {
|
|||
}
|
||||
|
||||
switch (indexString) {
|
||||
case "@random":
|
||||
return this.access(this.randomElement(targetObject), inputStringTail);
|
||||
case "@random":
|
||||
return this.access(this.randomElement(targetObject), inputStringTail);
|
||||
// add special keywords here
|
||||
default:
|
||||
// expecting integer
|
||||
return this.access(targetObject[parseInt(indexString)], inputStringTail);
|
||||
default:
|
||||
// expecting integer
|
||||
return this.access(targetObject[parseInt(indexString)], inputStringTail);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -80,9 +80,9 @@ var JSONPathParser = function () {
|
|||
* @param inputObject
|
||||
* @returns {*}
|
||||
*/
|
||||
this.randomElement = function(inputObject) {
|
||||
this.randomElement = function (inputObject) {
|
||||
let keys = Object.keys(inputObject);
|
||||
let randomIndex = Math.floor(Math.random()*keys.length);
|
||||
let randomIndex = Math.floor(Math.random() * keys.length);
|
||||
|
||||
return inputObject[keys[randomIndex]];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ var Logger = new Lang.Class({
|
|||
_prefix: null,
|
||||
_callingClass: null,
|
||||
|
||||
_init: function(prefix, callingClass) {
|
||||
_init: function (prefix, callingClass) {
|
||||
this._prefix = prefix;
|
||||
this._callingClass = callingClass;
|
||||
},
|
||||
|
||||
_log: function(level, message) {
|
||||
_log: function (level, message) {
|
||||
global.log(this._prefix + " [" + level + "] >> " + this._callingClass + " :: " + message);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
{
|
||||
"shell-version": [
|
||||
"3.20",
|
||||
"3.22",
|
||||
"3.24",
|
||||
"3.26",
|
||||
"3.28"
|
||||
],
|
||||
"uuid": "randomwallpaper@iflow.space",
|
||||
"settings-schema": "org.gnome.shell.extensions.space.iflow.randomwallpaper",
|
||||
"name": "Random Wallpaper",
|
||||
"description": "Fetches a random wallpaper from an online source and sets it as desktop background. \nThe desktop background can be updated periodically or manually.",
|
||||
"version": 11,
|
||||
"semantic-version": "2.2.2",
|
||||
"url": "https://github.com/ifl0w/RandomWallpaperGnome3"
|
||||
"shell-version": [
|
||||
"3.20",
|
||||
"3.22",
|
||||
"3.24",
|
||||
"3.26",
|
||||
"3.28"
|
||||
],
|
||||
"uuid": "randomwallpaper@iflow.space",
|
||||
"settings-schema": "org.gnome.shell.extensions.space.iflow.randomwallpaper",
|
||||
"name": "Random Wallpaper",
|
||||
"description": "Fetches a random wallpaper from an online source and sets it as desktop background. \nThe desktop background can be updated periodically or manually.",
|
||||
"version": 11,
|
||||
"semantic-version": "2.2.2",
|
||||
"url": "https://github.com/ifl0w/RandomWallpaperGnome3"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@
|
|||
<key type='x' name='timer-last-trigger'>
|
||||
<default>0</default>
|
||||
<summary>Timestamp of the last timer trigger.</summary>
|
||||
<description>A JS timestamp of the last timer callback trigger. Zero if no last change registered.</description>
|
||||
<description>A JS timestamp of the last timer callback trigger. Zero if no last change registered.
|
||||
</description>
|
||||
</key>
|
||||
|
||||
<key type='b' name='change-lock-screen'>
|
||||
|
|
@ -104,7 +105,9 @@
|
|||
<key type='b' name='featured-only'>
|
||||
<default>false</default>
|
||||
<summary>Featured images only</summary>
|
||||
<description>This results in a smaller wallpaper pool but the images are considered to have higher quality.</description>
|
||||
<description>This results in a smaller wallpaper pool but the images are considered to have higher
|
||||
quality.
|
||||
</description>
|
||||
</key>
|
||||
</schema>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,46 +1,55 @@
|
|||
|
||||
.rwg_system_status_icon {
|
||||
icon-size: 1em;
|
||||
padding: 0 0;
|
||||
position: absolute;
|
||||
-webkit-animation:spin 4s linear infinite;
|
||||
-moz-animation:spin 4s linear infinite;
|
||||
animation:spin 4s linear infinite;
|
||||
icon-size: 1em;
|
||||
padding: 0 0;
|
||||
position: absolute;
|
||||
-webkit-animation: spin 4s linear infinite;
|
||||
-moz-animation: spin 4s linear infinite;
|
||||
animation: spin 4s linear infinite;
|
||||
}
|
||||
|
||||
@-moz-keyframes spin {
|
||||
100% { -moz-transform: rotate(360deg); }
|
||||
@-moz-keyframes spin {
|
||||
100% {
|
||||
-moz-transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes spin {
|
||||
100% { -webkit-transform: rotate(360deg); }
|
||||
|
||||
@-webkit-keyframes spin {
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes spin {
|
||||
100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); }
|
||||
|
||||
@keyframes spin {
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.rwg-new-lable {
|
||||
font-size: 130%;
|
||||
font-size: 130%;
|
||||
}
|
||||
|
||||
.rwg-recent-lable {
|
||||
width: 100%;
|
||||
font-size: 90%;
|
||||
text-align: left;
|
||||
border: 0;
|
||||
width: 100%;
|
||||
font-size: 90%;
|
||||
text-align: left;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.rwg-history-index {
|
||||
text-align: left;
|
||||
padding-top: .35em;
|
||||
font-size: 130%;
|
||||
font-weight: lighter;
|
||||
text-align: left;
|
||||
padding-top: .35em;
|
||||
font-size: 130%;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
.rwg-history-date {
|
||||
font-size: 100%;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
.rwg-history-time {
|
||||
font-size: 100%;
|
||||
font-weight: lighter;
|
||||
font-size: 100%;
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
|
@ -8,11 +8,11 @@ const LoggerModule = Self.imports.logger;
|
|||
let _afTimerInstance = null;
|
||||
|
||||
// Singleton implementation of _AFTimer
|
||||
var AFTimer = function() {
|
||||
if (!_afTimerInstance) {
|
||||
_afTimerInstance = new _AFTimer();
|
||||
}
|
||||
return _afTimerInstance;
|
||||
var AFTimer = function () {
|
||||
if (!_afTimerInstance) {
|
||||
_afTimerInstance = new _AFTimer();
|
||||
}
|
||||
return _afTimerInstance;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -21,54 +21,54 @@ var AFTimer = function() {
|
|||
* @type {Lang}
|
||||
*/
|
||||
var _AFTimer = new Lang.Class({
|
||||
Name: 'AFTimer',
|
||||
Name: 'AFTimer',
|
||||
logger: null,
|
||||
|
||||
_timeout: null,
|
||||
_timoutEndCallback: null,
|
||||
_minutes: 30,
|
||||
_timeout: null,
|
||||
_timoutEndCallback: null,
|
||||
_minutes: 30,
|
||||
|
||||
_init: function() {
|
||||
_init: function () {
|
||||
this.logger = new LoggerModule.Logger('RWG3', 'Timer');
|
||||
|
||||
this._settings = new Prefs.Settings();
|
||||
},
|
||||
this._settings = new Prefs.Settings();
|
||||
},
|
||||
|
||||
isActive: function () {
|
||||
return this._settings.get('auto-fetch', 'boolean');
|
||||
},
|
||||
isActive: function () {
|
||||
return this._settings.get('auto-fetch', 'boolean');
|
||||
},
|
||||
|
||||
remainingMinutes: function() {
|
||||
let minutesElapsed = this._minutesElapsed();
|
||||
remainingMinutes: function () {
|
||||
let minutesElapsed = this._minutesElapsed();
|
||||
let remainder = minutesElapsed % this._minutes;
|
||||
return Math.max(this._minutes - remainder, 0);
|
||||
},
|
||||
},
|
||||
|
||||
registerCallback: function(callback) {
|
||||
this._timoutEndCallback = callback;
|
||||
},
|
||||
registerCallback: function (callback) {
|
||||
this._timoutEndCallback = callback;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the minutes of the timer.
|
||||
*
|
||||
* Sets the minutes of the timer.
|
||||
*
|
||||
* @param minutes
|
||||
*/
|
||||
setMinutes: function(minutes) {
|
||||
setMinutes: function (minutes) {
|
||||
this._minutes = minutes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Start the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
start: function() {
|
||||
/**
|
||||
* Start the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
start: function () {
|
||||
this.cleanup();
|
||||
|
||||
let last = this._settings.get('timer-last-trigger', 'int64');
|
||||
if (last === 0) {
|
||||
this.reset();
|
||||
}
|
||||
let last = this._settings.get('timer-last-trigger', 'int64');
|
||||
if (last === 0) {
|
||||
this.reset();
|
||||
}
|
||||
|
||||
let millisRemaining = this.remainingMinutes() * 60 * 1000;
|
||||
|
||||
|
|
@ -83,70 +83,65 @@ var _AFTimer = new Lang.Class({
|
|||
|
||||
// actual timer function
|
||||
this._timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, millisRemaining, () => {
|
||||
if (this._timoutEndCallback) {
|
||||
this._timoutEndCallback();
|
||||
}
|
||||
if (this._timoutEndCallback) {
|
||||
this._timoutEndCallback();
|
||||
}
|
||||
|
||||
this.start(); // restart timer
|
||||
});
|
||||
},
|
||||
this.start(); // restart timer
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
stop: function() {
|
||||
this._settings.set('timer-last-trigger', 'int64', 0);
|
||||
this.cleanup();
|
||||
},
|
||||
/**
|
||||
* Stop the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
stop: function () {
|
||||
this._settings.set('timer-last-trigger', 'int64', 0);
|
||||
this.cleanup();
|
||||
},
|
||||
|
||||
/**
|
||||
* Cleanup the timeout callback if it exists.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
cleanup: function() {
|
||||
if (this._timeout) { // only remove if a timeout is active
|
||||
GLib.source_remove(this._timeout);
|
||||
this._timeout = null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Cleanup the timeout callback if it exists.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
cleanup: function () {
|
||||
if (this._timeout) { // only remove if a timeout is active
|
||||
GLib.source_remove(this._timeout);
|
||||
this._timeout = null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Reset the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
reset: function() {
|
||||
this._settings.set('timer-last-trigger', 'int64', new Date().getTime());
|
||||
this.cleanup();
|
||||
},
|
||||
/**
|
||||
* Reset the timer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
reset: function () {
|
||||
this._settings.set('timer-last-trigger', 'int64', new Date().getTime());
|
||||
this.cleanup();
|
||||
},
|
||||
|
||||
_minutesElapsed: function() {
|
||||
let now = Date.now();
|
||||
let last = this._settings.get('timer-last-trigger', 'int64');
|
||||
_minutesElapsed: function () {
|
||||
let now = Date.now();
|
||||
let last = this._settings.get('timer-last-trigger', 'int64');
|
||||
|
||||
if (last === 0) {
|
||||
return 0;
|
||||
}
|
||||
if (last === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let elapsed = Math.max(now - last, 0);
|
||||
return Math.floor(elapsed / (60 * 1000));
|
||||
},
|
||||
let elapsed = Math.max(now - last, 0);
|
||||
return Math.floor(elapsed / (60 * 1000));
|
||||
},
|
||||
|
||||
_surpassedInterval: function() {
|
||||
_surpassedInterval: function () {
|
||||
let now = Date.now();
|
||||
let last = this._settings.get('timer-last-trigger', 'int64');
|
||||
let diff = now - last;
|
||||
let intervalLength = this._minutes * 60 * 1000;
|
||||
|
||||
if (diff > intervalLength) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return diff > intervalLength;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ var WallpaperController = new Lang.Class({
|
|||
* @param callback
|
||||
* @private
|
||||
*/
|
||||
_setPictureUriOfSettingsObject: function(settings, path, callback) {
|
||||
_setPictureUriOfSettingsObject: function (settings, path, callback) {
|
||||
/*
|
||||
inspired from:
|
||||
https://bitbucket.org/LukasKnuth/backslide/src/7e36a49fc5e1439fa9ed21e39b09b61eca8df41a/backslide@codeisland.org/settings.js?at=master
|
||||
|
|
|
|||
Loading…
Reference in a new issue