Skip to content
Open
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
19 changes: 11 additions & 8 deletions Random_Walls@Antares/assets/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ var ConfigControls = GObject.registerClass(
_openConfigWidget() {
let _appSys = Shell.AppSystem.get_default();
let _gsmPrefs = _appSys.lookup_app("org.gnome.Extensions.desktop");
if (_gsmPrefs.get_state() == _gsmPrefs.SHELL_APP_STATE_RUNNING) {
// The proper value is Shell.AppState.RUNNING; Not sure what the other value is, but it's kept
// in as that was there previously
// See: (https://gjs-docs.gnome.org/shell01~0.1_api/shell.appstate)
if (_gsmPrefs.get_state() == _gsmPrefs.SHELL_APP_STATE_RUNNING || Shell.AppState.RUNNING) {
_gsmPrefs.activate();
} else {
let info = _gsmPrefs.get_app_info();
Expand Down Expand Up @@ -154,9 +157,9 @@ var ThumbPreviews = GObject.registerClass(class ThumbPreviews extends PopupMenu.
this._isNextThumbs = isNextThumbs;
this._wallUtils = wallUtils;
//Main Box
let MainBox = new St.BoxLayout({vertical: false});
let MainBox = new St.BoxLayout({ vertical: false });
//Label + Icon Desktop Wallpaper Box
let desktopBox = new St.BoxLayout({vertical: true});
let desktopBox = new St.BoxLayout({ vertical: true });
let currentMode = _settings.get_string(SETTINGS_CHANGE_MODE);
let textLabel, whoami;
/* 1st step: Label and identifier */
Expand All @@ -175,7 +178,7 @@ var ThumbPreviews = GObject.registerClass(class ThumbPreviews extends PopupMenu.
whoami = (this._isNextThumbs) ? NEXT_LOCK : CURRENT_LOCK;
break;
}
desktopBox.add_child(new St.Label({text: textLabel, style_class: "label-thumb"}));
desktopBox.add_child(new St.Label({ text: textLabel, style_class: "label-thumb" }));
/* End 1st step */

/* 2nd step: Create wallIcon (only if not in lockscreen mode)*/
Expand All @@ -187,7 +190,7 @@ var ThumbPreviews = GObject.registerClass(class ThumbPreviews extends PopupMenu.
});
desktopBox.add_actor(this.wallIcon);
MainBox.add_child(desktopBox);
MainBox.add_child(new St.Icon({width: 20}));
MainBox.add_child(new St.Icon({ width: 20 }));
}
/* End 2nd step */

Expand All @@ -198,8 +201,8 @@ var ThumbPreviews = GObject.registerClass(class ThumbPreviews extends PopupMenu.
//whoami was NEXT or CURRENT desktop on the 1st step. Now is NEXT or CURRENT lock
lockwhoami = (this._isNextThumbs) ? NEXT_LOCK : CURRENT_LOCK;
case "lockscreen":
let lockBox = new St.BoxLayout({vertical: true});
lockBox.add_child(new St.Label({text: _("Lockscreen"), style_class: "label-thumb"}));
let lockBox = new St.BoxLayout({ vertical: true });
lockBox.add_child(new St.Label({ text: _("Lockscreen"), style_class: "label-thumb" }));
let lockwall = wallUtils.getCurrentLockWall();
this.lockIcon = new Chooser.ThumbIcon(lockwall, function () {
indicator.close();
Expand Down Expand Up @@ -245,7 +248,7 @@ var RandWallMenu = GObject.registerClass(

this._wallUtils = wallUtils;

let hbox = new St.BoxLayout({style_class: 'panel-status-menu-box'});
let hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' });
let gicon = imports.gi.Gio.icon_new_for_string(Me.path + "/icons/randwall-symbolic.symbolic.png");
let icon = new St.Icon({
style_class: 'system-status-icon randwall-icon',
Expand Down
11 changes: 6 additions & 5 deletions Random_Walls@Antares/assets/pictureChooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ var ThumbIcon = GObject.registerClass(class ThumbIcon extends St.Button {

var PictureChooser = GObject.registerClass(class PictureChooser extends ModalDialog.ModalDialog {
_init(whoami, wallutils) {
super._init({destroyOnClose: false});
super._init({ destroyOnClose: false });
this._wallUtils = wallutils;
this._whoami = whoami;

Expand Down Expand Up @@ -212,8 +212,9 @@ var PictureChooser = GObject.registerClass(class PictureChooser extends ModalDia
let table_col = 0;
let table;
for (var i = 0; i < images.length; i++) {
if (table_col == 0)
table = new St.BoxLayout({x_expand: true, style_class: "chooser-row-box-table"});
if (table_col == 0) {
table = new St.BoxLayout({ x_expand: true, style_class: "chooser-row-box-table" });
}

//create a icon with the current image
let imagepath = images[i];
Expand Down Expand Up @@ -301,12 +302,12 @@ var PictureChooser = GObject.registerClass(class PictureChooser extends ModalDia
let child = fileEnum.get_child(info);
//Check if is a regular file
if (info.get_file_type() == Gio.FileType.REGULAR)
//Check if file is a valid image
//Check if file is a valid image
if (info.get_content_type().match(/^image\//i)) {
let imagepath = child.get_parse_name();
//For every row create a table
if (table_col == 0)
table = new St.BoxLayout({x_expand: true, vertical: false, style_class: "chooser-row-box-table"});
table = new St.BoxLayout({ x_expand: true, vertical: false, style_class: "chooser-row-box-table" });

//create a icon with the current image
let image = new ThumbIcon(this._wallUtils.getGiconFromPath(imagepath), null);
Expand Down
259 changes: 259 additions & 0 deletions Random_Walls@Antares/assets/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,259 @@
const { Gio, GObject, Gtk } = imports.gi;
const Lang = imports.lang;
const Config = imports.misc.config;

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;

const Gettext = imports.gettext.domain('randwall');
const _ = Gettext.gettext;

const Columns = {
FOLDER_NAME: 0
};

const SETTINGS_FOLDER_LIST = 'folder-list';
const SETTINGS_CHANGE_TIME = "change-time";
const SETTINGS_CHANGE_MODE = "change-mode";
const SETTINGS_HIDE_ICON = "hide-icon";

const margins = {
margin_top: 10,
margin_bottom: 10,
margin_start: 10,
margin_end: 10
};

function horizSeparator() {
return new Gtk.Separator({ orientation: Gtk.Orientation.HORIZONTAL });
}

function horizBox() {
return new Gtk.Box({
orientation: Gtk.Orientation.HORIZONTAL, spacing: 20, ...margins
});
}

const FILE_REGEX = /^file:\/\//;

var RandWallSettingsWidget = GObject.registerClass({
GTypeName: 'RandWallSettingsWidget',
}, class RandWallSettingsWidget extends Gtk.Box {

_init(params = {}) {
super._init();
this.set_size_request(-1, 500);
this.set_orientation(Gtk.Orientation.VERTICAL);

this._settings = Convenience.getSettings();
this._settings.connect('changed', Lang.bind(this, this._refresh));
this._changedPermitted = false;

this._store = new Gtk.ListStore();
this._store.set_column_types([GObject.TYPE_STRING]);
//Change Mode
this.append(horizSeparator());

let gHBoxMode = horizBox();

gHBoxMode.append(new Gtk.Label({
label: _("Change mode"), halign: 1,
}));

let modeLabels = {
'different': _("Change both desktop and lockscreen"),
'same': _("Change desktop and lockscreen using the same image"),
'desktop': _("Change only desktop wallpaper"),
'lockscreen': _("Change only Lockscreen wallpaper")
};

let radio = null;
let range = this._settings.get_range(SETTINGS_CHANGE_MODE);
let currentMode = this._settings.get_string(SETTINGS_CHANGE_MODE);
let modes = range.deep_unpack()[1].deep_unpack();

let grid = new Gtk.Grid({
orientation: Gtk.Orientation.VERTICAL, row_spacing: 6, column_spacing: 6,
margin_top: 6, margin_start: 20
});

for (let i = 0; i < modes.length; i++) {
let mode = modes[i];
let label = modeLabels[mode];

if (!label) {
log('Unhandled option "%s" for lock-mode'.format(mode));
continue;
}

radio = new Gtk.ToggleButton({
active: currentMode == mode, label: label, group: radio
});

grid.attach(radio, 0, i, 1, 1);

if (currentMode === mode) {
radio.set_active(true);
}

radio.connect('toggled', Lang.bind(this, function (button) {
if (button.active)
this._settings.set_string(SETTINGS_CHANGE_MODE, mode);
}));
}

gHBoxMode.append(grid);

this.append(gHBoxMode);
this.append(horizSeparator());

//Hide Icon
let gHBoxHideIcon = horizBox();

gHBoxHideIcon.append(new Gtk.Label({
halign: 1, hexpand: true, label: _("Hide Icon")
}));

let iconSwitch = new Gtk.Switch({
active: this._settings.get_boolean(SETTINGS_HIDE_ICON),
});

gHBoxHideIcon.append(iconSwitch);

this.append(gHBoxHideIcon);
this.append(horizSeparator());

this._settings.bind(SETTINGS_HIDE_ICON, iconSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);

//Change time
let gHBoxTimer = horizBox();

let gLabelTimer = new Gtk.Label({
label: _("Interval (in minutes)"), halign: 1, hexpand: true
});
gHBoxTimer.append(gLabelTimer);

this._interval = Gtk.SpinButton.new_with_range(0, 3000, 1);
gHBoxTimer.append(this._interval);
this._settings.bind(SETTINGS_CHANGE_TIME, this._interval, 'value', Gio.SettingsBindFlags.DEFAULT);

// this._interval.connect('changed',Lang.bind(this,this._changeInterval));
this.append(gHBoxTimer);

//Scroll list
let scrolled = new Gtk.ScrolledWindow();
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
this.append(scrolled);

//Folder tree view
this._treeView = new Gtk.TreeView({
model: this._store, hexpand: true, vexpand: true
});
this._treeView.get_selection().set_mode(Gtk.SelectionMode.SINGLE);

let folderColumn = new Gtk.TreeViewColumn({
expand: true, sort_column_id: Columns.FOLDER_NAME, title: _("Image Folders")
});

let nameRenderer = new Gtk.CellRendererText;
folderColumn.pack_start(nameRenderer, true);
folderColumn.add_attribute(nameRenderer, "text", Columns.FOLDER_NAME);
this._treeView.append_column(folderColumn);
scrolled.set_child(this._treeView);

//Toolbar
let toolbar = horizBox();
this.append(toolbar);

let newButtonBox = horizBox();
newButtonBox.append(new Gtk.Label({ label: _("Add Folder") }));
newButtonBox.append(new Gtk.Image({ icon_name: "bookmark-new-symbolic" }));

//add Button
this._newButton = new Gtk.Button();
this._newButton.set_child(newButtonBox);


this._newButton.connect('clicked', Lang.bind(this, this._createFolderDialog));
toolbar.append(this._newButton);

//delete button
let delButton = new Gtk.Button({ icon_name: 'edit-delete-symbolic' });
delButton.connect('clicked', Lang.bind(this, this._deleteSelected));
toolbar.append(delButton);

let selection = this._treeView.get_selection();
selection.connect('changed', function () {
delButton.sensitive = selection.count_selected_rows() > 0;
});
delButton.sensitive = selection.count_selected_rows() > 0;

let currentInterval = this._settings.get_int(SETTINGS_CHANGE_TIME);
this._interval.set_value(currentInterval);

this._changedPermitted = true;
this._refresh();
}


_createFolderDialog() {
let folderDialog = new Gtk.FileChooserNative({
title: _("Select a folder"),
modal: true,
action: Gtk.FileChooserAction.SELECT_FOLDER
});

folderDialog.set_transient_for(this._newButton.get_root());

folderDialog.connect('response', Lang.bind(this, function (dialog, id) {
log(id);
if (id != Gtk.ResponseType.ACCEPT) {
dialog.destroy();
} else {
let filename = dialog.get_file().get_uri().replace(FILE_REGEX, "");

let items = this._settings.get_strv(SETTINGS_FOLDER_LIST);
let exists = items.indexOf(filename);
if (exists == -1) {
items.push(filename);
this._settings.set_strv(SETTINGS_FOLDER_LIST, items);
}
dialog.destroy();
}
}));

folderDialog.show();
}

_deleteSelected() {
let [any, model, iter] = this._treeView.get_selection().get_selected();
if (any) {
let folderName = this._store.get_value(iter, Columns.FOLDER_NAME);
this._changedPermitted = false;
let currentItems = this._settings.get_strv(SETTINGS_FOLDER_LIST);
let index = currentItems.indexOf(folderName);
if (index < 0) {
return;
}
currentItems.splice(index, 1);
this._settings.set_strv(SETTINGS_FOLDER_LIST, currentItems);
this._changedPermitted = true;
this._store.remove(iter);
this._refresh;
}

}

_refresh() {
if (!this._changedPermitted)
return;

this._store.clear();
let currentItems = this._settings.get_strv(SETTINGS_FOLDER_LIST);
for (var i = 0; i < currentItems.length; i++) {
let iter = this._store.append();
this._store.set(iter, [Columns.FOLDER_NAME], [currentItems[i]]);
}
}
});
2 changes: 1 addition & 1 deletion Random_Walls@Antares/assets/timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var MyTimer = class MyTimer {
this._timeout = this._settings.get_int(SETTINGS_TIMEOUT) * 60000;
this._timerId = null;
this._changed = false;

// Listen to changes and restart with new timeout.
this._settings.connect('changed::' + SETTINGS_TIMEOUT, Lang.bind(this, function (value) {
let newValue = value.get_int(SETTINGS_TIMEOUT);
Expand Down
Loading