aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/conversation_selector
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/ui/conversation_selector')
-rw-r--r--main/src/ui/conversation_selector/conversation_selector.vala50
-rw-r--r--main/src/ui/conversation_selector/conversation_selector_row.vala14
2 files changed, 29 insertions, 35 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();
diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala
index f813ddfc..76cbabb3 100644
--- a/main/src/ui/conversation_selector/conversation_selector_row.vala
+++ b/main/src/ui/conversation_selector/conversation_selector_row.vala
@@ -229,11 +229,11 @@ public class ConversationSelectorRow : ListBoxRow {
unread_count_label.visible = true;
if (conversation.get_notification_setting(stream_interactor) == Conversation.NotifySetting.ON) {
- unread_count_label.get_style_context().add_class("unread-count-notify");
- unread_count_label.get_style_context().remove_class("unread-count");
+ unread_count_label.add_css_class("unread-count-notify");
+ unread_count_label.remove_css_class("unread-count");
} else {
- unread_count_label.get_style_context().add_class("unread-count");
- unread_count_label.get_style_context().remove_class("unread-count-notify");
+ unread_count_label.add_css_class("unread-count");
+ unread_count_label.remove_css_class("unread-count-notify");
}
name_label.attributes.insert(attr_weight_new(Weight.BOLD));
@@ -266,7 +266,7 @@ public class ConversationSelectorRow : ListBoxRow {
private Widget generate_tooltip() {
Grid grid = new Grid() { row_spacing=5, column_homogeneous=false, column_spacing=5, margin_start=7, margin_end=7, margin_top=7, margin_bottom=7 };
- Label label = new Label(conversation.counterpart.to_string()) { valign=Align.START, xalign=0, visible=true };
+ Label label = new Label(conversation.counterpart.to_string()) { valign=Align.START, xalign=0 };
label.attributes = new AttrList();
label.attributes.insert(attr_weight_new(Weight.BOLD));
@@ -284,7 +284,7 @@ public class ConversationSelectorRow : ListBoxRow {
stream_interactor.get_module(EntityInfo.IDENTITY).get_identity.begin(conversation.account, full_jid, (_, res) => {
Xep.ServiceDiscovery.Identity? identity = stream_interactor.get_module(EntityInfo.IDENTITY).get_identity.end(res);
- Image image = new Image() { hexpand=false, valign=Align.CENTER, visible=true };
+ Image image = new Image() { hexpand=false, valign=Align.CENTER };
if (identity != null && (identity.type_ == Xep.ServiceDiscovery.Identity.TYPE_PHONE || identity.type_ == Xep.ServiceDiscovery.Identity.TYPE_TABLET)) {
image.set_from_icon_name("dino-device-phone-symbolic");
} else {
@@ -322,7 +322,7 @@ public class ConversationSelectorRow : ListBoxRow {
sb.append(" <i>(").append(status).append(")</i>");
}
- Label resource = new Label(sb.str) { use_markup=true, hexpand=true, xalign=0, visible=true };
+ Label resource = new Label(sb.str) { use_markup=true, hexpand=true, xalign=0 };
grid.attach(image, 0, i_cache + 1, 1, 1);
grid.attach(resource, 1, i_cache + 1, 1, 1);