Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
andy128k committed Aug 10, 2024
1 parent 007a259 commit 20c0a3a
Show file tree
Hide file tree
Showing 24 changed files with 707 additions and 443 deletions.
302 changes: 166 additions & 136 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ aes = "0.8"
cbc = "0.1"
deflate = "1"
inflate = "0.4"
quick-xml = "0.33"
quick-xml = "0.36"

toml = "0.8"
serde = { version = "1", features = ["derive"] }

gtk = { package = "gtk4", version = "0.8", features = ["v4_12"] }
awesome-glib = "0.4"
awesome-gtk = "0.4"
gtk = { package = "gtk4", version = "0.9", features = ["v4_12"] }
awesome-glib = "0.5"
awesome-gtk = "0.5"

clap = { version = "4.5.4", features = ["derive"] }

[build-dependencies]
glib-build-tools = "0.19"
glib-build-tools = "0.20"

[target.'cfg(target_os = "windows")'.build-dependencies]
embed-resource = "2"
Expand Down
10 changes: 6 additions & 4 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ mod imp {

let files = files.to_owned();
let hint = hint.to_owned();
glib::MainContext::default().spawn_local(
glib::clone!(@weak self as imp => async move {
glib::MainContext::default().spawn_local(glib::clone!(
#[weak(rename_to = imp)]
self,
async move {
imp.on_open(&files, &hint).await;
}),
);
}
));
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/format/revelation/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ fn read_attribute<R: BufRead>(
for attr in atts.with_checks(false) {
let attr = attr?;
if attr.key.as_ref() == name {
let value = attr.decode_and_unescape_value(reader)?.to_string();
let value = attr
.decode_and_unescape_value(reader.decoder())?
.to_string();
return Ok(Some(value));
}
}
Expand Down
94 changes: 57 additions & 37 deletions src/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,55 +159,73 @@ mod imp {
});
*self.delete_handler.borrow_mut() = Some(delete_handler);

self.search_bar
.connect_search(glib::clone!(@weak win => move |event| {
self.search_bar.connect_search(glib::clone!(
#[weak]
win,
move |event| {
glib::MainContext::default().spawn_local(async move {
win.search(&event).await;
});
}));
self.search_bar.connect_configure(
glib::clone!(@weak self as imp => move |search_config| {
imp.config_service.get().unwrap()
.update(|config| {
config.search_in_secrets = search_config.search_in_secrets;
});
}),
);
self.search_bar
.connect_search_closed(glib::clone!(@weak self as imp => move || {
}
));
self.search_bar.connect_configure(glib::clone!(
#[weak(rename_to = imp)]
self,
move |search_config| {
imp.config_service.get().unwrap().update(|config| {
config.search_in_secrets = search_config.search_in_secrets;
});
}
));
self.search_bar.connect_search_closed(glib::clone!(
#[weak(rename_to = imp)]
self,
move || {
imp.search_reset();
imp.set_mode(imp::AppMode::FileOpened);
}));
}
));

self.file_pane.connect_edit_record(
glib::clone!(@weak win => move |_, position, record_node| {
self.file_pane.connect_edit_record(glib::clone!(
#[weak]
win,
move |_, position, record_node| {
glib::MainContext::default().spawn_local(async move {
win.action_edit(position, record_node).await;
});
}),
);
self.file_pane
.connect_file_changed(glib::clone!(@weak win => move |_| {
}
));
self.file_pane.connect_file_changed(glib::clone!(
#[weak]
win,
move |_| {
win.set_changed(true);
}));
self.file_pane.connect_user_notification(
glib::clone!(@weak self as imp => move |_, message| {
}
));
self.file_pane.connect_user_notification(glib::clone!(
#[weak(rename_to = imp)]
self,
move |_, message| {
imp.toast.notify(message);
}),
);
}
));

self.search_pane.connect_edit_record(
glib::clone!(@weak win => move |_, position, record_node| {
self.search_pane.connect_edit_record(glib::clone!(
#[weak]
win,
move |_, position, record_node| {
glib::MainContext::default().spawn_local(async move {
win.action_edit(position, record_node).await;
});
}),
);
self.search_pane.connect_user_notification(
glib::clone!(@weak self as imp => move |_, message| {
}
));
self.search_pane.connect_user_notification(glib::clone!(
#[weak(rename_to = imp)]
self,
move |_, message| {
imp.toast.notify(message);
}),
);
}
));
}
}

Expand Down Expand Up @@ -511,11 +529,13 @@ impl PSMainWindow {

let config = config_service.get();
win.imp().search_bar.configure(config.search_in_secrets);
config_service
.on_change
.subscribe(glib::clone!(@weak win => move |new_config| {
config_service.on_change.subscribe(glib::clone!(
#[weak]
win,
move |new_config| {
win.imp().search_bar.configure(new_config.search_in_secrets);
}));
}
));

win.present();
win.imp().set_mode(imp::AppMode::Initial);
Expand Down
24 changes: 17 additions & 7 deletions src/ui/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ pub fn file_row(
.child(&grid)
.build();

remove_button.connect_clicked(glib::clone!(@weak row => move |_| {
on_remove(&row, &filename);
}));
remove_button.connect_clicked(glib::clone!(
#[weak]
row,
move |_| {
on_remove(&row, &filename);
}
));

set_group_title(&row, "Recent files");

Expand Down Expand Up @@ -194,10 +198,16 @@ impl PSDashboard {
for filename in cache.recent_files() {
if let Some(row) = file_row(
filename,
glib::clone!(@weak self.listbox as listbox, @strong cache => move |row, filename| {
cache.remove_file(filename);
listbox.remove(row);
}),
glib::clone!(
#[weak(rename_to = listbox)]
self.listbox,
#[strong]
cache,
move |row, filename| {
cache.remove_file(filename);
listbox.remove(row);
}
),
) {
self.listbox.append(&row);
if first_row.is_none() {
Expand Down
28 changes: 18 additions & 10 deletions src/ui/dialogs/generic_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ mod imp {
*self.sender.borrow_mut() = Some(sender.clone());
*self.receiver.borrow_mut() = Some(receiver);

self.cancel_button.connect_clicked(
glib::clone!(@weak self as imp => move |_| imp.send(gtk::ResponseType::Cancel)),
);
self.cancel_button.connect_clicked(glib::clone!(
#[weak(rename_to = imp)]
self,
move |_| imp.send(gtk::ResponseType::Cancel)
));
header.pack_start(&self.cancel_button);

self.ok_button.connect_clicked(
glib::clone!(@weak self as imp => move |_| imp.send(gtk::ResponseType::Ok)),
);
self.ok_button.connect_clicked(glib::clone!(
#[weak(rename_to = imp)]
self,
move |_| imp.send(gtk::ResponseType::Ok)
));
header.pack_end(&self.ok_button);

self.obj().set_modal(true);
Expand All @@ -72,8 +76,12 @@ mod imp {
self.obj().set_icon_name(Some("password-storage"));

let key_controller = gtk::EventControllerKey::new();
key_controller.connect_key_pressed(
glib::clone!(@weak self as imp => @default-return glib::Propagation::Proceed, move |_controller, key, _keycode, modifier| {
key_controller.connect_key_pressed(glib::clone!(
#[weak(rename_to = imp)]
self,
#[upgrade_or]
glib::Propagation::Proceed,
move |_controller, key, _keycode, modifier| {
const NO_MODIFIER: gdk::ModifierType = gdk::ModifierType::empty();
match (key, modifier) {
(gdk::Key::Escape, NO_MODIFIER)
Expand All @@ -88,8 +96,8 @@ mod imp {
}
_ => glib::Propagation::Proceed,
}
}),
);
}
));
self.obj().add_controller(key_controller);
}
}
Expand Down
20 changes: 12 additions & 8 deletions src/ui/dialogs/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,24 @@ pub fn shortcuts_window(
window.set_transient_for(parent);

let key_controller = gtk::EventControllerKey::new();
key_controller.connect_key_pressed(
glib::clone!(@weak window => @default-return glib::Propagation::Proceed, move |_controller, key, _keycode, modifier| {
key_controller.connect_key_pressed(glib::clone!(
#[weak]
window,
#[upgrade_or]
glib::Propagation::Proceed,
move |_controller, key, _keycode, modifier| {
const NO_MODIFIER: gdk::ModifierType = gdk::ModifierType::empty();
match (key, modifier) {
(gdk::Key::Escape, NO_MODIFIER) |
(gdk::Key::w, PRIMARY_MODIFIER) |
(gdk::Key::W, PRIMARY_MODIFIER) => {
(gdk::Key::Escape, NO_MODIFIER)
| (gdk::Key::w, PRIMARY_MODIFIER)
| (gdk::Key::W, PRIMARY_MODIFIER) => {
window.close();
glib::Propagation::Stop
},
}
_ => glib::Propagation::Proceed,
}
}),
);
}
));
window.add_controller(key_controller);

let grid = gtk::Grid::builder()
Expand Down
10 changes: 7 additions & 3 deletions src/ui/edit_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ pub async fn edit_object<T: 'static, W: FormWidget<T> + 'static>(
dlg.set_child(Some(&form));

dlg.set_ok_sensitive(widget.get_value().is_some());
widget.connect_changed(Box::new(glib::clone!(@weak dlg => move |value| {
dlg.set_ok_sensitive(value.is_some());
})));
widget.connect_changed(Box::new(glib::clone!(
#[weak]
dlg,
move |value| {
dlg.set_ok_sensitive(value.is_some());
}
)));

widget.set_value(object);

Expand Down
34 changes: 23 additions & 11 deletions src/ui/edit_record/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,15 @@ impl RecordWidget {
callback: RefCell::new(Box::new(no_op)),
}));

open_button.connect_clicked(glib::clone!(@weak widget => move |_| {
glib::MainContext::default().spawn_local(async move {
widget.open().await;
});
}));
open_button.connect_clicked(glib::clone!(
#[weak]
widget,
move |_| {
glib::MainContext::default().spawn_local(async move {
widget.open().await;
});
}
));

widget
}
Expand All @@ -172,9 +176,13 @@ impl RecordWidget {

let popover = RecordTypePopoverBuilder::default()
.record_types(&convert_to_types)
.on_activate(glib::clone!(@weak self as this => move |dest_record_type| {
this.convert_to(dest_record_type);
}))
.on_activate(glib::clone!(
#[weak(rename_to = this)]
self,
move |dest_record_type| {
this.convert_to(dest_record_type);
}
))
.build();

self.0.convert_button.set_popover(Some(&popover));
Expand All @@ -187,9 +195,13 @@ impl RecordWidget {
self.0.grid.remove(&old_form);
}
let mut form = RecordForm::new(record_type, &self.0.names);
form.connect_changed(Box::new(glib::clone!(@weak self as this => move |value| {
this.0.callback.borrow()(value);
})));
form.connect_changed(Box::new(glib::clone!(
#[weak(rename_to = this)]
self,
move |value| {
this.0.callback.borrow()(value);
}
)));
let form_widget = form.get_widget();
*self.0.form.borrow_mut() = Some(form);

Expand Down
10 changes: 7 additions & 3 deletions src/ui/edit_record/record_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,13 @@ mod imp {
.build();
self.grid.attach(&label_widget, 0, index as i32, 1, 1);

widget.connect_changed(Box::new(glib::clone!(@weak self as this => move |_| {
this.obj().emit_by_name::<()>("record-changed", &[]);
})));
widget.connect_changed(Box::new(glib::clone!(
#[weak(rename_to = this)]
self,
move |_| {
this.obj().emit_by_name::<()>("record-changed", &[]);
}
)));
self.grid
.attach(&widget.get_widget(), 1, index as i32, 1, 1);

Expand Down
Loading

0 comments on commit 20c0a3a

Please sign in to comment.