Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
andy128k committed Mar 4, 2024
1 parent c69a351 commit 50b0302
Show file tree
Hide file tree
Showing 21 changed files with 214 additions and 191 deletions.
291 changes: 162 additions & 129 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 @@ -10,7 +10,7 @@ readme = "README.md"

[dependencies]
futures = "0.3"
os_str_bytes = { version = "6", features = ["conversions"] }
os_str_bytes = { version = "7", features = ["conversions"] }

rand = "0.8"
aes = "0.8"
Expand All @@ -22,12 +22,12 @@ quick-xml = "0.31"
toml = "0.8"
serde = { version = "1", features = ["derive"] }

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

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

[target.'cfg(target_os = "windows")'.build-dependencies]
embed-resource = "2"
Expand Down
5 changes: 2 additions & 3 deletions src/ui/accel_label/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use gtk::{glib, prelude::*, subclass::prelude::*};

mod imp {
use super::*;
use crate::utils::ui::orphan_all_children;

#[derive(Default)]
pub struct AccelLabel;
Expand Down Expand Up @@ -32,9 +33,7 @@ mod imp {
}

fn dispose(&self) {
while let Some(child) = self.obj().first_child() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::ui::accel_label::AccelLabel;
use gtk::{gdk, glib, prelude::*};

pub fn shortcuts_window(
parent: Option<&impl glib::IsA<gtk::Window>>,
parent: Option<&impl IsA<gtk::Window>>,
shortcuts: &[ShortcutGroup<'static>],
) -> gtk::Window {
let window = gtk::Window::builder()
Expand Down
5 changes: 2 additions & 3 deletions src/ui/edit_record/record_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod imp {
use crate::ui::forms::entry::*;
use crate::ui::forms::multiline::*;
use crate::ui::password_editor::PasswordEditor;
use crate::utils::ui::orphan_all_children;
use std::cell::OnceCell;
use std::sync::OnceLock;

Expand Down Expand Up @@ -55,9 +56,7 @@ mod imp {
}

fn dispose(&self) {
while let Some(child) = self.obj().first_child() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/ui/edit_record/record_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use gtk::{glib, prelude::*, subclass::prelude::*};
use std::cell::RefCell;

mod imp {
use crate::ui::dialogs::show_uri::show_uri;

use super::*;
use crate::ui::dialogs::show_uri::show_uri;
use crate::utils::ui::orphan_all_children;
use std::sync::OnceLock;

pub struct RecordWidget {
Expand Down Expand Up @@ -93,9 +93,7 @@ mod imp {
}

fn dispose(&self) {
while let Some(child) = self.obj().first_child() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/ui/file_pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod imp {
use crate::ui::record_type_popover::RecordTypePopoverBuilder;
use crate::ui::record_view::item::DropOption;
use crate::utils::typed_list_store::TypedListStore;
use crate::utils::ui::{action_button, action_popover_button};
use crate::utils::ui::{action_button, action_popover_button, orphan_all_children};
use std::cell::RefCell;
use std::sync::OnceLock;

Expand Down Expand Up @@ -195,9 +195,7 @@ mod imp {
}

fn dispose(&self) {
while let Some(child) = self.obj().first_child() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/group_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use gtk::{gio, glib, prelude::*};

use super::list_item_factory::PSListItemFactory;

pub fn singleton_list(item: &impl glib::IsA<glib::Object>) -> gio::ListStore {
pub fn singleton_list(item: &impl IsA<glib::Object>) -> gio::ListStore {
let list = gio::ListStore::with_type(item.type_());
list.append(item);
list
Expand Down
5 changes: 2 additions & 3 deletions src/ui/nav_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod imp {
use crate::model::tree::RecordNode;
use crate::ui::list_item_factory::PSListItemFactory;
use crate::utils::grid_layout::PSGridLayoutExt;
use crate::utils::ui::orphan_all_children;
use std::cell::Cell;
use std::sync::OnceLock;

Expand Down Expand Up @@ -147,9 +148,7 @@ mod imp {
}

fn dispose(&self) {
while let Some(child) = self.obj().first_child() {
child.unparent();
}
orphan_all_children(&*self.obj());
self.disconnect_model_change_handler();
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/ui/open_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use std::error::Error;

mod imp {
use super::*;
use crate::utils::ui::{hexpander, vexpander};
use awesome_gtk::widget::AwesomeWidgetTraverseExt;
use crate::utils::ui::{hexpander, orphan_all_children, vexpander};

pub struct OpenFile {
pub entry: gtk::Entry,
Expand Down Expand Up @@ -146,9 +145,7 @@ mod imp {
}

fn dispose(&self) {
for child in self.obj().children() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/ui/password_strength_bar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use gtk::{glib, prelude::*, subclass::prelude::*};

mod imp {
use super::*;
use crate::utils::ui::orphan_all_children;

#[derive(Default)]
pub struct PasswordStrengthBar {
Expand Down Expand Up @@ -43,9 +44,7 @@ mod imp {
}

fn dispose(&self) {
while let Some(child) = self.obj().first_child() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ui/record_view/compose_paintable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ glib::wrapper! {
}

impl PSBackgroundPaintable {
pub fn new(next: impl glib::IsA<gdk::Paintable>) -> Self {
pub fn new(next: impl IsA<gdk::Paintable>) -> Self {
let obj: Self = glib::Object::builder().build();
obj.imp().next.set(next.upcast()).unwrap();
obj
Expand Down
6 changes: 2 additions & 4 deletions src/ui/record_view/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod imp {
use crate::ui::dialogs::show_uri::show_uri;
use crate::ui::record_view::compose_paintable::PSBackgroundPaintable;
use crate::utils::style::StaticCssExt;
use awesome_gtk::widget::AwesomeWidgetTraverseExt;
use crate::utils::ui::orphan_all_children;
use std::cell::{Cell, RefCell};
use std::sync::OnceLock;

Expand Down Expand Up @@ -159,9 +159,7 @@ mod imp {
}

fn dispose(&self) {
for child in self.obj().children() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/ui/record_view/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
mod imp {
use super::*;
use crate::ui::record_view::item::PSRecordViewItem;
use crate::utils::ui::scrolled;
use crate::utils::ui::{orphan_all_children, scrolled};
use crate::weak_map::WeakMap;
use std::cell::RefCell;
use std::rc::Rc;
Expand Down Expand Up @@ -112,9 +112,7 @@ mod imp {
}

fn dispose(&self) {
while let Some(child) = self.obj().first_child() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/ui/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub struct SearchConfig {

mod imp {
use super::*;
use crate::utils::ui::orphan_all_children;
use std::sync::OnceLock;

#[derive(Default)]
Expand Down Expand Up @@ -133,9 +134,7 @@ mod imp {
}

fn dispose(&self) {
while let Some(child) = self.obj().first_child() {
child.unparent();
}
orphan_all_children(&*self.obj());
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/utils/grid_layout.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use gtk::{glib, prelude::*};
use gtk::prelude::*;

pub trait PSGridLayoutExt {
fn grid_attach(&self, child: &impl glib::IsA<gtk::Widget>) -> gtk::GridLayoutChild;
fn grid_attach(&self, child: &impl IsA<gtk::Widget>) -> gtk::GridLayoutChild;
}

impl<T: glib::IsA<gtk::Widget>> PSGridLayoutExt for T {
fn grid_attach(&self, child: &impl glib::IsA<gtk::Widget>) -> gtk::GridLayoutChild {
impl<T: IsA<gtk::Widget>> PSGridLayoutExt for T {
fn grid_attach(&self, child: &impl IsA<gtk::Widget>) -> gtk::GridLayoutChild {
child.set_parent(self);
self.layout_manager()
.and_downcast::<gtk::GridLayout>()
Expand Down
4 changes: 2 additions & 2 deletions src/utils/list_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ pub trait ListModelImmutableExt {
fn last(&self) -> Option<glib::Object>;
fn sliced(&self, range: impl RangeBounds<u32>) -> gio::ListStore;

fn appended<T: glib::IsA<glib::Object>>(&self, new_item: &T) -> gio::ListStore {
fn appended<T: IsA<glib::Object>>(&self, new_item: &T) -> gio::ListStore {
let result = self.sliced(..);
result.append(new_item);
result
}
}

impl<T: glib::IsA<gio::ListModel>> ListModelImmutableExt for T {
impl<T: IsA<gio::ListModel>> ListModelImmutableExt for T {
fn first(&self) -> Option<glib::Object> {
let size = self.n_items();
if size > 0 {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub trait StaticCssExt {
fn add_static_css(&self, css: &'static str, priority: u32);
}

impl<W: glib::IsA<gtk::Widget>> StaticCssExt for W {
impl<W: IsA<gtk::Widget>> StaticCssExt for W {
fn add_static_css(&self, css: &'static str, priority: u32) {
self.connect_realize(move |this| {
add_static_css(&this.display(), css, priority);
Expand All @@ -31,7 +31,7 @@ pub trait PSStyleContextExt {
fn set_css_class(&self, class_name: &str, set: bool);
}

impl<O: glib::IsA<gtk::Widget>> PSStyleContextExt for O {
impl<O: IsA<gtk::Widget>> PSStyleContextExt for O {
fn set_css_class(&self, class_name: &str, set: bool) {
if set {
self.add_css_class(class_name);
Expand Down
12 changes: 6 additions & 6 deletions src/utils/typed_list_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct TypedListStore<T>(gio::ListStore, PhantomData<T>);

impl<T> TypedListStore<T>
where
T: glib::IsA<glib::Object>,
T: IsA<glib::Object>,
{
pub fn from_untyped(list: gio::ListStore) -> Self {
Self(list, PhantomData)
Expand Down Expand Up @@ -165,7 +165,7 @@ where

impl<T> std::default::Default for TypedListStore<T>
where
T: glib::IsA<glib::Object>,
T: IsA<glib::Object>,
{
fn default() -> Self {
Self::new()
Expand All @@ -179,7 +179,7 @@ pub struct ListStoreIterator<T> {

impl<T> std::iter::Iterator for ListStoreIterator<T>
where
T: glib::IsA<glib::Object>,
T: IsA<glib::Object>,
{
type Item = T;

Expand All @@ -194,7 +194,7 @@ where

impl<T> std::iter::IntoIterator for &TypedListStore<T>
where
T: glib::IsA<glib::Object>,
T: IsA<glib::Object>,
{
type Item = T;
type IntoIter = ListStoreIterator<T>;
Expand All @@ -206,7 +206,7 @@ where

impl<T> std::iter::FromIterator<T> for TypedListStore<T>
where
T: glib::IsA<glib::Object>,
T: IsA<glib::Object>,
{
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
let list = TypedListStore::new();
Expand All @@ -219,7 +219,7 @@ where

impl<T> std::cmp::PartialEq for TypedListStore<T>
where
T: glib::IsA<glib::Object> + PartialEq,
T: IsA<glib::Object> + PartialEq,
{
fn eq(&self, other: &TypedListStore<T>) -> bool {
let len = self.len();
Expand Down
6 changes: 6 additions & 0 deletions src/utils/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ impl PSWidgetLookupExt for Option<gtk::Widget> {
}
}

pub fn orphan_all_children(widget: &impl IsA<gtk::Widget>) {
while let Some(child) = widget.first_child() {
child.unparent();
}
}

pub fn centered<W: IsA<gtk::Widget>>(widget: &W) -> gtk::Widget {
widget.set_hexpand(true);
widget.set_halign(gtk::Align::Center);
Expand Down
6 changes: 3 additions & 3 deletions src/weak_map.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use gtk::{glib, glib::prelude::*};
use std::cell::RefCell;

pub struct WeakMap<K: Copy, V: glib::ObjectType> {
pub struct WeakMap<K: Copy, V: ObjectType> {
mappings: RefCell<Vec<(K, glib::WeakRef<V>)>>,
}

impl<K: Copy, V: glib::ObjectType> Default for WeakMap<K, V> {
impl<K: Copy, V: ObjectType> Default for WeakMap<K, V> {
fn default() -> Self {
Self {
mappings: Default::default(),
}
}
}

impl<K: Copy + PartialEq, V: glib::ObjectType> WeakMap<K, V> {
impl<K: Copy + PartialEq, V: ObjectType> WeakMap<K, V> {
pub fn add(&self, key: K, value: &V) {
self.clean_expired();
let position = self
Expand Down

0 comments on commit 50b0302

Please sign in to comment.