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
252 changes: 127 additions & 125 deletions [email protected]/files/[email protected]/desklet.js
Original file line number Diff line number Diff line change
@@ -1,125 +1,127 @@
/*
* A themeable desklet that shows the time.
*
* Copyright (C) 2022 Gobinath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http:*www.gnu.org/licenses/>.
*/

const Gio = imports.gi.Gio;
const St = imports.gi.St;
const Settings = imports.ui.settings;
const Desklet = imports.ui.desklet;

const Lang = imports.lang;
const Mainloop = imports.mainloop;
const GLib = imports.gi.GLib;
const Gettext = imports.gettext;
const UUID = "[email protected]";

// l10n/translation support
Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale")

imports.searchPath.unshift(GLib.get_home_dir() + "/.local/share/cinnamon/desklets/[email protected]/themes");
const Config = imports.theme.Config;
const Themes = imports.themes.Themes;

function _(str) {
return Gettext.dgettext(UUID, str);
}

function Timelet(metadata, deskletID) {
this._init(metadata, deskletID);
}

Timelet.prototype = {
__proto__: Desklet.Desklet.prototype,

_init: function (metadata, deskletID) {
Desklet.Desklet.prototype._init.call(this, metadata, deskletID);
this.setHeader(_("Timelet"));

this.settings = new Settings.DeskletSettings(this, this.metadata["uuid"], this.instance_id);
this.settings.bind("themeName", "themeName", this.onSettingChanged);
this.settings.bind("use24H", "use24H", this.onSettingChanged);
this.settings.bind("textColor", "textColor", this.onSettingChanged);
this.settings.bind("bgColor", "bgColor", this.onSettingChanged);
this.settings.bind("scale", "scale", this.onSettingChanged);
this.settings.bind("transparency", "transparency", this.onSettingChanged);
this.settings.bind("cornerRadius", "cornerRadius", this.onSettingChanged);

// Populate the theme names
let themeNames = {};
let sorted = Themes.getThemeNames().sort();
sorted.forEach(name => {
themeNames[name] = name;
});

this.settings.setOptions("themeName", themeNames);

this._setTheme();
this._updateDateTime();
},

onSettingChanged() {
this._setTheme();
},

on_desklet_removed: function () {
Mainloop.source_remove(this.timeout);
},

_setTheme() {
// Set the theme
this._theme = Themes.getTheme(this.themeName, new Config(this.use24H, this.scale, this.textColor));

// Define the desklet container
let deskletContainer = new St.BoxLayout({ vertical: true,style_class: "desklet" });
deskletContainer.style = "padding: 10px; border-radius: " + this.cornerRadius + "px; background-color: " + (this.bgColor.replace(")", "," + (1.0 - this.transparency) + ")")).replace("rgb", "rgba") + "; color: " + this.textColor;

// Add the theme container
deskletContainer.add(this._theme.getWidget());
this.setContent(deskletContainer);

// Update the desklet with current time
let locale = GLib.getenv("LANG");
if (locale) {
// convert $LANG from format "en_GB.UTF-8" to "en-GB"
locale = GLib.getenv("LANG").replace(/_/g, "-").replace(/\..+/, "");
}
if (!locale || locale === "C") {
// fallback locale
locale = "en-US";
}
this._theme.setDateTime(new Date(), locale);
},

_updateDateTime: function () {
let locale = GLib.getenv("LANG");
if (locale) {
// convert $LANG from format "en_GB.UTF-8" to "en-GB"
locale = GLib.getenv("LANG").replace(/_/g, "-").replace(/\..+/, "");
}
if (!locale || locale === "C") {
// fallback locale
locale = "en-US";
}
this._theme.setDateTime(new Date(), locale);
this.timeout = Mainloop.timeout_add_seconds(1, Lang.bind(this, this._updateDateTime));
}
}

function main(metadata, deskletID) {
let desklet = new Timelet(metadata, deskletID);
return desklet;
}
/*
* A themeable desklet that shows the time.
*
* Copyright (C) 2022 Gobinath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http:*www.gnu.org/licenses/>.
*/

const Gio = imports.gi.Gio;
const St = imports.gi.St;
const Settings = imports.ui.settings;
const Desklet = imports.ui.desklet;

const Lang = imports.lang;
const Mainloop = imports.mainloop;
const GLib = imports.gi.GLib;
const Gettext = imports.gettext;
const UUID = "[email protected]";

// l10n/translation support
Gettext.bindtextdomain(UUID, GLib.get_home_dir() + "/.local/share/locale")

imports.searchPath.unshift(GLib.get_home_dir() + "/.local/share/cinnamon/desklets/[email protected]/themes");
const Config = imports.theme.Config;
const Themes = imports.themes.Themes;

function _(str) {
return Gettext.dgettext(UUID, str);
}

function Timelet(metadata, deskletID) {
this._init(metadata, deskletID);
}

Timelet.prototype = {
__proto__: Desklet.Desklet.prototype,

_init: function (metadata, deskletID) {
Desklet.Desklet.prototype._init.call(this, metadata, deskletID);
this.setHeader(_("Timelet"));

this.settings = new Settings.DeskletSettings(this, this.metadata["uuid"], this.instance_id);
this.settings.bindProperty(Settings.BindingDirection.IN, "themeName", "themeName", Lang.bind(this, this._setTheme));
this.settings.bindProperty(Settings.BindingDirection.IN, "use24H", "use24H", Lang.bind(this, this._setTheme));
this.settings.bindProperty(Settings.BindingDirection.IN, "textColor", "textColor", Lang.bind(this, this._setTheme));
this.settings.bindProperty(Settings.BindingDirection.IN, "bgColor", "bgColor", Lang.bind(this, this._setTheme));
this.settings.bindProperty(Settings.BindingDirection.IN, "scale", "scale", Lang.bind(this, this._setTheme));
this.settings.bindProperty(Settings.BindingDirection.IN, "transparency", "transparency", Lang.bind(this, this._setTheme));
this.settings.bindProperty(Settings.BindingDirection.IN, "cornerRadius", "cornerRadius", Lang.bind(this, this._setTheme));
this.settings.bindProperty(Settings.BindingDirection.IN, "hideDecorations", "hideDecorations", Lang.bind(this, this._toggleDecoration));

// Populate the theme names
let themeNames = {};
let sorted = Themes.getThemeNames().sort();
sorted.forEach(name => {
themeNames[name] = name;
});

this.settings.setOptions("themeName", themeNames);

this._setTheme();
this._updateDateTime();
},

on_desklet_removed: function () {
Mainloop.source_remove(this.timeout);
},

_setTheme() {
// Set the theme
this._theme = Themes.getTheme(this.themeName, new Config(this.use24H, this.scale, this.textColor));

// Define the desklet container
let deskletContainer = new St.BoxLayout({ vertical: true,style_class: "desklet" });
deskletContainer.style = "padding: 10px; border-radius: " + this.cornerRadius + "px; background-color: " + (this.bgColor.replace(")", "," + (1.0 - this.transparency) + ")")).replace("rgb", "rgba") + "; color: " + this.textColor;

// Add the theme container
deskletContainer.add(this._theme.getWidget());
this.setContent(deskletContainer);

// Update the desklet with current time
let locale = GLib.getenv("LANG");
if (locale) {
// convert $LANG from format "en_GB.UTF-8" to "en-GB"
locale = GLib.getenv("LANG").replace(/_/g, "-").replace(/\..+/, "");
}
if (!locale || locale === "C") {
// fallback locale
locale = "en-US";
}
this._theme.setDateTime(new Date(), locale);
},

_updateDateTime: function () {
let locale = GLib.getenv("LANG");
if (locale) {
// convert $LANG from format "en_GB.UTF-8" to "en-GB"
locale = GLib.getenv("LANG").replace(/_/g, "-").replace(/\..+/, "");
}
if (!locale || locale === "C") {
// fallback locale
locale = "en-US";
}
this._theme.setDateTime(new Date(), locale);
this.timeout = Mainloop.timeout_add_seconds(1, Lang.bind(this, this._updateDateTime));
},

_toggleDecoration() {
this.metadata['prevent-decorations'] = this.hideDecorations;
this._updateDecoration();
},
}

function main(metadata, deskletID) {
let desklet = new Timelet(metadata, deskletID);
return desklet;
}
16 changes: 10 additions & 6 deletions [email protected]/files/[email protected]/po/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Copyright (C) 2022 Gobinath
# This file is distributed under the same license as the Timelet package.
# Daniel <d3vf4n (at) tutanota (dot) com>, 2024.
#
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2024-05-18 00:10+0200\n"
"POT-Creation-Date: 2025-10-16 23:33+0200\n"
"PO-Revision-Date: 2024-05-18 00:12+0200\n"
"Last-Translator: Daniel <d3vf4n (at) tutanota (dot) com>\n"
"Language-Team: \n"
Expand All @@ -20,19 +20,19 @@ msgstr ""
"X-Generator: Poedit 3.0.1\n"

#. metadata.json->name
#: desklet.js:50
#. desklet.js:50
msgid "Timelet"
msgstr "Timelet"

#: themes/theme.js:143
#. themes/theme.js:143
msgid "AM"
msgstr "AM"

#: themes/theme.js:145
#. themes/theme.js:145
msgid "Noon"
msgstr "Vespre"

#: themes/theme.js:147
#. themes/theme.js:147
msgid "PM"
msgstr "PM"

Expand Down Expand Up @@ -95,3 +95,7 @@ msgstr "Radi de les cantonades del fons"
#. settings-schema.json->cornerRadius->tooltip
msgid "Radius for rounding the desklet's corners"
msgstr "Defineix el radi d'arrodoniment de les cantonades de la miniaplicació"

#. settings-schema.json->hideDecorations->description
msgid "Hide decorations"
msgstr ""
22 changes: 14 additions & 8 deletions [email protected]/files/[email protected]/po/da.po
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Timelet
# Copyright (C) 2022 Gobinath
# This file is distributed under the same license as the Timelet package.
#
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-08-10 21:39-0400\n"
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-desklets/"
"issues\n"
"POT-Creation-Date: 2025-10-16 23:33+0200\n"
"PO-Revision-Date: 2023-12-08 11:59+0100\n"
"Last-Translator: Alan Mortensen <[email protected]>\n"
"Language-Team: \n"
Expand All @@ -18,19 +19,19 @@ msgstr ""
"X-Generator: Poedit 3.0.1\n"

#. metadata.json->name
#: desklet.js:50
#. desklet.js:50
msgid "Timelet"
msgstr "Skrivebordstid"

#: themes/theme.js:143
#. themes/theme.js:143
msgid "AM"
msgstr "AM"

#: themes/theme.js:145
#. themes/theme.js:145
msgid "Noon"
msgstr "Middag"

#: themes/theme.js:147
#. themes/theme.js:147
msgid "PM"
msgstr "PM"

Expand All @@ -51,7 +52,8 @@ msgid "Use 24H"
msgstr "Anvend 24 timers ur"

#. settings-schema.json->use24H->tooltip
msgid "Display time in 24H if the theme supports it"
#, fuzzy
msgid "Display time in 24H"
msgstr "Vis tiden i 24-timersformat hvis temaet understøtter det"

#. settings-schema.json->textColor->description
Expand Down Expand Up @@ -93,3 +95,7 @@ msgstr "Baggrundens hjørneradius"
#. settings-schema.json->cornerRadius->tooltip
msgid "Radius for rounding the desklet's corners"
msgstr "Radius for rundingen på skrivebordsprogrammets hjørner"

#. settings-schema.json->hideDecorations->description
msgid "Hide decorations"
msgstr ""
Loading