client: Simplify main window outer leaflet state change handling

This commit is contained in:
Michael Gratton 2021-04-11 11:58:55 +10:00 committed by Michael James Gratton
parent 5aea0ad10f
commit dbb9cc35e8
2 changed files with 20 additions and 11 deletions

View file

@ -282,6 +282,18 @@ public class Application.MainWindow :
get; private set; default = null; get; private set; default = null;
} }
/** Specifies if the conversation list is currently displayed. */
public bool is_folder_list_shown {
get {
return (
(!this.outer_leaflet.folded ||
this.outer_leaflet.visible_child_name == INNER_LEAFLET) &&
(!this.inner_leaflet.folded ||
this.inner_leaflet.visible_child_name == FOLDER_LIST)
);
}
}
/** Specifies if the conversation list is currently displayed. */ /** Specifies if the conversation list is currently displayed. */
public bool is_conversation_list_shown { public bool is_conversation_list_shown {
get { get {
@ -2047,15 +2059,12 @@ public class Application.MainWindow :
} }
[GtkCallback] [GtkCallback]
private void on_outer_leaflet_visible_child_changed() { private void on_outer_leaflet_changed() {
if (this.outer_leaflet.child_transition_running) if (this.has_composer &&
return; this.outer_leaflet.folded &&
(this.is_folder_list_shown || this.is_conversation_list_shown)) {
if (this.outer_leaflet.visible_child_name == INNER_LEAFLET && close_composer(false, false);
this.outer_leaflet.folded) }
if (this.conversation_viewer.current_composer != null) {
this.conversation_viewer.current_composer.activate_close_action();
}
} }
private void on_offline_infobar_response() { private void on_offline_infobar_response() {

View file

@ -22,8 +22,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_swipe_back">True</property> <property name="can_swipe_back">True</property>
<property name="transition_type">over</property> <property name="transition_type">over</property>
<signal name="notify::visible-child" handler="on_outer_leaflet_visible_child_changed" swapped="no"/> <signal name="notify::folded" handler="on_outer_leaflet_changed" swapped="no"/>
<signal name="notify::child-transition-running" handler="on_outer_leaflet_visible_child_changed" swapped="no"/> <signal name="notify::visible-child" handler="on_outer_leaflet_changed" swapped="no"/>
<child> <child>
<object class="HdyLeaflet" id="inner_leaflet"> <object class="HdyLeaflet" id="inner_leaflet">
<property name="visible">True</property> <property name="visible">True</property>