gtk: add split view navigation stack support
This commit is contained in:
@@ -5,6 +5,7 @@ public class MainWindow : Adw.ApplicationWindow
|
|||||||
{
|
{
|
||||||
private ConversationListView conversation_list_view;
|
private ConversationListView conversation_list_view;
|
||||||
private TranscriptContainerView transcript_container_view;
|
private TranscriptContainerView transcript_container_view;
|
||||||
|
private NavigationSplitView split_view;
|
||||||
|
|
||||||
private EventControllerMotion _motion_controller = new EventControllerMotion();
|
private EventControllerMotion _motion_controller = new EventControllerMotion();
|
||||||
private bool _motion_queued = false;
|
private bool _motion_queued = false;
|
||||||
@@ -12,10 +13,15 @@ public class MainWindow : Adw.ApplicationWindow
|
|||||||
public MainWindow () {
|
public MainWindow () {
|
||||||
Object (title: "Kordophone");
|
Object (title: "Kordophone");
|
||||||
|
|
||||||
var split_view = new NavigationSplitView ();
|
split_view = new NavigationSplitView ();
|
||||||
split_view.set_min_sidebar_width (400);
|
split_view.set_min_sidebar_width (400);
|
||||||
|
split_view.show_content = false;
|
||||||
set_content (split_view);
|
set_content (split_view);
|
||||||
|
|
||||||
|
var breakpoint = new Breakpoint (BreakpointCondition.parse ("max-width: 750sp"));
|
||||||
|
breakpoint.add_setter (split_view, "collapsed", true);
|
||||||
|
add_breakpoint (breakpoint);
|
||||||
|
|
||||||
conversation_list_view = new ConversationListView ();
|
conversation_list_view = new ConversationListView ();
|
||||||
conversation_list_view.conversation_selected.connect (conversation_selected);
|
conversation_list_view.conversation_selected.connect (conversation_selected);
|
||||||
conversation_list_view.conversation_activated.connect (open_conversation_in_new_window);
|
conversation_list_view.conversation_activated.connect (open_conversation_in_new_window);
|
||||||
@@ -100,6 +106,10 @@ public class MainWindow : Adw.ApplicationWindow
|
|||||||
GLib.warning("Failed to sync conversation: %s", e.message);
|
GLib.warning("Failed to sync conversation: %s", e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (split_view.collapsed) {
|
||||||
|
split_view.show_content = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ public class ConversationListView : Adw.Bin
|
|||||||
|
|
||||||
private string? selected_conversation_guid = null;
|
private string? selected_conversation_guid = null;
|
||||||
private bool selection_update_queued = false;
|
private bool selection_update_queued = false;
|
||||||
|
private bool suppress_row_selected = false;
|
||||||
|
|
||||||
public ConversationListView () {
|
public ConversationListView () {
|
||||||
container = new Adw.ToolbarView ();
|
container = new Adw.ToolbarView ();
|
||||||
@@ -29,6 +30,10 @@ public class ConversationListView : Adw.Bin
|
|||||||
scrolled_window.set_child (list_box);
|
scrolled_window.set_child (list_box);
|
||||||
|
|
||||||
list_box.row_selected.connect ((row) => {
|
list_box.row_selected.connect ((row) => {
|
||||||
|
if (suppress_row_selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var conversation_row = (ConversationRow?) row;
|
var conversation_row = (ConversationRow?) row;
|
||||||
if (conversation_row != null) {
|
if (conversation_row != null) {
|
||||||
selected_conversation_guid = conversation_row.conversation.guid;
|
selected_conversation_guid = conversation_row.conversation.guid;
|
||||||
@@ -112,7 +117,9 @@ public class ConversationListView : Adw.Bin
|
|||||||
if (conversation.guid == selected_conversation_guid) {
|
if (conversation.guid == selected_conversation_guid) {
|
||||||
var row = list_box.get_row_at_index((int)i);
|
var row = list_box.get_row_at_index((int)i);
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
|
suppress_row_selected = true;
|
||||||
list_box.select_row(row);
|
list_box.select_row(row);
|
||||||
|
suppress_row_selected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,4 +130,4 @@ public class ConversationListView : Adw.Bin
|
|||||||
Conversation conversation = (Conversation) item;
|
Conversation conversation = (Conversation) item;
|
||||||
return new ConversationRow (conversation);
|
return new ConversationRow (conversation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user