[geary/wip/765516-gtk-widget-conversation-viewer: 205/207] Ensure new embedded composers are scrolled into view when opened.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/765516-gtk-widget-conversation-viewer: 205/207] Ensure new embedded composers are scrolled into view when opened.
- Date: Tue, 4 Oct 2016 00:13:38 +0000 (UTC)
commit bb1a6c0c88daedf0ddb79120e37a2c57732ad6ee
Author: Michael James Gratton <mike vee net>
Date: Tue Sep 27 10:26:00 2016 +1000
Ensure new embedded composers are scrolled into view when opened.
* src/client/conversation-viewer/conversation-list-box.vala
(ConversationRow): Pull should_scroll machinery up from EmailRow
subclass so we can also use it for scrolling to ComposerRow.
(ConversationListBox::add_embedded_composer): Enable should_scroll for
composer rows, scroll to it when triggered. Remove existing,
non-functional attempt to focus the composer.
(ConversationListBox::scroll_to): Allow scrolling to any kind of
ConversationRow.
* src/client/composer/composer-embed.vala (ComposerEmbed): Remove unused
loaded signal.
src/client/composer/composer-embed.vala | 2 -
.../conversation-viewer/conversation-list-box.vala | 36 ++++++++++++-------
2 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/src/client/composer/composer-embed.vala b/src/client/composer/composer-embed.vala
index f11325e..ffb62b5 100644
--- a/src/client/composer/composer-embed.vala
+++ b/src/client/composer/composer-embed.vala
@@ -30,7 +30,6 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
private int min_height = MIN_EDITOR_HEIGHT;
- public signal void loaded();
public signal void vanished();
@@ -74,7 +73,6 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
}
Idle.add(() => {
recalc_height();
- loaded();
return false;
});
}
diff --git a/src/client/conversation-viewer/conversation-list-box.vala
b/src/client/conversation-viewer/conversation-list-box.vala
index f68e850..2398015 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -66,6 +66,12 @@ public class ConversationListBox : Gtk.ListBox {
}
+ // We can only scroll to a specific row once it has been
+ // allocated space. This signal allows the viewer to hook up
+ // to appropriate times to try to do that scroll.
+ public signal void should_scroll();
+
+
public ConversationRow(Geary.Email? email) {
this.email = email;
}
@@ -80,6 +86,12 @@ public class ConversationListBox : Gtk.ListBox {
// Not supported by default
}
+ // Enables firing the should_scroll signal when this row is
+ // allocated a size
+ public void enable_should_scroll() {
+ this.size_allocate.connect(on_size_allocate);
+ }
+
protected inline void set_style_context_class(string class_name, bool value) {
if (value) {
get_style_context().add_class(class_name);
@@ -88,6 +100,13 @@ public class ConversationListBox : Gtk.ListBox {
}
}
+ protected virtual void on_size_allocate() {
+ // Disable should_scroll so we don't keep on scrolling
+ // later, like when the window has been resized.
+ this.size_allocate.disconnect(on_size_allocate);
+ should_scroll();
+ }
+
}
@@ -116,12 +135,6 @@ public class ConversationListBox : Gtk.ListBox {
public ConversationEmail view { get; private set; }
- // We can only scroll to a specific row once it has been
- // allocated space. This signal allows the viewer to hook up
- // to appropriate times to try to do that scroll.
- public signal void should_scroll();
-
-
public EmailRow(ConversationEmail view) {
base(view.email);
this.view = view;
@@ -139,11 +152,7 @@ public class ConversationListBox : Gtk.ListBox {
update_row_expansion();
}
- public void enable_should_scroll() {
- this.size_allocate.connect(on_size_allocate);
- }
-
- private void on_size_allocate() {
+ protected override void on_size_allocate() {
// We need to wait the web view to load first, so that the
// message has a non-trivial height, and then wait for it
// to be reallocated, so that it picks up the web_view's
@@ -438,11 +447,12 @@ public class ConversationListBox : Gtk.ListBox {
ComposerRow row = new ComposerRow(embed);
row.show();
+ row.enable_should_scroll();
+ row.should_scroll.connect(() => { scroll_to(row); });
add(row);
update_last_row();
embed.composer.draft_id_changed.connect((id) => { this.draft_id = id; });
- embed.loaded.connect(() => { row.grab_focus(); });
embed.vanished.connect(() => {
this.draft_id = null;
remove(row);
@@ -765,7 +775,7 @@ public class ConversationListBox : Gtk.ListBox {
set_placeholder(spinner);
}
- private void scroll_to(EmailRow row) {
+ private void scroll_to(ConversationRow row) {
Gtk.Allocation? alloc = null;
row.get_allocation(out alloc);
int y = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]