Start private conversation with MUC occupant via occupant menu
This commit is contained in:
parent
2a49d4a1aa
commit
ea5d3e50c6
|
@ -6,7 +6,7 @@ using Dino.Entities;
|
|||
namespace Dino {
|
||||
|
||||
public class Database : Qlite.Database {
|
||||
private const int VERSION = 0;
|
||||
private const int VERSION = 1;
|
||||
|
||||
public class AccountTable : Table {
|
||||
public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true };
|
||||
|
@ -79,7 +79,7 @@ public class Database : Qlite.Database {
|
|||
public Column<int> id = new Column.Integer("id") { primary_key = true, auto_increment = true };
|
||||
public Column<int> account_id = new Column.Integer("account_id") { not_null = true };
|
||||
public Column<int> jid_id = new Column.Integer("jid_id") { not_null = true };
|
||||
public Column<string> resource = new Column.Text("resource");
|
||||
public Column<string> resource = new Column.Text("resource") { min_version=1 };
|
||||
public Column<bool> active = new Column.BoolInt("active");
|
||||
public Column<long> last_active = new Column.Long("last_active");
|
||||
public Column<int> type_ = new Column.Integer("type");
|
||||
|
|
|
@ -90,8 +90,9 @@ SOURCES
|
|||
src/ui/manage_accounts/add_account_dialog.vala
|
||||
src/ui/manage_accounts/dialog.vala
|
||||
src/ui/notifications.vala
|
||||
src/ui/occupant_list.vala
|
||||
src/ui/occupant_list_row.vala
|
||||
src/ui/occupant_menu/list.vala
|
||||
src/ui/occupant_menu/list_row.vala
|
||||
src/ui/occupant_menu/view.vala
|
||||
src/ui/settings_dialog.vala
|
||||
src/ui/unified_window.vala
|
||||
src/ui/util.vala
|
||||
|
|
|
@ -1,34 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.22"/>
|
||||
<template class="DinoUiOccupantList">
|
||||
<template class="DinoUiOccupantMenuList">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkToolbar">
|
||||
<property name="icon_size">1</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkToolItem">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search_entry">
|
||||
<property name="margin">5</property>
|
||||
<property name="margin">8</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="max_content_height">500</property>
|
||||
<property name="propagate_natural_height">True</property>
|
||||
<property name="margin">5</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkListBox" id="list_box">
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="DinoUiOccupantListRow" parent="GtkListBoxRow">
|
||||
<template class="DinoUiOccupantMenuListRow" parent="GtkListBoxRow">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">3</property>
|
||||
<property name="margin-top">3</property>
|
||||
<property name="margin-left">7</property>
|
||||
<property name="margin-bottom">3</property>
|
||||
<property name="margin-right">7</property>
|
||||
<property name="column-spacing">10</property>
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
|
|
|
@ -61,11 +61,8 @@ public class ConversationTitlebar : Gtk.HeaderBar {
|
|||
groupchat_button.visible = conversation.type_ == Conversation.Type.GROUPCHAT;
|
||||
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
|
||||
groupchat_button.set_use_popover(true);
|
||||
Popover popover = new Popover(null);
|
||||
OccupantList occupant_list = new OccupantList(stream_interactor, conversation);
|
||||
popover.add(occupant_list);
|
||||
occupant_list.show_all();
|
||||
groupchat_button.set_popover(popover);
|
||||
OccupantMenu.View menu = new OccupantMenu.View(stream_interactor, conversation);
|
||||
groupchat_button.set_popover(menu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,22 +3,22 @@ using Gtk;
|
|||
|
||||
using Dino.Entities;
|
||||
|
||||
namespace Dino.Ui{
|
||||
namespace Dino.Ui.OccupantMenu{
|
||||
|
||||
[GtkTemplate (ui = "/org/dino-im/occupant_list.ui")]
|
||||
public class OccupantList : Box {
|
||||
public class List : Box {
|
||||
|
||||
public signal void conversation_selected(Conversation? conversation);
|
||||
private StreamInteractor stream_interactor;
|
||||
|
||||
[GtkChild] private ListBox list_box;
|
||||
[GtkChild] public ListBox list_box;
|
||||
[GtkChild] private SearchEntry search_entry;
|
||||
|
||||
private Conversation? conversation;
|
||||
private string[]? filter_values;
|
||||
private HashMap<Jid, OccupantListRow> rows = new HashMap<Jid, OccupantListRow>(Jid.hash_func, Jid.equals_func);
|
||||
private HashMap<Jid, ListRow> rows = new HashMap<Jid, ListRow>(Jid.hash_func, Jid.equals_func);
|
||||
|
||||
public OccupantList(StreamInteractor stream_interactor, Conversation conversation) {
|
||||
public List(StreamInteractor stream_interactor, Conversation conversation) {
|
||||
this.stream_interactor = stream_interactor;
|
||||
list_box.set_header_func(header);
|
||||
list_box.set_sort_func(sort);
|
||||
|
@ -57,7 +57,7 @@ public class OccupantList : Box {
|
|||
}
|
||||
|
||||
public void add_occupant(Jid jid) {
|
||||
rows[jid] = new OccupantListRow(stream_interactor, conversation.account, jid);
|
||||
rows[jid] = new ListRow(stream_interactor, conversation.account, jid);
|
||||
list_box.add(rows[jid]);
|
||||
list_box.invalidate_filter();
|
||||
list_box.invalidate_sort();
|
||||
|
@ -89,8 +89,8 @@ public class OccupantList : Box {
|
|||
}
|
||||
|
||||
private bool filter(ListBoxRow r) {
|
||||
if (r.get_type().is_a(typeof(OccupantListRow))) {
|
||||
OccupantListRow row = r as OccupantListRow;
|
||||
if (r.get_type().is_a(typeof(ListRow))) {
|
||||
ListRow row = r as ListRow;
|
||||
foreach (string filter in filter_values) {
|
||||
return row.name_label.label.down().contains(filter.down());
|
||||
}
|
||||
|
@ -99,9 +99,9 @@ public class OccupantList : Box {
|
|||
}
|
||||
|
||||
private int sort(ListBoxRow row1, ListBoxRow row2) {
|
||||
if (row1.get_type().is_a(typeof(OccupantListRow)) && row2.get_type().is_a(typeof(OccupantListRow))) {
|
||||
OccupantListRow c1 = row1 as OccupantListRow;
|
||||
OccupantListRow c2 = row2 as OccupantListRow;
|
||||
if (row1.get_type().is_a(typeof(ListRow)) && row2.get_type().is_a(typeof(ListRow))) {
|
||||
ListRow c1 = row1 as ListRow;
|
||||
ListRow c2 = row2 as ListRow;
|
||||
return c1.name_label.label.collate(c2.name_label.label);
|
||||
}
|
||||
return 0;
|
|
@ -3,18 +3,23 @@ using Gtk;
|
|||
using Dino.Entities;
|
||||
using Xmpp;
|
||||
|
||||
namespace Dino.Ui {
|
||||
namespace Dino.Ui.OccupantMenu {
|
||||
|
||||
[GtkTemplate (ui = "/org/dino-im/occupant_list_item.ui")]
|
||||
public class OccupantListRow : ListBoxRow {
|
||||
public class ListRow : ListBoxRow {
|
||||
|
||||
[GtkChild] private Image image;
|
||||
[GtkChild] public Label name_label;
|
||||
|
||||
public OccupantListRow(StreamInteractor stream_interactor, Account account, Jid jid) {
|
||||
public Account account;
|
||||
public Jid jid;
|
||||
|
||||
public ListRow(StreamInteractor stream_interactor, Account account, Jid jid) {
|
||||
this.account = account;
|
||||
this.jid = jid;
|
||||
|
||||
name_label.label = Util.get_display_name(stream_interactor, jid, account);
|
||||
Util.image_set_from_scaled_pixbuf(image, (new AvatarGenerator(30, 30, image.scale_factor)).draw_jid(stream_interactor, jid, account));
|
||||
//has_tooltip = true;
|
||||
}
|
||||
|
||||
public void on_presence_received(Presence.Stanza presence) {
|
79
main/src/ui/occupant_menu/view.vala
Normal file
79
main/src/ui/occupant_menu/view.vala
Normal file
|
@ -0,0 +1,79 @@
|
|||
using Gtk;
|
||||
|
||||
using Dino.Entities;
|
||||
|
||||
namespace Dino.Ui.OccupantMenu {
|
||||
public class View : Popover {
|
||||
|
||||
private StreamInteractor stream_interactor;
|
||||
private Conversation conversation;
|
||||
|
||||
private Stack stack = new Stack() { vhomogeneous=false, visible=true };
|
||||
private List list;
|
||||
private Label header_label = new Label("") { xalign=0.5f, hexpand=true, visible=true };
|
||||
|
||||
public View(StreamInteractor stream_interactor, Conversation conversation) {
|
||||
this.stream_interactor = stream_interactor;
|
||||
this.conversation = conversation;
|
||||
|
||||
list = new List(stream_interactor, conversation) { visible=true };
|
||||
stack.add_named(list, "list");
|
||||
setup_menu();
|
||||
add(stack);
|
||||
stack.visible_child_name = "list";
|
||||
|
||||
list.list_box.row_activated.connect((row) => {
|
||||
ListRow list_row = row as ListRow;
|
||||
header_label.label = list_row.name_label.label;
|
||||
show_menu();
|
||||
});
|
||||
|
||||
hide.connect(reset);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
stack.transition_type = StackTransitionType.NONE;
|
||||
stack.visible_child_name = "list";
|
||||
list.list_box.unselect_all();
|
||||
}
|
||||
|
||||
private void setup_menu() {
|
||||
Box header_box = new Box(Orientation.HORIZONTAL, 5) { visible=true };
|
||||
header_box.add(new Image.from_icon_name("pan-start-symbolic", IconSize.SMALL_TOOLBAR) { visible=true });
|
||||
header_box.add(header_label);
|
||||
|
||||
Button header_button = new Button() { relief=ReliefStyle.NONE, visible=true };
|
||||
header_button.add(header_box);
|
||||
|
||||
ModelButton private_button = new ModelButton() { active=true, text="Start private conversation", visible=true };
|
||||
|
||||
Box outer_box = new Box(Orientation.VERTICAL, 5) { margin=10, visible=true };
|
||||
outer_box.add(header_button);
|
||||
outer_box.add(private_button);
|
||||
stack.add_named(outer_box, "menu");
|
||||
|
||||
header_button.clicked.connect(show_list);
|
||||
private_button.clicked.connect(private_conversation_button_clicked);
|
||||
}
|
||||
|
||||
private void show_list() {
|
||||
list.list_box.unselect_all();
|
||||
stack.transition_type = StackTransitionType.SLIDE_RIGHT;
|
||||
stack.visible_child_name = "list";
|
||||
}
|
||||
|
||||
private void show_menu() {
|
||||
stack.transition_type = StackTransitionType.SLIDE_LEFT;
|
||||
stack.visible_child_name = "menu";
|
||||
}
|
||||
|
||||
private void private_conversation_button_clicked() {
|
||||
ListRow? list_row = list.list_box.get_selected_row() as ListRow;
|
||||
if (list_row == null) return;
|
||||
|
||||
Conversation conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(list_row.jid, list_row.account, Conversation.Type.GROUPCHAT_PM);
|
||||
stream_interactor.get_module(ConversationManager.IDENTITY).start_conversation(conversation, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -90,7 +90,7 @@ public class Table {
|
|||
public void add_columns_for_version(long old_version, long new_version) throws DatabaseError {
|
||||
ensure_init();
|
||||
foreach (Column c in columns) {
|
||||
if (c.min_version <= new_version && c.max_version >= new_version && c.min_version > old_version && c.max_version < old_version) {
|
||||
if (c.min_version <= new_version && c.max_version >= new_version && c.min_version > old_version) {
|
||||
db.exec(@"ALTER TABLE $name ADD COLUMN $c");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue