aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_selector/conversation_selector.vala
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/conversation_selector/conversation_selector.vala')
-rw-r--r--main/src/ui/conversation_selector/conversation_selector.vala50
1 files changed, 22 insertions, 28 deletions
diff --git a/main/src/ui/conversation_selector/conversation_selector.vala b/main/src/ui/conversation_selector/conversation_selector.vala
index 2e262bf1..609e1be1 100644
--- a/main/src/ui/conversation_selector/conversation_selector.vala
+++ b/main/src/ui/conversation_selector/conversation_selector.vala
@@ -1,3 +1,4 @@
+using Gdk;
using Gee;
using Gtk;
@@ -18,7 +19,7 @@ public class ConversationSelector : Widget {
public ConversationSelector init(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
- list_box.insert_after(this, null);
+ list_box.set_parent(this);
this.layout_manager = new BinLayout();
stream_interactor.get_module(ConversationManager.IDENTITY).conversation_activated.connect(add_conversation);
@@ -36,7 +37,7 @@ public class ConversationSelector : Widget {
}
construct {
- get_style_context().add_class("sidebar");
+ add_css_class("sidebar");
list_box.set_header_func(header);
list_box.set_sort_func(sort);
@@ -78,36 +79,29 @@ public class ConversationSelector : Widget {
rows[conversation] = 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);
+
+ // Set up drag motion behaviour (select conversation after timeout)
+ DropControllerMotion drop_motion_controller = new DropControllerMotion();
+ uint drag_timeout = 0;
+ drop_motion_controller.motion.connect((x, y) => {
+ if (drag_timeout != 0) return;
+ drag_timeout = Timeout.add(200, () => {
+ conversation_selected(conversation);
+ drag_timeout = 0;
+ return false;
+ });
+ });
+ drop_motion_controller.leave.connect(() => {
+ if (drag_timeout != 0) {
+ Source.remove(drag_timeout);
+ drag_timeout = 0;
+ }
+ });
+ row.add_controller(drop_motion_controller);
}
list_box.invalidate_sort();
}
- /*public bool on_drag_motion(Widget widget, Gdk.DragContext context,
- int x, int y, uint time) {
- if (this.drag_timeout != null)
- return false;
- this.drag_timeout = Timeout.add(200, () => {
- if (widget.get_type().is_a(typeof(ConversationSelectorRow))) {
- ConversationSelectorRow row = widget as ConversationSelectorRow;
- conversation_selected(row.conversation);
- }
- this.drag_timeout = null;
- return false;
- });
- return false;
- }
-
- public void on_drag_leave(Widget widget, Gdk.DragContext context, uint time) {
- if (this.drag_timeout != null) {
- Source.remove(this.drag_timeout);
- this.drag_timeout = null;
- }
- }*/
-
private void select_fallback_conversation(Conversation conversation) {
if (list_box.get_selected_row() == rows[conversation]) {
int index = rows[conversation].get_index();