[fractal] fractal-gtk: message widget: Show last edit date in tooltip
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] fractal-gtk: message widget: Show last edit date in tooltip
- Date: Fri, 3 Jul 2020 06:53:56 +0000 (UTC)
commit 881c10799cd7c265bae938aa9b5d01b1011cbbf3
Author: Juraj Fiala <jurf riseup net>
Date: Tue Jun 30 18:49:44 2020 +0200
fractal-gtk: message widget: Show last edit date in tooltip
fractal-gtk/src/appop/message.rs | 5 +++++
fractal-gtk/src/uitypes.rs | 1 +
fractal-gtk/src/widgets/message.rs | 5 ++++-
fractal-gtk/src/widgets/room_history.rs | 2 ++
4 files changed, 12 insertions(+), 1 deletion(-)
---
diff --git a/fractal-gtk/src/appop/message.rs b/fractal-gtk/src/appop/message.rs
index e3946cfd..182cf64b 100644
--- a/fractal-gtk/src/appop/message.rs
+++ b/fractal-gtk/src/appop/message.rs
@@ -550,6 +550,11 @@ fn create_ui_message(
mtype: t,
body: msg.body,
date: msg.date,
+ replace_date: if msg.replace.is_some() {
+ Some(msg.date)
+ } else {
+ None
+ },
thumb: msg.thumb,
url: msg.url,
formatted_body: msg.formatted_body,
diff --git a/fractal-gtk/src/uitypes.rs b/fractal-gtk/src/uitypes.rs
index f73f15d1..c6c44b1f 100644
--- a/fractal-gtk/src/uitypes.rs
+++ b/fractal-gtk/src/uitypes.rs
@@ -15,6 +15,7 @@ pub struct MessageContent {
pub mtype: RowType,
pub body: String,
pub date: DateTime<Local>,
+ pub replace_date: Option<DateTime<Local>>,
pub thumb: Option<String>,
pub url: Option<String>,
pub formatted_body: Option<String>,
diff --git a/fractal-gtk/src/widgets/message.rs b/fractal-gtk/src/widgets/message.rs
index d0d0de37..310e1500 100644
--- a/fractal-gtk/src/widgets/message.rs
+++ b/fractal-gtk/src/widgets/message.rs
@@ -242,7 +242,7 @@ impl MessageBox {
body_bx.pack_start(&body, true, true, 0);
- if msg.msg.replace != None {
+ if let Some(replace_date) = msg.replace_date {
let edit_mark = gtk::Image::new_from_icon_name(
Some("document-edit-symbolic"),
gtk::IconSize::Button,
@@ -250,6 +250,9 @@ impl MessageBox {
edit_mark.get_style_context().add_class("edit-mark");
edit_mark.set_valign(gtk::Align::End);
+ let edit_tooltip = replace_date.format(&i18n("Last edited %c")).to_string();
+ edit_mark.set_tooltip_text(Some(&edit_tooltip));
+
body_bx.pack_start(&edit_mark, false, false, 0);
}
body_bx
diff --git a/fractal-gtk/src/widgets/room_history.rs b/fractal-gtk/src/widgets/room_history.rs
index b318dd71..223feb1c 100644
--- a/fractal-gtk/src/widgets/room_history.rs
+++ b/fractal-gtk/src/widgets/room_history.rs
@@ -475,6 +475,7 @@ impl RoomHistory {
return Continue(true);
}
if let Some(pos) = edits.iter().position(|edit| item.id == edit.msg.replace) {
+ edits[pos].date = item.date;
item = edits.remove(pos).unwrap();
}
@@ -621,6 +622,7 @@ impl RoomHistory {
}
_ => None,
})?;
+ item.date = msg.date;
let msg_widget = msg.widget.clone()?;
item.widget = Some(create_row(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]