Use set-markup property for toasts

This commit is contained in:
kramo
2023-07-04 19:11:17 +02:00
parent 536e6792e7
commit df461421c3
3 changed files with 4 additions and 9 deletions

View File

@@ -2,7 +2,6 @@ using Gtk 4.0;
using Adw 1; using Adw 1;
template $PreferencesWindow : Adw.PreferencesWindow { template $PreferencesWindow : Adw.PreferencesWindow {
default-height: 500;
Adw.PreferencesPage general_page { Adw.PreferencesPage general_page {
name: "general"; name: "general";

View File

@@ -24,7 +24,7 @@ import subprocess
from pathlib import Path from pathlib import Path
from time import time from time import time
from gi.repository import Adw, GLib, GObject, Gtk from gi.repository import Adw, GObject, Gtk
from src import shared from src import shared
@@ -97,6 +97,7 @@ class Game(Gtk.Box):
def create_toast(self, title, action=None): def create_toast(self, title, action=None):
toast = Adw.Toast.new(title.format(self.name)) toast = Adw.Toast.new(title.format(self.name))
toast.set_priority(Adw.ToastPriority.HIGH) toast.set_priority(Adw.ToastPriority.HIGH)
toast.set_use_markup(False)
if action: if action:
toast.set_button_label(_("Undo")) toast.set_button_label(_("Undo"))
@@ -149,9 +150,7 @@ class Game(Gtk.Box):
if toast: if toast:
self.create_toast( self.create_toast(
# The variable is the title of the game # The variable is the title of the game
(_("{} hidden") if self.hidden else _("{} unhidden")).format( (_("{} hidden") if self.hidden else _("{} unhidden")).format(self.name),
GLib.markup_escape_text(self.name)
),
"hide", "hide",
) )
@@ -165,9 +164,7 @@ class Game(Gtk.Box):
self.win.navigation_view.pop() self.win.navigation_view.pop()
# The variable is the title of the game # The variable is the title of the game
self.create_toast( self.create_toast(_("{} removed").format(self.name), "remove")
_("{} removed").format(GLib.markup_escape_text(self.name)), "remove"
)
def set_loading(self, state): def set_loading(self, state):
self.loading += state self.loading += state

View File

@@ -127,7 +127,6 @@ class PreferencesWindow(Adw.PreferencesWindow):
if shared.PROFILE == "development": if shared.PROFILE == "development":
self.reset_action_row.set_visible(True) self.reset_action_row.set_visible(True)
self.reset_button.connect("clicked", self.reset_app) self.reset_button.connect("clicked", self.reset_app)
self.set_default_size(-1, 560)
# Sources settings # Sources settings
for source_class in ( for source_class in (