[geary/mjog/493-undo-send: 14/25] Clean up Composer.Widget header management
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/493-undo-send: 14/25] Clean up Composer.Widget header management
- Date: Tue, 12 Nov 2019 21:49:02 +0000 (UTC)
commit 1670a2a62a609b26369efee721a3aa6cdd390856
Author: Michael Gratton <mike vee net>
Date: Tue Nov 12 11:35:39 2019 +1100
Clean up Composer.Widget header management
Make the composer's containers completely manage attaching and detaching the
the composer's header, rather than mixing it between them. Remove a use
of the global `GearyApplication.instance` var.
src/client/composer/composer-box.vala | 9 ++++-----
src/client/composer/composer-embed.vala | 3 +++
src/client/composer/composer-widget.vala | 8 +++++---
src/client/composer/composer-window.vala | 3 +--
.../conversation-viewer/conversation-viewer.vala | 20 +++++++++++---------
5 files changed, 24 insertions(+), 19 deletions(-)
---
diff --git a/src/client/composer/composer-box.vala b/src/client/composer/composer-box.vala
index e6700afb..d2a455af 100644
--- a/src/client/composer/composer-box.vala
+++ b/src/client/composer/composer-box.vala
@@ -26,11 +26,11 @@ public class Composer.Box : Gtk.Frame, Container {
public signal void vanished();
- public Box(Widget composer) {
+ public Box(Widget composer, MainToolbar main_toolbar) {
this.composer = composer;
- this.composer.free_header();
- this.main_toolbar = GearyApplication.instance.controller.main_window.main_toolbar;
+ this.main_toolbar = main_toolbar;
+ this.main_toolbar.set_conversation_header(composer.header);
get_style_context().add_class("geary-composer-box");
this.halign = Gtk.Align.FILL;
@@ -38,15 +38,14 @@ public class Composer.Box : Gtk.Frame, Container {
this.vexpand_set = true;
add(this.composer);
- this.main_toolbar.set_conversation_header(composer.header);
show();
}
/** {@inheritDoc} */
public void close() {
- this.main_toolbar.remove_conversation_header(composer.header);
vanished();
+ this.main_toolbar.remove_conversation_header(composer.header);
remove(this.composer);
destroy();
}
diff --git a/src/client/composer/composer-embed.vala b/src/client/composer/composer-embed.vala
index ce70ee81..4d188c5e 100644
--- a/src/client/composer/composer-embed.vala
+++ b/src/client/composer/composer-embed.vala
@@ -36,6 +36,8 @@ public class Composer.Embed : Gtk.EventBox, Container {
Gtk.ScrolledWindow outer_scroller) {
this.referred = referred;
this.composer = composer;
+ this.composer.embed_header();
+
this.outer_scroller = outer_scroller;
get_style_context().add_class("geary-composer-embed");
@@ -53,6 +55,7 @@ public class Composer.Embed : Gtk.EventBox, Container {
disable_scroll_reroute(this);
vanished();
+ this.composer.free_header();
remove(this.composer);
destroy();
}
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 8b2b10a6..39dba06e 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -517,8 +517,6 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
this.context_menu_webkit_spelling = (Menu) builder.get_object("context_menu_webkit_spelling");
this.context_menu_webkit_text_entry = (Menu) builder.get_object("context_menu_webkit_text_entry");
- embed_header();
-
// Listen to account signals to update from menu.
this.application.engine.account_available.connect(
on_account_available
@@ -773,6 +771,10 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
this.is_closing = !enabled;
this.set_sensitive(enabled);
+ // Need to update this separately since it may be detached
+ // from the widget itself.
+ this.header.set_sensitive(enabled);
+
if (enabled) {
this.open_draft_manager_async.begin(null, null);
} else {
@@ -1324,7 +1326,7 @@ public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
}
internal void free_header() {
- if (this.header.parent != null)
+ if (this.header.parent != null) {
this.header.parent.remove(this.header);
}
diff --git a/src/client/composer/composer-window.vala b/src/client/composer/composer-window.vala
index e62ea1f5..33650e42 100644
--- a/src/client/composer/composer-window.vala
+++ b/src/client/composer/composer-window.vala
@@ -33,7 +33,6 @@ public class Composer.Window : Gtk.ApplicationWindow, Container {
public Window(Widget composer, GearyApplication application) {
Object(application: application, type: Gtk.WindowType.TOPLEVEL);
this.composer = composer;
- this.composer.header.detached();
// XXX Bug 764622
set_property("name", "GearyComposerWindow");
@@ -44,7 +43,6 @@ public class Composer.Window : Gtk.ApplicationWindow, Container {
composer.embed_header();
} else {
composer.header.show_close_button = true;
- composer.free_header();
set_titlebar(this.composer.header);
}
@@ -57,6 +55,7 @@ public class Composer.Window : Gtk.ApplicationWindow, Container {
/** {@inheritDoc} */
public new void close() {
+ this.composer.free_header();
remove(this.composer);
destroy();
}
diff --git a/src/client/conversation-viewer/conversation-viewer.vala
b/src/client/conversation-viewer/conversation-viewer.vala
index bf769704..fe4909ce 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -146,21 +146,23 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
* Puts the view into composer mode, showing a full-height composer.
*/
public void do_compose(Composer.Widget composer) {
- Composer.Box box = new Composer.Box(composer);
- this.current_composer = composer;
-
- // XXX move the ConversationListView management code into
- // MainWindow or somewhere more appropriate
MainWindow? main_window = get_toplevel() as MainWindow;
if (main_window != null) {
+ Composer.Box box = new Composer.Box(
+ composer, main_window.main_toolbar
+ );
+ this.current_composer = composer;
+
+ // XXX move the ConversationListView management code into
+ // MainWindow or somewhere more appropriate
ConversationListView conversation_list = main_window.conversation_list_view;
this.selection_while_composing = conversation_list.get_selected_conversations();
conversation_list.get_selection().unselect_all();
- }
- box.vanished.connect(on_composer_closed);
- this.composer_page.add(box);
- set_visible_child(this.composer_page);
+ box.vanished.connect(on_composer_closed);
+ this.composer_page.add(box);
+ set_visible_child(this.composer_page);
+ }
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]