upgrade gtk-rs version

This commit is contained in:
Ashley Wulber 2022-01-19 10:19:56 -05:00
parent 0b5f6b8386
commit cc577b1367
23 changed files with 401 additions and 317 deletions

View file

@ -130,7 +130,7 @@ fn main() {
}
}
}
})
});
});
app.run();

View file

@ -1,7 +1,7 @@
use std::cell::RefCell;
use std::rc::Rc;
use glib::{ParamFlags, ParamSpec, Value};
use glib::{ParamFlags, ParamSpec, ParamSpecBoxed, Value};
use gtk4::glib;
use gtk4::prelude::*;
use gtk4::subclass::prelude::*;
@ -27,7 +27,7 @@ impl ObjectSubclass for SearchResultObject {
impl ObjectImpl for SearchResultObject {
fn properties() -> &'static [ParamSpec] {
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
vec![ParamSpec::new_boxed(
vec![ParamSpecBoxed::new(
// Name
"data",
// Nickname

View file

@ -14,11 +14,7 @@ impl SearchResultObject {
}
pub fn data(&self) -> Option<pop_launcher::SearchResult> {
if let Ok(data) = self.property("data") {
if let Ok(search_result) = data.get::<BoxedSearchResult>() {
return search_result.0;
}
}
None
let search_result = self.property::<BoxedSearchResult>("data");
return search_result.0;
}
}

View file

@ -102,18 +102,15 @@ impl SearchResultRow {
pub fn set_search_result(&self, search_obj: SearchResultObject) {
let self_ = imp::SearchResultRow::from_instance(self);
if let Ok(search_result) = search_obj.property("data") {
if let Ok(search_result) = search_result.get::<BoxedSearchResult>() {
if let Some(search_result) = search_result.0 {
self_.name.borrow().set_text(&search_result.name);
self_
.description
.borrow()
.set_text(&search_result.description);
icon_source(&self_.image, &search_result.icon);
icon_source(&self_.category_image, &search_result.category_icon);
}
}
let search_result = search_obj.property::<BoxedSearchResult>("data");
if let Some(search_result) = search_result.0 {
self_.name.borrow().set_text(&search_result.name);
self_
.description
.borrow()
.set_text(&search_result.description);
icon_source(&self_.image, &search_result.icon);
icon_source(&self_.category_image, &search_result.category_icon);
}
}

View file

@ -2,8 +2,8 @@ use gtk4::glib;
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Clone, Debug, Default, glib::GBoxed)]
#[gboxed(type_name = "BoxedSearchResult")]
#[derive(Clone, Debug, Default, glib::Boxed)]
#[boxed_type(name = "BoxedSearchResult")]
pub struct BoxedSearchResult(pub Option<pop_launcher::SearchResult>);
pub fn icon_source(icon: &Rc<RefCell<gtk4::Image>>, source: &Option<pop_launcher::IconSource>) {

View file

@ -198,20 +198,17 @@ impl Window {
);
}
let resize = glib::clone!(@weak window => move || {
let s = window.surface().expect("Failed to get Surface for Window");
let s = window.surface();
let height = window.height();
let width = window.width();
if let Some((display, _surface)) = x::get_window_x11(&window) {
let monitor = display
.primary_monitor()
.expect("Failed to get Monitor");
let Rectangle {
x: monitor_x,
y: monitor_y,
width: monitor_width,
height: monitor_height,
} = monitor.geometry();
let geom = display
.primary_monitor().geometry();
let monitor_x = geom.x();
let monitor_y = geom.y();
let monitor_width = geom.width();
let monitor_height = geom.height();
// dbg!(monitor_width);
// dbg!(monitor_height);
// dbg!(width);
@ -233,7 +230,7 @@ impl Window {
conn.flush().expect("failed to flush");
}
});
let s = window.surface().expect("Failed to get Surface for Window");
let s = window.surface();
let resize_height = resize.clone();
s.connect_height_notify(move |_s| {
glib::source::idle_add_local_once(resize_height.clone());