upgrade gtk-rs version
This commit is contained in:
parent
0b5f6b8386
commit
cc577b1367
23 changed files with 401 additions and 317 deletions
|
|
@ -62,48 +62,43 @@ impl DockPopover {
|
|||
Box::new(Orientation::Vertical, 4);
|
||||
};
|
||||
menu_handle.append(&all_windows_item_container);
|
||||
if let Ok(window_list) = dock_object
|
||||
.property("active")
|
||||
.unwrap()
|
||||
.get::<BoxedWindowList>()
|
||||
{
|
||||
if window_list.0.len() == 0 {
|
||||
all_windows_item_container.hide();
|
||||
} else {
|
||||
let window_listbox = cascade! {
|
||||
ListBox::new();
|
||||
..set_activate_on_single_click(true);
|
||||
let window_list = dock_object.property::<BoxedWindowList>("active");
|
||||
if window_list.0.len() == 0 {
|
||||
all_windows_item_container.hide();
|
||||
} else {
|
||||
let window_listbox = cascade! {
|
||||
ListBox::new();
|
||||
..set_activate_on_single_click(true);
|
||||
};
|
||||
all_windows_item_container.append(&window_listbox);
|
||||
for w in window_list.0 {
|
||||
let window_box = cascade! {
|
||||
Box::new(Orientation::Vertical, 4);
|
||||
};
|
||||
all_windows_item_container.append(&window_listbox);
|
||||
for w in window_list.0 {
|
||||
let window_box = cascade! {
|
||||
Box::new(Orientation::Vertical, 4);
|
||||
};
|
||||
window_listbox.append(&window_box);
|
||||
window_listbox.append(&window_box);
|
||||
|
||||
let window_title = cascade! {
|
||||
Label::new(Some(w.name.as_str()));
|
||||
..set_margin_start(4);
|
||||
..set_margin_end(4);
|
||||
..set_margin_top(4);
|
||||
..set_margin_bottom(4);
|
||||
..set_wrap(true);
|
||||
..set_max_width_chars(20);
|
||||
..set_ellipsize(EllipsizeMode::End);
|
||||
..add_css_class("title-4");
|
||||
..add_css_class("window_title");
|
||||
};
|
||||
let window_title = cascade! {
|
||||
Label::new(Some(w.name.as_str()));
|
||||
..set_margin_start(4);
|
||||
..set_margin_end(4);
|
||||
..set_margin_top(4);
|
||||
..set_margin_bottom(4);
|
||||
..set_wrap(true);
|
||||
..set_max_width_chars(20);
|
||||
..set_ellipsize(EllipsizeMode::End);
|
||||
..add_css_class("title-4");
|
||||
..add_css_class("window_title");
|
||||
};
|
||||
|
||||
let window_image = cascade! {
|
||||
//TODO fill with image of window
|
||||
Image::from_pixbuf(None);
|
||||
};
|
||||
window_box.append(&window_image);
|
||||
window_box.append(&window_title);
|
||||
}
|
||||
// imp.all_windows_item_revealer.replace(window_list_revealer);
|
||||
imp.window_list.replace(window_listbox);
|
||||
let window_image = cascade! {
|
||||
//TODO fill with image of window
|
||||
Image::from_pixbuf(None);
|
||||
};
|
||||
window_box.append(&window_image);
|
||||
window_box.append(&window_title);
|
||||
}
|
||||
// imp.all_windows_item_revealer.replace(window_list_revealer);
|
||||
imp.window_list.replace(window_listbox);
|
||||
}
|
||||
|
||||
let launch_item_container = cascade! {
|
||||
|
|
@ -119,33 +114,30 @@ impl DockPopover {
|
|||
imp.launch_new_item.replace(launch_new_item);
|
||||
|
||||
let favorite_item = cascade! {
|
||||
Button::with_label(if dock_object.property("saved").unwrap().get::<bool>().unwrap() {"Remove from Favorites"} else {"Add to Favorites"});
|
||||
Button::with_label(if dock_object.property::<bool>("saved") {"Remove from Favorites"} else {"Add to Favorites"});
|
||||
};
|
||||
menu_handle.append(&favorite_item);
|
||||
imp.favorite_item.replace(favorite_item);
|
||||
|
||||
if let Ok(window_list) = dock_object
|
||||
.property("active")
|
||||
.unwrap()
|
||||
.get::<BoxedWindowList>()
|
||||
{
|
||||
if window_list.0.len() > 1 {
|
||||
let quit_all_item = cascade! {
|
||||
Button::with_label(format!("Quit {} Windows", window_list.0.len()).as_str());
|
||||
};
|
||||
menu_handle.append(&quit_all_item);
|
||||
imp.quit_all_item.replace(quit_all_item);
|
||||
} else {
|
||||
let quit_all_item = cascade! {
|
||||
Button::with_label("Quit");
|
||||
};
|
||||
menu_handle.append(&quit_all_item);
|
||||
if window_list.0.len() == 0 {
|
||||
quit_all_item.hide();
|
||||
}
|
||||
imp.quit_all_item.replace(quit_all_item);
|
||||
let window_list = dock_object.property::<BoxedWindowList>("active");
|
||||
|
||||
if window_list.0.len() > 1 {
|
||||
let quit_all_item = cascade! {
|
||||
Button::with_label(format!("Quit {} Windows", window_list.0.len()).as_str());
|
||||
};
|
||||
menu_handle.append(&quit_all_item);
|
||||
imp.quit_all_item.replace(quit_all_item);
|
||||
} else {
|
||||
let quit_all_item = cascade! {
|
||||
Button::with_label("Quit");
|
||||
};
|
||||
menu_handle.append(&quit_all_item);
|
||||
if window_list.0.len() == 0 {
|
||||
quit_all_item.hide();
|
||||
}
|
||||
imp.quit_all_item.replace(quit_all_item);
|
||||
}
|
||||
|
||||
self.setup_handlers();
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +153,7 @@ impl DockPopover {
|
|||
}
|
||||
|
||||
fn emit_hide(&self) {
|
||||
self.emit_by_name::<&str>("menu-hide", &[]).unwrap();
|
||||
self.emit_by_name::<()>("menu-hide", &[]);
|
||||
}
|
||||
|
||||
pub fn reset_menu(&self) {
|
||||
|
|
@ -190,7 +182,7 @@ impl DockPopover {
|
|||
// println!("setting up popover menu handlers");
|
||||
let self_ = self.clone();
|
||||
launch_new_item.connect_clicked(glib::clone!(@weak dock_object, => move |_| {
|
||||
let app_info = dock_object.property("appinfo").expect("DockObject must have appinfo property").get::<Option<DesktopAppInfo>>().expect("Failed to convert value to DesktopAppInfo").unwrap();
|
||||
let app_info = dock_object.property::<Option<DesktopAppInfo>>("appinfo").expect("Failed to convert value to DesktopAppInfo");
|
||||
|
||||
let window = self_.root().unwrap().downcast::<Window>().unwrap();
|
||||
let context = window.display().app_launch_context();
|
||||
|
|
@ -209,7 +201,7 @@ impl DockPopover {
|
|||
|
||||
let self_ = self.clone();
|
||||
quit_all_item.connect_clicked(glib::clone!(@weak dock_object => move |_| {
|
||||
let active = dock_object.property("active").expect("DockObject must have active property").get::<BoxedWindowList>().expect("Failed to convert value to WindowList").0;
|
||||
let active = dock_object.property::<BoxedWindowList>("active").0;
|
||||
for w in active {
|
||||
let entity = w.entity.clone();
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
|
|
@ -223,7 +215,7 @@ impl DockPopover {
|
|||
|
||||
let self_ = self.clone();
|
||||
favorite_item.connect_clicked(glib::clone!(@weak dock_object => move |_| {
|
||||
let saved = dock_object.property("saved").expect("DockObject must have saved property").get::<bool>().expect("Failed to convert value to bool");
|
||||
let saved = dock_object.property::<bool>("saved");
|
||||
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
if let Some(tx) = TX.get() {
|
||||
|
|
@ -244,16 +236,18 @@ impl DockPopover {
|
|||
// );
|
||||
|
||||
let self_ = self.clone();
|
||||
window_listbox.connect_row_activated(glib::clone!(@weak dock_object => move |_, item| {
|
||||
let active = dock_object.property("active").expect("DockObject must have active property").get::<BoxedWindowList>().expect("Failed to convert value to WindowList").0;
|
||||
let entity = active[usize::try_from(item.index()).unwrap()].entity.clone();
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
if let Some(tx) = TX.get() {
|
||||
let _ = tx.send(Event::Activate(entity)).await;
|
||||
}
|
||||
});
|
||||
self_.emit_hide();
|
||||
}));
|
||||
window_listbox.connect_row_activated(
|
||||
glib::clone!(@weak dock_object => move |_, item| {
|
||||
let active = dock_object.property::<BoxedWindowList>("active").0;
|
||||
let entity = active[usize::try_from(item.index()).unwrap()].entity.clone();
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
if let Some(tx) = TX.get() {
|
||||
let _ = tx.send(Event::Activate(entity)).await;
|
||||
}
|
||||
});
|
||||
self_.emit_hide();
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue