Browse Source

sidebar: Show dot for unread rooms

fractal-13
Kévin Commaille 5 months ago
parent
commit
a5ad73fa03
No known key found for this signature in database
GPG Key ID: F26F4BE20A08255B
  1. 47
      src/session_view/sidebar/room_row.blp
  2. 9
      src/session_view/sidebar/room_row.rs
  3. 10
      src/session_view/sidebar/section_row.blp
  4. 11
      src/session_view/sidebar/section_row.rs

47
src/session_view/sidebar/room_row.blp

@ -24,17 +24,42 @@ template $SidebarRoomRow: Adw.Bin {
}
[end]
Gtk.Label notification_count {
hexpand: true;
halign: end;
valign: center;
yalign: 1.0;
visible: bind template.room as <$Room>.has-notifications;
label: bind template.room as <$Room>.notification-count;
styles [
"notification-count",
]
Gtk.Stack {
visible: bind $logical_or(template.room as <$Room>.has-notifications, $invert_boolean(template.room as <$Room>.is-read) as <bool>) as <bool>;
visible-child-name: bind $ternary_string(template.room as <$Room>.has-notifications, "count", "dot") as <string>;
Gtk.StackPage {
name: "dot";
child: Gtk.Image {
halign: end;
icon-name: "dot-symbolic";
styles [
"dimmed",
]
accessibility {
label: "Unread messages";
}
};
}
Gtk.StackPage {
name: "count";
child: Gtk.Label notification_count {
hexpand: true;
halign: end;
valign: center;
yalign: 1.0;
label: bind template.room as <$Room>.notification-count;
styles [
"notification-count",
]
};
}
}
}
}

9
src/session_view/sidebar/room_row.rs

@ -7,7 +7,7 @@ use crate::{
i18n::{gettext_f, ngettext_f},
prelude::*,
session::{HighlightFlags, Room, RoomCategory},
utils::BoundObject,
utils::{BoundObject, TemplateCallbacks},
};
mod imp {
@ -21,9 +21,6 @@ mod imp {
#[template(resource = "/org/gnome/Fractal/ui/session_view/sidebar/room_row.ui")]
#[properties(wrapper_type = super::SidebarRoomRow)]
pub struct SidebarRoomRow {
/// The room represented by this row.
#[property(get, set = Self::set_room, explicit_notify, nullable)]
room: BoundObject<Room>,
#[template_child]
avatar: TemplateChild<Avatar>,
#[template_child]
@ -33,6 +30,9 @@ mod imp {
#[template_child]
notification_count: TemplateChild<gtk::Label>,
direct_icon: RefCell<Option<gtk::Image>>,
/// The room represented by this row.
#[property(get, set = Self::set_room, explicit_notify, nullable)]
room: BoundObject<Room>,
}
#[glib::object_subclass]
@ -43,6 +43,7 @@ mod imp {
fn class_init(klass: &mut Self::Class) {
Self::bind_template(klass);
TemplateCallbacks::bind_template_callbacks(klass);
klass.set_css_name("room");
klass.set_accessible_role(gtk::AccessibleRole::Group);

10
src/session_view/sidebar/section_row.blp

@ -19,14 +19,14 @@ template $SidebarSectionRow: Adw.Bin {
}
[end]
Gtk.Stack notification_status {
Gtk.Stack {
visible: bind $invert_boolean($logical_or(template.section as <$SidebarSection>.is-expanded, template.section as <$SidebarSection>.is-read) as <bool>) as <bool>;
visible-child-name: bind $ternary_string(template.section as <$SidebarSection>.has-notifications, "notification-count", "highlight-dot") as <string>;
visible-child-name: bind $ternary_string(template.section as <$SidebarSection>.has-notifications, "count", "dot") as <string>;
Gtk.StackPage {
name: "highlight-dot";
name: "dot";
child: Gtk.Image highlight_dot {
child: Gtk.Image {
halign: end;
icon-name: "dot-symbolic";
@ -41,7 +41,7 @@ template $SidebarSectionRow: Adw.Bin {
}
Gtk.StackPage {
name: "notification-count";
name: "count";
child: Gtk.Label notification_count {
hexpand: true;

11
src/session_view/sidebar/section_row.rs

@ -21,6 +21,10 @@ mod imp {
#[template(resource = "/org/gnome/Fractal/ui/session_view/sidebar/section_row.ui")]
#[properties(wrapper_type = super::SidebarSectionRow)]
pub struct SidebarSectionRow {
#[template_child]
pub(super) display_name: TemplateChild<gtk::Label>,
#[template_child]
notification_count: TemplateChild<gtk::Label>,
/// The section of this row.
#[property(get, set = Self::set_section, explicit_notify, nullable)]
section: BoundObject<SidebarSection>,
@ -37,13 +41,6 @@ mod imp {
/// This will change the label according to the action that can be
/// performed when dropping a room with the given category.
show_label_for_room_category: Cell<Option<RoomCategory>>,
/// The label showing the category name.
#[template_child]
pub(super) display_name: TemplateChild<gtk::Label>,
#[template_child]
notification_status: TemplateChild<gtk::Stack>,
#[template_child]
notification_count: TemplateChild<gtk::Label>,
}
#[glib::object_subclass]

Loading…
Cancel
Save