mirror of
https://gitlab.gnome.org/World/tootle
synced 2025-02-08 23:58:45 +01:00
MainWindow: Fix unused view clean-up (Fix #261)
This commit is contained in:
parent
cc9404aabc
commit
af9c0dcffb
@ -11,9 +11,9 @@
|
|||||||
<object class="HdyDeck" id="deck">
|
<object class="HdyDeck" id="deck">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="transition_type">slide</property>
|
|
||||||
<property name="can_swipe_back">True</property>
|
<property name="can_swipe_back">True</property>
|
||||||
<property name="can_swipe_forward">True</property>
|
<signal name="notify::transition-running" handler="on_child_transition"/>
|
||||||
|
<signal name="notify::visible-child" handler="on_child_transition"/>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
@ -40,26 +40,18 @@ public class Tootle.Dialogs.MainWindow: Hdy.Window, ISavedWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public bool back () {
|
public bool back () {
|
||||||
var children = deck.get_children ();
|
deck.navigate (Hdy.NavigationDirection.BACK);
|
||||||
unowned var current = children.find (deck.visible_child);
|
|
||||||
if (current != null) {
|
|
||||||
unowned var prev = current.prev;
|
|
||||||
if (current.prev != null) {
|
|
||||||
deck.visible_child = prev.data;
|
|
||||||
(current.data as Views.Base).unused = true;
|
|
||||||
Timeout.add (deck.transition_duration, clean_unused_views);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool clean_unused_views () {
|
[GtkCallback]
|
||||||
deck.get_children ().foreach (c => {
|
void on_child_transition () {
|
||||||
var view = c as Views.Base;
|
if (deck.transition_running)
|
||||||
if (view != null && view.unused)
|
return;
|
||||||
view.destroy ();
|
|
||||||
});
|
Widget unused_child;
|
||||||
return Source.REMOVE;
|
while ((unused_child = deck.get_adjacent_child (Hdy.NavigationDirection.FORWARD)) != null)
|
||||||
|
unused_child.destroy ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool delete_event (Gdk.EventAny event) {
|
public override bool delete_event (Gdk.EventAny event) {
|
||||||
|
@ -10,7 +10,6 @@ public class Tootle.Views.Base : Box {
|
|||||||
public string label { get; set; default = ""; }
|
public string label { get; set; default = ""; }
|
||||||
public bool needs_attention { get; set; default = false; }
|
public bool needs_attention { get; set; default = false; }
|
||||||
public bool current { get; set; default = false; }
|
public bool current { get; set; default = false; }
|
||||||
public bool unused { get; set; default = false; }
|
|
||||||
public SimpleActionGroup? actions { get; set; }
|
public SimpleActionGroup? actions { get; set; }
|
||||||
|
|
||||||
public Container content { get; set; }
|
public Container content { get; set; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user