-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
256 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const Self = imports.misc.extensionUtils.getCurrentExtension(); | ||
const HistoryModule = Self.imports.history; | ||
const JSONPath = Self.imports.jsonpath.jsonpath; | ||
const SettingsModule = Self.imports.settings; | ||
|
||
const BaseAdapter = Self.imports.adapter.baseAdapter; | ||
|
||
const RWG_SETTINGS_SCHEMA_URL_SOURCE = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.sources.urlSource'; | ||
|
||
var UrlSourceAdapter = class extends BaseAdapter.BaseAdapter { | ||
constructor(id, wallpaperLocation) { | ||
super(wallpaperLocation); | ||
let path = `/org/gnome/shell/extensions/space-iflow-randomwallpaper/sources/urlSource/${id}/`; | ||
this._settings = new SettingsModule.Settings(RWG_SETTINGS_SCHEMA_URL_SOURCE, path); | ||
} | ||
|
||
requestRandomImage(callback) { | ||
let imageDownloadUrl = this._settings.get("image-url", "string"); | ||
let authorName = this._settings.get("author-name", "string"); | ||
let authorUrl = this._settings.get("author-url", "string"); | ||
let domainUrl = this._settings.get("domain", "string"); | ||
let postUrl = this._settings.get("domain", "string"); | ||
|
||
let identifier = this._settings.get("name", "string"); | ||
if (identifier === null || identifier === "") { | ||
identifier = 'Static URL'; | ||
} | ||
|
||
if (typeof postUrl !== 'string' || !postUrl instanceof String) { | ||
postUrl = null; | ||
} | ||
|
||
if (typeof authorName !== 'string' || !authorName instanceof String) { | ||
authorName = null; | ||
} | ||
|
||
if (typeof authorUrl !== 'string' || !authorUrl instanceof String) { | ||
authorUrl = null; | ||
} | ||
|
||
if (callback) { | ||
let historyEntry = new HistoryModule.HistoryEntry(authorName, identifier, imageDownloadUrl); | ||
|
||
if (authorUrl !== null && authorUrl !== "") { | ||
historyEntry.source.authorUrl = authorUrl; | ||
} | ||
|
||
if (postUrl !== null && postUrl !== "") { | ||
historyEntry.source.imageLinkUrl = postUrl; | ||
} | ||
|
||
if (domainUrl !== null && domainUrl !== "") { | ||
historyEntry.source.sourceUrl = domainUrl; | ||
} | ||
|
||
callback(historyEntry); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using Gtk 4.0; | ||
using Adw 1; | ||
|
||
template UrlSourceSettingsGroup : Adw.PreferencesGroup { | ||
Adw.PreferencesGroup { | ||
title: _("General"); | ||
|
||
Adw.EntryRow domain { | ||
title: _("Domain"); | ||
input-purpose: url; | ||
|
||
LinkButton { | ||
valign: center; | ||
uri: bind domain.text; | ||
|
||
Adw.ButtonContent { | ||
icon-name: "globe-symbolic"; | ||
} | ||
|
||
styles [ | ||
"flat", | ||
] | ||
} | ||
} | ||
|
||
Adw.EntryRow image_url { | ||
title: _("Image URL"); | ||
|
||
LinkButton { | ||
valign: center; | ||
uri: bind image_url.text; | ||
|
||
Adw.ButtonContent { | ||
icon-name: "globe-symbolic"; | ||
} | ||
|
||
styles [ | ||
"flat", | ||
] | ||
} | ||
} | ||
|
||
Adw.EntryRow post_url { | ||
title: _("Post URL"); | ||
input-purpose: free_form; | ||
|
||
LinkButton { | ||
valign: center; | ||
uri: bind post_url.text; | ||
|
||
Adw.ButtonContent { | ||
icon-name: "globe-symbolic"; | ||
} | ||
|
||
styles [ | ||
"flat", | ||
] | ||
} | ||
} | ||
} | ||
|
||
Adw.PreferencesGroup { | ||
title: _("Author"); | ||
|
||
Adw.EntryRow author_name { | ||
title: _("Name"); | ||
input-purpose: free_form; | ||
} | ||
|
||
Adw.EntryRow author_url { | ||
title: _("URL"); | ||
input-purpose: free_form; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const Adw = imports.gi.Adw; | ||
const ExtensionUtils = imports.misc.extensionUtils; | ||
const Gio = imports.gi.Gio; | ||
const GLib = imports.gi.GLib; | ||
const GObject = imports.gi.GObject; | ||
|
||
const Self = ExtensionUtils.getCurrentExtension(); | ||
const Convenience = Self.imports.convenience; | ||
|
||
const RWG_SETTINGS_SCHEMA_LOCAL_FOLDER = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.sources.urlSource'; | ||
|
||
var UrlSourceSettingsGroup = GObject.registerClass({ | ||
GTypeName: 'UrlSourceSettingsGroup', | ||
Template: GLib.filename_to_uri(Self.path + '/ui/urlSource.ui', null), | ||
InternalChildren: [ | ||
'author_name', | ||
'author_url', | ||
'domain', | ||
'image_url', | ||
'post_url', | ||
] | ||
}, class UrlSourceSettingsGroup extends Adw.PreferencesGroup { | ||
constructor(parent_row, params = {}) { | ||
super(params); | ||
|
||
const path = `/org/gnome/shell/extensions/space-iflow-randomwallpaper/sources/urlSource/${parent_row.id}/`; | ||
this._settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA_LOCAL_FOLDER, path); | ||
|
||
this._settings.bind('name', | ||
parent_row.source_name, | ||
'text', | ||
Gio.SettingsBindFlags.DEFAULT); | ||
|
||
this._settings.bind('author-name', | ||
this._author_name, | ||
'text', | ||
Gio.SettingsBindFlags.DEFAULT); | ||
this._settings.bind('author-url', | ||
this._author_url, | ||
'text', | ||
Gio.SettingsBindFlags.DEFAULT); | ||
this._settings.bind('domain', | ||
this._domain, | ||
'text', | ||
Gio.SettingsBindFlags.DEFAULT); | ||
this._settings.bind('image-url', | ||
this._image_url, | ||
'text', | ||
Gio.SettingsBindFlags.DEFAULT); | ||
this._settings.bind('post-url', | ||
this._post_url, | ||
'text', | ||
Gio.SettingsBindFlags.DEFAULT); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters