Browse Source

join-room: add button to copy alias

af-copy-room-alias
Alexandre Franke 1 year ago
parent
commit
76e59608e7
  1. 15
      src/components/dialogs/join_room.rs
  2. 18
      src/components/dialogs/join_room.ui

15
src/components/dialogs/join_room.rs

@ -180,6 +180,21 @@ mod imp {
self.go_back_btn.set_visible(self.can_go_back());
}
/// Copy the room alias to the clipboard.
#[template_callback]
fn copy_room_alias(&self) {
let Some(room) = self.room.borrow().clone() else {
return;
};
let alias = room.alias();
if let Some(alias) = &alias {
let obj = self.obj();
obj.clipboard().set_text(alias.as_str());
toast!(obj, gettext("Matrix room alias copied to clipboard"));
}
}
/// Update the state of the entry page.
#[template_callback]
fn update_entry_page(&self) {

18
src/components/dialogs/join_room.ui

@ -144,6 +144,8 @@
</style>
</object>
</child>
<child>
<object class="GtkCenterBox">
<child>
<object class="GtkLabel" id="room_alias">
<property name="wrap">true</property>
@ -154,6 +156,22 @@
</style>
</object>
</child>
<child type="end">
<object class="GtkButton">
<property name="icon-name">copy-symbolic</property>
<property name="tooltip-text" translatable="yes">Copy Room Alias</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="halign">start</property>
<property name="margin-start">6</property>
<signal name="clicked" handler="copy_room_alias" swapped="yes"/>
<style>
<class name="flat"/>
</style>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="room_topic">
<property name="wrap">true</property>

Loading…
Cancel
Save