parent
cb3b19b01d
commit
75500dc767
|
@ -42,9 +42,10 @@ public class Conversation : Object {
|
||||||
|
|
||||||
public enum Setting { DEFAULT, ON, OFF }
|
public enum Setting { DEFAULT, ON, OFF }
|
||||||
public Setting send_typing { get; set; default = Setting.DEFAULT; }
|
public Setting send_typing { get; set; default = Setting.DEFAULT; }
|
||||||
|
|
||||||
public Setting send_marker { get; set; default = Setting.DEFAULT; }
|
public Setting send_marker { get; set; default = Setting.DEFAULT; }
|
||||||
|
|
||||||
|
public int pinned { get; set; default = 0; }
|
||||||
|
|
||||||
private Database? db;
|
private Database? db;
|
||||||
|
|
||||||
public Conversation(Jid jid, Account account, Type type) {
|
public Conversation(Jid jid, Account account, Type type) {
|
||||||
|
@ -74,6 +75,7 @@ public class Conversation : Object {
|
||||||
notify_setting = (NotifySetting) row[db.conversation.notification];
|
notify_setting = (NotifySetting) row[db.conversation.notification];
|
||||||
send_typing = (Setting) row[db.conversation.send_typing];
|
send_typing = (Setting) row[db.conversation.send_typing];
|
||||||
send_marker = (Setting) row[db.conversation.send_marker];
|
send_marker = (Setting) row[db.conversation.send_marker];
|
||||||
|
pinned = row[db.conversation.pinned];
|
||||||
|
|
||||||
notify.connect(on_update);
|
notify.connect(on_update);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +93,8 @@ public class Conversation : Object {
|
||||||
.value(db.conversation.active_last_changed, (long) active_last_changed.to_unix())
|
.value(db.conversation.active_last_changed, (long) active_last_changed.to_unix())
|
||||||
.value(db.conversation.notification, notify_setting)
|
.value(db.conversation.notification, notify_setting)
|
||||||
.value(db.conversation.send_typing, send_typing)
|
.value(db.conversation.send_typing, send_typing)
|
||||||
.value(db.conversation.send_marker, send_marker);
|
.value(db.conversation.send_marker, send_marker)
|
||||||
|
.value(db.conversation.pinned, pinned);
|
||||||
if (read_up_to != null) {
|
if (read_up_to != null) {
|
||||||
insert.value(db.conversation.read_up_to, read_up_to.id);
|
insert.value(db.conversation.read_up_to, read_up_to.id);
|
||||||
}
|
}
|
||||||
|
@ -197,6 +200,8 @@ public class Conversation : Object {
|
||||||
update.set(db.conversation.send_typing, send_typing); break;
|
update.set(db.conversation.send_typing, send_typing); break;
|
||||||
case "send-marker":
|
case "send-marker":
|
||||||
update.set(db.conversation.send_marker, send_marker); break;
|
update.set(db.conversation.send_marker, send_marker); break;
|
||||||
|
case "pinned":
|
||||||
|
update.set(db.conversation.pinned, pinned); break;
|
||||||
}
|
}
|
||||||
update.perform();
|
update.perform();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ using Dino.Entities;
|
||||||
namespace Dino {
|
namespace Dino {
|
||||||
|
|
||||||
public class Database : Qlite.Database {
|
public class Database : Qlite.Database {
|
||||||
private const int VERSION = 24;
|
private const int VERSION = 25;
|
||||||
|
|
||||||
public class AccountTable : Table {
|
public class AccountTable : Table {
|
||||||
public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true };
|
public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true };
|
||||||
|
@ -244,10 +244,11 @@ public class Database : Qlite.Database {
|
||||||
public Column<int> notification = new Column.Integer("notification") { min_version=3 };
|
public Column<int> notification = new Column.Integer("notification") { min_version=3 };
|
||||||
public Column<int> send_typing = new Column.Integer("send_typing") { min_version=3 };
|
public Column<int> send_typing = new Column.Integer("send_typing") { min_version=3 };
|
||||||
public Column<int> send_marker = new Column.Integer("send_marker") { min_version=3 };
|
public Column<int> send_marker = new Column.Integer("send_marker") { min_version=3 };
|
||||||
|
public Column<int> pinned = new Column.Integer("pinned") { default="0", min_version=25 };
|
||||||
|
|
||||||
internal ConversationTable(Database db) {
|
internal ConversationTable(Database db) {
|
||||||
base(db, "conversation");
|
base(db, "conversation");
|
||||||
init({id, account_id, jid_id, resource, active, active_last_changed, last_active, type_, encryption, read_up_to, read_up_to_item, notification, send_typing, send_marker});
|
init({id, account_id, jid_id, resource, active, active_last_changed, last_active, type_, encryption, read_up_to, read_up_to_item, notification, send_typing, send_marker, pinned});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,15 +88,19 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkRevealer" id="unread_count_revealer">
|
<object class="GtkRevealer" id="top_row_revealer">
|
||||||
<property name="transition-type">slide-right</property>
|
<property name="transition-type">slide-right</property>
|
||||||
<property name="transition-duration">50</property>
|
<property name="transition-duration">50</property>
|
||||||
<property name="reveal-child">True</property>
|
<property name="reveal-child">True</property>
|
||||||
|
<property name="margin-start">15</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox">
|
||||||
|
<property name="orientation">horizontal</property>
|
||||||
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="unread_count_label">
|
<object class="GtkLabel" id="unread_count_label">
|
||||||
<property name="vexpand">False</property>
|
<property name="vexpand">False</property>
|
||||||
<property name="visible">False</property>
|
<property name="visible">False</property>
|
||||||
<property name="margin-start">15</property>
|
|
||||||
<property name="xalign">0.5</property>
|
<property name="xalign">0.5</property>
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="scale" value="0.6"/>
|
<attribute name="scale" value="0.6"/>
|
||||||
|
@ -104,6 +108,15 @@
|
||||||
</attributes>
|
</attributes>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="pinned_image">
|
||||||
|
<property name="icon-name">view-pin-symbolic</property>
|
||||||
|
<property name="pixel-size">12</property>
|
||||||
|
<property name="visible">False</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
@ -49,6 +49,12 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
|
||||||
combobox.active_id = get_notify_setting_id(conversation.notify_setting);
|
combobox.active_id = get_notify_setting_id(conversation.notify_setting);
|
||||||
combobox.changed.connect(() => { conversation.notify_setting = get_notify_setting(combobox.active_id); } );
|
combobox.changed.connect(() => { conversation.notify_setting = get_notify_setting(combobox.active_id); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Switch pinned_switch = new Switch();
|
||||||
|
string category = conversation.type_ == Conversation.Type.GROUPCHAT ? DETAILS_HEADLINE_ROOM : DETAILS_HEADLINE_CHAT;
|
||||||
|
contact_details.add(category, _("Pin conversation"), _("Pins the conversation to the top of the conversation list"), pinned_switch);
|
||||||
|
pinned_switch.state = conversation.pinned != 0;
|
||||||
|
pinned_switch.state_set.connect((state) => { conversation.pinned = state ? 1 : 0; return false; });
|
||||||
}
|
}
|
||||||
|
|
||||||
private Conversation.Setting get_setting(string id) {
|
private Conversation.Setting get_setting(string id) {
|
||||||
|
|
|
@ -75,6 +75,8 @@ public class ConversationSelector : Widget {
|
||||||
private void add_conversation(Conversation conversation) {
|
private void add_conversation(Conversation conversation) {
|
||||||
ConversationSelectorRow row;
|
ConversationSelectorRow row;
|
||||||
if (!rows.has_key(conversation)) {
|
if (!rows.has_key(conversation)) {
|
||||||
|
conversation.notify["pinned"].connect(list_box.invalidate_sort);
|
||||||
|
|
||||||
row = new ConversationSelectorRow(stream_interactor, conversation);
|
row = new ConversationSelectorRow(stream_interactor, conversation);
|
||||||
rows[conversation] = row;
|
rows[conversation] = row;
|
||||||
list_box.append(row);
|
list_box.append(row);
|
||||||
|
@ -119,6 +121,8 @@ public class ConversationSelector : Widget {
|
||||||
private async void remove_conversation(Conversation conversation) {
|
private async void remove_conversation(Conversation conversation) {
|
||||||
select_fallback_conversation(conversation);
|
select_fallback_conversation(conversation);
|
||||||
if (rows.has_key(conversation)) {
|
if (rows.has_key(conversation)) {
|
||||||
|
conversation.notify["pinned"].disconnect(list_box.invalidate_sort);
|
||||||
|
|
||||||
yield rows[conversation].colapse();
|
yield rows[conversation].colapse();
|
||||||
list_box.remove(rows[conversation]);
|
list_box.remove(rows[conversation]);
|
||||||
rows.unset(conversation);
|
rows.unset(conversation);
|
||||||
|
@ -149,6 +153,10 @@ public class ConversationSelector : Widget {
|
||||||
if (cr1 != null && cr2 != null) {
|
if (cr1 != null && cr2 != null) {
|
||||||
Conversation c1 = cr1.conversation;
|
Conversation c1 = cr1.conversation;
|
||||||
Conversation c2 = cr2.conversation;
|
Conversation c2 = cr2.conversation;
|
||||||
|
|
||||||
|
int pin_comp = c2.pinned - c1.pinned;
|
||||||
|
if (pin_comp != 0) return pin_comp;
|
||||||
|
|
||||||
if (c1.last_active == null) return -1;
|
if (c1.last_active == null) return -1;
|
||||||
if (c2.last_active == null) return 1;
|
if (c2.last_active == null) return 1;
|
||||||
int comp = c2.last_active.compare(c1.last_active);
|
int comp = c2.last_active.compare(c1.last_active);
|
||||||
|
|
|
@ -21,7 +21,8 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
[GtkChild] protected unowned Button x_button;
|
[GtkChild] protected unowned Button x_button;
|
||||||
[GtkChild] protected unowned Revealer time_revealer;
|
[GtkChild] protected unowned Revealer time_revealer;
|
||||||
[GtkChild] protected unowned Revealer xbutton_revealer;
|
[GtkChild] protected unowned Revealer xbutton_revealer;
|
||||||
[GtkChild] protected unowned Revealer unread_count_revealer;
|
[GtkChild] protected unowned Revealer top_row_revealer;
|
||||||
|
[GtkChild] protected unowned Image pinned_image;
|
||||||
[GtkChild] public unowned Revealer main_revealer;
|
[GtkChild] public unowned Revealer main_revealer;
|
||||||
|
|
||||||
public Conversation conversation { get; private set; }
|
public Conversation conversation { get; private set; }
|
||||||
|
@ -102,8 +103,10 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
});
|
});
|
||||||
image.set_conversation(stream_interactor, conversation);
|
image.set_conversation(stream_interactor, conversation);
|
||||||
conversation.notify["read-up-to-item"].connect(() => update_read());
|
conversation.notify["read-up-to-item"].connect(() => update_read());
|
||||||
|
conversation.notify["pinned"].connect(() => { update_pinned_icon(); });
|
||||||
|
|
||||||
update_name_label();
|
update_name_label();
|
||||||
|
update_pinned_icon();
|
||||||
content_item_received();
|
content_item_received();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +138,10 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
name_label.label = Util.get_conversation_display_name(stream_interactor, conversation);
|
name_label.label = Util.get_conversation_display_name(stream_interactor, conversation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void update_pinned_icon() {
|
||||||
|
pinned_image.visible = conversation.pinned != 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected void update_time_label(DateTime? new_time = null) {
|
protected void update_time_label(DateTime? new_time = null) {
|
||||||
if (last_content_item != null) {
|
if (last_content_item != null) {
|
||||||
time_label.visible = true;
|
time_label.visible = true;
|
||||||
|
@ -252,11 +259,11 @@ public class ConversationSelectorRow : ListBoxRow {
|
||||||
StateFlags curr_flags = get_state_flags();
|
StateFlags curr_flags = get_state_flags();
|
||||||
if ((curr_flags & StateFlags.PRELIGHT) != 0) {
|
if ((curr_flags & StateFlags.PRELIGHT) != 0) {
|
||||||
time_revealer.set_reveal_child(false);
|
time_revealer.set_reveal_child(false);
|
||||||
unread_count_revealer.set_reveal_child(false);
|
top_row_revealer.set_reveal_child(false);
|
||||||
xbutton_revealer.set_reveal_child(true);
|
xbutton_revealer.set_reveal_child(true);
|
||||||
} else {
|
} else {
|
||||||
time_revealer.set_reveal_child(true);
|
time_revealer.set_reveal_child(true);
|
||||||
unread_count_revealer.set_reveal_child(true);
|
top_row_revealer.set_reveal_child(true);
|
||||||
xbutton_revealer.set_reveal_child(false);
|
xbutton_revealer.set_reveal_child(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue