Rewrite contact details dialog

This commit is contained in:
fiaxh 2023-09-22 22:26:10 +02:00
parent 2fba24ccae
commit e54a528375
27 changed files with 1339 additions and 479 deletions

View file

@ -35,6 +35,7 @@ SOURCES
src/service/calls.vala
src/service/chat_interaction.vala
src/service/connection_manager.vala
src/service/contact_model.vala
src/service/content_item_store.vala
src/service/conversation_manager.vala
src/service/counterpart_interaction_manager.vala

View file

@ -47,6 +47,7 @@ sources = files(
'src/service/calls.vala',
'src/service/chat_interaction.vala',
'src/service/connection_manager.vala',
'src/service/contact_model.vala',
'src/service/content_item_store.vala',
'src/service/conversation_manager.vala',
'src/service/counterpart_interaction_manager.vala',

View file

@ -57,6 +57,7 @@ public interface Application : GLib.Application {
Reactions.start(stream_interactor, db);
Replies.start(stream_interactor, db);
FallbackBody.start(stream_interactor, db);
ContactModels.start(stream_interactor);
create_actions();

View file

@ -0,0 +1,58 @@
using Xmpp;
using Gee;
using Qlite;
using Dino.Entities;
public class Dino.Model.ConversationDisplayName : Object {
public string display_name { get; set; }
}
namespace Dino {
public class ContactModels : StreamInteractionModule, Object {
public static ModuleIdentity<ContactModels> IDENTITY = new ModuleIdentity<ContactModels>("contact_models");
public string id { get { return IDENTITY.id; } }
private StreamInteractor stream_interactor;
private HashMap<Conversation, Model.ConversationDisplayName> conversation_models = new HashMap<Conversation, Model.ConversationDisplayName>(Conversation.hash_func, Conversation.equals_func);
public static void start(StreamInteractor stream_interactor) {
ContactModels m = new ContactModels(stream_interactor);
stream_interactor.add_module(m);
}
private ContactModels(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
stream_interactor.get_module(MucManager.IDENTITY).room_info_updated.connect((account, jid) => {
check_update_models(account, jid, Conversation.Type.GROUPCHAT);
});
stream_interactor.get_module(MucManager.IDENTITY).private_room_occupant_updated.connect((account, room, occupant) => {
check_update_models(account, room, Conversation.Type.GROUPCHAT);
});
stream_interactor.get_module(MucManager.IDENTITY).subject_set.connect((account, jid, subject) => {
check_update_models(account, jid, Conversation.Type.GROUPCHAT);
});
stream_interactor.get_module(RosterManager.IDENTITY).updated_roster_item.connect((account, jid, roster_item) => {
check_update_models(account, jid, Conversation.Type.CHAT);
});
}
private void check_update_models(Account account, Jid jid, Conversation.Type conversation_ty) {
var conversation = stream_interactor.get_module(ConversationManager.IDENTITY).get_conversation(jid, account, conversation_ty);
if (conversation == null) return;
var display_name_model = conversation_models[conversation];
if (display_name_model == null) return;
display_name_model.display_name = Dino.get_conversation_display_name(stream_interactor, conversation, "%s (%s)");
}
public Model.ConversationDisplayName get_display_name_model(Conversation conversation) {
if (conversation_models.has_key(conversation)) return conversation_models[conversation];
var model = new Model.ConversationDisplayName();
model.display_name = Dino.get_conversation_display_name(stream_interactor, conversation, "%s (%s)");
conversation_models[conversation] = model;
return model;
}
}
}

View file

@ -58,7 +58,7 @@ set(RESOURCE_LIST
call_widget.ui
chat_input.ui
contact_details_dialog.ui
conversation_details.ui
conversation_item_widget.ui
conversation_list_titlebar.ui
conversation_list_titlebar_csd.ui
@ -68,6 +68,9 @@ set(RESOURCE_LIST
file_send_overlay.ui
global_search.ui
gtk/help-overlay.ui
join_room_dialog.ui
join_room_dialog1.ui
join_room_dialog2.ui
conversation_content_view/item_metadata_header.ui
conversation_content_view/view.ui
manage_accounts/account_row.ui
@ -86,6 +89,7 @@ set(RESOURCE_LIST
unified_main_content.ui
unified_window_placeholder.ui
conversation_details.css
style.css
style-dark.css
)
@ -114,6 +118,12 @@ endif()
if(Adwaita_VERSION VERSION_GREATER_EQUAL "1.2")
set(MAIN_DEFINITIONS ${MAIN_DEFINITIONS} Adw_1_2)
endif()
if(Adwaita_VERSION VERSION_GREATER_EQUAL "1.3")
set(MAIN_DEFINITIONS ${MAIN_DEFINITIONS} Adw_1_3)
endif()
if(Adwaita_VERSION VERSION_GREATER_EQUAL "1.4")
set(MAIN_DEFINITIONS ${MAIN_DEFINITIONS} Adw_1_4)
endif()
vala_precompile(MAIN_VALA_C
SOURCES
@ -172,11 +182,10 @@ SOURCES
src/ui/chat_input/smiley_converter.vala
src/ui/chat_input/view.vala
src/ui/contact_details/blocking_provider.vala
src/ui/contact_details/settings_provider.vala
src/ui/contact_details/permissions_provider.vala
src/ui/contact_details/dialog.vala
src/ui/contact_details/muc_config_form_provider.vala
src/ui/conversation_details.vala
src/ui/conversation_selector/conversation_selector.vala
src/ui/conversation_selector/conversation_selector_row.vala
@ -207,6 +216,11 @@ SOURCES
src/ui/widgets/date_separator.vala
src/ui/widgets/fixed_ratio_picture.vala
src/ui/widgets/natural_size_increase.vala
src/view_model/conversation_details.vala
src/view_model/preferences_row.vala
src/windows/conversation_details.vala
CUSTOM_VAPIS
${CMAKE_BINARY_DIR}/exports/xmpp-vala.vapi
${CMAKE_BINARY_DIR}/exports/qlite.vapi

View file

@ -1,110 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="DinoUiContactDetailsDialog">
<property name="title">Conversation Details</property>
<property name="modal">True</property>
<child type="titlebar">
<object class="GtkHeaderBar">
</object>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<child>
<object class="GtkScrolledWindow">
<property name="propagate_natural_height">1</property>
<property name="max_content_height">500</property>
<property name="hscrollbar_policy">never</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
<property name="child">
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid">
<property name="margin-top">20</property>
<property name="margin-bottom">12</property>
<property name="margin-end">100</property>
<property name="margin-start">100</property>
<property name="column-spacing">10</property>
<child>
<object class="DinoUiAvatarPicture" id="avatar">
<property name="height-request">50</property>
<property name="width-request">50</property>
<property name="valign">center</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
<property name="row-span">2</property>
</layout>
</object>
</child>
<child>
<object class="DinoUiUtilEntryLabelHybrid" id="name_hybrid">
<property name="xalign">0</property>
<property name="hexpand">True</property>
<layout>
<property name="column">1</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="name_label">
<property name="xalign">0</property>
<property name="hexpand">1</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"></attribute>
</attributes>
<layout>
<property name="column">1</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="jid_label">
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="selectable">1</property>
<property name="hexpand">1</property>
<layout>
<property name="column">1</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="account_label">
<property name="xalign">1</property>
<property name="yalign">1</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="hexpand">1</property>
<layout>
<property name="column">2</property>
<property name="row">1</property>
</layout>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox" id="main_box">
<property name="orientation">vertical</property>
<property name="margin-end">100</property>
<property name="margin-start">100</property>
</object>
</child>
</object>
</property>
</object>
</child>
</object>
</child>
</template>
</interface>

View file

@ -0,0 +1,7 @@
.extended-headerbar {
background-color: @headerbar_bg_color;
}
.extended-headerbar-end {
padding-bottom: 24px;
border-bottom: 1px solid @borders;
}

View file

@ -0,0 +1,207 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<object class="DinoUiViewModelConversationDetails" id="model"/>
<template class="DinoUiConversationDetailsDialog">
<property name="default-width">600</property>
<!-- <property name="default-height">400</property>-->
<property name="modal">True</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar">
<style>
<class name="flat"/>
<class name="extended-headerbar"/>
</style>
<property name="title_widget">
<object class="GtkBox"/>
</property>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwClamp">
<style>
<class name="extended-headerbar"/>
<class name="extended-headerbar-end"/>
</style>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">18</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="DinoUiAvatarPicture" id="picture">
<property name="height-request">72</property>
<property name="width-request">72</property>
<property name="halign">center</property>
<property name="model" bind-source="model" bind-property="avatar"/>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" bind-source="model" bind-property="name"/>
<property name="ellipsize">end</property>
<property name="hexpand">True</property>
<property name="valign">center</property>
<property name="xalign">0</property>
<attributes>
<attribute name="scale" value="1.4"/>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="spacing">12</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<child>
<object class="GtkButton" id="pin_button">
<child>
<object class="AdwButtonContent" id="pin_button_content">
<property name="icon-name">view-pin-symbolic</property>
<property name="label">Pin</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="notification_button_toggle">
<child>
<object class="AdwButtonContent" id="notification_button_toggle_content">
<property name="icon-name">notification-symbolic</property>
<property name="label">Mute</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuButton" id="notification_button_menu">
<property name="menu_model">notification_menu_button_menu_model</property>
<child>
<object class="GtkBox">
<property name="spacing">6</property>
<property name="orientation">horizontal</property>
<child>
<object class="AdwButtonContent" id="notification_button_menu_content">
<property name="icon-name">notification-symbolic</property>
<property name="label">Mute</property>
<property name="can-shrink">True</property>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">pan-down-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwSplitButton" id="notification_button_split">
<property name="menu_model">notification_split_button_menu_model</property>
<child>
<object class="AdwButtonContent" id="notification_button_split_content">
<property name="icon-name">notification-symbolic</property>
<property name="label">Mute</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="block_button">
<property name="visible" bind-source="model" bind-property="show-blocked" bind-flags="sync-create"/>
<child>
<object class="AdwButtonContent" id="block_button_content">
<property name="icon-name">action-unavailable-symbolic</property>
<property name="label">Block</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="propagate-natural-height">True</property>
<child>
<object class="AdwClamp">
<child>
<object class="GtkBox" id="about_box">
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<property name="margin-end">12</property>
<property name="margin-start">12</property>
<property name="margin-top">12</property>
<property name="margin-bottom">40</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
<menu id="notification_split_button_menu_model">
<section>
<item>
<attribute name="label">Enable notifications</attribute>
<attribute name="action">notification.on</attribute>
</item>
<item>
<attribute name="label">Disable notifications</attribute>
<attribute name="action">notification.off</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Reset to default</attribute>
<attribute name="action">notification.default</attribute>
</item>
</section>
</menu>
<menu id="notification_menu_button_menu_model">
<section>
<item>
<attribute name="label">Notify for all messages</attribute>
<attribute name="action">notification.on</attribute>
</item>
<item>
<attribute name="label">Notify only for mentions</attribute>
<attribute name="action">notification.highlight</attribute>
</item>
<item>
<attribute name="label">Disable notifications</attribute>
<attribute name="action">notification.off</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Reset to default</attribute>
<attribute name="action">notification.default</attribute>
</item>
</section>
</menu>
</interface>

View file

@ -8,9 +8,9 @@
<file>add_conversation/select_jid_fragment.ui</file>
<file>call_widget.ui</file>
<file>chat_input.ui</file>
<file>contact_details_dialog.ui</file>
<file>conversation_content_view/item_metadata_header.ui</file>
<file>conversation_content_view/view.ui</file>
<file>conversation_details.ui</file>
<file>conversation_item_widget.ui</file>
<file>conversation_list_titlebar.ui</file>
<file>conversation_list_titlebar_csd.ui</file>
@ -49,6 +49,9 @@
<file>icons/scalable/status/dino-tick-symbolic.svg</file>
<file>icons/scalable/status/dino-video-off-symbolic.svg</file>
<file>icons/scalable/status/dino-video-symbolic.svg</file>
<file>join_room_dialog.ui</file>
<file>join_room_dialog1.ui</file>
<file>join_room_dialog2.ui</file>
<file>manage_accounts/account_row.ui</file>
<file>manage_accounts/add_account_dialog.ui</file>
<file>manage_accounts/dialog.ui</file>

View file

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<object class="DinoUiViewModelJoinChannelDialog" id="model" />
<object class="AdwWindow" id="dialog">
<property name="default-width">500</property>
<property name="default-height">600</property>
<property name="modal">True</property>
<child>
<object class="GtkStack" id="left_stack">
<property name="visible-child-name" bind-source="model" bind-property="stack_page" />
<property name="hexpand">False</property>
<child>
<object class="GtkStackPage">
<property name="name">channel_selection</property>
<property name="child">
<object class="DinoUiJoinChannelChannelSelectionPage" id="channel_selection">
<binding name="model">
<lookup name="channel_selection">
model
</lookup>
</binding>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">confirmation</property>
<property name="child">
<object class="DinoUiJoinChannelConfirmationPage" id="confirmation">
<binding name="model">
<lookup name="confirmation">
model
</lookup>
</binding>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</interface>

View file

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="DinoUiJoinChannelChannelSelectionPage">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar" id="header_bar">
<style>
<class name="flat"/>
</style>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">8</property>
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="placeholder-text" translatable="true">Search for channels or enter an XMPP address</property>
<property name="margin-start">16</property>
<property name="margin-end">16</property>
<!-- <signal name="search-changed" object="list" handler="dino_ui_join_room_dialog_view_model_on_search_changed" />-->
</object>
</child>
<child>
<object class="GtkStack">
<binding name="visible-child-name">
<lookup name="stack_page">
<lookup name="model">DinoUiJoinChannelChannelSelectionPage</lookup>
</lookup>
</binding>
<child>
<object class="GtkStackPage">
<property name="name">channels</property>
<property name="child">
<object class="GtkScrolledWindow">
<property name="vexpand">True</property>
<style>
<class name="undershoot-top"/>
</style>
<child>
<!-- We put a box around this such that the card isn't rounded at the bottom but continues, because of interactions between ScrolledWindow and ListView-->
<!-- <object class="GtkBox">-->
<!-- <property name="orientation">vertical</property>-->
<!-- <child>-->
<object class="GtkListView" id="bookmarks_list">
<property name="margin-start">16</property>
<property name="margin-end">16</property>
<property name="margin-top">8</property>
<property name="margin-bottom">16</property>
<binding name="model">
<lookup name="bookmarks">
<lookup name="model">DinoUiJoinChannelChannelSelectionPage</lookup>
</lookup>
</binding>
<property name="single-click-activate">True</property>
<property name="show-separators">True</property>
<property name="valign">start</property>
<style>
<class name="card"/>
</style>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="resource">/im/dino/Dino/room_list_row.ui</property>
</object>
</property>
</object>
<!-- </child>-->
<!-- </object>-->
</child>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">direct-match</property>
<property name="child">
<object class="GtkListView" id="direct_match_list">
<binding name="model">
<lookup name="direct-match">
<lookup name="model">DinoUiJoinChannelChannelSelectionPage</lookup>
</lookup>
</binding>
<property name="single-click-activate">True</property>
<property name="show-separators">True</property>
<property name="valign">start</property>
<property name="margin-start">16</property>
<property name="margin-end">16</property>
<property name="margin-top">8</property>
<property name="margin-bottom">16</property>
<style>
<class name="card"/>
</style>
<property name="factory">
<object class="GtkBuilderListItemFactory">
<property name="resource">/im/dino/Dino/room_list_row.ui</property>
</object>
</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">loading</property>
<property name="child">
<object class="GtkSpinner">
<property name="spinning">True</property>
<property name="valign">center</property>
<property name="halign">center</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">no-results</property>
<property name="child">
<object class="AdwStatusPage">
<property name="icon-name">face-uncertain-symbolic</property>
<property name="title" translatable="yes">No channels found</property>
<property name="description" translatable="yes">None of your bookmarks matches your search and the XMPP address could not be resolved.</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">no-channels</property>
<property name="child">
<object class="AdwStatusPage">
<property name="icon-name">im.dino.Dino-symbolic</property>
<property name="title" translatable="yes">No known channels</property>
<property name="description" translatable="yes">Discover new channels or enter an XMPP address!</property>
</object>
</property>
</object>
</child>
<child>
<object class="GtkStackPage">
<property name="name">offline</property>
<property name="child">
<object class="AdwStatusPage">
<property name="icon-name">im.dino.Dino-symbolic</property>
<property name="title" translatable="yes">You are offline</property>
</object>
</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

View file

@ -0,0 +1,232 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="DinoUiJoinChannelConfirmationPage">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwHeaderBar" id="header_bar">
<child>
<object class="GtkButton" id="back_button">
<property name="icon-name">go-previous-symbolic</property>
</object>
</child>
<style>
<class name="flat"/>
</style>
</object>
</child>
<child>
<object class="AdwToastOverlay" id="toast_overlay">
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="valign">center</property>
<property name="vexpand">True</property>
<property name="spacing">6</property>
<property name="margin-top">20</property>
<property name="margin-start">20</property>
<property name="margin-end">20</property>
<property name="margin-bottom">20</property>
<child>
<object class="DinoUiAvatarPicture" id="picture">
<property name="height-request">100</property>
<property name="width-request">100</property>
<property name="margin-bottom">20</property>
<property name="halign">center</property>
<binding name="model">
<lookup name="avatar">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkLabel">
<binding name="label">
<lookup name="name">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
<attributes>
<attribute name="scale" value="1.4"/>
</attributes>
<property name="ellipsize">end</property>
<property name="hexpand">True</property>
<property name="halign">center</property>
<binding name="visible">
<closure type="gboolean" function="dino_ui_view_model_join_channel_is_not_null">
<lookup name="name">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="GtkLabel">
<binding name="label">
<lookup name="jid">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
<style>
<class name="dim-label"/>
</style>
<property name="ellipsize">end</property>
<property name="hexpand">True</property>
<property name="halign">center</property>
</object>
</child>
<child>
<object class="GtkLabel">
<binding name="label">
<lookup name="description">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
<property name="wrap">True</property>
<property name="halign">center</property>
<binding name="visible">
<closure type="gboolean" function="dino_ui_view_model_join_channel_is_not_null">
<lookup name="description">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</closure>
</binding>
</object>
</child>
<child>
<object class="GtkBox">
<property name="spacing">6</property>
<property name="halign">center</property>
<property name="orientation">horizontal</property>
<binding name="visible">
<closure type="gboolean" function="dino_ui_view_model_join_channel_is_not_null">
<lookup name="members">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</closure>
</binding>
<child>
<object class="GtkImage">
<property name="icon-name">system-users-symbolic</property>
<property name="pixel-size">10</property>
</object>
</child>
<child>
<object class="GtkLabel">
<binding name="label">
<lookup name="members">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
<property name="ellipsize">end</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkBox">
<property name="spacing">2</property>
<property name="margin-top">20</property>
<property name="halign">center</property>
<property name="orientation">horizontal</property>
<child>
<object class="GtkLabel">
<property name="label">Joining as</property>
<property name="ellipsize">end</property>
</object>
</child>
<child>
<object class="GtkButton">
<style>
<class name="flat"/>
<class name="dino-joining-as"/>
</style>
<child>
<object class="GtkBox">
<property name="spacing">4</property>
<child>
<object class="GtkLabel">
<binding name="label">
<lookup name="nick">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkImage">
<property name="icon-name">document-edit-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton">
<property name="action-name">win.join</property>
<!-- <binding name="sensitive">-->
<!-- <lookup name="spinner-active">-->
<!-- <lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>-->
<!-- </lookup>-->
<!-- </binding>-->
<property name="margin-top">20</property>
<property name="margin-bottom">26</property>
<property name="halign">center</property>
<style>
<class name="pill"/>
<class name="suggested-action"/>
</style>
<child>
<object class="GtkBox">
<child>
<object class="GtkLabel">
<property name="label" translatable="1">Join</property>
</object>
</child>
<child>
<object class="GtkRevealer">
<property name="transition-type">slide-left</property>
<property name="transition-duration">200</property>
<binding name="reveal-child">
<lookup name="spinner-active">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
<child>
<object class="GtkSpinner">
<binding name="visible">
<lookup name="spinner-active">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
<binding name="spinning">
<lookup name="spinner-active">
<lookup name="model">DinoUiJoinChannelConfirmationPage</lookup>
</lookup>
</binding>
<property name="margin-start">10</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
</child>
</object>
</child>
</template>
</interface>

View file

@ -3,6 +3,8 @@
* It provides sane defaults for things that are very Dino-specific.
*/
@import url("conversation_details.css");
statuspage {
opacity: 0.5;
}

View file

@ -36,9 +36,6 @@ sources = files(
'src/ui/chat_input/occupants_tab_completer.vala',
'src/ui/chat_input/smiley_converter.vala',
'src/ui/chat_input/view.vala',
'src/ui/contact_details/blocking_provider.vala',
'src/ui/contact_details/dialog.vala',
'src/ui/contact_details/muc_config_form_provider.vala',
'src/ui/contact_details/permissions_provider.vala',
'src/ui/contact_details/settings_provider.vala',
'src/ui/conversation_content_view/call_widget.vala',
@ -55,6 +52,7 @@ sources = files(
'src/ui/conversation_content_view/quote_widget.vala',
'src/ui/conversation_content_view/reactions_widget.vala',
'src/ui/conversation_content_view/subscription_notification.vala',
'src/ui/conversation_details.vala',
'src/ui/conversation_list_titlebar.vala',
'src/ui/conversation_selector/conversation_selector.vala',
'src/ui/conversation_selector/conversation_selector_row.vala',
@ -89,6 +87,9 @@ sources = files(
'src/ui/widgets/date_separator.vala',
'src/ui/widgets/fixed_ratio_picture.vala',
'src/ui/widgets/natural_size_increase.vala',
'src/view_model/conversation_details.vala',
'src/view_model/preferences_row.vala',
'src/windows/conversation_details.vala',
)
sources += import('gnome').compile_resources(
'dino-resources',

View file

@ -54,9 +54,8 @@ public class ChatInputController : Object {
status_description_label.activate_link.connect((uri) => {
if (uri == OPEN_CONVERSATION_DETAILS_URI){
ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation);
contact_details_dialog.set_transient_for((Gtk.Window) chat_input.get_root());
contact_details_dialog.present();
var conversation_details = ConversationDetails.setup_dialog(conversation, stream_interactor, (Window)chat_input.get_root());
conversation_details.present();
}
return true;
});

View file

@ -1,36 +0,0 @@
using Gtk;
using Dino.Entities;
namespace Dino.Ui.ContactDetails {
public class BlockingProvider : Plugins.ContactDetailsProvider, Object {
public string id { get { return "blocking"; } }
private StreamInteractor stream_interactor;
public BlockingProvider(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
}
public void populate(Conversation conversation, Plugins.ContactDetails contact_details, Plugins.WidgetType type) {
if (type != Plugins.WidgetType.GTK4) return;
if (conversation.type_ != Conversation.Type.CHAT) return;
if (stream_interactor.get_module(BlockingManager.IDENTITY).is_supported(conversation.account)) {
bool is_blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(conversation.account, conversation.counterpart);
Switch sw = new Switch() { active=is_blocked, valign=Align.CENTER };
sw.state_set.connect((state) => {
if (state) {
stream_interactor.get_module(BlockingManager.IDENTITY).block(conversation.account, conversation.counterpart);
} else {
stream_interactor.get_module(BlockingManager.IDENTITY).unblock(conversation.account, conversation.counterpart);
}
return false;
});
contact_details.add(_("Settings"), _("Block"), _("Communication and status updates in either direction are blocked"), sw);
}
}
}
}

View file

@ -1,159 +0,0 @@
using Gee;
using Gtk;
using Markup;
using Pango;
using Dino.Entities;
namespace Dino.Ui.ContactDetails {
[GtkTemplate (ui = "/im/dino/Dino/contact_details_dialog.ui")]
public class Dialog : Gtk.Dialog {
[GtkChild] public unowned AvatarPicture avatar;
[GtkChild] public unowned Util.EntryLabelHybrid name_hybrid;
[GtkChild] public unowned Label name_label;
[GtkChild] public unowned Label jid_label;
[GtkChild] public unowned Label account_label;
[GtkChild] public unowned Box main_box;
private StreamInteractor stream_interactor;
private Conversation conversation;
private Plugins.ContactDetails contact_details = new Plugins.ContactDetails();
private HashMap<string, ListBox> categories = new HashMap<string, ListBox>();
private Util.LabelHybridGroup hybrid_group = new Util.LabelHybridGroup();
construct {
name_hybrid.label.attributes = new AttrList();
name_hybrid.label.attributes.insert(attr_weight_new(Weight.BOLD));
}
public Dialog(StreamInteractor stream_interactor, Conversation conversation) {
Object(use_header_bar : Util.use_csd() ? 1 : 0);
this.stream_interactor = stream_interactor;
this.conversation = conversation;
title = conversation.type_ == Conversation.Type.GROUPCHAT ? _("Conference Details") : _("Contact Details");
if (Util.use_csd()) {
// TODO get_header_bar directly returns a HeaderBar in vala > 0.48
Box titles_box = new Box(Orientation.VERTICAL, 0) { valign=Align.CENTER };
var title_label = new Label(title);
title_label.attributes = new AttrList();
title_label.attributes.insert(Pango.attr_weight_new(Weight.BOLD));
titles_box.append(title_label);
var subtitle_label = new Label(Util.get_conversation_display_name(stream_interactor, conversation));
subtitle_label.attributes = new AttrList();
subtitle_label.attributes.insert(Pango.attr_scale_new(Pango.Scale.SMALL));
subtitle_label.add_css_class("dim-label");
titles_box.append(subtitle_label);
get_header_bar().set_title_widget(titles_box);
}
setup_top();
contact_details.add.connect(add_entry);
Application app = GLib.Application.get_default() as Application;
app.plugin_registry.register_contact_details_entry(new SettingsProvider(stream_interactor));
app.plugin_registry.register_contact_details_entry(new BlockingProvider(stream_interactor));
app.plugin_registry.register_contact_details_entry(new MucConfigFormProvider(stream_interactor));
app.plugin_registry.register_contact_details_entry(new PermissionsProvider(stream_interactor));
foreach (Plugins.ContactDetailsProvider provider in app.plugin_registry.contact_details_entries) {
provider.populate(conversation, contact_details, Plugins.WidgetType.GTK4);
}
close_request.connect(() => {
contact_details.save();
return false;
});
}
private void setup_top() {
if (conversation.type_ == Conversation.Type.CHAT) {
name_label.visible = false;
jid_label.margin_start = new Button().get_style_context().get_padding().left + 1;
name_hybrid.text = Util.get_conversation_display_name(stream_interactor, conversation);
close_request.connect(() => {
if (name_hybrid.text != Util.get_conversation_display_name(stream_interactor, conversation)) {
stream_interactor.get_module(RosterManager.IDENTITY).set_jid_handle(conversation.account, conversation.counterpart, name_hybrid.text);
}
return false;
});
} else {
name_hybrid.visible = false;
name_label.label = Util.get_conversation_display_name(stream_interactor, conversation);
}
jid_label.label = conversation.counterpart.to_string();
account_label.label = "via " + conversation.account.bare_jid.to_string();
avatar.model = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(conversation);
}
private void add_entry(string category, string label, string? description, Object wo) {
if (!(wo is Widget)) return;
Widget w = (Widget) wo;
add_category(category);
ListBoxRow list_row = new ListBoxRow() { activatable=false };
Box row = new Box(Orientation.HORIZONTAL, 20) { margin_start=15, margin_end=15, margin_top=3, margin_bottom=3 };
list_row.set_child(row);
Label label_label = new Label(label) { xalign=0, yalign=0.5f, hexpand=true };
if (description != null && description != "") {
Box box = new Box(Orientation.VERTICAL, 0);
box.append(label_label);
Label desc_label = new Label("") { xalign=0, yalign=0.5f, hexpand=true };
desc_label.set_markup("<span size='small'>%s</span>".printf(Markup.escape_text(description)));
desc_label.add_css_class("dim-label");
box.append(desc_label);
row.append(box);
} else {
row.append(label_label);
}
Widget widget = w;
if (widget.get_type().is_a(typeof(Entry))) {
Util.EntryLabelHybrid hybrid = new Util.EntryLabelHybrid.wrap(widget as Entry) { xalign=1 };
hybrid_group.add(hybrid);
widget = hybrid;
} else if (widget.get_type().is_a(typeof(ComboBoxText))) {
Util.ComboBoxTextLabelHybrid hybrid = new Util.ComboBoxTextLabelHybrid.wrap(widget as ComboBoxText) { xalign=1 };
hybrid_group.add(hybrid);
widget = hybrid;
}
widget.margin_bottom = 5;
widget.margin_top = 5;
row.append(widget);
categories[category].append(list_row);
int width = get_content_area().get_width();
int pref_height, pref_width;
get_content_area().measure(Orientation.VERTICAL, width, null, out pref_height, null, null);
default_height = pref_height + 48;
}
private void add_category(string category) {
if (!categories.has_key(category)) {
ListBox list_box = new ListBox() { selection_mode=SelectionMode.NONE };
categories[category] = list_box;
list_box.set_header_func((row, before_row) => {
if (row.get_header() == null && before_row != null) {
row.set_header(new Separator(Orientation.HORIZONTAL));
}
});
Box box = new Box(Orientation.VERTICAL, 5) { margin_top=12, margin_bottom=12 };
Label category_label = new Label("") { xalign=0 };
category_label.set_markup(@"<b>$(Markup.escape_text(category))</b>");
box.append(category_label);
Frame frame = new Frame(null);
frame.set_child(list_box);
box.append(frame);
main_box.append(box);
}
}
}
}

View file

@ -1,93 +0,0 @@
using Gee;
using Gtk;
using Dino.Entities;
using Xmpp.Xep;
namespace Dino.Ui.ContactDetails {
public class MucConfigFormProvider : Plugins.ContactDetailsProvider, Object {
public string id { get { return "muc_config_form"; } }
private StreamInteractor stream_interactor;
public MucConfigFormProvider(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
}
public void populate(Conversation conversation, Plugins.ContactDetails contact_details, Plugins.WidgetType type) {
if (type != Plugins.WidgetType.GTK4) return;
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
Xmpp.XmppStream? stream = stream_interactor.get_stream(conversation.account);
if (stream == null) return;
stream_interactor.get_module(MucManager.IDENTITY).get_config_form.begin(conversation.account, conversation.counterpart, (_, res) => {
DataForms.DataForm? data_form = stream_interactor.get_module(MucManager.IDENTITY).get_config_form.end(res);
if (data_form == null) return;
for (int i = 0; i < data_form.fields.size; i++) {
DataForms.DataForm.Field field = data_form.fields[i];
add_field(field, contact_details);
}
string config_backup = data_form.stanza_node.to_string();
contact_details.save.connect(() => {
// Only send the config form if something was changed
if (config_backup != data_form.stanza_node.to_string()) {
stream_interactor.get_module(MucManager.IDENTITY).set_config_form.begin(conversation.account, conversation.counterpart, data_form);
}
});
});
}
}
public static void add_field(DataForms.DataForm.Field field, Plugins.ContactDetails contact_details) {
string label = field.label ?? "";
string? desc = null;
if (field.var != null) {
switch (field.var) {
case "muc#roomconfig_roomname":
label = _("Name of the room");
break;
case "muc#roomconfig_roomdesc":
label = _("Description of the room");
break;
case "muc#roomconfig_persistentroom":
label = _("Persistent");
desc = _("The room will persist after the last occupant leaves");
break;
case "muc#roomconfig_publicroom":
label = _("Publicly searchable");
break;
case "muc#roomconfig_changesubject":
label = _("Occupants may change the subject");
break;
case "muc#roomconfig_whois":
label = _("Permission to view JIDs");
desc = _("Who is allowed to view the occupants' JIDs?");
break;
case "muc#roomconfig_roomsecret":
label = _("Password");
desc = _("A password to restrict access to the room");
break;
case "muc#roomconfig_moderatedroom":
label = _("Moderated");
desc = _("Only occupants with voice may send messages");
break;
case "muc#roomconfig_membersonly":
label = _("Members only");
desc = _("Only members may enter the room");
break;
case "muc#roomconfig_historylength":
label = _("Message history");
desc = _("Maximum amount of backlog issued by the room");
break;
}
}
Widget? widget = Util.get_data_form_field_widget(field);
if (widget != null) contact_details.add(_("Room Configuration"), label, desc, widget);
}
}
}

View file

@ -22,7 +22,7 @@ public class PermissionsProvider : Plugins.ContactDetailsProvider, Object {
if (stream_interactor.get_module(MucManager.IDENTITY).get_role(own_jid, conversation.account) == Xmpp.Xep.Muc.Role.VISITOR){
Button voice_request = new Button.with_label(_("Request"));
voice_request.clicked.connect(()=>stream_interactor.get_module(MucManager.IDENTITY).request_voice(conversation.account, conversation.counterpart));
contact_details.add(_("Permissions"), _("Request permission to send messages"), "", voice_request);
contact_details.add("Permissions", _("Request permission to send messages"), "", voice_request);
}
}
}

View file

@ -9,8 +9,8 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
private StreamInteractor stream_interactor;
private string DETAILS_HEADLINE_CHAT = _("Settings");
private string DETAILS_HEADLINE_ROOM = _("Local Settings");
private string DETAILS_HEADLINE_CHAT = "Settings";
private string DETAILS_HEADLINE_ROOM = "Local Settings";
public SettingsProvider(StreamInteractor stream_interactor) {
this.stream_interactor = stream_interactor;
@ -33,28 +33,7 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
contact_details.add(DETAILS_HEADLINE_CHAT, _("Send read receipts"), "", combobox_marker);
combobox_marker.active_id = get_setting_id(conversation.send_marker);
combobox_marker.changed.connect(() => { conversation.send_marker = get_setting(combobox_marker.active_id); } );
ComboBoxText combobox_notifications = get_combobox(Dino.Application.get_default().settings.notifications);
contact_details.add(DETAILS_HEADLINE_CHAT, _("Notifications"), "", combobox_notifications);
combobox_notifications.active_id = get_notify_setting_id(conversation.notify_setting);
combobox_notifications.changed.connect(() => { conversation.notify_setting = get_notify_setting(combobox_notifications.active_id); } );
} else if (conversation.type_ == Conversation.Type.GROUPCHAT) {
ComboBoxText combobox = new ComboBoxText();
combobox.append("default", get_notify_setting_string(Conversation.NotifySetting.DEFAULT, conversation.get_notification_default_setting(stream_interactor)));
combobox.append("highlight", get_notify_setting_string(Conversation.NotifySetting.HIGHLIGHT));
combobox.append("on", get_notify_setting_string(Conversation.NotifySetting.ON));
combobox.append("off", get_notify_setting_string(Conversation.NotifySetting.OFF));
contact_details.add(DETAILS_HEADLINE_ROOM, _("Notifications"), "", combobox);
combobox.active_id = get_notify_setting_id(conversation.notify_setting);
combobox.changed.connect(() => { conversation.notify_setting = get_notify_setting(combobox.active_id); } );
}
Switch pinned_switch = new Switch() { valign=Align.CENTER };
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) {
@ -69,34 +48,6 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
assert_not_reached();
}
private Conversation.NotifySetting get_notify_setting(string id) {
switch (id) {
case "default":
return Conversation.NotifySetting.DEFAULT;
case "on":
return Conversation.NotifySetting.ON;
case "off":
return Conversation.NotifySetting.OFF;
case "highlight":
return Conversation.NotifySetting.HIGHLIGHT;
}
assert_not_reached();
}
private string get_notify_setting_string(Conversation.NotifySetting setting, Conversation.NotifySetting? default_setting = null) {
switch (setting) {
case Conversation.NotifySetting.ON:
return _("On");
case Conversation.NotifySetting.OFF:
return _("Off");
case Conversation.NotifySetting.HIGHLIGHT:
return _("Only when mentioned");
case Conversation.NotifySetting.DEFAULT:
return _("Default: %s").printf(get_notify_setting_string(default_setting));
}
assert_not_reached();
}
private string get_setting_id(Conversation.Setting setting) {
switch (setting) {
case Conversation.Setting.DEFAULT:
@ -109,20 +60,6 @@ public class SettingsProvider : Plugins.ContactDetailsProvider, Object {
assert_not_reached();
}
private string get_notify_setting_id(Conversation.NotifySetting setting) {
switch (setting) {
case Conversation.NotifySetting.DEFAULT:
return "default";
case Conversation.NotifySetting.ON:
return "on";
case Conversation.NotifySetting.OFF:
return "off";
case Conversation.NotifySetting.HIGHLIGHT:
return "highlight";
}
assert_not_reached();
}
private ComboBoxText get_combobox(bool default_val) {
ComboBoxText combobox = new ComboBoxText();
combobox = new ComboBoxText();

View file

@ -0,0 +1,188 @@
using Dino.Entities;
using Xmpp;
using Xmpp.Xep;
using Gee;
using Gtk;
namespace Dino.Ui.ConversationDetails {
public void populate_dialog(Model.ConversationDetails model, Conversation conversation, StreamInteractor stream_interactor) {
model.conversation = conversation;
model.display_name = stream_interactor.get_module(ContactModels.IDENTITY).get_display_name_model(conversation);
model.blocked = stream_interactor.get_module(BlockingManager.IDENTITY).is_blocked(model.conversation.account, model.conversation.counterpart);
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
stream_interactor.get_module(MucManager.IDENTITY).get_config_form.begin(conversation.account, conversation.counterpart, (_, res) => {
model.data_form = stream_interactor.get_module(MucManager.IDENTITY).get_config_form.end(res);
model.data_form_bak = model.data_form.stanza_node.to_string();
});
}
}
public void bind_dialog(Model.ConversationDetails model, ViewModel.ConversationDetails view_model, StreamInteractor stream_interactor) {
view_model.avatar = new ViewModel.CompatAvatarPictureModel(stream_interactor).set_conversation(model.conversation);
view_model.show_blocked = model.conversation.type_ == Conversation.Type.CHAT && stream_interactor.get_module(BlockingManager.IDENTITY).is_supported(model.conversation.account);
model.display_name.bind_property("display-name", view_model, "name", BindingFlags.SYNC_CREATE);
model.conversation.bind_property("notify-setting", view_model, "notification", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
switch (model.conversation.get_notification_setting(stream_interactor)) {
case Conversation.NotifySetting.ON:
to = ViewModel.ConversationDetails.NotificationSetting.ON;
break;
case Conversation.NotifySetting.OFF:
to = ViewModel.ConversationDetails.NotificationSetting.OFF;
break;
case Conversation.NotifySetting.HIGHLIGHT:
to = ViewModel.ConversationDetails.NotificationSetting.HIGHLIGHT;
break;
}
return true;
});
model.conversation.bind_property("notify-setting", view_model, "notification-is-default", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
var notify_setting = (Conversation.NotifySetting) from;
to = notify_setting == Conversation.NotifySetting.DEFAULT;
return true;
});
model.conversation.bind_property("pinned", view_model, "pinned", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
var from_int = (int) from;
to = from_int > 0;
return true;
});
model.conversation.bind_property("type-", view_model, "notification-options", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
var ty = (Conversation.Type) from;
to = ty == Conversation.Type.GROUPCHAT ? ViewModel.ConversationDetails.NotificationOptions.ON_HIGHLIGHT_OFF : ViewModel.ConversationDetails.NotificationOptions.ON_OFF;
return true;
});
model.bind_property("blocked", view_model, "blocked", BindingFlags.SYNC_CREATE);
model.bind_property("data-form", view_model, "room-configuration-rows", BindingFlags.SYNC_CREATE, (_, from, ref to) => {
var data_form = (DataForms.DataForm) from;
if (data_form == null) return true;
var list_store = new GLib.ListStore(typeof(ViewModel.PreferencesRow.Any));
foreach (var field in data_form.fields) {
var field_view_model = Util.get_data_form_field_view_model(field);
if (field_view_model != null) {
list_store.append(field_view_model);
}
}
to = list_store;
return true;
});
view_model.pin_changed.connect(() => {
model.conversation.pinned = model.conversation.pinned == 1 ? 0 : 1;
});
view_model.block_changed.connect(() => {
if (view_model.blocked) {
stream_interactor.get_module(BlockingManager.IDENTITY).unblock(model.conversation.account, model.conversation.counterpart);
} else {
stream_interactor.get_module(BlockingManager.IDENTITY).block(model.conversation.account, model.conversation.counterpart);
}
view_model.blocked = !view_model.blocked;
});
view_model.notification_changed.connect((setting) => {
switch (setting) {
case ON:
model.conversation.notify_setting = ON;
break;
case OFF:
model.conversation.notify_setting = OFF;
break;
case HIGHLIGHT:
model.conversation.notify_setting = HIGHLIGHT;
break;
case DEFAULT:
model.conversation.notify_setting = DEFAULT;
break;
}
});
view_model.notification_flipped.connect(() => {
model.conversation.notify_setting = view_model.notification == ON ? Conversation.NotifySetting.OFF : Conversation.NotifySetting.ON;
});
}
public Window setup_dialog(Conversation conversation, StreamInteractor stream_interactor, Window parent) {
var dialog = new Dialog() { transient_for = parent };
var model = new Model.ConversationDetails();
populate_dialog(model, conversation, stream_interactor);
bind_dialog(model, dialog.model, stream_interactor);
dialog.model.about_rows.append(new ViewModel.PreferencesRow.Text() {
title = _("XMPP Address"),
text = conversation.counterpart.to_string()
});
if (model.conversation.type_ == Conversation.Type.CHAT) {
var about_row = new ViewModel.PreferencesRow.Entry() {
title = _("Display name"),
text = dialog.model.name
};
about_row.changed.connect(() => {
if (about_row.text != Util.get_conversation_display_name(stream_interactor, conversation)) {
stream_interactor.get_module(RosterManager.IDENTITY).set_jid_handle(conversation.account, conversation.counterpart, about_row.text);
}
});
dialog.model.about_rows.append(about_row);
}
if (model.conversation.type_ == Conversation.Type.GROUPCHAT) {
var topic = stream_interactor.get_module(MucManager.IDENTITY).get_groupchat_subject(conversation.counterpart, conversation.account);
if (topic != null && topic != "") {
dialog.model.about_rows.append(new ViewModel.PreferencesRow.Text() {
title = _("Topic"),
text = Util.parse_add_markup(topic, null, true, true)
});
}
}
dialog.close_request.connect(() => {
// Only send the config form if something was changed
if (model.data_form_bak != null && model.data_form_bak != model.data_form.stanza_node.to_string()) {
stream_interactor.get_module(MucManager.IDENTITY).set_config_form.begin(conversation.account, conversation.counterpart, model.data_form);
}
return false;
});
Plugins.ContactDetails contact_details = new Plugins.ContactDetails();
contact_details.add.connect((c, l, d, wo) => {
add_entry(c, l, d, wo, dialog);
});
Application app = GLib.Application.get_default() as Application;
app.plugin_registry.register_contact_details_entry(new ContactDetails.SettingsProvider(stream_interactor));
app.plugin_registry.register_contact_details_entry(new ContactDetails.PermissionsProvider(stream_interactor));
foreach (Plugins.ContactDetailsProvider provider in app.plugin_registry.contact_details_entries) {
provider.populate(conversation, contact_details, Plugins.WidgetType.GTK4);
}
return dialog;
}
private void add_entry(string category, string label, string? description, Object wo, Dialog dialog) {
if (!(wo is Widget)) return;
Widget widget = (Widget) wo;
if (widget.get_type().is_a(typeof(Entry))) {
Util.EntryLabelHybrid hybrid = new Util.EntryLabelHybrid.wrap(widget as Entry) { xalign=1 };
widget = hybrid;
} else if (widget.get_type().is_a(typeof(ComboBoxText))) {
Util.ComboBoxTextLabelHybrid hybrid = new Util.ComboBoxTextLabelHybrid.wrap(widget as ComboBoxText) { xalign=1 };
widget = hybrid;
}
var view_model = new ViewModel.PreferencesRow.WidgetDeprecated() {
title = label,
widget = widget
};
switch (category) {
case "Encryption":
dialog.model.encryption_rows.append(view_model);
break;
case "Permissions":
case "Local Settings":
case "Settings":
dialog.model.settings_rows.append(view_model);
break;
}
}
}

View file

@ -34,9 +34,8 @@ class MenuEntry : Plugins.ConversationTitlebarEntry, Object {
}
private void on_clicked() {
ContactDetails.Dialog contact_details_dialog = new ContactDetails.Dialog(stream_interactor, conversation);
contact_details_dialog.set_transient_for((Window) button.get_root());
contact_details_dialog.present();
var conversation_details = ConversationDetails.setup_dialog(conversation, stream_interactor, (Window)button.get_root());
conversation_details.present();
}
public Object? get_widget(Plugins.WidgetType type) {

View file

@ -6,6 +6,100 @@ using Xmpp.Xep;
namespace Dino.Ui.Util {
public static ViewModel.PreferencesRow.Any? get_data_form_field_view_model(DataForms.DataForm.Field field) {
if (field.type_ == null) return null;
ViewModel.PreferencesRow.Any? view_model = null;
string? label = null;
string? desc = null;
if (field.var != null) {
switch (field.var) {
case "muc#roomconfig_roomname":
label = _("Name of the room");
break;
case "muc#roomconfig_roomdesc":
label = _("Description of the room");
break;
case "muc#roomconfig_persistentroom":
label = _("Persistent");
desc = _("The room will persist after the last occupant leaves");
break;
case "muc#roomconfig_publicroom":
label = _("Publicly searchable");
break;
case "muc#roomconfig_changesubject":
label = _("Occupants may change the subject");
break;
case "muc#roomconfig_whois":
label = _("Permission to view JIDs");
desc = _("Who is allowed to view the occupants' JIDs?");
break;
case "muc#roomconfig_roomsecret":
label = _("Password");
// desc = _("A password to restrict access to the room");
break;
case "muc#roomconfig_moderatedroom":
label = _("Moderated");
desc = _("Only occupants with voice may send messages");
break;
case "muc#roomconfig_membersonly":
label = _("Members only");
desc = _("Only members may enter the room");
break;
// case "muc#roomconfig_historylength":
// label = _("Message history");
// desc = _("Maximum amount of backlog issued by the room");
// break;
}
}
if (label == null) label = field.label;
switch (field.type_) {
case DataForms.DataForm.Type.BOOLEAN:
DataForms.DataForm.BooleanField boolean_field = field as DataForms.DataForm.BooleanField;
var toggle_model = new ViewModel.PreferencesRow.Toggle() { subtitle = desc, state = boolean_field.value };
boolean_field.bind_property("value", toggle_model, "state", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
view_model = toggle_model;
break;
case DataForms.DataForm.Type.JID_MULTI:
return null;
case DataForms.DataForm.Type.LIST_SINGLE:
DataForms.DataForm.ListSingleField list_single_field = field as DataForms.DataForm.ListSingleField;
var combobox_model = new ViewModel.PreferencesRow.ComboBox();
for (int i = 0; i < list_single_field.options.size; i++) {
DataForms.DataForm.Option option = list_single_field.options[i];
combobox_model.items.add(option.label);
if (option.value == list_single_field.value) combobox_model.active_item = i;
}
combobox_model.bind_property("active-item", list_single_field, "value", BindingFlags.DEFAULT, (binding, from, ref to) => {
var src_field = (DataForms.DataForm.ListSingleField) binding.dup_target();
var active_item = (int) from;
to = list_single_field.options[active_item].value;
return true;
});
view_model = combobox_model;
break;
case DataForms.DataForm.Type.LIST_MULTI:
return null;
case DataForms.DataForm.Type.TEXT_PRIVATE:
return null;
case DataForms.DataForm.Type.TEXT_SINGLE:
DataForms.DataForm.TextSingleField text_single_field = field as DataForms.DataForm.TextSingleField;
var entry_model = new ViewModel.PreferencesRow.Entry() { text = text_single_field.value };
text_single_field.bind_property("value", entry_model, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
view_model = entry_model;
break;
default:
return null;
}
view_model.title = label;
return view_model;
}
public static Widget? get_data_form_field_widget(DataForms.DataForm.Field field) {
if (field.type_ == null) return null;
switch (field.type_) {

View file

@ -0,0 +1,49 @@
using Dino.Entities;
using Xmpp;
using Xmpp.Xep;
using Gee;
using Gtk;
public class Dino.Ui.ViewModel.ConversationDetails : Object {
public signal void pin_changed();
public signal void block_changed();
public signal void notification_flipped();
public signal void notification_changed(NotificationSetting setting);
public enum NotificationOptions {
ON_OFF,
ON_HIGHLIGHT_OFF
}
public enum NotificationSetting {
DEFAULT,
ON,
HIGHLIGHT,
OFF
}
public ViewModel.CompatAvatarPictureModel avatar { get; set; }
public string name { get; set; }
public bool pinned { get; set; }
public NotificationSetting notification { get; set; }
public NotificationOptions notification_options { get; set; }
public bool notification_is_default { get; set; }
public bool show_blocked { get; set; }
public bool blocked { get; set; }
public GLib.ListStore preferences_rows = new GLib.ListStore(typeof(PreferencesRow.Any));
public GLib.ListStore about_rows = new GLib.ListStore(typeof(PreferencesRow.Any));
public GLib.ListStore encryption_rows = new GLib.ListStore(typeof(PreferencesRow.Any));
public GLib.ListStore settings_rows = new GLib.ListStore(typeof(PreferencesRow.Any));
public GLib.ListStore room_configuration_rows { get; set; }
}
public class Dino.Ui.Model.ConversationDetails : Object {
public Conversation conversation { get; set; }
public Dino.Model.ConversationDisplayName display_name { get; set; }
public DataForms.DataForm? data_form { get; set; }
public string? data_form_bak;
public bool blocked { get; set; }
}

View file

@ -0,0 +1,34 @@
using Dino.Entities;
using Xmpp;
using Xmpp.Xep;
using Gee;
using Gtk;
namespace Dino.Ui.ViewModel.PreferencesRow {
public abstract class Any : Object {
public string title { get; set; }
}
public class Text : Any {
public string text { get; set; }
}
public class Entry : Any {
public signal void changed();
public string text { get; set; }
}
public class Toggle : Any {
public string subtitle { get; set; }
public bool state { get; set; }
}
public class ComboBox : Any {
public Gee.List<string> items = new ArrayList<string>();
public int active_item { get; set; }
}
public class WidgetDeprecated : Any {
public Widget widget;
}
}

View file

@ -0,0 +1,227 @@
using Dino.Entities;
using Xmpp;
using Xmpp.Xep;
using Gee;
using Gtk;
namespace Dino.Ui.ConversationDetails {
[GtkTemplate (ui = "/im/dino/Dino/conversation_details.ui")]
public class Dialog : Adw.Window {
[GtkChild] public unowned Box about_box;
[GtkChild] public unowned Button pin_button;
[GtkChild] public unowned Adw.ButtonContent pin_button_content;
[GtkChild] public unowned Button block_button;
[GtkChild] public unowned Adw.ButtonContent block_button_content;
[GtkChild] public unowned Button notification_button_toggle;
[GtkChild] public unowned Adw.ButtonContent notification_button_toggle_content;
[GtkChild] public unowned MenuButton notification_button_menu;
[GtkChild] public unowned Adw.ButtonContent notification_button_menu_content;
[GtkChild] public unowned Adw.SplitButton notification_button_split;
[GtkChild] public unowned Adw.ButtonContent notification_button_split_content;
[GtkChild] public unowned ViewModel.ConversationDetails model { get; }
class construct {
install_action("notification.on", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.ON); } );
install_action("notification.off", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.OFF); } );
install_action("notification.highlight", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.HIGHLIGHT); } );
install_action("notification.default", null, (widget, action_name) => { ((Dialog) widget).model.notification_changed(ViewModel.ConversationDetails.NotificationSetting.DEFAULT); } );
}
construct {
pin_button.clicked.connect(() => { model.pin_changed(); });
block_button.clicked.connect(() => { model.block_changed(); });
notification_button_toggle.clicked.connect(() => { model.notification_flipped(); });
notification_button_split.clicked.connect(() => { model.notification_flipped(); });
model.notify["pinned"].connect(update_pinned_button);
model.notify["blocked"].connect(update_blocked_button);
model.notify["notification"].connect(update_notification_button);
model.notify["notification"].connect(update_notification_button_state);
model.notify["notification-options"].connect(update_notification_button_visibility);
model.notify["notification-is-default"].connect(update_notification_button_visibility);
model.about_rows.items_changed.connect(create_preferences_rows);
model.encryption_rows.items_changed.connect(create_preferences_rows);
model.settings_rows.items_changed.connect(create_preferences_rows);
model.notify["room-configuration-rows"].connect(create_preferences_rows);
}
private void update_pinned_button() {
pin_button_content.icon_name = "view-pin-symbolic";
pin_button_content.label = model.pinned ? _("Pinned") : _("Pin");
if (model.pinned) {
pin_button.add_css_class("accent");
} else {
pin_button.remove_css_class("accent");
}
}
private void update_blocked_button() {
block_button_content.icon_name = "action-unavailable-symbolic";
block_button_content.label = model.blocked ? _("Blocked") : _("Block");
if (model.blocked) {
block_button.add_css_class("error");
} else {
block_button.remove_css_class("error");
}
}
private void update_notification_button() {
string icon_name = model.notification == OFF ?
"notifications-disabled-symbolic" : "notification-symbolic";
notification_button_toggle_content.icon_name = icon_name;
notification_button_split_content.icon_name = icon_name;
notification_button_menu_content.icon_name = icon_name;
}
private void update_notification_button_state() {
switch (model.notification) {
case ON:
notification_button_toggle_content.label = _("Mute");
notification_button_split_content.label = _("Mute");
notification_button_menu_content.label = _("Notifications enabled");
break;
case HIGHLIGHT:
notification_button_menu_content.label = _("Notifications for mentions");
break;
case OFF:
notification_button_toggle_content.label = _("Muted");
notification_button_split_content.label = _("Muted");
notification_button_menu_content.label = _("Notifications disabled");
break;
}
}
private void update_notification_button_visibility() {
notification_button_toggle.visible = notification_button_menu.visible = notification_button_split.visible = false;
if (model.notification_options == ON_OFF) {
if (model.notification_is_default) {
notification_button_toggle.visible = true;
} else {
notification_button_split.visible = true;
}
} else {
notification_button_menu.visible = true;
}
}
private void create_preferences_rows() {
var widget = about_box.get_first_child();
while (widget != null) {
about_box.remove(widget);
widget = about_box.get_first_child();
}
if (model.about_rows.get_n_items() > 0) {
about_box.append(rows_to_preference_group(model.about_rows, _("About")));
}
if (model.encryption_rows.get_n_items() > 0) {
about_box.append(rows_to_preference_group(model.encryption_rows, _("Encryption")));
}
if (model.settings_rows.get_n_items() > 0) {
about_box.append(rows_to_preference_group(model.settings_rows, _("Settings")));
}
if (model.room_configuration_rows != null && model.room_configuration_rows.get_n_items() > 0) {
about_box.append(rows_to_preference_group(model.room_configuration_rows, _("Room Configuration")));
}
}
private Adw.PreferencesGroup rows_to_preference_group(GLib.ListStore row_view_models, string title) {
var preference_group = new Adw.PreferencesGroup() { title=title };
for (int preference_group_i = 0; preference_group_i < row_view_models.get_n_items(); preference_group_i++) {
var preferences_row = (ViewModel.PreferencesRow.Any) row_view_models.get_item(preference_group_i);
Widget? w = null;
var entry_view_model = preferences_row as ViewModel.PreferencesRow.Entry;
if (entry_view_model != null) {
#if Adw_1_2
Adw.EntryRow view = new Adw.EntryRow() { title = entry_view_model.title, show_apply_button=true };
entry_view_model.bind_property("text", view, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL, (_, from, ref to) => {
var str = (string) from;
to = str ?? "";
return true;
});
view.apply.connect(() => {
entry_view_model.changed();
});
#else
var view = new Adw.ActionRow() { title = entry_view_model.title };
var entry = new Entry() { text=entry_view_model.text, valign=Align.CENTER };
entry_view_model.bind_property("text", entry, "text", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
entry.changed.connect(() => {
entry_view_model.changed();
});
view.activatable_widget = entry;
view.add_suffix(entry);
#endif
w = view;
}
var row_text = preferences_row as ViewModel.PreferencesRow.Text;
if (row_text != null) {
w = new Adw.ActionRow() {
title = row_text.title,
subtitle = row_text.text,
#if Adw_1_3
subtitle_selectable = true
#endif
};
w.add_css_class("property");
Util.force_css(w, "row.property > box.header > box.title > .title { font-weight: 400; font-size: 9pt; opacity: 0.55; }");
Util.force_css(w, "row.property > box.header > box.title > .subtitle { font-size: inherit; opacity: 1; }");
}
var toggle_view_model = preferences_row as ViewModel.PreferencesRow.Toggle;
if (toggle_view_model != null) {
var view = new Adw.ActionRow() { title = toggle_view_model.title, subtitle = toggle_view_model.subtitle };
var toggle = new Switch() { valign = Align.CENTER };
view.activatable_widget = toggle;
view.add_suffix(toggle);
toggle_view_model.bind_property("state", toggle, "active", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
w = view;
}
var combobox_view_model = preferences_row as ViewModel.PreferencesRow.ComboBox;
if (combobox_view_model != null) {
var string_list = new StringList(null);
foreach (string text in combobox_view_model.items) {
string_list.append(text);
}
#if Adw_1_4
var view = new Adw.ComboRow() { title = combobox_view_model.title };
view.model = string_list;
combobox_view_model.bind_property("active-item", view, "selected", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
#else
var view = new Adw.ActionRow() { title = combobox_view_model.title };
var drop_down = new DropDown(string_list, null) { valign = Align.CENTER };
combobox_view_model.bind_property("active-item", drop_down, "selected", BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
view.activatable_widget = drop_down;
view.add_suffix(drop_down);
#endif
w = view;
}
var widget_view_model = preferences_row as ViewModel.PreferencesRow.WidgetDeprecated;
if (widget_view_model != null) {
var view = new Adw.ActionRow() { title = widget_view_model.title };
view.add_suffix(widget_view_model.widget);
w = view;
}
if (w == null) {
continue;
}
preference_group.add(w);
}
return preference_group;
}
}
}

View file

@ -38,7 +38,7 @@ public class DataForm {
}
}
public class Field {
public class Field : Object {
public StanzaNode node { get; set; }
public string? label {
get { return node.get_attribute("label", NS_URI); }