allow date format in clock tooltip text #104
This commit is contained in:
@@ -105,6 +105,7 @@ SKELETON_PANEL: dict = {
|
|||||||
"clock": {
|
"clock": {
|
||||||
"format": "%a, %d. %b %H:%M:%S",
|
"format": "%a, %d. %b %H:%M:%S",
|
||||||
"tooltip-text": "",
|
"tooltip-text": "",
|
||||||
|
"tooltip-date-format": False,
|
||||||
"on-left-click": "",
|
"on-left-click": "",
|
||||||
"on-middle-click": "",
|
"on-middle-click": "",
|
||||||
"on-right-click": "",
|
"on-right-click": "",
|
||||||
@@ -1000,6 +1001,7 @@ class EditorWrapper(object):
|
|||||||
defaults = {
|
defaults = {
|
||||||
"format": "%a, %d. %b %H:%M:%S",
|
"format": "%a, %d. %b %H:%M:%S",
|
||||||
"tooltip-text": "",
|
"tooltip-text": "",
|
||||||
|
"tooltip-date-format": False,
|
||||||
"on-left-click": "",
|
"on-left-click": "",
|
||||||
"on-middle-click": "",
|
"on-middle-click": "",
|
||||||
"on-right-click": "",
|
"on-right-click": "",
|
||||||
@@ -1021,6 +1023,9 @@ class EditorWrapper(object):
|
|||||||
self.eb_tooltip_text = builder.get_object("tooltip-text")
|
self.eb_tooltip_text = builder.get_object("tooltip-text")
|
||||||
self.eb_tooltip_text.set_text(settings["tooltip-text"])
|
self.eb_tooltip_text.set_text(settings["tooltip-text"])
|
||||||
|
|
||||||
|
self.eb_tooltip_date = builder.get_object("tooltip-date")
|
||||||
|
self.eb_tooltip_date.set_active(settings["tooltip-date-format"])
|
||||||
|
|
||||||
self.eb_on_left_click = builder.get_object("on-left-click")
|
self.eb_on_left_click = builder.get_object("on-left-click")
|
||||||
self.eb_on_left_click.set_text(settings["on-left-click"])
|
self.eb_on_left_click.set_text(settings["on-left-click"])
|
||||||
|
|
||||||
@@ -1057,6 +1062,7 @@ class EditorWrapper(object):
|
|||||||
|
|
||||||
settings["format"] = self.eb_format.get_text()
|
settings["format"] = self.eb_format.get_text()
|
||||||
settings["tooltip-text"] = self.eb_tooltip_text.get_text()
|
settings["tooltip-text"] = self.eb_tooltip_text.get_text()
|
||||||
|
settings["tooltip-date-format"] = self.eb_tooltip_date.get_active()
|
||||||
settings["on-left-click"] = self.eb_on_left_click.get_text()
|
settings["on-left-click"] = self.eb_on_left_click.get_text()
|
||||||
settings["on-middle-click"] = self.eb_on_middle_click.get_text()
|
settings["on-middle-click"] = self.eb_on_middle_click.get_text()
|
||||||
settings["on-right-click"] = self.eb_on_right_click.get_text()
|
settings["on-right-click"] = self.eb_on_right_click.get_text()
|
||||||
|
@@ -250,6 +250,7 @@
|
|||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="tooltip-text" translatable="yes">See 'man date' for format details</property>
|
<property name="tooltip-text" translatable="yes">See 'man date' for format details</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
<property name="stock">gtk-about</property>
|
<property name="stock">gtk-about</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
@@ -258,7 +259,19 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<object class="GtkCheckButton" id="tooltip-date">
|
||||||
|
<property name="label" translatable="yes">date format</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can-focus">True</property>
|
||||||
|
<property name="receives-default">False</property>
|
||||||
|
<property name="tooltip-text" translatable="yes">Allow using 'date' format for tooltip text</property>
|
||||||
|
<property name="halign">start</property>
|
||||||
|
<property name="draw-indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left-attach">2</property>
|
||||||
|
<property name="top-attach">2</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
|
@@ -27,6 +27,7 @@ class Clock(Gtk.EventBox):
|
|||||||
check_key(settings, "root-css-name", "root-clock")
|
check_key(settings, "root-css-name", "root-clock")
|
||||||
check_key(settings, "css-name", "clock")
|
check_key(settings, "css-name", "clock")
|
||||||
check_key(settings, "tooltip-text", "")
|
check_key(settings, "tooltip-text", "")
|
||||||
|
check_key(settings, "tooltip-date-format", False)
|
||||||
check_key(settings, "on-left-click", "")
|
check_key(settings, "on-left-click", "")
|
||||||
check_key(settings, "on-right-click", "")
|
check_key(settings, "on-right-click", "")
|
||||||
check_key(settings, "on-middle-click", "")
|
check_key(settings, "on-middle-click", "")
|
||||||
@@ -59,8 +60,10 @@ class Clock(Gtk.EventBox):
|
|||||||
if settings["interval"] > 0:
|
if settings["interval"] > 0:
|
||||||
Gdk.threads_add_timeout_seconds(GLib.PRIORITY_LOW, settings["interval"], self.refresh)
|
Gdk.threads_add_timeout_seconds(GLib.PRIORITY_LOW, settings["interval"], self.refresh)
|
||||||
|
|
||||||
def update_widget(self, output):
|
def update_widget(self, output, tooltip=""):
|
||||||
self.label.set_text(output)
|
self.label.set_text(output)
|
||||||
|
if self.settings["tooltip-date-format"] and tooltip:
|
||||||
|
self.set_tooltip_text(tooltip)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -68,7 +71,8 @@ class Clock(Gtk.EventBox):
|
|||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
try:
|
try:
|
||||||
time = now.strftime(self.settings["format"])
|
time = now.strftime(self.settings["format"])
|
||||||
GLib.idle_add(self.update_widget, time)
|
tooltip = now.strftime(self.settings["tooltip-text"])
|
||||||
|
GLib.idle_add(self.update_widget, time, tooltip)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user