LonelyMachines

Timelet Gotham theme

Nov 24th, 2024
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 KB | Fixit | 0 0
  1. /*
  2. * A themeable desklet that shows the time.
  3. *
  4. * Copyright (C) 2022 Gobinath
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http:*www.gnu.org/licenses/>.
  17. */
  18.  
  19. // Import dependencies
  20. const St = imports.gi.St;
  21. const GLib = imports.gi.GLib;
  22. imports.searchPath.unshift(GLib.get_home_dir() + "/.local/share/cinnamon/desklets/[email protected]/themes");
  23. const Theme = imports.theme.Theme;
  24.  
  25. /**
  26. * Gotham theme class.
  27. */
  28. var GothamTheme = class GothamTheme extends Theme {
  29.  
  30. constructor(config) {
  31. super(config);
  32. }
  33.  
  34. getWidget() {
  35. this._clockContainer = new St.BoxLayout({ vertical: false });
  36. this._timeContainer = new St.BoxLayout({ vertical: false });
  37. this._dateParentContainer = new St.BoxLayout({ vertical: true, y_align: St.Align.END });
  38. this._dateContainer = new St.BoxLayout({ vertical: false });
  39.  
  40. this._time = this.createLabel("Bookerly", 80, "right");
  41. this._weekday = this.createLabel("Bookerly", 40, "left");
  42. this._date = this.createLabel("Bookerly", 20, "left", "#fca903");
  43. this._month_year = this.createLabel("Bookerly", 20, "right");
  44.  
  45. this._time.style += "margin-right: 10px;";
  46. this._date.style += "margin-right: 5px;";
  47.  
  48. this._timeContainer.add(this._time);
  49. this._dateContainer.add(this._date);
  50. this._dateContainer.add(this._month_year);
  51. this._dateParentContainer.add(this._dateContainer);
  52. this._dateParentContainer.add(this._weekday);
  53. this._clockContainer.add(this._timeContainer);
  54. this._clockContainer.add(this._dateParentContainer);
  55.  
  56. return this._clockContainer;
  57. }
  58.  
  59. setDateTime(date, locale) {
  60. let time = this.to2Digit(this.is24H() ? date.getHours() : this.to12Hours(date.getHours())) + ":" + this.to2Digit(date.getMinutes());
  61. this._time.set_text(time);
  62. this._weekday.set_text(this.formatDateTime(date, locale, { weekday: "long" }));
  63. this._date.set_text(this.formatDateTime(date, locale, { day: "2-digit" }));
  64. this._month_year.set_text(this.formatDateTime(date, locale, { month: "long", year: "numeric" }));
  65. }
  66.  
  67. }
Tags: Timelet
Advertisement
Add Comment
Please, Sign In to add comment