diff --git a/nwg_panel/config.py b/nwg_panel/config.py index 9ca601d..d2528c5 100644 --- a/nwg_panel/config.py +++ b/nwg_panel/config.py @@ -105,6 +105,7 @@ SKELETON_PANEL: dict = { "clock": { "format": "%a, %d. %b %H:%M:%S", "tooltip-text": "", + "tooltip-date-format": False, "on-left-click": "", "on-middle-click": "", "on-right-click": "", @@ -1000,6 +1001,7 @@ class EditorWrapper(object): defaults = { "format": "%a, %d. %b %H:%M:%S", "tooltip-text": "", + "tooltip-date-format": False, "on-left-click": "", "on-middle-click": "", "on-right-click": "", @@ -1021,6 +1023,9 @@ class EditorWrapper(object): self.eb_tooltip_text = builder.get_object("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.set_text(settings["on-left-click"]) @@ -1057,6 +1062,7 @@ class EditorWrapper(object): settings["format"] = self.eb_format.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-middle-click"] = self.eb_on_middle_click.get_text() settings["on-right-click"] = self.eb_on_right_click.get_text() diff --git a/nwg_panel/glade/config_clock.glade b/nwg_panel/glade/config_clock.glade index 9b6b1ff..3a36641 100644 --- a/nwg_panel/glade/config_clock.glade +++ b/nwg_panel/glade/config_clock.glade @@ -250,6 +250,7 @@ True False See 'man date' for format details + start gtk-about @@ -258,7 +259,19 @@ - + + date format + True + True + False + Allow using 'date' format for tooltip text + start + True + + + 2 + 2 + diff --git a/nwg_panel/modules/clock.py b/nwg_panel/modules/clock.py index 69fa0c5..4abe794 100644 --- a/nwg_panel/modules/clock.py +++ b/nwg_panel/modules/clock.py @@ -27,6 +27,7 @@ class Clock(Gtk.EventBox): check_key(settings, "root-css-name", "root-clock") check_key(settings, "css-name", "clock") check_key(settings, "tooltip-text", "") + check_key(settings, "tooltip-date-format", False) check_key(settings, "on-left-click", "") check_key(settings, "on-right-click", "") check_key(settings, "on-middle-click", "") @@ -59,8 +60,10 @@ class Clock(Gtk.EventBox): if settings["interval"] > 0: 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) + if self.settings["tooltip-date-format"] and tooltip: + self.set_tooltip_text(tooltip) return False @@ -68,7 +71,8 @@ class Clock(Gtk.EventBox): now = datetime.now() try: 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: print(e)