more tweaks to styling and behavior
This commit is contained in:
parent
4ca3867233
commit
d5481fd134
5 changed files with 40 additions and 22 deletions
|
|
@ -1,14 +1,14 @@
|
||||||
child:hover {
|
child:hover {
|
||||||
transition: 100ms;
|
transition: 100ms;
|
||||||
background: #b1a6a6;
|
background: #888888;
|
||||||
}
|
}
|
||||||
child {
|
child {
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
}
|
}
|
||||||
gridview {
|
gridview {
|
||||||
background: #474141;
|
background: #333333;
|
||||||
}
|
}
|
||||||
window {
|
window {
|
||||||
background: #474141;
|
background: #333333;
|
||||||
border-radius: 15px;
|
border-radius: 15px;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="description">
|
<object class="GtkLabel" id="description">
|
||||||
<property name="halign">start</property>
|
<property name="halign">start</property>
|
||||||
<property name="wrap">True</property>
|
<property name="ellipsize">end</property>
|
||||||
|
<property name="max-width-chars">50</property>
|
||||||
<style>
|
<style>
|
||||||
<class name="body" />
|
<class name="body" />
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
row:hover {
|
||||||
|
transition: 100ms;
|
||||||
|
background: #888888;
|
||||||
|
}
|
||||||
|
row {
|
||||||
|
background: #333333;
|
||||||
|
}
|
||||||
|
listview {
|
||||||
|
background: #333333;
|
||||||
|
}
|
||||||
|
window {
|
||||||
|
background: #333333;
|
||||||
|
border-radius: 15px;
|
||||||
|
}
|
||||||
|
|
@ -40,7 +40,12 @@ impl Window {
|
||||||
let model = gio::ListStore::new(ApplicationObject::static_type());
|
let model = gio::ListStore::new(ApplicationObject::static_type());
|
||||||
|
|
||||||
let slice_model = gtk::SliceListModel::new(Some(&model), 0, NUM_LAUNCHER_ITEMS.into());
|
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");
|
imp.model.set(model).expect("Could not set model");
|
||||||
// Wrap model with selection and pass it to the list view
|
// 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::<gtk::SingleSelection>()
|
||||||
|
.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);
|
println!("acitvating... {}", i + 1);
|
||||||
let model = list_view.model().unwrap();
|
|
||||||
let app_info = model.item(i);
|
let app_info = model.item(i);
|
||||||
if app_info.is_none() {
|
if app_info.is_none() {
|
||||||
println!("oops no app for this row...");
|
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();
|
let search = search.text().to_string();
|
||||||
|
|
||||||
glib::MainContext::default().spawn_local(async move {
|
glib::MainContext::default().spawn_local(async move {
|
||||||
|
|
@ -106,9 +118,9 @@ impl Window {
|
||||||
let _ = tx.send(crate::Event::Search(search)).await;
|
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();
|
let search = search.text().to_string();
|
||||||
|
|
||||||
glib::MainContext::default().spawn_local(async move {
|
glib::MainContext::default().spawn_local(async move {
|
||||||
|
|
@ -117,7 +129,7 @@ impl Window {
|
||||||
let _ = tx.send(crate::Event::Search(search)).await;
|
let _ = tx.send(crate::Event::Search(search)).await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}));
|
||||||
|
|
||||||
window.connect_realize(move |window| {
|
window.connect_realize(move |window| {
|
||||||
if let Some((display, surface)) = x::get_window_x11(window) {
|
if let Some((display, surface)) = x::get_window_x11(window) {
|
||||||
|
|
|
||||||
|
|
@ -18,16 +18,7 @@
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkScrolledWindow">
|
<object class="GtkListView" id="list_view"/>
|
||||||
<property name="hscrollbar-policy">never</property>
|
|
||||||
<property name="min-content-height">500</property>
|
|
||||||
<property name="vexpand">true</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkListView" id="list_view">
|
|
||||||
<property name="single-click-activate">true</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue