diff --git a/examples/app_library/style.css b/examples/app_library/style.css index b912d5f..fef7259 100644 --- a/examples/app_library/style.css +++ b/examples/app_library/style.css @@ -1,14 +1,14 @@ child:hover { transition: 100ms; - background: #b1a6a6; + background: #888888; } child { border-radius: 5px; } gridview { - background: #474141; + background: #333333; } window { - background: #474141; + background: #333333; border-radius: 15px; } diff --git a/examples/launcher/application_row/application_row.ui b/examples/launcher/application_row/application_row.ui index 5e477e0..70de6cf 100644 --- a/examples/launcher/application_row/application_row.ui +++ b/examples/launcher/application_row/application_row.ui @@ -38,7 +38,8 @@ start - True + end + 50 diff --git a/examples/launcher/style.css b/examples/launcher/style.css index e69de29..4bfa4ac 100644 --- a/examples/launcher/style.css +++ b/examples/launcher/style.css @@ -0,0 +1,14 @@ +row:hover { + transition: 100ms; + background: #888888; +} +row { + background: #333333; +} +listview { + background: #333333; +} +window { + background: #333333; + border-radius: 15px; +} diff --git a/examples/launcher/window/mod.rs b/examples/launcher/window/mod.rs index d2492e3..3fc0bad 100644 --- a/examples/launcher/window/mod.rs +++ b/examples/launcher/window/mod.rs @@ -40,7 +40,12 @@ impl Window { let model = gio::ListStore::new(ApplicationObject::static_type()); let slice_model = gtk::SliceListModel::new(Some(&model), 0, NUM_LAUNCHER_ITEMS.into()); - let selection_model = gtk::SingleSelection::new(Some(&slice_model)); + let selection_model = gtk::SingleSelection::builder() + .model(&slice_model) + .autoselect(false) + .can_unselect(true) + .selected(gtk4::INVALID_LIST_POSITION) + .build(); imp.model.set(model).expect("Could not set model"); // Wrap model with selection and pass it to the list view @@ -77,9 +82,16 @@ impl Window { } })); } - list_view.connect_activate(move |list_view, i| { + + let app_selection_model = list_view + .model() + .expect("List view missing selection model") + .downcast::() + .expect("could not downcast listview model to single selection model"); + + app_selection_model.connect_selected_notify(glib::clone!(@weak window => move |model| { + let i = model.selected(); println!("acitvating... {}", i + 1); - let model = list_view.model().unwrap(); let app_info = model.item(i); if app_info.is_none() { println!("oops no app for this row..."); @@ -95,9 +107,9 @@ impl Window { } }); } - }); + })); - entry.connect_changed(move |search: >k::Entry| { + entry.connect_changed(glib::clone!(@weak lv => move |search: >k::Entry| { let search = search.text().to_string(); glib::MainContext::default().spawn_local(async move { @@ -106,9 +118,9 @@ impl Window { let _ = tx.send(crate::Event::Search(search)).await; } }); - }); + })); - entry.connect_realize(move |search: >k::Entry| { + entry.connect_realize(glib::clone!(@weak lv => move |search: >k::Entry| { let search = search.text().to_string(); glib::MainContext::default().spawn_local(async move { @@ -117,7 +129,7 @@ impl Window { let _ = tx.send(crate::Event::Search(search)).await; } }); - }); + })); window.connect_realize(move |window| { if let Some((display, surface)) = x::get_window_x11(window) { diff --git a/examples/launcher/window/window.ui b/examples/launcher/window/window.ui index 9b8e96b..e8e1be1 100644 --- a/examples/launcher/window/window.ui +++ b/examples/launcher/window/window.ui @@ -18,16 +18,7 @@ - - never - 500 - true - - - true - - - +