mirror of
https://github.com/Hopiu/RandomWallpaperGnome3.git
synced 2026-03-16 22:20:24 +00:00
init rework
This commit is contained in:
parent
0815caa19f
commit
c519fdacf6
10 changed files with 659 additions and 108 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
**/*~
|
||||
12
README.md
12
README.md
|
|
@ -3,14 +3,22 @@ RandomWallpaperGnome3
|
|||
|
||||
Random Wallpapers for Gnome 3 is a gnome shell extension which fetches a random wallpaper from an online source and sets it as desktop background.
|
||||
|
||||
## Installation
|
||||
## Installation
|
||||
|
||||
Open the commandline and type the following lines:
|
||||
|
||||
```
|
||||
git clone git@github.com:ifl0w/RandomWallpaperGnome3.git
|
||||
cp RandomWallpaperGnome3/randomwallpaper@iflow.productions ~/.local/share/gnome-shell/extensions/
|
||||
cd ~/.local/share/gnome-shell/extensions/
|
||||
ln -s /path/to/source/randomwallpaper@iflow.productions .
|
||||
```
|
||||
|
||||
Then open the command prompt (Alt+F2) end enter `r` without qotes.
|
||||
Now you should be able to activate the extension through the gnome-tweak-tool.
|
||||
|
||||
## Debuging
|
||||
Debuging can be started via `sh debug.sh`. Information can be printed with `global.log()`.
|
||||
To debug the prefs.js use `sh debug.sh perfs`. In this case you should print debug messages with `print()`.
|
||||
|
||||
## Compiling schemas
|
||||
This can be done with the command: `glib-compile-schemas schemas/`
|
||||
|
|
|
|||
7
debug.sh
Normal file
7
debug.sh
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ $1 == 'prefs' ]]; then
|
||||
gnome-shell-extension-prefs randomwallpaper@iflow.space
|
||||
else
|
||||
journalctl -f /usr/bin/gnome-shell
|
||||
fi
|
||||
39
randomwallpaper@iflow.space/Timer.js
Normal file
39
randomwallpaper@iflow.space/Timer.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
const Lang = imports.lang;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Convenience = Self.imports.convenience;
|
||||
|
||||
let AFTimer = new Lang.Class({
|
||||
|
||||
_timeout: null,
|
||||
_timoutEndCallback: null,
|
||||
|
||||
_init: function() {
|
||||
this._settings = Convenience.getSettings();
|
||||
this._settings.connect('changed::minutes_elapsed', this._loadSettings.bind(this));
|
||||
this._settings.connect('changed::minutes_', this._loadSettings.bind(this));
|
||||
}
|
||||
|
||||
registerCallback: function(callback) {
|
||||
this._timoutEndCallback = callback;
|
||||
}
|
||||
|
||||
start: function(delay) {
|
||||
if (this._timeout) {
|
||||
this.stop();
|
||||
}
|
||||
|
||||
// TODO: calc elapsed time
|
||||
// TODO: check > 0
|
||||
|
||||
this._timeout = GLib.timeout_add(, delay, function() {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
stop: function(delay, callback) {
|
||||
if (_timeout) {
|
||||
Glib.source_remove(_timeout)
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -164,7 +164,7 @@ let RandomWallpaperEntry = new Lang.Class({
|
|||
function enable() {
|
||||
// Extension enabled
|
||||
this.settings = Convenience.getSettings();
|
||||
|
||||
|
||||
// UI
|
||||
panelEntry = new RandomWallpaperEntry(0, "Random wallpaper");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,121 +1,78 @@
|
|||
const Gio = imports.gi.Gio;
|
||||
const GLib = imports.gi.GLib;
|
||||
const Gtk = imports.gi.Gtk;
|
||||
const Gdk = imports.gi.Gdk;
|
||||
const Lang = imports.lang;
|
||||
const ExtensionUtils = imports.misc.extensionUtils;
|
||||
|
||||
const Self = imports.misc.extensionUtils.getCurrentExtension();
|
||||
//const Convenience = Self.imports.convenience;
|
||||
const Self = ExtensionUtils.getCurrentExtension();
|
||||
const Convenience = Self.imports.convenience;
|
||||
|
||||
//const Gettext = imports.gettext.domain('space.iflow.randomwallpaper');
|
||||
const Gettext = imports.gettext.domain('space.iflow.randomwallpaper');
|
||||
//const _ = Gettext.gettext;
|
||||
|
||||
/* Settings Keys */
|
||||
const SETTINGS_HIDE_CORNERS = 'hide-corners';
|
||||
const SETTINGS_TRANSITION_SPEED = 'transition-speed';
|
||||
const SETTINGS_FORCE_ANIMATION = 'force-animation';
|
||||
const SETTINGS_UNMAXIMIZED_OPACITY = 'unmaximized-opacity';
|
||||
const SETTINGS_MAXIMIZED_OPACITY = 'maximized-opacity';
|
||||
const SETTINGS_PANEL_COLOR = 'panel-color';
|
||||
|
||||
/* Color Scaling Factor (Byte to Decimal) */
|
||||
const SCALE_FACTOR = 255.9999999;
|
||||
const RWG_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.space.iflow.randomwallpaper';
|
||||
|
||||
function init() {
|
||||
// Convenience.initTranslations();
|
||||
//Convenience.initTranslations();
|
||||
}
|
||||
|
||||
function buildPrefsWidget() {
|
||||
let widget = new RandomWallpaperSettingsWidget();
|
||||
let settings = new RandomWallpaperSettings();
|
||||
let widget = settings.widget;
|
||||
widget.show_all();
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
/* UI Setup */
|
||||
const RandomWallpaperSettingsWidget = new Lang.Class({
|
||||
Name: 'RandomWallpaper.Prefs.SettingsUI',
|
||||
GTypeName: 'RandomWallpaperSettingsWidget',
|
||||
Extends: Gtk.Grid,
|
||||
const RandomWallpaperSettings = new Lang.Class({
|
||||
Name: 'RandomWallpaper.Settings',
|
||||
|
||||
_init: function(params) {
|
||||
this.parent(params);
|
||||
|
||||
this.margin = this.row_spacing = this.column_spacing = 20;
|
||||
_init: function() {
|
||||
this._settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA);
|
||||
this._builder = new Gtk.Builder();
|
||||
//this._builder.set_translation_domain(Self.metadata['gettext-domain']);
|
||||
this._builder.add_from_file(Self.path + '/settings.ui');
|
||||
|
||||
//this._settings = Convenience.getSettings();
|
||||
this._toggleAfSliders();
|
||||
|
||||
let i = 0;
|
||||
this.widget = this._builder.get_object('main-widget');
|
||||
|
||||
this.attach(new Gtk.Label({ label: 'Poll Sensors Every (sec)', halign : Gtk.Align.END}), 0, i++, 1, 1);
|
||||
let updateTime = Gtk.SpinButton.new_with_range (1, 60, 1);
|
||||
this.attach(updateTime, 1, i++, 1, 1);
|
||||
// this._settings.bind('update-time', updateTime, 'value', Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
let adjustment = new Gtk.Adjustment({
|
||||
lower: 10,
|
||||
upper: 60,
|
||||
step_increment: 1
|
||||
});
|
||||
let scale = new Gtk.HScale({
|
||||
digits:2,
|
||||
adjustment: adjustment,
|
||||
value_pos: Gtk.PositionType.RIGHT
|
||||
});
|
||||
|
||||
this.add(scale);
|
||||
|
||||
this._addSwitch({key : 'group-voltage', y : i++, x : 2,
|
||||
label : 'Group Voltage Items',
|
||||
help : "Works if you have more than three voltage sensors"});
|
||||
|
||||
/*
|
||||
this._addComboBox({
|
||||
items : {
|
||||
'none' : 'None',
|
||||
'nvidia-settings' : 'NVIDIA',
|
||||
'aticonfig' : 'Catalyst',
|
||||
'bumblebee-nvidia-smi': 'Bumblebee + NVIDIA' },
|
||||
key: 'gpu-utility', y : i, x : 2,
|
||||
label: 'Video Card Temperature Utility'
|
||||
}); */
|
||||
this._builder.get_object('af-switch').connect('notify::active', function(toggleSwitch) {
|
||||
this._toggleAfSliders();
|
||||
}.bind(this))
|
||||
|
||||
this._settings.bind('history-length',
|
||||
this._builder.get_object('history-length'),
|
||||
'value',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
this._settings.bind('minutes',
|
||||
this._builder.get_object('duration-minutes'),
|
||||
'value',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
this._settings.bind('hours',
|
||||
this._builder.get_object('duration-hours'),
|
||||
'value',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
this._settings.bind('source',
|
||||
this._builder.get_object('source-combo'),
|
||||
'active-id',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
this._settings.bind('auto-fetch',
|
||||
this._builder.get_object('af-switch'),
|
||||
'active',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
},
|
||||
|
||||
_addSwitch : function(params){
|
||||
let lbl = new Gtk.Label({label: params.label,halign : Gtk.Align.END});
|
||||
this.attach(lbl, params.x, params.y, 1, 1);
|
||||
let sw = new Gtk.Switch({halign : Gtk.Align.END, valign : Gtk.Align.CENTER});
|
||||
this.attach(sw, params.x + 1, params.y, 1, 1);
|
||||
if(params.help){
|
||||
lbl.set_tooltip_text(params.help);
|
||||
sw.set_tooltip_text(params.help);
|
||||
}
|
||||
//this._settings.bind(params.key, sw, 'active', Gio.SettingsBindFlags.DEFAULT);
|
||||
},
|
||||
|
||||
_addComboBox : function(params){
|
||||
let model = new Gtk.ListStore();
|
||||
model.set_column_types([GObject.TYPE_STRING, GObject.TYPE_STRING]);
|
||||
|
||||
let combobox = new Gtk.ComboBox({model: model});
|
||||
let renderer = new Gtk.CellRendererText();
|
||||
combobox.pack_start(renderer, true);
|
||||
combobox.add_attribute(renderer, 'text', 1);
|
||||
|
||||
for(let k in params.items){
|
||||
model.set(model.append(), [0, 1], [k, params.items[k]]);
|
||||
}
|
||||
|
||||
//combobox.set_active(Object.keys(params.items).indexOf(this._settings.get_string(params.key)));
|
||||
|
||||
combobox.connect('changed', Lang.bind(this, function(entry) {
|
||||
let [success, iter] = combobox.get_active_iter();
|
||||
if (!success)
|
||||
return;
|
||||
//this._settings.set_string(params.key, model.get_value(iter, 0))
|
||||
}));
|
||||
|
||||
this.attach(new Gtk.Label({ label: params.label, halign : Gtk.Align.END}), params.x, params.y, 1, 1);
|
||||
this.attach(combobox, params.x + 1, params.y, 1, 1);
|
||||
_toggleAfSliders: function() {
|
||||
if(this._builder.get_object('af-switch').active) {
|
||||
this._builder.get_object('duration-slider-hours').set_sensitive(true);
|
||||
this._builder.get_object('duration-slider-minutes').set_sensitive(true);
|
||||
} else {
|
||||
this._builder.get_object('duration-slider-hours').set_sensitive(false);
|
||||
this._builder.get_object('duration-slider-minutes').set_sensitive(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,13 +1,59 @@
|
|||
<schemalist gettext-domain="space.iflow.randomwallpaper">
|
||||
<schema id="org.gnome.shell.extensions.space.iflow.randomwallpaper"
|
||||
path="/org/gnome/shell/extensions/space/iflow/randomwallpaper/">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist gettext-domain='gnome-shell-extensions'>
|
||||
|
||||
<key type="i" name="boot-wait">
|
||||
<default>15</default>
|
||||
<summary>Time to wait before first check (seconds)</summary>
|
||||
<description>A first check is made this number of seconds after startup</description>
|
||||
<range min="5" max="5000"/>
|
||||
</key>
|
||||
<enum id='org.gnome.shell.extensions.space.iflow.randomwallpaper.sources'>
|
||||
<value value='0' nick='desktoppr'/>
|
||||
<value value='1' nick='unsplash'/>
|
||||
<value value='2' nick='wallheaven'/>
|
||||
</enum>
|
||||
|
||||
</schema>
|
||||
<schema path="/org/gnome/shell/extensions/space-iflow-randomwallpaper-sources/"
|
||||
id='org.gnome.shell.extensions.space.iflow.randomwallpaper'>
|
||||
|
||||
<key type='i' name='history-length'>
|
||||
<default>10</default>
|
||||
<summary>History size</summary>
|
||||
<description>Number of wallpapers stored locally</description>
|
||||
<range min='2' max='100'/>
|
||||
</key>
|
||||
|
||||
<key type='b' name='auto-fetch'>
|
||||
<default>false</default>
|
||||
<summary>Auto-Fetch</summary>
|
||||
<description>Update the wallpaper based on a duration</description>
|
||||
</key>
|
||||
|
||||
<key type='i' name='minutes'>
|
||||
<default>30</default>
|
||||
<summary>Duration</summary>
|
||||
<description>Minutes to wait before a new wallpaper is fetched</description>
|
||||
<range min='1' max='59'/>
|
||||
</key>
|
||||
|
||||
<key type='i' name='hours'>
|
||||
<default>1</default>
|
||||
<summary>Duration</summary>
|
||||
<description>Minutes to wait before a new wallpaper is fetched</description>
|
||||
<range min='0' max='23'/>
|
||||
</key>
|
||||
|
||||
<key name='source' enum='org.gnome.shell.extensions.space.iflow.randomwallpaper.sources'>
|
||||
<default>'desktoppr'</default>
|
||||
<summary>Wallpaper Source</summary>
|
||||
<description>Describs the adapter that will be used.</description>
|
||||
</key>
|
||||
|
||||
<key type='as' name='history'>
|
||||
<default>[]</default>
|
||||
<summary>History</summary>
|
||||
<description>Stores the history objects as stringified JSONs</description>
|
||||
</key>
|
||||
|
||||
<key type='i' name='minutes-elapsed'>
|
||||
<default>0</default>
|
||||
<summary>Elapsed Time</summary>
|
||||
<description>The time that already elapsed.</description>
|
||||
</key>
|
||||
|
||||
</schema>
|
||||
</schemalist>
|
||||
|
|
|
|||
464
randomwallpaper@iflow.space/settings.ui
Normal file
464
randomwallpaper@iflow.space/settings.ui
Normal file
|
|
@ -0,0 +1,464 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.20.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.20"/>
|
||||
<object class="GtkAdjustment" id="duration-hours">
|
||||
<property name="upper">23</property>
|
||||
<property name="value">1</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="duration-minutes">
|
||||
<property name="lower">5</property>
|
||||
<property name="upper">59</property>
|
||||
<property name="value">30</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="history-length">
|
||||
<property name="lower">1</property>
|
||||
<property name="upper">100</property>
|
||||
<property name="value">10</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkBox" id="main-widget">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="valign">start</property>
|
||||
<property name="margin_left">15</property>
|
||||
<property name="margin_right">15</property>
|
||||
<property name="margin_top">15</property>
|
||||
<property name="margin_bottom">15</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="baseline_position">top</property>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">10</property>
|
||||
<property name="margin_right">10</property>
|
||||
<property name="margin_top">10</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
<property name="row_spacing">10</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="column_spacing">10</property>
|
||||
<property name="baseline_row">2</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">False</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="source-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Wallpaper Source</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="source-description">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">The source that is used to fetch random wallpapers. You can select between desktoppr.co (default) and an experimental version of wallheaven.cc.</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="column_spacing">20</property>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="source-combo">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="active_id">0</property>
|
||||
<items>
|
||||
<item id="desktoppr" translatable="yes">desktoppr.co</item>
|
||||
<item id="unsplash" translatable="yes">unsplash.com</item>
|
||||
<item id="wallheaven" translatable="yes">alpha.wallheaven.cc</item>
|
||||
</items>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="left_padding">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">10</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
<property name="label" translatable="yes">No Settings Available</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">10</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">10</property>
|
||||
<property name="margin_right">10</property>
|
||||
<property name="margin_top">10</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
<property name="row_spacing">10</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">False</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="history-size-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">History lenght</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="history-size-description">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">The number of wallpapers that will be shown in the history and stored in the wallpaper folder of this extension.</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="adjustment">history-length</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparator">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">10</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_left">10</property>
|
||||
<property name="margin_right">10</property>
|
||||
<property name="margin_top">10</property>
|
||||
<property name="margin_bottom">10</property>
|
||||
<property name="row_spacing">10</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="column_spacing">10</property>
|
||||
<property name="baseline_row">2</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">False</property>
|
||||
<property name="column_homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="af-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Auto-Fetching</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="af-description">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="label" translatable="yes">Automatically fetch a new wallpaper based on a period.</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="af-switch">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">start</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="column_spacing">20</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="af-minutes-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="label" translatable="yes">Minutes</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="af-hours-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="valign">end</property>
|
||||
<property name="label" translatable="yes">Hours</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="duration-slider-hours">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="adjustment">duration-hours</property>
|
||||
<property name="show_fill_level">True</property>
|
||||
<property name="restrict_to_fill_level">False</property>
|
||||
<property name="fill_level">0</property>
|
||||
<property name="round_digits">0</property>
|
||||
<property name="digits">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScale" id="duration-slider-minutes">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="adjustment">duration-minutes</property>
|
||||
<property name="show_fill_level">True</property>
|
||||
<property name="restrict_to_fill_level">False</property>
|
||||
<property name="fill_level">0</property>
|
||||
<property name="round_digits">0</property>
|
||||
<property name="digits">0</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="top_attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
@ -11,6 +11,7 @@ const Gio = imports.gi.Gio;
|
|||
//self
|
||||
const Self = imports.misc.extensionUtils.getCurrentExtension();
|
||||
const SourceAdapter = Self.imports.sourceAdapter;
|
||||
const Convenience = Self.imports.convenience;
|
||||
|
||||
let WallpaperController = new Lang.Class({
|
||||
Name: "WallpaperController",
|
||||
|
|
@ -22,13 +23,38 @@ let WallpaperController = new Lang.Class({
|
|||
history: [],
|
||||
imageSourceAdapter: undefined,
|
||||
|
||||
autoFetch : {
|
||||
active: false,
|
||||
duration: 30,
|
||||
},
|
||||
|
||||
_init: function(extensionMeta){
|
||||
this.extensionMeta = extensionMeta;
|
||||
this.wallpaperlocation = this.extensionMeta.path + '/wallpapers/';
|
||||
|
||||
this._settings = Convenience.getSettings();
|
||||
this._settings.connect('changed', this._loadSettings.bind(this));
|
||||
this._loadSettings();
|
||||
|
||||
this.history = this._loadHistory();
|
||||
this.currentWallpaper = this._getCurrentWallpaper();
|
||||
|
||||
this.imageSourceAdapter = new SourceAdapter.DesktopperAdapter();
|
||||
this.imageSourceAdapter = new SourceAdapter.WallheavenAdapter();
|
||||
|
||||
if (autoFetch.active) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
_loadSettings: function() {
|
||||
this.historySize = this._settings.get_int('history-length');
|
||||
this.autoFetch.active = this._settings.get_boolean('auto-fetch');
|
||||
|
||||
let duration = 0;
|
||||
duration += this._settings.get_int('minutes');
|
||||
duration += this._settings.get_int('hours') * 60;
|
||||
this.autoFetch.duration = duration;
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
@ -83,6 +109,8 @@ let WallpaperController = new Lang.Class({
|
|||
file.move(newFile, Gio.FileCopyFlags.NONE, null, function(){
|
||||
});
|
||||
|
||||
// TODO: error handling, what if move fails?
|
||||
|
||||
this.history[i] = name;
|
||||
|
||||
this.history.sort();
|
||||
|
|
@ -97,6 +125,7 @@ let WallpaperController = new Lang.Class({
|
|||
|
||||
_setBackground: function(path, callback){
|
||||
let background_setting = new Gio.Settings({schema: "org.gnome.desktop.background"});
|
||||
this.deleteOldPictures();
|
||||
|
||||
/*
|
||||
inspired from:
|
||||
|
|
@ -118,7 +147,6 @@ let WallpaperController = new Lang.Class({
|
|||
// TODO: error handling
|
||||
}
|
||||
|
||||
this.deleteOldPictures();
|
||||
},
|
||||
|
||||
_getCurrentWallpaper: function() {
|
||||
|
|
@ -156,6 +184,7 @@ let WallpaperController = new Lang.Class({
|
|||
},
|
||||
|
||||
deleteOldPictures: function() {
|
||||
this.historySize = this._settings.get_int('history-length');
|
||||
let deleteFile;
|
||||
while(this.history.length > this.historySize) {
|
||||
deleteFile = Gio.file_new_for_path(this.wallpaperlocation + this.history.pop());
|
||||
|
|
|
|||
Loading…
Reference in a new issue