[geary/wip/730682-refine-convo-list] Tune conversation list selection mode a bit.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/730682-refine-convo-list] Tune conversation list selection mode a bit.
- Date: Wed, 3 Jan 2018 09:02:56 +0000 (UTC)
commit b5cd158440d077152754aa15d91679b8f9ab7077
Author: Michael James Gratton <mike vee net>
Date: Wed Dec 27 00:23:58 2017 +1030
Tune conversation list selection mode a bit.
* src/client/conversation-list/conversation-list.vala
(ConversationListBox): Freeze selection when entering selection mode,
thaw it when leaving, so selecting a conversation in selection mode
seems a bit less heavyweight. If an evaporating conversation is the
last marked one, notify that all marked have evaporated.
* src/client/components/main-window.vala (MainWindow): Disable selection
mode if its marked conversations have evaporated so users don't
e.g. need to disable it after archiving some conversations. Show a
conversation if marked as well as if selected.
src/client/components/main-window.vala | 76 +++++++++++--------
.../conversation-list/conversation-list.vala | 13 +++-
2 files changed, 56 insertions(+), 33 deletions(-)
---
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index e43cb35..55ede0c 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -82,6 +82,7 @@ public class MainWindow : Gtk.ApplicationWindow {
this.conversation_list.conversation_selection_changed.connect(on_conversation_selection_changed);
this.conversation_list.conversation_activated.connect(on_conversation_activated);
this.conversation_list.item_marked.connect(on_conversation_item_marked);
+ this.conversation_list.marked_conversations_evaporated.connect(on_selection_mode_disabled);
this.conversation_list.selection_mode_enabled.connect(on_selection_mode_enabled);
this.conversation_list.visible_conversations_changed.connect(on_visible_conversations_changed);
@@ -345,11 +346,47 @@ public class MainWindow : Gtk.ApplicationWindow {
return (SimpleAction) lookup_action(name);
}
+ private void show_conversation(Geary.App.Conversation? target) {
+ Geary.App.Conversation? current = null;
+ ConversationListBox? listbox = this.conversation_viewer.current_list;
+ if (listbox != null) {
+ current = listbox.conversation;
+ }
+ SimpleAction find_action = get_action(
+ GearyController.ACTION_FIND_IN_CONVERSATION
+ );
+ if (target != null) {
+ if (target != current &&
+ !this.conversation_viewer.is_composer_visible) {
+ this.conversation_viewer.load_conversation.begin(
+ target,
+ this.application.config,
+ this.application.controller.avatar_session,
+ (obj, ret) => {
+ try {
+ this.conversation_viewer.load_conversation.end(ret);
+ this.application.controller.enable_message_buttons(true);
+ find_action.set_enabled(true);
+ } catch (Error err) {
+ debug("Unable to load conversation: %s",
+ err.message);
+ }
+ }
+ );
+ }
+ } else {
+ find_action.set_enabled(false);
+ this.application.controller.enable_message_buttons(false);
+ this.conversation_viewer.show_none_selected();
+ }
+ }
+
private void set_selection_mode_enabled(bool enabled) {
get_action(ACTION_SELECTION_MODE_DISABLE).set_enabled(enabled);
get_action(ACTION_SELECTION_MODE_ENABLE).set_enabled(!enabled);
this.main_toolbar.set_selection_mode_enabled(enabled);
this.conversation_list.set_selection_mode_enabled(enabled);
+ this.conversation_viewer.show_none_selected();
}
private void on_conversation_monitor_changed() {
@@ -412,6 +449,7 @@ public class MainWindow : Gtk.ApplicationWindow {
this.current_folder = folder;
update_headerbar();
+ set_selection_mode_enabled(false);
}
private void on_account_available(Geary.AccountInformation account) {
@@ -464,38 +502,7 @@ public class MainWindow : Gtk.ApplicationWindow {
}
private void on_conversation_selection_changed(Geary.App.Conversation? selection) {
- Geary.App.Conversation? current = null;
- ConversationListBox? listbox = this.conversation_viewer.current_list;
- if (listbox != null) {
- current = listbox.conversation;
- }
- SimpleAction find_action = get_action(
- GearyController.ACTION_FIND_IN_CONVERSATION
- );
- if (selection != null) {
- if (selection != current &&
- !this.conversation_viewer.is_composer_visible) {
- this.conversation_viewer.load_conversation.begin(
- selection,
- this.application.config,
- this.application.controller.avatar_session,
- (obj, ret) => {
- try {
- this.conversation_viewer.load_conversation.end(ret);
- this.application.controller.enable_message_buttons(true);
- find_action.set_enabled(true);
- } catch (Error err) {
- debug("Unable to load conversation: %s",
- err.message);
- }
- }
- );
- }
- } else {
- find_action.set_enabled(false);
- this.application.controller.enable_message_buttons(false);
- this.conversation_viewer.show_none_selected();
- }
+ show_conversation(selection);
}
private void on_conversation_activated(Geary.App.Conversation activated) {
@@ -513,6 +520,11 @@ public class MainWindow : Gtk.ApplicationWindow {
}
private void on_conversation_item_marked(ConversationListItem item, bool marked) {
+ if (marked) {
+ show_conversation(item.conversation);
+ } else {
+ this.conversation_viewer.show_none_selected();
+ }
this.main_toolbar.update_selection_count(
this.conversation_list.get_marked_items().size
);
diff --git a/src/client/conversation-list/conversation-list.vala
b/src/client/conversation-list/conversation-list.vala
index dd4b4b2..8c2f410 100644
--- a/src/client/conversation-list/conversation-list.vala
+++ b/src/client/conversation-list/conversation-list.vala
@@ -69,6 +69,11 @@ public class ConversationList : Gtk.ListBox {
public signal void selection_mode_enabled();
/**
+ * Fired when all marked conversations were removed from the folder.
+ */
+ public signal void marked_conversations_evaporated();
+
+ /**
* Fired when a list item was marked as selected in selection mode.
*/
public signal void item_marked(ConversationListItem item, bool marked);
@@ -238,7 +243,9 @@ public class ConversationList : Gtk.ListBox {
}
internal void set_selection_mode_enabled(bool enabled) {
- if (!enabled) {
+ if (enabled) {
+ freeze_selection();
+ } else {
// Call to_array here to get a copy of the value
// collection, since unmarking the items will cause the
// underlying map to be modified
@@ -246,6 +253,7 @@ public class ConversationList : Gtk.ListBox {
item.set_marked(false);
}
this.marked.clear();
+ thaw_selection();
}
this.is_selection_mode_enabled = enabled;
}
@@ -406,6 +414,9 @@ public class ConversationList : Gtk.ListBox {
foreach (Geary.App.Conversation convo in removed) {
this.marked.remove(convo);
}
+ if (this.marked.is_empty) {
+ marked_conversations_evaporated();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]