Skip to content

Commit

Permalink
[email protected]: Add Modern theme (#1259)
Browse files Browse the repository at this point in the history
  • Loading branch information
slgobinath authored Aug 17, 2024
1 parent eb1bdc9 commit f5b20d4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions [email protected]/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Install the fonts required by each theme for the best result.
- Gotham: [GE Inspira](https://fontsgeek.com/fonts/GE-Inspira-Regular)
- Jelly: [Roboto](https://fonts.google.com/specimen/Roboto)
- Metro: [Ubuntu](https://fonts.google.com/specimen/Ubuntu)
- Modern: [Anurati](https://font.download/font/anurati), [Ubuntu](https://fonts.google.com/specimen/Ubuntu)

## Development

Expand Down
60 changes: 60 additions & 0 deletions [email protected]/files/[email protected]/themes/modern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* A themeable desklet that shows the time.
*
* Copyright (C) 2024 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/>.
*/

// Import dependencies
const St = imports.gi.St;
const GLib = imports.gi.GLib;
imports.searchPath.unshift(GLib.get_home_dir() + "/.local/share/cinnamon/desklets/[email protected]/themes");
const Theme = imports.theme.Theme;

/**
* Modern theme class.
*/
var ModernTheme = class ModernTheme extends Theme {

constructor(config) {
super(config);
}

getWidget() {
this._clockContainer = new St.BoxLayout({ vertical: true });

this._weekday = this.createLabel("Anurati", 72, "center");
this._date = this.createLabel("Ubuntu", 20, "left");
this._time = this.createLabel("Ubuntu", 20, "right");

this._weekday.style += "font-weight: 300;";
this._date.style += "font-weight: 300; padding-top: 10px;";
this._time.style += "font-weight: 300; padding-top: 10px;";

this._clockContainer.add(this._weekday, { x_fill: false, x_align: St.Align.MIDDLE });
this._clockContainer.add(this._date, { x_fill: false, x_align: St.Align.MIDDLE });
this._clockContainer.add(this._time, { x_fill: false, x_align: St.Align.MIDDLE });
return this._clockContainer;
}

setDateTime(date, locale) {
let time = this.to2Digit(this.is24H() ? date.getHours() : this.to12Hours(date.getHours())) + ":" + this.to2Digit(date.getMinutes());
if (!this.is24H()) {
time += " " + this.toPeriod(date.getHours());
}
this._weekday.set_text(this.formatDateTime(date, locale, { weekday: "long" }).toUpperCase());
this._date.set_text(this.formatDateTime(date, locale, { day: "2-digit", month: "short", year: "numeric" }));
this._time.set_text("- " + time + " -");
}
}
5 changes: 4 additions & 1 deletion [email protected]/files/[email protected]/themes/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const FlairTheme = imports.flair.FlairTheme;
const GothamTheme = imports.gotham.GothamTheme;
const JellyTheme = imports.jelly.JellyTheme;
const MetroTheme = imports.metro.MetroTheme;
const ModernTheme = imports.modern.ModernTheme;

/**
* A factory class acts as a theme register.
Expand All @@ -41,7 +42,7 @@ var Themes = class Themes {
* @returns Return the list of registered theme names.
*/
static getThemeNames() {
return ["Digital", "Flair", "Gotham", "Jelly", "Metro"];
return ["Digital", "Flair", "Gotham", "Jelly", "Metro", "Modern"];
}

/**
Expand All @@ -61,6 +62,8 @@ var Themes = class Themes {
return new JellyTheme(config);
} else if (themeName == "Metro") {
return new MetroTheme(config);
} else if (themeName == "Modern") {
return new ModernTheme(config);
}
}
}
Binary file modified [email protected]/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f5b20d4

Please sign in to comment.