better datetime tooltip

This commit is contained in:
sonichy
2025-09-10 21:31:15 +08:00
parent 8a68b93933
commit f7b56975cb
3 changed files with 23 additions and 13 deletions

View File

@@ -12,6 +12,13 @@ Display date and time on GNOME taskbar.
[Guide](https://gjs.guide/extensions/development/creating.html)
[Cinnamon_Applet](https://github.com/sonichy/Cinnamon_Applet)
[Calendar](https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/dateMenu.js#L901)
[Tooltip](https://gitlab.com/arcmenu/ArcMenu)
[Dialog](https://gjs.guide/extensions/topics/dialogs.html)
[Settings](https://gjs.guide/extensions/development/preferences.html)
[Settings](https://gjs.guide/guides/gtk/3/16-settings.html#title:-application-settings)
## GSettings schema must be compiled
`glib-compile-schemas schemas/`
## Debug
dbus-run-session -- gnome-shell --nested --wayland

View File

@@ -94,16 +94,19 @@ export default class DatetimeExtension extends Extension {
var date = new Date();
var h = date.getHours();
if (h < 10)
h = "0" + h;
h = '0' + h;
var m = date.getMinutes();
if (m < 10)
m = "0" + m;
m = '0' + m;
var day = date.getDay();
var weekday = ["日", "一", "二", "三", "四", "五", "六"];
var weekday1 = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
var weekday = ['日', '一', '二', '三', '四', '五', '六'];
var weekday1 = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
var text = h + ':' + m + '\n' + (date.getMonth() + 1) + '/' + date.getDate() + ' ' + weekday[day];
label.set_text(text);
var s = this._settings.get_string('memo');
if (s == '')
this.label_tooltip.text = date.toLocaleString() + ' ' + weekday1[day];
else
this.label_tooltip.text = date.toLocaleString() + ' ' + weekday1[day] + '\n' + s;
// Run as loop, not once.
return GLib.SOURCE_CONTINUE;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 KiB

After

Width:  |  Height:  |  Size: 140 KiB