Skip to content

Commit

Permalink
feat: get rid of weak ref
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Jul 9, 2024
1 parent fad09fa commit f1c8b09
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Dialogs/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ public class Tuba.Dialogs.MainWindow: Adw.ApplicationWindow, Saveable {
var content_base = navigation_view.visible_page.child as Views.Base;
if (content_base != null && content_base.last_widget != null && (content_base.last_widget as Gtk.Widget) != null)
content_base.last_widget.grab_focus ();
content_base.update_last_widget (true);
}

public bool back () {
Expand Down
6 changes: 3 additions & 3 deletions src/Views/Base.vala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Tuba.Views.Base : Adw.BreakpointBin {
public int badge_number { get; set; default = 0; }
public int uid { get; set; default = -1; }
protected SimpleActionGroup actions { get; set; default = new SimpleActionGroup (); }
public weak Gtk.Widget? last_widget { get; private set; default=null; }
public Gtk.Widget? last_widget { get; private set; default=null; }
public string empty_timeline_icon { get; set; default="tuba-background-app-ghost-symbolic"; }

private bool _show_back_button = true;
Expand Down Expand Up @@ -210,8 +210,8 @@ public class Tuba.Views.Base : Adw.BreakpointBin {
status_button.sensitive = true;
}

public void update_last_widget () {
this.last_widget = app.main_window.get_focus ();
public void update_last_widget (bool clear = false) {
this.last_widget = clear ? null : app.main_window.get_focus ();
// Alternative way to grab focus of label links
// Currently replaced by RichLabel's activate_link's
// grab_focus as it's more reliable for this use case
Expand Down

0 comments on commit f1c8b09

Please sign in to comment.