@ -11,21 +11,22 @@ mod imp {
use super ::* ;
#[ derive(Debug, Default, CompositeTemplate) ]
#[ template(resource = " /org/gnome/Fractal/user-entry -row.ui " ) ]
pub struct UserEntry Row {
#[ template(resource = " /org/gnome/Fractal/session-item -row.ui " ) ]
pub struct SessionItem Row {
#[ template_child ]
pub account_a vatar : TemplateChild < AvatarWithSelection > ,
pub avatar : TemplateChild < AvatarWithSelection > ,
#[ template_child ]
pub display_name : TemplateChild < gtk ::Label > ,
#[ template_child ]
pub user_id : TemplateChild < gtk ::Label > ,
/// The session this item represents.
pub session : glib ::WeakRef < Session > ,
}
#[ glib::object_subclass ]
impl ObjectSubclass for UserEntry Row {
const NAME : & ' static str = "UserEntry Row" ;
type Type = super ::UserEntry Row;
impl ObjectSubclass for SessionItem Row {
const NAME : & ' static str = "SessionItem Row" ;
type Type = super ::SessionItem Row;
type ParentType = gtk ::ListBoxRow ;
fn class_init ( klass : & mut Self ::Class ) {
@ -38,7 +39,7 @@ mod imp {
}
}
impl ObjectImpl for UserEntry Row {
impl ObjectImpl for SessionItem Row {
fn properties ( ) -> & ' static [ glib ::ParamSpec ] {
static PROPERTIES : Lazy < Vec < glib ::ParamSpec > > = Lazy ::new ( | | {
vec! [
@ -75,18 +76,19 @@ mod imp {
}
}
impl WidgetImpl for UserEntry Row { }
impl BinImpl for UserEntry Row { }
impl ListBoxRowImpl for UserEntry Row { }
impl WidgetImpl for SessionItem Row { }
impl BinImpl for SessionItem Row { }
impl ListBoxRowImpl for SessionItem Row { }
}
glib ::wrapper ! {
pub struct UserEntryRow ( ObjectSubclass < imp ::UserEntryRow > )
/// A `GtkListBoxRow` representing a logged-in session.
pub struct SessionItemRow ( ObjectSubclass < imp ::SessionItemRow > )
@ extends gtk ::Widget , gtk ::ListBoxRow , @ implements gtk ::Accessible ;
}
#[ gtk::template_callbacks ]
impl UserEntry Row {
impl SessionItem Row {
pub fn new ( session : & Session ) -> Self {
glib ::Object ::builder ( ) . property ( "session" , session ) . build ( )
}
@ -95,11 +97,11 @@ impl UserEntryRow {
pub fn set_selected ( & self , selected : bool ) {
let imp = self . imp ( ) ;
if imp . account_a vatar . is_selected ( ) = = selected {
if imp . avatar . is_selected ( ) = = selected {
return ;
}
imp . account_a vatar . set_selected ( selected ) ;
imp . avatar . set_selected ( selected ) ;
if selected {
imp . display_name . add_css_class ( "bold" ) ;
@ -112,7 +114,7 @@ impl UserEntryRow {
/// Whether this session is selected.
pub fn is_selected ( & self ) -> bool {
self . imp ( ) . account_a vatar . is_selected ( )
self . imp ( ) . avatar . is_selected ( )
}
#[ template_callback ]
@ -128,12 +130,12 @@ impl UserEntryRow {
. unwrap ( ) ;
}
/// The session this entry represents.
/// The session this item represents.
pub fn session ( & self ) -> Option < Session > {
self . imp ( ) . session . upgrade ( )
}
/// Set the session this entry represents.
/// Set the session this item represents.
pub fn set_session ( & self , session : Option < & Session > ) {
self . imp ( ) . session . set ( session ) ;
}