feat: Gtk.MessageDialog -> Adw.MessageDialog & enable them
This commit is contained in:
parent
031040c629
commit
67944b3b19
|
@ -215,21 +215,21 @@ namespace Tooth {
|
|||
dlg.destroy ();
|
||||
}
|
||||
|
||||
public bool question (string text, string? msg = null, Gtk.Window? win = main_window) {
|
||||
var dlg = new Gtk.MessageDialog (
|
||||
public Adw.MessageDialog question (string text, string? msg = null, Gtk.Window? win = main_window, string yes_label = _("Yes"), Adw.ResponseAppearance yes_appearence = Adw.ResponseAppearance.DEFAULT, string no_label = _("Cancel"), Adw.ResponseAppearance no_appearence = Adw.ResponseAppearance.DEFAULT) {
|
||||
var dlg = new Adw.MessageDialog (
|
||||
win,
|
||||
Gtk.DialogFlags.MODAL,
|
||||
Gtk.MessageType.QUESTION,
|
||||
Gtk.ButtonsType.YES_NO,
|
||||
null
|
||||
text,
|
||||
msg
|
||||
);
|
||||
dlg.text = text;
|
||||
dlg.secondary_text = msg;
|
||||
|
||||
dlg.add_response("no", no_label);
|
||||
dlg.set_response_appearance("no", no_appearence);
|
||||
|
||||
dlg.add_response("yes", yes_label);
|
||||
dlg.set_response_appearance("yes", yes_appearence);
|
||||
|
||||
dlg.transient_for = win;
|
||||
// var i = dlg.run ();
|
||||
dlg.destroy ();
|
||||
// return i == ResponseType.YES;
|
||||
return false;
|
||||
return dlg;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -187,13 +187,22 @@ public class Tooth.Dialogs.ListEditor: Adw.Window {
|
|||
[GtkCallback]
|
||||
void on_cancel_clicked () {
|
||||
if (dirty) {
|
||||
var yes = app.question (
|
||||
var dlg = app.question (
|
||||
_("Discard changes?"),
|
||||
_("You need to save the list if you want to keep them."),
|
||||
this
|
||||
this,
|
||||
_("Discard"),
|
||||
Adw.ResponseAppearance.DESTRUCTIVE
|
||||
);
|
||||
if (yes)
|
||||
destroy ();
|
||||
|
||||
dlg.response.connect(res => {
|
||||
if (res == "yes") {
|
||||
destroy ();
|
||||
}
|
||||
dlg.destroy();
|
||||
});
|
||||
|
||||
dlg.present ();
|
||||
}
|
||||
else
|
||||
destroy ();
|
||||
|
|
|
@ -29,14 +29,23 @@ public class Tooth.Views.Lists : Views.Timeline {
|
|||
void on_remove_clicked () {
|
||||
var remove = app.question (
|
||||
_("Delete \"%s\"?").printf (list.title),
|
||||
_("This action cannot be reverted.")
|
||||
_("This action cannot be reverted."),
|
||||
app.main_window,
|
||||
_("Discard"),
|
||||
Adw.ResponseAppearance.DESTRUCTIVE
|
||||
);
|
||||
if (remove) {
|
||||
new Request.DELETE (@"/api/v1/lists/$(list.id)")
|
||||
|
||||
remove.response.connect(res => {
|
||||
if (res == "yes") {
|
||||
new Request.DELETE (@"/api/v1/lists/$(list.id)")
|
||||
.with_account (accounts.active)
|
||||
.then (() => { this.destroy (); })
|
||||
.exec ();
|
||||
}
|
||||
}
|
||||
remove.destroy();
|
||||
});
|
||||
|
||||
remove.present ();
|
||||
}
|
||||
|
||||
public virtual signal void open () {
|
||||
|
|
|
@ -163,11 +163,24 @@ public class Tooth.Views.Profile : Views.Timeline {
|
|||
blocking_action.change_state.connect (v => {
|
||||
var block = v.get_boolean ();
|
||||
var q = block ? _("Block \"%s\"?") : _("Unblock \"%s\"?");
|
||||
var yes = app.question (q.printf (profile.handle));
|
||||
warning (q);
|
||||
|
||||
if (yes)
|
||||
rs.modify (block ? "block" : "unblock");
|
||||
var confirmed = app.question (
|
||||
q.printf (profile.handle),
|
||||
null,
|
||||
app.main_window,
|
||||
block ? _("Block") : _("Unblock"),
|
||||
Adw.ResponseAppearance.DESTRUCTIVE
|
||||
);
|
||||
|
||||
confirmed.response.connect(res => {
|
||||
if (res == "yes") {
|
||||
rs.modify (block ? "block" : "unblock");
|
||||
}
|
||||
confirmed.destroy();
|
||||
});
|
||||
|
||||
confirmed.present ();
|
||||
});
|
||||
actions.add_action (blocking_action);
|
||||
|
||||
|
@ -176,13 +189,17 @@ public class Tooth.Views.Profile : Views.Timeline {
|
|||
var block = v.get_boolean ();
|
||||
var q = block ? _("Block Entire \"%s\"?") : _("Unblock Entire \"%s\"?");
|
||||
warning (q);
|
||||
var yes = app.question (
|
||||
var confirmed = app.question (
|
||||
q.printf (profile.domain),
|
||||
_("Blocking a domain will:\n\n• Remove its public posts and notifications from your timelines\n• Remove its followers from your account\n• Prevent you from following its users")
|
||||
_("Blocking a domain will:\n\n• Remove its public posts and notifications from your timelines\n• Remove its followers from your account\n• Prevent you from following its users"),
|
||||
app.main_window,
|
||||
block ? _("Block") : _("Unblock"),
|
||||
Adw.ResponseAppearance.DESTRUCTIVE
|
||||
);
|
||||
|
||||
if (yes) {
|
||||
var req = new Request.POST ("/api/v1/domain_blocks")
|
||||
confirmed.response.connect(res => {
|
||||
if (res == "yes") {
|
||||
var req = new Request.POST ("/api/v1/domain_blocks")
|
||||
.with_account (accounts.active)
|
||||
.with_param ("domain", profile.domain)
|
||||
.then (() => {
|
||||
|
@ -191,7 +208,11 @@ public class Tooth.Views.Profile : Views.Timeline {
|
|||
|
||||
if (!block) req.method = "DELETE";
|
||||
req.exec ();
|
||||
}
|
||||
}
|
||||
confirmed.destroy();
|
||||
});
|
||||
|
||||
confirmed.present ();
|
||||
});
|
||||
actions.add_action (domain_blocking_action);
|
||||
|
||||
|
|
|
@ -189,17 +189,25 @@ public class Tooth.Views.Sidebar : Box, AccountHolder {
|
|||
var confirmed = app.question (
|
||||
_("Forget %s?".printf (account.handle)),
|
||||
_("This account will be removed from the application."),
|
||||
app.main_window
|
||||
app.main_window,
|
||||
_("Forget"),
|
||||
Adw.ResponseAppearance.DESTRUCTIVE
|
||||
);
|
||||
if (confirmed) {
|
||||
try {
|
||||
accounts.remove (account);
|
||||
|
||||
confirmed.response.connect(res => {
|
||||
if (res == "yes") {
|
||||
try {
|
||||
accounts.remove (account);
|
||||
}
|
||||
catch (Error e) {
|
||||
warning (e.message);
|
||||
app.inform (Gtk.MessageType.ERROR, _("Error"), e.message);
|
||||
}
|
||||
}
|
||||
catch (Error e) {
|
||||
warning (e.message);
|
||||
app.inform (Gtk.MessageType.ERROR, _("Error"), e.message);
|
||||
}
|
||||
}
|
||||
confirmed.destroy();
|
||||
});
|
||||
|
||||
confirmed.present ();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue