Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remember search_pdf and search_office across restarts #12

Merged
merged 1 commit into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions gnome/src/config/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ pub struct Config {
#[property(get, set = Self::set_window_maximized, default = false)]
window_maximized: Cell<bool>,

#[property(get, set = Self::set_search_pdf, default = false)]
search_pdf: Cell<bool>,
#[property(get, set = Self::set_search_office, default = false)]
search_office: Cell<bool>,

config: OnceCell<cosmic_config::Config>,
}

Expand All @@ -36,6 +41,18 @@ impl Config {
let _ = config.set("window_maximized", maximized);
self.window_maximized.set(maximized);
}

fn set_search_pdf(&self, search_pdf: bool) {
let config = self.config.get().unwrap();
let _ = config.set("search_pdf", search_pdf);
self.search_pdf.set(search_pdf);
}

fn set_search_office(&self, search_office: bool) {
let config = self.config.get().unwrap();
let _ = config.set("search_office", search_office);
self.search_office.set(search_office);
}
}

// Basic declaration of our type for the GObject type system
Expand All @@ -62,6 +79,14 @@ impl ObjectImpl for Config {
self.window_maximized.set(window_maximized);
}

if let Ok(search_pdf) = config.get("search_pdf") {
self.search_pdf.set(search_pdf);
}

if let Ok(search_office) = config.get("search_office") {
self.search_office.set(search_office);
}

let _ = self.config.set(config);
}
}
12 changes: 12 additions & 0 deletions gnome/src/search_window/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ impl ObjectImpl for SearchWindow {
.sync_create()
.build();

self.config
.bind_property("search_pdf", obj.as_ref(), "search_pdf")
.bidirectional()
.sync_create()
.build();

self.config
.bind_property("search_office", obj.as_ref(), "search_office")
.bidirectional()
.sync_create()
.build();

obj.results().connect_items_changed(clone!(
#[weak]
obj,
Expand Down
Loading