diff --git a/src/session/view/event_details_dialog.rs b/src/session/view/event_details_dialog.rs index dddbbd77..a3776e62 100644 --- a/src/session/view/event_details_dialog.rs +++ b/src/session/view/event_details_dialog.rs @@ -4,7 +4,7 @@ use gtk::{glib, CompositeTemplate}; use sourceview::prelude::*; use crate::{ - components::{ButtonRow, ToastableDialog}, + components::{ButtonRow, CopyableRow, ToastableDialog}, prelude::*, session::model::Event, toast, utils, @@ -27,18 +27,6 @@ mod imp { #[template_child] pub navigation_view: TemplateChild, #[template_child] - pub original_event_id_row: TemplateChild, - #[template_child] - pub room_id_row: TemplateChild, - #[template_child] - pub sender_id_row: TemplateChild, - #[template_child] - pub original_timestamp_row: TemplateChild, - #[template_child] - pub edit_event_id_row: TemplateChild, - #[template_child] - pub edit_timestamp_row: TemplateChild, - #[template_child] pub source_page: TemplateChild, #[template_child] pub source_view: TemplateChild, @@ -52,76 +40,11 @@ mod imp { fn class_init(klass: &mut Self::Class) { ButtonRow::static_type(); + CopyableRow::static_type(); Self::bind_template(klass); Self::Type::bind_template_callbacks(klass); - klass.install_action( - "event-details-dialog.copy-original-event-id", - None, - move |obj, _, _| { - let clipboard = obj.clipboard(); - let subtitle = obj.imp().original_event_id_row.subtitle(); - clipboard.set_text(subtitle.as_deref().unwrap_or_default()); - toast!(obj, gettext("Event ID copied to clipboard")) - }, - ); - - klass.install_action( - "event-details-dialog.copy-room-id", - None, - move |obj, _, _| { - let clipboard = obj.clipboard(); - let subtitle = obj.imp().room_id_row.subtitle(); - clipboard.set_text(subtitle.as_deref().unwrap_or_default()); - toast!(obj, gettext("Room ID copied to clipboard")) - }, - ); - - klass.install_action( - "event-details-dialog.copy-sender-id", - None, - move |obj, _, _| { - let clipboard = obj.clipboard(); - let subtitle = obj.imp().sender_id_row.subtitle(); - clipboard.set_text(subtitle.as_deref().unwrap_or_default()); - toast!(obj, gettext("Sender ID copied to clipboard")) - }, - ); - - klass.install_action( - "event-details-dialog.copy-original-timestamp", - None, - move |obj, _, _| { - let clipboard = obj.clipboard(); - let subtitle = obj.imp().original_timestamp_row.subtitle(); - clipboard.set_text(subtitle.as_deref().unwrap_or_default()); - toast!(obj, gettext("Timestamp copied to clipboard")) - }, - ); - - klass.install_action( - "event-details-dialog.copy-edit-event-id", - None, - move |obj, _, _| { - let clipboard = obj.clipboard(); - let subtitle = obj.imp().edit_event_id_row.subtitle(); - clipboard.set_text(subtitle.as_deref().unwrap_or_default()); - toast!(obj, gettext("Event ID copied to clipboard")) - }, - ); - - klass.install_action( - "event-details-dialog.copy-edit-timestamp", - None, - move |obj, _, _| { - let clipboard = obj.clipboard(); - let subtitle = obj.imp().edit_timestamp_row.subtitle(); - clipboard.set_text(subtitle.as_deref().unwrap_or_default()); - toast!(obj, gettext("Timestamp copied to clipboard")) - }, - ); - klass.install_action( "event-details-dialog.copy-source", None, diff --git a/src/session/view/event_details_dialog.ui b/src/session/view/event_details_dialog.ui index 7dfc273f..0d7f0a1b 100644 --- a/src/session/view/event_details_dialog.ui +++ b/src/session/view/event_details_dialog.ui @@ -58,32 +58,21 @@ - + + subtitle Event ID EventDetailsDialog - False - - - - copy-symbolic - event-details-dialog.copy-original-event-id - Copy event ID to clipboard - center - - - + Copy event ID to clipboard + Event ID copied to clipboard - + + subtitle Room ID @@ -92,71 +81,34 @@ - False - - - - copy-symbolic - event-details-dialog.copy-room-id - Copy room ID to clipboard - center - - - + Copy room ID to clipboard + Room ID copied to clipboard - + + subtitle Sender ID EventDetailsDialog - False - - - - copy-symbolic - event-details-dialog.copy-sender-id - Copy sender ID to clipboard - center - - - + Copy sender ID to clipboard + Sender ID copied to clipboard - + + subtitle Timestamp EventDetailsDialog - False - - - - copy-symbolic - event-details-dialog.copy-original-timestamp - Copy timestamp to clipboard - center - - - + Copy timestamp to clipboard + Timestamp copied to clipboard @@ -195,53 +147,29 @@ - + + subtitle Event ID EventDetailsDialog - False - - - - copy-symbolic - event-details-dialog.copy-edit-event-id - Copy event ID to clipboard - center - - - + Copy event ID to clipboard + Event ID copied to clipboard - + + subtitle Timestamp EventDetailsDialog - False - - - - copy-symbolic - event-details-dialog.copy-edit-timestamp - Copy timestamp to clipboard - center - - - + Copy timestamp to clipboard + Timestamp copied to clipboard