better datetime tooltip
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -94,17 +94,20 @@ 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');
|
||||
this.label_tooltip.text = date.toLocaleString() + ' ' + weekday1[day] + '\n' + s;
|
||||
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 |
Reference in New Issue
Block a user