merge
This commit is contained in:
commit
9f5af5e573
3 changed files with 39 additions and 6 deletions
14
Cargo.toml
14
Cargo.toml
|
|
@ -10,7 +10,17 @@ gdk4-x11 = "0.3.0"
|
|||
gio = "0.14.8"
|
||||
gtk4 = "0.3.1"
|
||||
x11 = { version = "2", features = ["xlib"] }
|
||||
|
||||
# examples/launcher
|
||||
pop-launcher = "1.0.3"
|
||||
serde_json = "1.0.70"
|
||||
#pop-launcher = "1.0.3"
|
||||
pop-launcher = { git = "https://github.com/pop-os/launcher", branch = "master" }
|
||||
serde_json = "1.0.72"
|
||||
pop-launcher-service = { git = "https://github.com/pop-os/launcher", branch = "master" }
|
||||
postage = "0.4.1"
|
||||
futures = "0.3.17"
|
||||
glib = "0.14.8"
|
||||
# examples/gtklauncher
|
||||
once_cell = "1.8.0"
|
||||
xdg = "2.4.0"
|
||||
serde = "1.0.130"
|
||||
x11rb = "0.9.0"
|
||||
|
|
|
|||
|
|
@ -62,12 +62,16 @@ impl DockItem {
|
|||
if let Some(drag_controller) = self_.drag_controller.get() {
|
||||
// if let Some(file) = app_info.filename() {
|
||||
// let file = File::for_path(file);
|
||||
let provider = ContentProvider::for_value(&app_info.to_value());
|
||||
drag_controller.set_content(Some(&provider));
|
||||
if let Some(file) = app_info.filename() {
|
||||
let file = File::for_path(file);
|
||||
let provider = ContentProvider::for_value(&file.to_value());
|
||||
drag_controller.set_content(Some(&provider));
|
||||
}
|
||||
// }
|
||||
drag_controller.connect_drag_end(move |_self, _drag, delete_data| {
|
||||
dbg!("removing", delete_data);
|
||||
});
|
||||
//TODO investigate X11 errors when reordering dock items
|
||||
drag_controller.connect_drag_cancel(
|
||||
glib::clone!(@weak saved_app_model => @default-return true, move |_self, _drag, _delete_data| {
|
||||
dbg!("removing {}", i);
|
||||
|
|
|
|||
|
|
@ -223,15 +223,34 @@ impl Window {
|
|||
// None => drag.actions(),
|
||||
// }
|
||||
// });
|
||||
|
||||
let saved_app_list_view = saved_app_list_view.get();
|
||||
drop_controller.connect_drop(
|
||||
glib::clone!(@weak saved_app_model => @default-return true, move |_self, drop_value, x, y| {
|
||||
glib::clone!(@weak saved_app_model, @weak saved_app_list_view => @default-return true, move |_self, drop_value, x, y| {
|
||||
dbg!(x);
|
||||
dbg!(y);
|
||||
let max_y = saved_app_list_view.allocated_height();
|
||||
let max_x = saved_app_list_view.allocated_width();
|
||||
dbg!(max_x);
|
||||
dbg!(max_y);
|
||||
let n_buckets = saved_app_model.n_items() * 2;
|
||||
|
||||
let drop_bucket = (x * n_buckets as f64 / (max_x as f64 + 0.1)) as u32;
|
||||
let index = if drop_bucket == 0 {
|
||||
0
|
||||
} else if drop_bucket == n_buckets - 1 {
|
||||
saved_app_model.n_items()
|
||||
} else {
|
||||
(drop_bucket + 1) / 2
|
||||
};
|
||||
dbg!(index);
|
||||
dbg!("dropped it!");
|
||||
if let Ok(Some(path)) = drop_value.get::<Option<String>>() {
|
||||
dbg!(&path);
|
||||
if let Some(path) = &Path::new(&path).file_name() {
|
||||
if let Some(app_info) = gio::DesktopAppInfo::new(&path.to_string_lossy()) {
|
||||
dbg!(app_info.name());
|
||||
saved_app_model.append(&app_info);
|
||||
saved_app_model.insert(index, &app_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue