From b5e76a3b3e8501c699eb2f4f911e4dbaa0f01af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Thu, 8 Feb 2024 17:22:28 +0100 Subject: [PATCH] room-details: Allow to view and change room addresses --- Cargo.toml | 2 +- data/resources/style.css | 42 +- po/POTFILES.in | 3 + src/components/copyable_row.rs | 22 + src/components/copyable_row.ui | 3 + src/components/mod.rs | 2 + src/components/removable_row.rs | 45 +- src/components/removable_row.ui | 3 + src/components/substring_entry_row.rs | 458 +++++++++++ src/components/substring_entry_row.ui | 104 +++ src/session/model/mod.rs | 7 +- src/session/model/room/aliases.rs | 522 ++++++++++++ src/session/model/room/mod.rs | 12 +- .../addresses_subpage/completion_popover.rs | 357 ++++++++ .../addresses_subpage/completion_popover.ui | 29 + .../room_details/addresses_subpage/mod.rs | 776 ++++++++++++++++++ .../room_details/addresses_subpage/mod.ui | 94 +++ .../addresses_subpage/public_address.rs | 63 ++ .../content/room_details/general_page/mod.rs | 143 +++- .../content/room_details/general_page/mod.ui | 27 + src/session/view/content/room_details/mod.rs | 6 +- .../message_toolbar/completion/room_list.rs | 5 +- src/ui-resources.gresource.xml | 3 + 23 files changed, 2703 insertions(+), 25 deletions(-) create mode 100644 src/components/substring_entry_row.rs create mode 100644 src/components/substring_entry_row.ui create mode 100644 src/session/model/room/aliases.rs create mode 100644 src/session/view/content/room_details/addresses_subpage/completion_popover.rs create mode 100644 src/session/view/content/room_details/addresses_subpage/completion_popover.ui create mode 100644 src/session/view/content/room_details/addresses_subpage/mod.rs create mode 100644 src/session/view/content/room_details/addresses_subpage/mod.ui create mode 100644 src/session/view/content/room_details/addresses_subpage/public_address.rs diff --git a/Cargo.toml b/Cargo.toml index bb48249b..ba77bf01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,7 @@ gst_gtk = { version = "0.12", package = "gst-plugin-gtk4" } gst_pbutils = { version = "0.22", package = "gstreamer-pbutils" } gst_play = { version = "0.22", package = "gstreamer-play" } gst_video = { version = "0.22", package = "gstreamer-video" } -gtk = { package = "gtk4", version = "0.8", features = ["v4_10"] } +gtk = { package = "gtk4", version = "0.8", features = ["gnome_44"] } shumate = { package = "libshumate", version = "0.5" } sourceview = { package = "sourceview5", version = "0.8" } diff --git a/data/resources/style.css b/data/resources/style.css index 30329a29..54004274 100644 --- a/data/resources/style.css +++ b/data/resources/style.css @@ -99,15 +99,15 @@ button.overlaid { margin: 3px; /* Make sure the outline is fully visible */ } -.avatar-row-list contents { +.avatar-row-list contents, .string-row-list contents { padding: 0; } -.avatar-row-list viewport, .avatar-row-list listview { +.avatar-row-list viewport, .avatar-row-list listview, .string-row-list viewport, .string-row-list listview { padding: 8px; } -.avatar-row-list list, .avatar-row-list listview { +.avatar-row-list list, .avatar-row-list listview, .string-row-list list, .string-row-list listview { background-color: transparent; } @@ -126,22 +126,33 @@ button.overlaid { margin-bottom: 0px; } -.avatar-row-list row:focus { +.string-row-list row { + border-radius: 6px; + margin: 0px; + padding: 6px; + outline-width: 0; +} + +.avatar-row-list row:focus, .string-row-list row:focus { background-color: alpha(currentColor, .07); } -.avatar-row-list row:hover { +.avatar-row-list row:hover, .string-row-list row:hover { background-color: alpha(currentColor, .07); } -.avatar-row-list row:active { +.avatar-row-list row:active, .string-row-list row:active { background-color: alpha(currentColor, .16); } -.avatar-row-list row:checked { +.avatar-row-list row:checked, .string-row-list row:checked { background-color: alpha(currentColor, .1); } +.entry-row-error-revealer { + margin-top: 6px; +} + /* Components */ @@ -218,6 +229,15 @@ spinner-wrapper.large spinner { min-height: 32px; } +.substring-entry-row .header .subtitle { + margin-top: 4px; + margin-bottom: -4px; +} + +.substring-entry-row .header text placeholder { + opacity: 0.55; +} + /* Login */ @@ -864,6 +884,14 @@ dragoverlay statuspage { color: @accent_fg_color; } +.public-address-tag { + color: @accent_fg_color; + background-color: @accent_bg_color; + border-radius: 0.4em; + padding: 0.3em 0.5em; + margin-left: 0.5em; +} + /* Account Settings */ diff --git a/po/POTFILES.in b/po/POTFILES.in index 680891df..023ef407 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -71,6 +71,9 @@ src/session/view/content/explore/server_row.ui src/session/view/content/invite.rs src/session/view/content/invite.ui src/session/view/content/mod.ui +src/session/view/content/room_details/addresses_subpage/completion_popover.ui +src/session/view/content/room_details/addresses_subpage/mod.rs +src/session/view/content/room_details/addresses_subpage/mod.ui src/session/view/content/room_details/general_page/mod.rs src/session/view/content/room_details/general_page/mod.ui src/session/view/content/room_details/history_viewer/audio_row.rs diff --git a/src/components/copyable_row.rs b/src/components/copyable_row.rs index 27109df2..07ba8470 100644 --- a/src/components/copyable_row.rs +++ b/src/components/copyable_row.rs @@ -31,6 +31,8 @@ mod imp { pub struct CopyableRow { #[template_child] pub copy_button: TemplateChild, + #[template_child] + pub extra_suffix_bin: TemplateChild, /// The tooltip text of the copy button. #[property(get = Self::copy_button_tooltip_text, set = Self::set_copy_button_tooltip_text, explicit_notify, nullable)] pub copy_button_tooltip_text: PhantomData>, @@ -46,6 +48,11 @@ mod imp { /// CSS class is added. #[property(get, set = Self::set_main_title, explicit_notify, builder(ActionRowMainTitle::default()))] pub main_title: Cell, + /// The extra suffix widget of this row. + /// + /// The widget is placed before the remove button. + #[property(get = Self::extra_suffix, set = Self::set_extra_suffix, explicit_notify, nullable)] + pub extra_suffix: PhantomData>, } #[glib::object_subclass] @@ -128,6 +135,21 @@ mod imp { self.main_title.set(main_title); obj.notify_main_title(); } + + /// The extra suffix widget of this row. + fn extra_suffix(&self) -> Option { + self.extra_suffix_bin.child() + } + + /// Set the extra suffix widget of this row. + fn set_extra_suffix(&self, widget: Option<>k::Widget>) { + if self.extra_suffix().as_ref() == widget { + return; + } + + self.extra_suffix_bin.set_child(widget); + self.obj().notify_extra_suffix(); + } } } diff --git a/src/components/copyable_row.ui b/src/components/copyable_row.ui index 702d2984..ea191941 100644 --- a/src/components/copyable_row.ui +++ b/src/components/copyable_row.ui @@ -2,6 +2,9 @@