From eea9e9122e0e4cc61c3507f36b30de8d69f54a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Mon, 28 Apr 2025 12:27:23 +0200 Subject: [PATCH] room-history: Be consistent about compact visual content activation It was already not possible with the mouse, but there was still a hover effect, and the key bindings where still working. --- data/resources/stylesheet/_room_history.scss | 26 ++++++++++++------- .../room_history/message_row/visual_media.rs | 15 ++++++----- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/data/resources/stylesheet/_room_history.scss b/data/resources/stylesheet/_room_history.scss index ebca4fd9..68b4c000 100644 --- a/data/resources/stylesheet/_room_history.scss +++ b/data/resources/stylesheet/_room_history.scss @@ -279,6 +279,12 @@ state-group-row.room-history-row { border-radius: vendor.$menu_radius; } + &.compact { + > .instructions { + padding: 6px; + } + } + // Copied from .osd button style in https://gitlab.gnome.org/GNOME/libadwaita/-/blob/main/src/stylesheet/widgets/_buttons.scss &.has-placeholder { > .instructions { @@ -290,17 +296,19 @@ state-group-row.room-history-row { } } - &:hover { - > .instructions { - color: white; - background-color: color-mix(in srgb, black calc(0.85 * 65%), currentColor calc(0.15 * 65%)); + &:not(.compact) { + &:hover { + > .instructions { + color: white; + background-color: color-mix(in srgb, black calc(0.85 * 65%), currentColor calc(0.15 * 65%)); + } } - } - &:active { - > .instructions { - color: white; - background-color: color-mix(in srgb, black calc(0.75 * 65%), currentColor calc(0.25 * 65%)); + &:active { + > .instructions { + color: white; + background-color: color-mix(in srgb, black calc(0.75 * 65%), currentColor calc(0.25 * 65%)); + } } } } diff --git a/src/session/view/content/room_history/message_row/visual_media.rs b/src/session/view/content/room_history/message_row/visual_media.rs index 4ac2aca6..57a1357b 100644 --- a/src/session/view/content/room_history/message_row/visual_media.rs +++ b/src/session/view/content/room_history/message_row/visual_media.rs @@ -357,7 +357,7 @@ mod imp { }; self.preview_instructions_icon.set_icon_size(icon_size); - self.update_gesture_click(); + self.update_activation(); self.obj().notify_compact(); } @@ -369,16 +369,16 @@ mod imp { self.activatable.set(activatable); - self.update_gesture_click(); + self.update_activation(); self.obj().notify_activatable(); } - /// Add or remove the click controller given the current state. - fn update_gesture_click(&self) { - let needs_controller = self.activatable.get() && !self.compact.get(); + /// Enable or disable the activation of this row for the current state. + fn update_activation(&self) { + let is_activatable = self.activatable.get() && !self.compact.get(); let gesture_click = self.gesture_click.upgrade(); - if needs_controller && gesture_click.is_none() { + if is_activatable && gesture_click.is_none() { let gesture_click = gtk::GestureClick::new(); gesture_click.connect_released(clone!( @@ -395,6 +395,9 @@ mod imp { self.gesture_click.set(None); self.overlay.remove_controller(&gesture_click); } + + self.obj() + .action_set_enabled("message-visual-media.activate", is_activatable); } /// Set the cache key with the given value.