Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PreviewCard): don't remind me again option #666

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions data/dev.geopjr.Tuba.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
<key name="advanced-boost-dialog" type="b">
<default>false</default>
</key>
<key name="preview-card-reminder" type="b">
<default>true</default>
</key>
<key name="spellchecker-enabled" type="b">
<default>true</default>
</key>
Expand Down
26 changes: 24 additions & 2 deletions src/API/Status/PreviewCard.vala
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,36 @@ public class Tuba.API.PreviewCard : Entity, Widgetizable {
return new Widgets.PreviewCard (this);
}

private static int reminder_counter = 0;
public static void open_special_card (CardSpecialType card_special_type, string card_url) {
Gtk.CheckButton? reminder_checkbutton = null;
Adw.PreferencesGroup? reminder_pr = null;
if (reminder_counter >= 2) {
reminder_checkbutton = new Gtk.CheckButton () {
valign = Gtk.Align.CENTER
};
var reminder_row = new Adw.ActionRow () {
title = _("Don't remind me again"),
activatable = true,
activatable_widget = reminder_checkbutton
};
reminder_pr = new Adw.PreferencesGroup ();

reminder_row.add_prefix (reminder_checkbutton);
reminder_pr.add (reminder_row);
}

app.question.begin (
{card_special_type.to_dialog_title (), false},
{card_special_type.to_dialog_body (card_url), false},
app.main_window,
{ { _("Proceed"), Adw.ResponseAppearance.DESTRUCTIVE}, { _("Cancel"), Adw.ResponseAppearance.DEFAULT } },
false,
{ { _("Proceed"), Adw.ResponseAppearance.SUGGESTED}, { _("Cancel"), Adw.ResponseAppearance.DEFAULT } },
reminder_pr,
!settings.preview_card_reminder,
(obj, res) => {
if (reminder_counter < 2) reminder_counter++;
if (reminder_checkbutton != null) settings.preview_card_reminder = !reminder_checkbutton.active;

if (app.question.end (res)) {
if (card_special_type.open_special_card (card_url)) {
return;
Expand Down
5 changes: 5 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ namespace Tuba {
{ _("Yes"), Adw.ResponseAppearance.DEFAULT },
{ _("Cancel"), Adw.ResponseAppearance.DEFAULT }
},
Gtk.Widget? extra_child = null,
bool skip = false // skip the dialog, used for preferences to avoid duplicate code
) {
if (skip) return true;
Expand All @@ -523,6 +524,10 @@ namespace Tuba {

if (win != null)
dlg.transient_for = win;

if (extra_child != null)
dlg.extra_child = extra_child;

return (yield dlg.choose (null)) == "yes";
}

Expand Down
1 change: 1 addition & 0 deletions src/Dialogs/Composer/Dialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public class Tuba.Dialogs.Compose : Adw.Window {
{_("Your progress will be lost."), false},
this,
{ { _("Discard"), Adw.ResponseAppearance.DESTRUCTIVE }, { _("Cancel"), Adw.ResponseAppearance.DEFAULT } },
null,
false,
(obj, res) => {
if (app.question.end (res)) on_close ();
Expand Down
1 change: 1 addition & 0 deletions src/Services/Accounts/SecretAccountStore.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class Tuba.SecretAccountStore : AccountStore {
{@"$help_msg.", false},
app.add_account_window,
{ {"Read More", Adw.ResponseAppearance.SUGGESTED }, { "Close", Adw.ResponseAppearance.DEFAULT } },
null,
false,
(obj, res) => {
if (app.question.end (res)) Host.open_uri (wiki_page);
Expand Down
14 changes: 10 additions & 4 deletions src/Services/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class Tuba.Settings : GLib.Settings {
public bool use_blurhash { get; set; }
public bool group_push_notifications { get; set; }
public bool advanced_boost_dialog { get; set; }
public bool preview_card_reminder { get; set; }
public bool spellchecker_enabled { get; set; }

public string[] muted_notification_types { get; set; default = {}; }
Expand All @@ -47,25 +48,30 @@ public class Tuba.Settings : GLib.Settings {
"use-blurhash",
"group-push-notifications",
"advanced-boost-dialog",
"preview-card-reminder",
"spellchecker-enabled"
};

static string[] apply_instantly_keys = {
"work-in-background"
};

public Settings () {
Object (schema_id: Build.DOMAIN);

foreach (var key in keys_to_init) {
init (key);
}

init ("work-in-background", true);
foreach (var key in apply_instantly_keys) {
init (key);
}

changed.connect (on_changed);
}

string[] apply_instantly_keys = {};
void init (string key, bool apply_instantly = false) {
bind (key, this, key, SettingsBindFlags.DEFAULT);

if (apply_instantly) apply_instantly_keys += key;
}

void on_changed (string key) {
Expand Down
1 change: 1 addition & 0 deletions src/Views/Lists.vala
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class Tuba.Views.Lists : Views.Timeline {
{_("This action cannot be reverted."), false},
app.main_window,
{ { _("Delete"), Adw.ResponseAppearance.DESTRUCTIVE }, { _("Cancel"), Adw.ResponseAppearance.DEFAULT } },
null,
false,
(obj, res) => {
if (app.question.end (res)) {
Expand Down
2 changes: 2 additions & 0 deletions src/Views/Profile.vala
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public class Tuba.Views.Profile : Views.Timeline {
null,
app.main_window,
{ { block ? _("Block") : _("Unblock"), Adw.ResponseAppearance.DESTRUCTIVE }, { _("Cancel"), Adw.ResponseAppearance.DEFAULT } },
null,
false,
(obj, res) => {
if (app.question.end (res)) profile.rs.modify (block ? "block" : "unblock");
Expand All @@ -279,6 +280,7 @@ public class Tuba.Views.Profile : Views.Timeline {

app.main_window,
{ { block ? _("Block") : _("Unblock"), Adw.ResponseAppearance.DESTRUCTIVE }, { _("Cancel"), Adw.ResponseAppearance.DEFAULT } },
null,
false,
(obj, res) => {
if (app.question.end (res)) {
Expand Down
1 change: 1 addition & 0 deletions src/Views/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public class Tuba.Views.Sidebar : Gtk.Widget, AccountHolder {
{_("This account will be removed from the application."), false},
app.main_window,
{ { _("Forget"), Adw.ResponseAppearance.DESTRUCTIVE }, { _("Cancel"), Adw.ResponseAppearance.DEFAULT } },
null,
false,
(obj, res) => {
if (app.question.end (res)) {
Expand Down
1 change: 1 addition & 0 deletions src/Widgets/Status.vala
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@
null,
app.main_window,
{ { _("Delete"), Adw.ResponseAppearance.DESTRUCTIVE }, { _("Cancel"), Adw.ResponseAppearance.DEFAULT } },
null,
false,
(obj, res) => {
if (app.question.end (res)) {
Expand Down