Skip to content

Commit

Permalink
Manage accels for remaining dialogs and windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
toolstack committed Dec 31, 2024
1 parent ad22ce7 commit 2995763
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 4 deletions.
18 changes: 18 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,14 @@ namespace Tuba {
set_accels_for_action ("app.scroll-page-to-top", {});
}

public void enable_home_accel () {
set_accels_for_action ("app.scroll-page-to-top", {"Home"});
}

public void disable_home_accel () {
set_accels_for_action ("app.scroll-page-to-top", {});
}

private void on_proxy_change (bool recover = false) {
if (settings.proxy != "") {
try {
Expand Down Expand Up @@ -675,6 +683,11 @@ namespace Tuba {
// Static functions seem to avoid this peculiar behavior.
// dialog.translator_credits = Build.TRANSLATOR != " " ? Build.TRANSLATOR : null;
app.disable_window_accels ();
app.disable_nav_accels ();
dialog.closed.connect (on_about_closed);
dialog.present (main_window);
GLib.Idle.add (() => {
Expand All @@ -685,6 +698,11 @@ namespace Tuba {
});
}
public void on_about_closed () {
app.enable_window_accels ();
app.enable_nav_accels ();
}
public Adw.AlertDialog inform (string text, string? msg = null) {
var dlg = new Adw.AlertDialog (
text,
Expand Down
13 changes: 13 additions & 0 deletions src/Dialogs/NewAccount.vala
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,23 @@ public class Tuba.Dialogs.NewAccount: Adw.Window {
manual_auth_label.activate_link.connect (on_manual_auth);

reset ();

app.disable_window_accels ();
app.disable_nav_accels ();

this.close_request.connect (on_new_account_closed);

present ();
instance_entry.grab_focus ();
}

public bool on_new_account_closed () {
app.enable_window_accels ();
app.enable_nav_accels ();

return false;
}

private void add_toast (string content, uint timeout = 0) {
toast_overlay.add_toast (new Adw.Toast (content) {
timeout = timeout
Expand Down
5 changes: 5 additions & 0 deletions src/Dialogs/Preferences.vala
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog {
setup_notification_mutes ();
setup_filters ();
bind ();
app.disable_window_accels ();
app.disable_nav_accels ();
closed.connect (on_window_closed);
}

Expand Down Expand Up @@ -393,6 +395,9 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog {

if (settings.analytics) app.update_analytics.begin ();
app.update_contributors.begin ();

app.enable_window_accels ();
app.enable_nav_accels ();
}

protected class AnalyticsDialog : Adw.Dialog {
Expand Down
7 changes: 7 additions & 0 deletions src/Dialogs/ProfileEdit.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[GtkTemplate (ui = "/dev/geopjr/Tuba/ui/dialogs/profile_edit.ui")]
public class Tuba.Dialogs.ProfileEdit : Adw.Dialog {
~ProfileEdit () {
app.enable_window_accels ();
app.enable_nav_accels ();

debug (@"Destroying ProfileEdit for $(profile.handle)");
}

Expand Down Expand Up @@ -106,6 +109,10 @@ public class Tuba.Dialogs.ProfileEdit : Adw.Dialog {
cepbtn.visible = true;
bio_row.bind_property ("expanded", cepbtn, "sensitive", GLib.BindingFlags.SYNC_CREATE);
}

app.disable_window_accels ();
app.disable_nav_accels ();

}

protected void update_style_scheme () {
Expand Down
4 changes: 2 additions & 2 deletions src/Views/Lists.vala
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ public class Tuba.Views.Lists : Views.Timeline {
}

private void on_entry_focus_enter () {
app.disable_nav_accels ();
app.disable_home_accel ();
}

private void on_entry_focus_leave () {
app.enable_nav_accels ();
app.enable_home_accel ();
}

~Lists () {
Expand Down
4 changes: 2 additions & 2 deletions src/Views/Search.vala
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public class Tuba.Views.Search : Views.TabbedBase {
}

private void on_entry_focus_enter () {
app.disable_nav_accels ();
app.disable_home_accel ();
}

private void on_entry_focus_leave () {
app.enable_nav_accels ();
app.enable_home_accel ();
}

private void on_entry_activated () {
Expand Down

0 comments on commit 2995763

Please sign in to comment.