aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_selector/conversation_selector.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2022-02-14 14:55:59 +0100
committerfiaxh <git@lightrise.org>2022-07-27 20:34:20 +0200
commit7e7dcedaf31ee35499875491c9f569c575d28435 (patch)
tree0c5fee2b28baf320775fbc92b3c252e97d9d054f /main/src/ui/conversation_selector/conversation_selector.vala
parentf25bfb00969a7e09996da2d5500e6718f4cc0148 (diff)
downloaddino-7e7dcedaf31ee35499875491c9f569c575d28435.tar.gz
dino-7e7dcedaf31ee35499875491c9f569c575d28435.zip
Port from GTK3 to GTK4
Diffstat (limited to 'main/src/ui/conversation_selector/conversation_selector.vala')
-rw-r--r--main/src/ui/conversation_selector/conversation_selector.vala54
1 files changed, 30 insertions, 24 deletions
diff --git a/main/src/ui/conversation_selector/conversation_selector.vala b/main/src/ui/conversation_selector/conversation_selector.vala
index 4c7e6b8d..2e262bf1 100644
--- a/main/src/ui/conversation_selector/conversation_selector.vala
+++ b/main/src/ui/conversation_selector/conversation_selector.vala
@@ -6,16 +6,20 @@ using Dino.Entities;
namespace Dino.Ui {
-public class ConversationSelector : ListBox {
+public class ConversationSelector : Widget {
public signal void conversation_selected(Conversation conversation);
+ ListBox list_box = new ListBox() { hexpand=true };
+
private StreamInteractor stream_interactor;
private uint? drag_timeout;
private HashMap<Conversation, ConversationSelectorRow> rows = new HashMap<Conversation, ConversationSelectorRow>(Conversation.hash_func, Conversation.equals_func);
public ConversationSelector init(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
+ list_box.insert_after(this, null);
+ this.layout_manager = new BinLayout();
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(add_conversation);
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_deactivated.connect(remove_conversation);
@@ -33,19 +37,21 @@ public class ConversationSelector : ListBox {
construct {
get_style_context().add_class("sidebar");
- set_header_func(header);
- set_sort_func(sort);
+ list_box.set_header_func(header);
+ list_box.set_sort_func(sort);
realize.connect(() => {
- ListBoxRow? first_row = get_row_at_index(0);
+ ListBoxRow? first_row = list_box.get_row_at_index(0);
if (first_row != null) {
- select_row(first_row);
+ list_box.select_row(first_row);
row_activated(first_row);
}
});
+
+ list_box.row_activated.connect(row_activated);
}
- public override void row_activated(ListBoxRow r) {
+ public void row_activated(ListBoxRow r) {
ConversationSelectorRow? row = r as ConversationSelectorRow;
if (row != null) {
conversation_selected(row.conversation);
@@ -56,12 +62,12 @@ public class ConversationSelector : ListBox {
if (!rows.has_key(conversation)) {
add_conversation(conversation);
}
- this.select_row(rows[conversation]);
+ list_box.select_row(rows[conversation]);
}
private void on_content_item_received(ContentItem item, Conversation conversation) {
if (rows.has_key(conversation)) {
- invalidate_sort();
+ list_box.invalidate_sort();
}
}
@@ -70,17 +76,17 @@ public class ConversationSelector : ListBox {
if (!rows.has_key(conversation)) {
row = new ConversationSelectorRow(stream_interactor, conversation);
rows[conversation] = row;
- add(row);
+ list_box.append(row);
row.main_revealer.set_reveal_child(true);
- drag_dest_set(row, DestDefaults.MOTION, null, Gdk.DragAction.COPY);
- drag_dest_set_track_motion(row, true);
- row.drag_motion.connect(this.on_drag_motion);
- row.drag_leave.connect(this.on_drag_leave);
+// drag_dest_set(row, DestDefaults.MOTION, null, Gdk.DragAction.COPY);
+// drag_dest_set_track_motion(row, true);
+// row.drag_motion.connect(this.on_drag_motion);
+// row.drag_leave.connect(this.on_drag_leave);
}
- invalidate_sort();
+ list_box.invalidate_sort();
}
- public bool on_drag_motion(Widget widget, Gdk.DragContext context,
+ /*public bool on_drag_motion(Widget widget, Gdk.DragContext context,
int x, int y, uint time) {
if (this.drag_timeout != null)
return false;
@@ -100,17 +106,17 @@ public class ConversationSelector : ListBox {
Source.remove(this.drag_timeout);
this.drag_timeout = null;
}
- }
+ }*/
private void select_fallback_conversation(Conversation conversation) {
- if (get_selected_row() == rows[conversation]) {
+ if (list_box.get_selected_row() == rows[conversation]) {
int index = rows[conversation].get_index();
- ListBoxRow? next_select_row = get_row_at_index(index + 1);
+ ListBoxRow? next_select_row = list_box.get_row_at_index(index + 1);
if (next_select_row == null) {
- next_select_row = get_row_at_index(index - 1);
+ next_select_row = list_box.get_row_at_index(index - 1);
}
if (next_select_row != null) {
- select_row(next_select_row);
+ list_box.select_row(next_select_row);
row_activated(next_select_row);
}
}
@@ -120,17 +126,17 @@ public class ConversationSelector : ListBox {
select_fallback_conversation(conversation);
if (rows.has_key(conversation)) {
yield rows[conversation].colapse();
- remove(rows[conversation]);
+ list_box.remove(rows[conversation]);
rows.unset(conversation);
}
}
public void loop_conversations(bool backwards) {
- int index = get_selected_row().get_index();
+ int index = list_box.get_selected_row().get_index();
int new_index = ((index + (backwards ? -1 : 1)) + rows.size) % rows.size;
- ListBoxRow? next_select_row = get_row_at_index(new_index);
+ ListBoxRow? next_select_row = list_box.get_row_at_index(new_index);
if (next_select_row != null) {
- select_row(next_select_row);
+ list_box.select_row(next_select_row);
row_activated(next_select_row);
}
}