diff --git a/gramps/gui/glade/tipofday.glade b/gramps/gui/glade/tipofday.glade
index e468d71e040..6e310f8c104 100644
--- a/gramps/gui/glade/tipofday.glade
+++ b/gramps/gui/glade/tipofday.glade
@@ -2,7 +2,7 @@
-
diff --git a/gramps/gui/tipofday.py b/gramps/gui/tipofday.py
index 31e3f2751ce..1626868d6ab 100644
--- a/gramps/gui/tipofday.py
+++ b/gramps/gui/tipofday.py
@@ -36,6 +36,7 @@
# GTK/GNOME modules
#
# -------------------------------------------------------------------------
+from gi.repository import Gtk
# -------------------------------------------------------------------------
#
@@ -49,7 +50,6 @@
from gramps.gen.config import config
from .managedwindow import ManagedWindow
from .dialog import ErrorDialog
-from .glade import Glade
# -------------------------------------------------------------------------
@@ -57,27 +57,24 @@
# Tip Display class
#
# -------------------------------------------------------------------------
-class TipOfDay(ManagedWindow):
+@Gtk.Template(filename=os.path.join(os.path.dirname(__file__), "glade/tipofday.glade"))
+class TipOfDay(ManagedWindow, Gtk.Window):
+ __gtype_name__ = "TipOfDay"
+
+ title = Gtk.Template.Child()
+ tip = Gtk.Template.Child()
+ usetips = Gtk.Template.Child()
+ image = Gtk.Template.Child()
+
def __init__(self, uistate):
ManagedWindow.__init__(self, uistate, [], self)
+ Gtk.Window.__init__(self)
- xml = Glade()
- window = xml.toplevel
- self.set_window(
- window, xml.get_object("title"), _("Tip of the Day"), _("Tip of the Day")
- )
+ self.set_window(self, self.title, _("Tip of the Day"), _("Tip of the Day"))
self.setup_configs("interface.tipofday", 550, 350)
- self.tip = xml.get_object("tip")
- self.use = xml.get_object("usetips")
- self.use.set_active(config.get("behavior.use-tips"))
- image = xml.get_object("image")
- image.set_from_file(os.path.join(IMAGE_DIR, "splash.jpg"))
-
- next = xml.get_object("next")
- next.connect("clicked", self.next_tip_cb)
- close = xml.get_object("close")
- close.connect("clicked", self.close_cb)
+ self.usetips.set_active(config.get("behavior.use-tips"))
+ self.image.set_from_file(os.path.join(IMAGE_DIR, "splash.jpg"))
try:
tparser = TipParser()
@@ -106,17 +103,17 @@ def escape(self, text):
# Replace standalone > char
return text
+ @Gtk.Template.Callback()
def next_tip_cb(self, dummy=None):
tip_text = _(self.escape(self.tip_list[self.new_index[self.index]]))
- newtext = ""
- for line in tip_text.split("
"):
- newtext += line + "\n\n"
- self.tip.set_text(newtext[:-2])
+ newtext = "\n\n".join(tip_text.split("
"))
+ self.tip.set_text(newtext)
self.tip.set_use_markup(True)
self.index = (self.index + 1) % len(self.tip_list)
+ @Gtk.Template.Callback()
def close_cb(self, dummy=None):
- config.set("behavior.use-tips", self.use.get_active())
+ config.set("behavior.use-tips", self.usetips.get_active())
self.close()
def build_menu_names(self, obj):