[fractal/fractal-next] sidebar: Fix room highlight
- From: Julian Sparber <jsparber src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/fractal-next] sidebar: Fix room highlight
- Date: Mon, 28 Mar 2022 14:57:15 +0000 (UTC)
commit 0a733025548fd5e2b59eecfd2e8d00dce662b1db
Author: Kévin Commaille <zecakeh tedomum fr>
Date: Sun Mar 27 12:48:17 2022 +0200
sidebar: Fix room highlight
src/session/room/highlight_flags.rs | 8 +------
src/session/room/mod.rs | 2 +-
src/session/sidebar/room_row.rs | 42 +++++++++++++++++--------------------
3 files changed, 21 insertions(+), 31 deletions(-)
---
diff --git a/src/session/room/highlight_flags.rs b/src/session/room/highlight_flags.rs
index d4d096168..72b803b40 100644
--- a/src/session/room/highlight_flags.rs
+++ b/src/session/room/highlight_flags.rs
@@ -2,18 +2,12 @@ use gtk::glib;
#[glib::flags(name = "HighlightFlags")]
pub enum HighlightFlags {
- #[flags_value(name = "NONE")]
- NONE = 0b00000000,
- #[flags_value(name = "HIGHLIGHT")]
HIGHLIGHT = 0b00000001,
- #[flags_value(name = "BOLD")]
BOLD = 0b00000010,
- #[flags_value(skip)]
- HIGHLIGHT_BOLD = Self::HIGHLIGHT.bits() | Self::BOLD.bits(),
}
impl Default for HighlightFlags {
fn default() -> Self {
- HighlightFlags::NONE
+ HighlightFlags::empty()
}
}
diff --git a/src/session/room/mod.rs b/src/session/room/mod.rs
index 720b6e685..3c8d0bb0d 100644
--- a/src/session/room/mod.rs
+++ b/src/session/room/mod.rs
@@ -639,7 +639,7 @@ impl Room {
if count > 0 {
HighlightFlags::HIGHLIGHT
} else {
- HighlightFlags::NONE
+ HighlightFlags::empty()
}
}
diff --git a/src/session/sidebar/room_row.rs b/src/session/sidebar/room_row.rs
index fee66a87d..c8c960e73 100644
--- a/src/session/sidebar/room_row.rs
+++ b/src/session/sidebar/room_row.rs
@@ -187,44 +187,40 @@ impl RoomRow {
priv_.signal_handler.replace(Some(room.connect_notify_local(
Some("highlight"),
clone!(@weak self as obj => move |_, _| {
- obj.set_highlight();
+ obj.update_highlight();
}),
)));
if room.category() == RoomType::Left {
priv_.display_name.add_css_class("dim-label");
}
-
- self.set_highlight();
}
priv_.room.replace(room);
+ self.update_highlight();
self.update_actions();
self.notify("room");
}
- fn set_highlight(&self) {
+ fn update_highlight(&self) {
let priv_ = self.imp();
if let Some(room) = &*priv_.room.borrow() {
- match room.highlight() {
- HighlightFlags::NONE => {
- priv_.notification_count.remove_css_class("highlight");
- priv_.display_name.remove_css_class("bold");
- }
- HighlightFlags::HIGHLIGHT => {
- priv_.notification_count.add_css_class("highlight");
- priv_.display_name.remove_css_class("bold");
- }
- HighlightFlags::BOLD => {
- priv_.display_name.add_css_class("bold");
- priv_.notification_count.remove_css_class("highlight");
- }
- HighlightFlags::HIGHLIGHT_BOLD => {
- priv_.notification_count.add_css_class("highlight");
- priv_.display_name.add_css_class("bold");
- }
- _ => {}
- };
+ let flags = room.highlight();
+
+ if flags.contains(HighlightFlags::HIGHLIGHT) {
+ priv_.notification_count.add_css_class("highlight");
+ } else {
+ priv_.notification_count.remove_css_class("highlight");
+ }
+
+ if flags.contains(HighlightFlags::BOLD) {
+ priv_.display_name.add_css_class("bold");
+ } else {
+ priv_.display_name.remove_css_class("bold");
+ }
+ } else {
+ priv_.notification_count.remove_css_class("highlight");
+ priv_.display_name.remove_css_class("bold");
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]