Initial commit, Notification function
This commit is contained in:
119
cinnamon-dynamic-wallpaper@TobiZog/extension.js
Normal file
119
cinnamon-dynamic-wallpaper@TobiZog/extension.js
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/**
|
||||||
|
* @name Cinnamon-Dynamic-Wallpaper
|
||||||
|
* @alias TobiZog
|
||||||
|
* @since 2023
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/********** Constants **********/
|
||||||
|
|
||||||
|
const UUID = "cinnamon-dynamic-wallpaper@TobiZog";
|
||||||
|
const APPNAME = "Cinnamon Dynamic Wallpaper"
|
||||||
|
|
||||||
|
|
||||||
|
/********** Imports **********/
|
||||||
|
|
||||||
|
const MessageTray = imports.ui.messageTray;
|
||||||
|
const St = imports.gi.St;
|
||||||
|
const Main = imports.ui.main;
|
||||||
|
|
||||||
|
|
||||||
|
/********** Global Variables **********/
|
||||||
|
|
||||||
|
// The extension object
|
||||||
|
let extension;
|
||||||
|
|
||||||
|
|
||||||
|
/********** Objects **********/
|
||||||
|
|
||||||
|
function CinnamonDynamicWallpaperExtension(uuid) {
|
||||||
|
this._init(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
CinnamonDynamicWallpaperExtension.prototype = {
|
||||||
|
/**
|
||||||
|
* Initialization
|
||||||
|
*
|
||||||
|
* @param {string} uuid Universally Unique Identifier
|
||||||
|
*/
|
||||||
|
_init: function(uuid) {
|
||||||
|
// todo
|
||||||
|
|
||||||
|
// Display the welcome notification on activation
|
||||||
|
this.showNotification(
|
||||||
|
APPNAME,
|
||||||
|
"Welcome to " + APPNAME + "! Open the settings and configure the extensions.",
|
||||||
|
true
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displaying a desktop notification
|
||||||
|
*
|
||||||
|
* @param {string} title The Title in the notification
|
||||||
|
* @param {string} text The text in the notification
|
||||||
|
* @param {boolean} showOpenSettings Display the "Open settings" button in the notification, defaults to false
|
||||||
|
*/
|
||||||
|
showNotification: function (title, text, showOpenSettings = false) {
|
||||||
|
let source = new MessageTray.Source(this.uuid);
|
||||||
|
|
||||||
|
// Parameter
|
||||||
|
let params = {
|
||||||
|
icon: new St.Icon({
|
||||||
|
icon_name: "icon",
|
||||||
|
icon_type: St.IconType.FULLCOLOR,
|
||||||
|
icon_size: source.ICON_SIZE
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
// The notification itself
|
||||||
|
let notification = new MessageTray.Notification(source, title, text, params);
|
||||||
|
|
||||||
|
// Display the "Open settings" button, if showOpenSettings
|
||||||
|
if (showOpenSettings) {
|
||||||
|
notification.addButton("open-settings", _("Open settings"));
|
||||||
|
|
||||||
|
notification.connect("action-invoked", () =>
|
||||||
|
Util.spawnCommandLine("xlet-settings extension " + UUID));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put all together
|
||||||
|
Main.messageTray.add(source);
|
||||||
|
|
||||||
|
// Display it
|
||||||
|
source.notify(notification);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/********** Lifecycle **********/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lifecycle function on initialization
|
||||||
|
*
|
||||||
|
* @param {*} extensionMeta Metadata of the extension
|
||||||
|
*/
|
||||||
|
function init(extensionMeta) {
|
||||||
|
extension = new CinnamonDynamicWallpaperExtension(extensionMeta.uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lifecycle function on enable
|
||||||
|
*
|
||||||
|
* @returns The extension object
|
||||||
|
*/
|
||||||
|
function enable() {
|
||||||
|
return extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lifecycle function on disable
|
||||||
|
*/
|
||||||
|
function disable() {
|
||||||
|
// todo
|
||||||
|
}
|
||||||
1
cinnamon-dynamic-wallpaper@TobiZog/icon.png
Symbolic link
1
cinnamon-dynamic-wallpaper@TobiZog/icon.png
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
icons/icon.png
|
||||||
BIN
cinnamon-dynamic-wallpaper@TobiZog/icons/icon.png
Normal file
BIN
cinnamon-dynamic-wallpaper@TobiZog/icons/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
11
cinnamon-dynamic-wallpaper@TobiZog/metadata.json
Normal file
11
cinnamon-dynamic-wallpaper@TobiZog/metadata.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"uuid": "cinnamon-dynamic-wallpaper@TobiZog",
|
||||||
|
"name": "Cinnamon Dynamic Wallpaper",
|
||||||
|
"description": "Cinnamon extension for dynamic desktop backgrounds based on time and location",
|
||||||
|
"version": "1.0",
|
||||||
|
"cinnamon-version": [
|
||||||
|
"5.6"
|
||||||
|
],
|
||||||
|
"max-instances": 1,
|
||||||
|
"url": "https://github.com/TobiZog/cinnamon-dynamic-wallpaper"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user