From 35c94b4828a8c1e9089f48c7941f42dfdd9ede18 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 15 Aug 2024 12:29:33 +0200 Subject: [PATCH] Use Adw.AlertDialog for delete confirmation --- melon/playlist/__init__.py | 62 +++++++++------------------ melon/widgets/preferencerow.py | 60 ++++++++++---------------- po/de.po | 77 +++++++++++++++++++--------------- po/fa.po | 69 +++++++++++++++--------------- po/melon.pot | 47 +++++++-------------- po/nl.po | 77 +++++++++++++++++++--------------- 6 files changed, 180 insertions(+), 212 deletions(-) diff --git a/melon/playlist/__init__.py b/melon/playlist/__init__.py index f28b1f7..3d35672 100644 --- a/melon/playlist/__init__.py +++ b/melon/playlist/__init__.py @@ -286,50 +286,28 @@ class LocalPlaylistScreen(Adw.NavigationPage): # close edit dialog self.edit_diag.hide() # show delete confirmation dialog - self.dlt_diag = SimpleDialog() - self.dlt_diag.set_title(_("Delete Playlist")) - - info = Adw.PreferencesGroup() - info.set_title(_("Do you really want to delete this playlist?")) - info.set_description(_("This cannot be undone")) - self.dlt_diag.set_widget(info) - - bottom_bar = Gtk.Box() - btn_cancel = IconButton( - _("Cancel"), - "process-stop-symbolic", - tooltip=_("Do not delete the playlist"), + self.dlt_diag = Adw.AlertDialog.new( + _("Delete Playlist?"), + _("Do you really want to delete this playlist? This can not be undone."), ) - btn_confirm = IconButton( - _("Delete"), "list-add-symbolic", tooltip=_("Delete this playlist") + self.dlt_diag.add_response("cancel", _("Cancel")) + self.dlt_diag.set_response_appearance("cancel", Adw.ResponseAppearance.DEFAULT) + self.dlt_diag.add_response("delete", _("Delete")) + self.dlt_diag.set_response_appearance( + "delete", Adw.ResponseAppearance.DESTRUCTIVE ) - btn_confirm.connect("clicked", lambda _: self.delete()) - btn_cancel.connect("clicked", lambda _: self.dlt_diag.hide()) - padding = 12 - btn_confirm.set_vexpand(True) - btn_confirm.set_hexpand(True) - btn_confirm.set_margin_end(padding) - btn_confirm.set_margin_start(padding / 2) - btn_confirm.set_margin_top(padding) - btn_confirm.set_margin_bottom(padding) - btn_cancel.set_vexpand(True) - btn_cancel.set_hexpand(True) - btn_cancel.set_margin_start(padding) - btn_cancel.set_margin_end(padding / 2) - btn_cancel.set_margin_top(padding) - btn_cancel.set_margin_bottom(padding) - bottom_bar.append(btn_cancel) - bottom_bar.append(btn_confirm) - self.dlt_diag.toolbar_view.add_bottom_bar(bottom_bar) + self.dlt_diag.set_default_response("cancel") + self.dlt_diag.set_close_response("cancel") - self.dlt_diag.show(self) + self.dlt_diag.connect("response", self.on_delete_action) + self.dlt_diag.present(self) - def delete(self): - # make sure that this widget does not receive an update notification - self.unregister() - # go home and delete afterwards - # so that the reload/callback doesn't trigger - self.activate_action("win.home", None) - ensure_delete_local_playlist(self.playlist.id) - self.dlt_diag.hide() + def on_delete_action(self, w, action): + if action == "delete": + # make sure that this widget does not receive an update notification + self.unregister() + # go home and delete afterwards + # so that the reload/callback doesn't trigger + self.activate_action("win.home", None) + ensure_delete_local_playlist(self.playlist.id) diff --git a/melon/widgets/preferencerow.py b/melon/widgets/preferencerow.py index e7c051a..1298549 100644 --- a/melon/widgets/preferencerow.py +++ b/melon/widgets/preferencerow.py @@ -210,46 +210,30 @@ class MultiRow(Adw.PreferencesRow): diag.show(self) def confirm_delete(self, w, item: str, counter: int): - diag = SimpleDialog() - diag.set_title(_("Delete")) - # preview prferences group - preview = Adw.PreferencesGroup() - preview.set_title(_("Do you really want to delete this item?")) - preview.set_description(_("You won't be able to restore it afterwards")) - row = Adw.ActionRow() - row.set_title(item) - preview.add(row) - diag.set_widget(preview) - # place button bar in toolbar - bottom_bar = Gtk.Box() - btn_cancel = IconButton( - _("Cancel"), "process-stop-symbolic", tooltip=_("Do not remove item") - ) - btn_confirm = IconButton( - _("Delete"), "list-add-symbolic", tooltip=_("Remove item from list") + # show delete confirmation dialog + self.dlt_diag = Adw.AlertDialog.new( + _("Delete Item?"), + _( + "Do you really want to delete this item? You won't be able to restore it afterwards" + ), ) - btn_confirm.connect( - "clicked", - lambda _: many(self.values.pop(counter), self.notify(), diag.hide()), + self.dlt_diag.add_response("cancel", _("Cancel")) + self.dlt_diag.set_response_appearance("cancel", Adw.ResponseAppearance.DEFAULT) + self.dlt_diag.add_response("delete", _("Delete")) + self.dlt_diag.set_response_appearance( + "delete", Adw.ResponseAppearance.DESTRUCTIVE ) - btn_cancel.connect("clicked", lambda x: diag.hide()) - padding = 12 - btn_confirm.set_vexpand(True) - btn_confirm.set_hexpand(True) - btn_confirm.set_margin_end(padding) - btn_confirm.set_margin_start(padding / 2) - btn_confirm.set_margin_top(padding) - btn_confirm.set_margin_bottom(padding) - btn_cancel.set_vexpand(True) - btn_cancel.set_hexpand(True) - btn_cancel.set_margin_start(padding) - btn_cancel.set_margin_end(padding / 2) - btn_cancel.set_margin_top(padding) - btn_cancel.set_margin_bottom(padding) - bottom_bar.append(btn_cancel) - bottom_bar.append(btn_confirm) - diag.toolbar_view.add_bottom_bar(bottom_bar) - diag.show(self) + + self.dlt_diag.set_default_response("cancel") + self.dlt_diag.set_close_response("cancel") + + self.dlt_diag.connect("response", pass_me(self.on_delete_action, counter)) + self.dlt_diag.present(self) + + def on_delete_action(self, w, action, counter): + if action == "delete": + self.values.pop(counter) + self.notify() def move_up(self, _, item: str, counter: int): val = self.values.pop(counter) diff --git a/po/de.po b/po/de.po index 2cfc1b4..0075b68 100644 --- a/po/de.po +++ b/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Melon 0.1.2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-15 09:53+0200\n" +"POT-Creation-Date: 2024-08-15 12:29+0200\n" "PO-Revision-Date: 2024-04-20 14:18+0000\n" "Last-Translator: hurzelchen \n" @@ -482,7 +482,7 @@ msgid "Change playlist title and description. (Closes the dialog)" msgstr "" "Titel und Beschreibung der Wiedergabeliste ändern. (Schließt den Dialog)" -#: ../melon/playlist/__init__.py:244 ../melon/playlist/__init__.py:290 +#: ../melon/playlist/__init__.py:244 msgid "Delete Playlist" msgstr "Wiedergabeliste löschen" @@ -500,34 +500,25 @@ msgstr "Schließen" msgid "Close without changing anything" msgstr "" -#: ../melon/playlist/__init__.py:293 -msgid "Do you really want to delete this playlist?" -msgstr "Möchtest du diese Wiedergabeliste wirklich löschen?" +#: ../melon/playlist/__init__.py:290 +msgid "Delete Playlist?" +msgstr "" -#: ../melon/playlist/__init__.py:294 -msgid "This cannot be undone" -msgstr "Dies kann nicht rückgängig gemacht werden" +#: ../melon/playlist/__init__.py:291 +msgid "Do you really want to delete this playlist? This can not be undone." +msgstr "" -#: ../melon/playlist/__init__.py:299 ../melon/playlist/create.py:54 +#: ../melon/playlist/__init__.py:293 ../melon/playlist/create.py:54 #: ../melon/playlist/create.py:109 ../melon/playlist/pick.py:88 #: ../melon/playlist/pick.py:126 ../melon/widgets/preferencerow.py:181 -#: ../melon/widgets/preferencerow.py:226 +#: ../melon/widgets/preferencerow.py:220 msgid "Cancel" msgstr "Abbruch" -#: ../melon/playlist/__init__.py:301 -msgid "Do not delete the playlist" -msgstr "Wiedergabeliste nicht löschen" - -#: ../melon/playlist/__init__.py:304 ../melon/widgets/preferencerow.py:214 -#: ../melon/widgets/preferencerow.py:229 +#: ../melon/playlist/__init__.py:295 ../melon/widgets/preferencerow.py:222 msgid "Delete" msgstr "Löschen" -#: ../melon/playlist/__init__.py:304 -msgid "Delete this playlist" -msgstr "Diese Wiedergabeliste löschen" - #: ../melon/playlist/create.py:25 ../melon/playlist/pick.py:35 msgid "Video" msgstr "Video" @@ -846,25 +837,43 @@ msgstr "Gibt den neuen Wert hier ein" msgid "Value" msgstr "Wert" +#: ../melon/widgets/preferencerow.py:215 +msgid "Delete Item?" +msgstr "" + #: ../melon/widgets/preferencerow.py:217 -msgid "Do you really want to delete this item?" -msgstr "Möchtest du den Eintrag wirklich löschen?" +msgid "" +"Do you really want to delete this item? You won't be able to restore it " +"afterwards" +msgstr "" -#: ../melon/widgets/preferencerow.py:218 -msgid "You won't be able to restore it afterwards" -msgstr "Eine Wiederherstellung ist nicht möglich" +#: ../melon/window.py:93 +msgid "Stream videos on the go" +msgstr "Videos unterwegs streamen" -#: ../melon/widgets/preferencerow.py:226 -msgid "Do not remove item" -msgstr "Eintrag nicht entfernen" +#~ msgid "Do you really want to delete this playlist?" +#~ msgstr "Möchtest du diese Wiedergabeliste wirklich löschen?" -#: ../melon/widgets/preferencerow.py:229 -msgid "Remove item from list" -msgstr "Eintrag von der Liste entfernen" +#~ msgid "This cannot be undone" +#~ msgstr "Dies kann nicht rückgängig gemacht werden" -#: ../melon/window.py:94 -msgid "Stream videos on the go" -msgstr "Videos unterwegs streamen" +#~ msgid "Do not delete the playlist" +#~ msgstr "Wiedergabeliste nicht löschen" + +#~ msgid "Delete this playlist" +#~ msgstr "Diese Wiedergabeliste löschen" + +#~ msgid "Do you really want to delete this item?" +#~ msgstr "Möchtest du den Eintrag wirklich löschen?" + +#~ msgid "You won't be able to restore it afterwards" +#~ msgstr "Eine Wiederherstellung ist nicht möglich" + +#~ msgid "Do not remove item" +#~ msgstr "Eintrag nicht entfernen" + +#~ msgid "Remove item from list" +#~ msgstr "Eintrag von der Liste entfernen" #~ msgid ".m3u8 Player" #~ msgstr ".m3u8 Wiedergabeservice" diff --git a/po/fa.po b/po/fa.po index 08ee1d7..b94b78d 100644 --- a/po/fa.po +++ b/po/fa.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Melon 0.1.2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-15 09:53+0200\n" +"POT-Creation-Date: 2024-08-15 12:29+0200\n" "PO-Revision-Date: 2024-05-30 09:18+0000\n" "Last-Translator: sohrabbehdani \n" @@ -481,7 +481,7 @@ msgstr "ذخیره جزئیات" msgid "Change playlist title and description. (Closes the dialog)" msgstr "تغییر عنوان و توضیحات لیست پخش (این پنجره بسته می شود)" -#: ../melon/playlist/__init__.py:244 ../melon/playlist/__init__.py:290 +#: ../melon/playlist/__init__.py:244 msgid "Delete Playlist" msgstr "حذف لیست پخش" @@ -497,34 +497,25 @@ msgstr "بستن" msgid "Close without changing anything" msgstr "بستن بدون تغییر دادن چیزی" -#: ../melon/playlist/__init__.py:293 -msgid "Do you really want to delete this playlist?" -msgstr "آیا از حذف این لیست‌پخش اطمینان دارید؟" +#: ../melon/playlist/__init__.py:290 +msgid "Delete Playlist?" +msgstr "" -#: ../melon/playlist/__init__.py:294 -msgid "This cannot be undone" +#: ../melon/playlist/__init__.py:291 +msgid "Do you really want to delete this playlist? This can not be undone." msgstr "" -#: ../melon/playlist/__init__.py:299 ../melon/playlist/create.py:54 +#: ../melon/playlist/__init__.py:293 ../melon/playlist/create.py:54 #: ../melon/playlist/create.py:109 ../melon/playlist/pick.py:88 #: ../melon/playlist/pick.py:126 ../melon/widgets/preferencerow.py:181 -#: ../melon/widgets/preferencerow.py:226 +#: ../melon/widgets/preferencerow.py:220 msgid "Cancel" msgstr "لغو" -#: ../melon/playlist/__init__.py:301 -msgid "Do not delete the playlist" -msgstr "لیست‌پخش را حذف نکن." - -#: ../melon/playlist/__init__.py:304 ../melon/widgets/preferencerow.py:214 -#: ../melon/widgets/preferencerow.py:229 +#: ../melon/playlist/__init__.py:295 ../melon/widgets/preferencerow.py:222 msgid "Delete" msgstr "حذف" -#: ../melon/playlist/__init__.py:304 -msgid "Delete this playlist" -msgstr "حذف این لیست‌پخش" - #: ../melon/playlist/create.py:25 ../melon/playlist/pick.py:35 msgid "Video" msgstr "ویدیو" @@ -834,25 +825,37 @@ msgstr "مقادیر را اینجا وارد کنید." msgid "Value" msgstr "مقدار" -#: ../melon/widgets/preferencerow.py:217 -msgid "Do you really want to delete this item?" -msgstr "آیا از حذف این مورد اطمینان دارید؟" - -#: ../melon/widgets/preferencerow.py:218 -msgid "You won't be able to restore it afterwards" +#: ../melon/widgets/preferencerow.py:215 +msgid "Delete Item?" msgstr "" -#: ../melon/widgets/preferencerow.py:226 -msgid "Do not remove item" -msgstr "این مورد را حذف نکن." - -#: ../melon/widgets/preferencerow.py:229 -msgid "Remove item from list" -msgstr "حذف این مورد از لیست" +#: ../melon/widgets/preferencerow.py:217 +msgid "" +"Do you really want to delete this item? You won't be able to restore it " +"afterwards" +msgstr "" -#: ../melon/window.py:94 +#: ../melon/window.py:93 msgid "Stream videos on the go" msgstr "ویدیو‌هارا استریم کن" +#~ msgid "Do you really want to delete this playlist?" +#~ msgstr "آیا از حذف این لیست‌پخش اطمینان دارید؟" + +#~ msgid "Do not delete the playlist" +#~ msgstr "لیست‌پخش را حذف نکن." + +#~ msgid "Delete this playlist" +#~ msgstr "حذف این لیست‌پخش" + +#~ msgid "Do you really want to delete this item?" +#~ msgstr "آیا از حذف این مورد اطمینان دارید؟" + +#~ msgid "Do not remove item" +#~ msgstr "این مورد را حذف نکن." + +#~ msgid "Remove item from list" +#~ msgstr "حذف این مورد از لیست" + #~ msgid ".m3u8 Player" #~ msgstr "پخش کننده .m3u8" diff --git a/po/melon.pot b/po/melon.pot index 8969c0f..0bc6cd1 100644 --- a/po/melon.pot +++ b/po/melon.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: Melon 0.2.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-15 09:53+0200\n" +"POT-Creation-Date: 2024-08-15 12:29+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -466,7 +466,7 @@ msgstr "" msgid "Change playlist title and description. (Closes the dialog)" msgstr "" -#: ../melon/playlist/__init__.py:244 ../melon/playlist/__init__.py:290 +#: ../melon/playlist/__init__.py:244 msgid "Delete Playlist" msgstr "" @@ -482,34 +482,25 @@ msgstr "" msgid "Close without changing anything" msgstr "" -#: ../melon/playlist/__init__.py:293 -msgid "Do you really want to delete this playlist?" +#: ../melon/playlist/__init__.py:290 +msgid "Delete Playlist?" msgstr "" -#: ../melon/playlist/__init__.py:294 -msgid "This cannot be undone" +#: ../melon/playlist/__init__.py:291 +msgid "Do you really want to delete this playlist? This can not be undone." msgstr "" -#: ../melon/playlist/__init__.py:299 ../melon/playlist/create.py:54 +#: ../melon/playlist/__init__.py:293 ../melon/playlist/create.py:54 #: ../melon/playlist/create.py:109 ../melon/playlist/pick.py:88 #: ../melon/playlist/pick.py:126 ../melon/widgets/preferencerow.py:181 -#: ../melon/widgets/preferencerow.py:226 +#: ../melon/widgets/preferencerow.py:220 msgid "Cancel" msgstr "" -#: ../melon/playlist/__init__.py:301 -msgid "Do not delete the playlist" -msgstr "" - -#: ../melon/playlist/__init__.py:304 ../melon/widgets/preferencerow.py:214 -#: ../melon/widgets/preferencerow.py:229 +#: ../melon/playlist/__init__.py:295 ../melon/widgets/preferencerow.py:222 msgid "Delete" msgstr "" -#: ../melon/playlist/__init__.py:304 -msgid "Delete this playlist" -msgstr "" - #: ../melon/playlist/create.py:25 ../melon/playlist/pick.py:35 msgid "Video" msgstr "" @@ -806,22 +797,16 @@ msgstr "" msgid "Value" msgstr "" -#: ../melon/widgets/preferencerow.py:217 -msgid "Do you really want to delete this item?" +#: ../melon/widgets/preferencerow.py:215 +msgid "Delete Item?" msgstr "" -#: ../melon/widgets/preferencerow.py:218 -msgid "You won't be able to restore it afterwards" -msgstr "" - -#: ../melon/widgets/preferencerow.py:226 -msgid "Do not remove item" -msgstr "" - -#: ../melon/widgets/preferencerow.py:229 -msgid "Remove item from list" +#: ../melon/widgets/preferencerow.py:217 +msgid "" +"Do you really want to delete this item? You won't be able to restore it " +"afterwards" msgstr "" -#: ../melon/window.py:94 +#: ../melon/window.py:93 msgid "Stream videos on the go" msgstr "" diff --git a/po/nl.po b/po/nl.po index 549da92..dbc6c08 100644 --- a/po/nl.po +++ b/po/nl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Melon 0.2.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-08-15 09:53+0200\n" +"POT-Creation-Date: 2024-08-15 12:29+0200\n" "PO-Revision-Date: 2024-07-17 09:18+0000\n" "Last-Translator: Vistaus \n" "Language-Team: Dutch