application-main-window: add navigation via signle click on folder/conversation

Opening a conversation in a new window is currently disabled, because we
need a new key/button combination.
This commit is contained in:
Julian Sparber 2020-10-06 10:41:33 +02:00
parent 28a19775b8
commit 49823ec054
4 changed files with 33 additions and 0 deletions

View file

@ -1230,6 +1230,7 @@ public class Application.MainWindow :
this.folder_list.folder_selected.connect(on_folder_selected);
this.folder_list.move_conversation.connect(on_move_conversation);
this.folder_list.copy_conversation.connect(on_copy_conversation);
this.folder_list.folder_activated.connect(on_folder_activated);
this.folder_list_scrolled.add(this.folder_list);
// Conversation list
@ -2135,7 +2136,16 @@ public class Application.MainWindow :
}
}
private void on_folder_activated(Geary.Folder? folder) {
if (folder != null)
focus_next_pane();
}
private void on_conversation_activated(Geary.App.Conversation activated) {
if (main_leaflet.folded) {
focus_next_pane();
}
/* TODO: find correct UX for opening the conversation in a new window
if (this.selected_folder != null) {
if (this.selected_folder.used_as != DRAFTS) {
this.application.new_window.begin(
@ -2154,6 +2164,7 @@ public class Application.MainWindow :
);
}
}
*/
}
private void on_find_in_conversation_action() {

View file

@ -42,6 +42,7 @@ public class ConversationListView : Gtk.TreeView, Geary.BaseInterface {
base_ref();
set_show_expanders(false);
set_headers_visible(false);
set_activate_on_single_click(true);
this.config = config;

View file

@ -16,6 +16,7 @@ public class FolderList.Tree : Sidebar.Tree, Geary.BaseInterface {
public signal void folder_selected(Geary.Folder? folder);
public signal void folder_activated(Geary.Folder? folder);
public signal void copy_conversation(Geary.Folder folder);
public signal void move_conversation(Geary.Folder folder);
@ -30,7 +31,9 @@ public class FolderList.Tree : Sidebar.Tree, Geary.BaseInterface {
public Tree() {
base(TARGET_ENTRY_LIST, Gdk.DragAction.COPY | Gdk.DragAction.MOVE, drop_handler);
base_ref();
set_activate_on_single_click(true);
entry_selected.connect(on_entry_selected);
entry_activated.connect(on_entry_activated);
// GtkTreeView binds Ctrl+N to "move cursor to next". Not so interested in that, so we'll
// remove it.
@ -87,6 +90,13 @@ public class FolderList.Tree : Sidebar.Tree, Geary.BaseInterface {
}
}
private void on_entry_activated(Sidebar.SelectableEntry selectable) {
AbstractFolderEntry? entry = selectable as AbstractFolderEntry;
if (entry != null) {
folder_activated(entry.folder);
}
}
public void set_user_folders_root_name(Geary.Account account, string name) {
if (account_branches.has_key(account))
account_branches.get(account).user_folder_group.rename(name);

View file

@ -80,6 +80,8 @@ public class Sidebar.Tree : Gtk.TreeView {
public signal void entry_selected(Sidebar.SelectableEntry selectable);
public signal void entry_activated(Sidebar.SelectableEntry selectable);
public signal void selected_entry_removed(Sidebar.SelectableEntry removed);
public signal void branch_added(Sidebar.Branch branch);
@ -298,6 +300,15 @@ public class Sidebar.Tree : Gtk.TreeView {
return true;
}
public override void row_activated(Gtk.TreePath path, Gtk.TreeViewColumn column) {
EntryWrapper? wrapper = get_wrapper_at_path(path);
if (wrapper != null) {
Sidebar.SelectableEntry? selectable = wrapper.entry as Sidebar.SelectableEntry;
if (selectable != null)
entry_activated(selectable);
}
}
public override void cursor_changed() {
Gtk.TreePath? path = get_selected_path();
if (path == null) {