From dff62a9e31ff85305eb2d70b036ee25c90e4feeb Mon Sep 17 00:00:00 2001 From: Ricky Kresslein Date: Thu, 23 Mar 2023 09:34:44 +0100 Subject: Use gtk-rs 0.6.4 --- src/application.rs | 24 ++++++++++-------- src/main.rs | 4 +-- src/ui/history_box.rs | 10 ++++---- src/ui/preferences_window.rs | 15 +++++------ src/ui/report.rs | 18 +++++++------- src/ui/task_details.rs | 28 ++++++++++----------- src/ui/task_row.rs | 15 +++++------ src/ui/tasks_group.rs | 7 +++--- src/ui/tasks_page.rs | 12 ++++----- src/ui/window.rs | 59 +++++++++++++++++++++++--------------------- 10 files changed, 100 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/application.rs b/src/application.rs index 8d627c5..218bc9e 100644 --- a/src/application.rs +++ b/src/application.rs @@ -43,8 +43,9 @@ mod imp { } impl ObjectImpl for FurtheranceApplication { - fn constructed(&self, obj: &Self::Type) { - self.parent_constructed(obj); + fn constructed(&self) { + self.parent_constructed(); + let obj = self.obj(); obj.setup_gactions(); obj.setup_application(); @@ -57,16 +58,17 @@ mod imp { // has been launched. Additionally, this callback notifies us when the user // tries to launch a "second instance" of the application. When they try // to do that, we'll just present any existing window. - fn activate(&self, application: &Self::Type) { + fn activate(&self) { // Initialize the database let _ = database::db_init(); let _ = database::upgrade_old_db(); // Get the current window or create one if necessary + let application = self.obj(); let window = if let Some(window) = application.active_window() { window } else { - let window = FurtheranceWindow::new(application); + let window = FurtheranceWindow::new(&application.clone().upcast()); window.set_default_size(360, 600); window.set_title(Some("Furtherance")); window.upcast() @@ -100,8 +102,10 @@ glib::wrapper! { impl FurtheranceApplication { pub fn new(application_id: &str, flags: &gio::ApplicationFlags) -> Self { - glib::Object::new(&[("application-id", &application_id), ("flags", flags)]) - .expect("Failed to create FurtheranceApplication") + glib::Object::builder() + .property("application-id", application_id) + .property("flags", flags) + .build() } fn setup_gactions(&self) { @@ -158,14 +162,14 @@ impl FurtheranceApplication { let continue_pomodoro_action = gio::SimpleAction::new("continue-pomodoro-action", None); continue_pomodoro_action.connect_activate(clone!(@weak self as app => move |_, _| { - let imp = imp::FurtheranceApplication::from_instance(&app); + let imp = imp::FurtheranceApplication::from_obj(&app); imp.pomodoro_dialog.lock().unwrap().response(gtk::ResponseType::Accept); })); self.add_action(&continue_pomodoro_action); let stop_pomodoro_action = gio::SimpleAction::new("stop-pomodoro-action", None); stop_pomodoro_action.connect_activate(clone!(@weak self as app => move |_, _| { - let imp = imp::FurtheranceApplication::from_instance(&app); + let imp = imp::FurtheranceApplication::from_obj(&app); imp.pomodoro_dialog.lock().unwrap().response(gtk::ResponseType::Reject); })); self.add_action(&stop_pomodoro_action); @@ -185,7 +189,7 @@ impl FurtheranceApplication { .version(config::VERSION) .comments(&gettext("Track your time without being tracked")) .copyright("© 2023 LakoLiu") - .authors(vec!["Ricky Kresslein ".into()]) + .authors(vec!["Ricky Kresslein "]) .translator_credits(&gettext("translator-credits")) .website("https://furtherance.app") .license_type(gtk::License::Gpl30) @@ -315,7 +319,7 @@ impl FurtheranceApplication { } pub fn system_pomodoro_notification(&self, dialog: gtk::MessageDialog) { - let imp = imp::FurtheranceApplication::from_instance(self); + let imp = imp::FurtheranceApplication::from_obj(self); *imp.pomodoro_dialog.lock().unwrap() = dialog; let icon = Some("alarm-symbolic"); let notification = gio::Notification::new(&gettext("Time's up!")); diff --git a/src/main.rs b/src/main.rs index efe1522..abedf64 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,7 @@ fn main() { // Initialize GTK gtk::init().expect("Failed to initialize GTK."); // Initialize libadwaita - adw::init(); + let _ = adw::init(); // Set up gettext translations bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR).expect("Unable to bind the text domain"); @@ -55,5 +55,5 @@ fn main() { // exits. Upon return, we have our exit code to return to the shell. (This // is the code you see when you do `echo $?` after running a command in a // terminal. - std::process::exit(app.run()); + std::process::exit(app.run().into()); } diff --git a/src/ui/history_box.rs b/src/ui/history_box.rs index b36808e..8590bd0 100644 --- a/src/ui/history_box.rs +++ b/src/ui/history_box.rs @@ -15,7 +15,6 @@ // along with this program. If not, see . use glib::subclass; -use gtk::prelude::*; use gtk::subclass::prelude::*; use gtk::{glib, CompositeTemplate}; @@ -60,9 +59,10 @@ mod imp { } impl ObjectImpl for FurHistoryBox { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { + let obj = self.obj(); obj.setup_widgets(); - self.parent_constructed(obj); + self.parent_constructed(); } } impl WidgetImpl for FurHistoryBox {} @@ -90,7 +90,7 @@ impl FurHistoryBox { } fn set_view(&self, view: View) { - let imp = imp::FurHistoryBox::from_instance(self); + let imp = imp::FurHistoryBox::from_obj(self); let app = FurtheranceApplication::default(); app.delete_enabled(false); app.export_csv_enabled(false); @@ -115,7 +115,7 @@ impl FurHistoryBox { } pub fn create_tasks_page(&self) { - let imp = imp::FurHistoryBox::from_instance(self); + let imp = imp::FurHistoryBox::from_obj(self); let window = FurtheranceWindow::default(); imp.tasks_page.clear_task_list(); let is_saved_task: bool = match database::check_for_tasks() { diff --git a/src/ui/preferences_window.rs b/src/ui/preferences_window.rs index 6507ee3..ac0021d 100644 --- a/src/ui/preferences_window.rs +++ b/src/ui/preferences_window.rs @@ -19,7 +19,6 @@ use adw::subclass::prelude::*; use gettextrs::*; use glib::clone; use gtk::glib; -use gtk::subclass::prelude::*; use gtk::CompositeTemplate; use crate::settings_manager; @@ -95,14 +94,15 @@ mod imp { } impl ObjectImpl for FurPreferencesWindow { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { let window = FurtheranceWindow::default(); + let obj = self.obj(); obj.set_transient_for(Some(&window)); obj.setup_signals(); obj.setup_widgets(); - self.parent_constructed(obj); + self.parent_constructed(); } } @@ -124,13 +124,13 @@ glib::wrapper! { impl FurPreferencesWindow { pub fn new() -> Self { - glib::Object::new::(&[]).unwrap() + glib::Object::new::() } fn setup_widgets(&self) { self.set_search_enabled(false); - let imp = imp::FurPreferencesWindow::from_instance(self); + let imp = imp::FurPreferencesWindow::from_obj(self); let manager = adw::StyleManager::default(); let support_darkmode = manager.system_supports_color_schemes(); @@ -141,7 +141,7 @@ impl FurPreferencesWindow { } fn setup_signals(&self) { - let imp = imp::FurPreferencesWindow::from_instance(self); + let imp = imp::FurPreferencesWindow::from_obj(self); settings_manager::bind_property("dark-mode", &*imp.dark_theme_switch, "active"); @@ -253,7 +253,7 @@ impl FurPreferencesWindow { let settings = settings_manager::get_settings(); let _ = settings.set_string("database-loc", &path.to_string()); - let imp2 = imp::FurPreferencesWindow::from_instance(&this2); + let imp2 = imp::FurPreferencesWindow::from_obj(&this2); imp2.database_loc_row.set_subtitle(&path.to_string()); let window = FurtheranceWindow::default(); @@ -271,3 +271,4 @@ impl FurPreferencesWindow { })); } } + diff --git a/src/ui/report.rs b/src/ui/report.rs index a23bfda..a830b05 100644 --- a/src/ui/report.rs +++ b/src/ui/report.rs @@ -18,7 +18,6 @@ use adw::subclass::prelude::*; use chrono::{offset::TimeZone, Date, DateTime, Datelike, Duration, Local, NaiveDate}; use gettextrs::*; use glib::clone; -use gtk::subclass::prelude::*; use gtk::{glib, prelude::*, CompositeTemplate}; use itertools::Itertools; @@ -81,9 +80,10 @@ mod imp { } impl ObjectImpl for FurReport { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { + let obj = self.obj(); obj.setup_widgets(); - self.parent_constructed(obj); + self.parent_constructed(); } } @@ -101,7 +101,7 @@ glib::wrapper! { impl FurReport { pub fn new() -> Self { - let dialog: Self = glib::Object::new(&[]).unwrap(); + let dialog: Self = glib::Object::new::(); let window = FurtheranceWindow::default(); dialog.set_transient_for(Some(&window)); @@ -113,14 +113,14 @@ impl FurReport { } pub fn setup_widgets(&self) { - let imp = imp::FurReport::from_instance(self); + let imp = imp::FurReport::from_obj(self); imp.range_combo.set_active_id(Some("week_item")); imp.filter_combo.set_active_id(Some("tasks_item")); imp.range_combo .connect_changed(clone!(@weak self as this => move |combo|{ - let imp = imp::FurReport::from_instance(&this); + let imp = imp::FurReport::from_obj(&this); if combo.active_id().unwrap() != "date_range_item" { imp.date_range_box.set_visible(false); this.refresh_report(); @@ -131,7 +131,7 @@ impl FurReport { imp.filter_check .connect_toggled(clone!(@weak self as this => move |_|{ - let imp = imp::FurReport::from_instance(&this); + let imp = imp::FurReport::from_obj(&this); if imp.filter_box.get_visible() { imp.filter_box.set_visible(false); } else { @@ -141,7 +141,7 @@ impl FurReport { imp.filter_combo .connect_changed(clone!(@weak self as this => move |combo|{ - let imp = imp::FurReport::from_instance(&this); + let imp = imp::FurReport::from_obj(&this); if combo.active_id().unwrap() == "tasks_item" { imp.filter_entry.set_placeholder_text(Some(&gettext("Task, Task 2"))); } else { @@ -172,7 +172,7 @@ impl FurReport { } fn refresh_report(&self) { - let imp = imp::FurReport::from_instance(self); + let imp = imp::FurReport::from_obj(self); imp.format_error.set_visible(false); imp.start_end_error.set_visible(false); diff --git a/src/ui/task_details.rs b/src/ui/task_details.rs index f24a1bc..6939158 100644 --- a/src/ui/task_details.rs +++ b/src/ui/task_details.rs @@ -18,7 +18,6 @@ use adw::subclass::prelude::*; use chrono::{offset::TimeZone, DateTime, Local, NaiveDateTime, ParseError, Duration}; use gettextrs::*; use glib::clone; -use gtk::subclass::prelude::*; use gtk::{glib, prelude::*, CompositeTemplate}; use itertools::Itertools; @@ -80,11 +79,12 @@ mod imp { } impl ObjectImpl for FurTaskDetails { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { + let obj = self.obj(); obj.setup_signals(); obj.setup_delete_all(); obj.setup_add_similar(); - self.parent_constructed(obj); + self.parent_constructed(); } } @@ -102,7 +102,7 @@ glib::wrapper! { impl FurTaskDetails { pub fn new() -> Self { - let dialog: Self = glib::Object::new(&[]).unwrap(); + let dialog: Self = glib::Object::new::(); let window = FurtheranceWindow::default(); dialog.set_transient_for(Some(&window)); @@ -114,7 +114,7 @@ impl FurTaskDetails { } pub fn setup_widgets(&self, mut task_group: Vec) { - let imp = imp::FurTaskDetails::from_instance(self); + let imp = imp::FurTaskDetails::from_obj(self); imp.task_name_label.set_text(&task_group[0].task_name); let this_day_str = DateTime::parse_from_rfc3339(&task_group[0].start_time).unwrap(); @@ -435,7 +435,7 @@ impl FurTaskDetails { } fn clear_task_list(&self) { - let imp = imp::FurTaskDetails::from_instance(&self); + let imp = imp::FurTaskDetails::from_obj(&self); for task_box in &*imp.all_boxes.borrow() { imp.main_box.remove(task_box); @@ -474,12 +474,12 @@ impl FurTaskDetails { } fn setup_signals(&self) { - let imp = imp::FurTaskDetails::from_instance(self); + let imp = imp::FurTaskDetails::from_obj(self); // Add headerbar to dialog when scrolled far imp.scrolled_window.vadjustment().connect_value_notify( clone!(@weak self as this => move |adj|{ - let imp = imp::FurTaskDetails::from_instance(&this); + let imp = imp::FurTaskDetails::from_obj(&this); if adj.value() < 120.0 { imp.headerbar.add_css_class("hidden"); imp.dialog_title.set_visible(false); @@ -517,7 +517,7 @@ impl FurTaskDetails { let message_area = dialog.message_area().downcast::().unwrap(); let new_name_entry = gtk::Entry::new(); new_name_entry.set_placeholder_text(Some(&gettext("New Name #tags"))); - let imp3 = imp::FurTaskDetails::from_instance(&this); + let imp3 = imp::FurTaskDetails::from_obj(&this); new_name_entry.set_text(&imp3.orig_name_with_tags.borrow().to_string()); let cant_be_empty = gtk::Label::new(Some(&gettext("Task name cannot be empty."))); cant_be_empty.add_css_class("error_message"); @@ -546,7 +546,7 @@ impl FurTaskDetails { if !new_task_name.is_empty() { // Change all task names & tags - let imp2 = imp::FurTaskDetails::from_instance(&this); + let imp2 = imp::FurTaskDetails::from_obj(&this); for id in &*imp2.all_task_ids.borrow() { database::update_task_name(*id, new_task_name.trim().to_string()) .expect("Could not update group of task names"); @@ -572,7 +572,7 @@ impl FurTaskDetails { } fn setup_delete_all(&self) { - let imp = imp::FurTaskDetails::from_instance(self); + let imp = imp::FurTaskDetails::from_obj(self); imp.delete_all_btn.connect_clicked(clone!(@weak self as this => move |_|{ let dialog = gtk::MessageDialog::with_markup( Some(&this), @@ -611,9 +611,9 @@ impl FurTaskDetails { } fn setup_add_similar(&self) { - let imp = imp::FurTaskDetails::from_instance(self); + let imp = imp::FurTaskDetails::from_obj(self); imp.add_similar_btn.connect_clicked(clone!(@weak self as this => move |_|{ - let imp2 = imp::FurTaskDetails::from_instance(&this); + let imp2 = imp::FurTaskDetails::from_obj(&this); let dialog = gtk::MessageDialog::new( Some(&this), gtk::DialogFlags::MODAL, @@ -806,7 +806,7 @@ impl FurTaskDetails { } fn delete_all(&self) { - let imp = imp::FurTaskDetails::from_instance(self); + let imp = imp::FurTaskDetails::from_obj(self); let _ = database::delete_by_ids(imp.all_task_ids.borrow().to_vec()); } } diff --git a/src/ui/task_row.rs b/src/ui/task_row.rs index 810d12e..611ebed 100644 --- a/src/ui/task_row.rs +++ b/src/ui/task_row.rs @@ -64,9 +64,10 @@ mod imp { } impl ObjectImpl for FurTaskRow { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { + let obj = self.obj(); obj.setup_signals(); - self.parent_constructed(obj); + self.parent_constructed(); } } @@ -85,7 +86,7 @@ impl FurTaskRow { pub fn new() -> Self { /* This should take a model, object, or vec filled with the description details and fill out the labels based on those. */ - glib::Object::new(&[]).expect("Failed to create `FurTaskRow`.") + glib::Object::new::() } fn setup_signals(&self) { @@ -103,7 +104,7 @@ impl FurTaskRow { } pub fn set_row_labels(&self, task_list: Vec) { - let imp = imp::FurTaskRow::from_instance(&self); + let imp = imp::FurTaskRow::from_obj(&self); for task in task_list.clone() { imp.tasks.lock().unwrap().push(task); } @@ -129,7 +130,7 @@ impl FurTaskRow { window.duplicate_task(task_list[0].clone()); })); - self.add_controller(&gesture); + self.add_controller(gesture); imp.restart_task_btn .connect_clicked(clone!(@strong task_list => move |_| { @@ -161,12 +162,12 @@ impl FurTaskRow { } pub fn get_tasks(&self) -> Vec { - let imp = imp::FurTaskRow::from_instance(&self); + let imp = imp::FurTaskRow::from_obj(&self); imp.tasks.lock().unwrap().to_vec() } pub fn get_total_time(&self) -> i64 { - let imp = imp::FurTaskRow::from_instance(&self); + let imp = imp::FurTaskRow::from_obj(&self); *imp.total_time.borrow() } } diff --git a/src/ui/tasks_group.rs b/src/ui/tasks_group.rs index f53b13f..4ba93d2 100644 --- a/src/ui/tasks_group.rs +++ b/src/ui/tasks_group.rs @@ -15,7 +15,6 @@ // along with this program. If not, see . use adw::subclass::prelude::*; -use gtk::subclass::prelude::*; use gtk::{glib, prelude::*}; use crate::database; @@ -67,11 +66,11 @@ glib::wrapper! { impl FurTasksGroup { pub fn new() -> Self { - glib::Object::new(&[]).expect("Failed to create `FurTaskGroup`.") + glib::Object::new::() } pub fn add_task_model(&self, tasks: Vec) { - let imp = imp::FurTasksGroup::from_instance(&self); + let imp = imp::FurTasksGroup::from_obj(&self); let listbox = gtk::ListBox::new(); listbox.add_css_class("content"); @@ -115,7 +114,7 @@ impl FurTasksGroup { } pub fn get_total_day_time(&self) -> i64 { - let imp = imp::FurTasksGroup::from_instance(&self); + let imp = imp::FurTasksGroup::from_obj(&self); *imp.day_total_time.borrow() } } diff --git a/src/ui/tasks_page.rs b/src/ui/tasks_page.rs index 192a309..b480b77 100644 --- a/src/ui/tasks_page.rs +++ b/src/ui/tasks_page.rs @@ -19,8 +19,7 @@ use adw::subclass::prelude::*; use chrono::{DateTime, Duration, Local}; use chrono_locale::LocaleDate; use gettextrs::*; -use gtk::subclass::prelude::*; -use gtk::{glib, prelude::*}; +use gtk::glib; use std::env; use crate::database::{self, SortOrder, TaskSort}; @@ -55,9 +54,10 @@ mod imp { } impl ObjectImpl for FurTasksPage { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { + let obj = self.obj(); obj.setup_widgets(); - self.parent_constructed(obj); + self.parent_constructed(); } } @@ -77,7 +77,7 @@ impl FurTasksPage { } pub fn clear_task_list(&self) { - let imp = imp::FurTasksPage::from_instance(&self); + let imp = imp::FurTasksPage::from_obj(&self); for group in &*imp.all_groups.borrow() { self.remove(group); @@ -87,7 +87,7 @@ impl FurTasksPage { } pub fn build_task_list(&self) { - let imp = imp::FurTasksPage::from_instance(&self); + let imp = imp::FurTasksPage::from_obj(&self); // Get user's locale for date formatting let locale_env = env::var("LANG"); diff --git a/src/ui/window.rs b/src/ui/window.rs index bed1931..173d953 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -22,7 +22,7 @@ use directories::ProjectDirs; use gettextrs::*; use glib::{clone, timeout_add_local}; use gtk::subclass::prelude::*; -use gtk::{gio, glib, CompositeTemplate}; +use gtk::{Application, gio, glib, CompositeTemplate}; use itertools::Itertools; use std::cell::RefCell; use std::convert::TryFrom; @@ -94,11 +94,12 @@ mod imp { } impl ObjectImpl for FurtheranceWindow { - fn constructed(&self, obj: &Self::Type) { + fn constructed(&self) { + let obj = self.obj(); obj.setup_widgets(); obj.setup_signals(); obj.setup_settings(); - self.parent_constructed(obj); + self.parent_constructed(); } } impl WidgetImpl for FurtheranceWindow {} @@ -114,21 +115,23 @@ glib::wrapper! { } impl FurtheranceWindow { - pub fn new>(application: &P) -> Self { - glib::Object::new(&[("application", application)]) - .expect("Failed to create FurtheranceWindow") + pub fn new(app: &Application) -> Self { + glib::Object::builder() + .property("application", Some(app)) + .build() } + pub fn display_toast(&self, text: &str) { // Display in-app notifications - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); let toast = adw::Toast::new(text); - imp.toast_overlay.add_toast(&toast); + imp.toast_overlay.add_toast(toast); } fn set_watch_time(&self, text: &str) { // Update watch time while timer is running - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); imp.watch.set_text(text); if settings_manager::get_bool("notify-of-idle") { self.check_user_idle(); @@ -137,7 +140,7 @@ impl FurtheranceWindow { pub fn save_task(&self, start_time: DateTime, mut stop_time: DateTime) { // Save the most recent task to the database and clear the task_input field - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); if *imp.subtract_idle.lock().unwrap() { let idle_start = @@ -154,12 +157,12 @@ impl FurtheranceWindow { } pub fn reset_history_box(&self) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); imp.history_box.create_tasks_page(); } fn setup_widgets(&self) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); // Set initial minimum height and alignment let is_saved_task: bool = match database::check_for_tasks() { @@ -187,14 +190,14 @@ impl FurtheranceWindow { } fn setup_signals(&self) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); *imp.running.lock().unwrap() = false; let start_time = Rc::new(RefCell::new(Local::now())); let stop_time = Rc::new(RefCell::new(Local::now())); imp.task_input .connect_changed(clone!(@weak self as this => move |task_input| { - let imp2 = imp::FurtheranceWindow::from_instance(&this); + let imp2 = imp::FurtheranceWindow::from_obj(&this); let task_input_text = task_input.text(); let split_tags: Vec<&str> = task_input_text.trim().split('#').collect(); if split_tags[0].trim().is_empty() { @@ -205,7 +208,7 @@ impl FurtheranceWindow { })); imp.start_button.connect_clicked(clone!(@weak self as this => move |button| { - let imp2 = imp::FurtheranceWindow::from_instance(&this); + let imp2 = imp::FurtheranceWindow::from_obj(&this); if !*imp2.running.lock().unwrap() { if settings_manager::get_bool("pomodoro") && !*imp2.pomodoro_continue.lock().unwrap() { let pomodoro_time = settings_manager::get_int("pomodoro-time"); @@ -220,7 +223,7 @@ impl FurtheranceWindow { imp2.task_input.set_sensitive(false); let duration = Duration::new(1,0); timeout_add_local(duration, clone!(@strong this as this_clone => move || { - let imp3 = imp::FurtheranceWindow::from_instance(&this_clone); + let imp3 = imp::FurtheranceWindow::from_obj(&this_clone); if *imp3.running.lock().unwrap() { secs -= 1; if secs < 0 { @@ -274,7 +277,7 @@ impl FurtheranceWindow { let autosave_start = *start_time.borrow(); let duration = Duration::new(1,0); timeout_add_local(duration, clone!(@strong this as this_clone => move || { - let imp3 = imp::FurtheranceWindow::from_instance(&this_clone); + let imp3 = imp::FurtheranceWindow::from_obj(&this_clone); if *imp3.running.lock().unwrap() { secs += 1; if secs > 59 { @@ -500,7 +503,7 @@ impl FurtheranceWindow { } fn setup_settings(&self) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); self.reset_idle(); // Enter starts timer @@ -524,7 +527,7 @@ impl FurtheranceWindow { } fn check_user_idle(&self) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); // Check for user idle let idle_time = match self.get_idle_time() { Ok(val) => val, @@ -552,7 +555,7 @@ impl FurtheranceWindow { } fn resume_from_idle(&self) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); let resume_time = Local::now(); let idle_start = @@ -631,7 +634,7 @@ impl FurtheranceWindow { dialog.connect_response(clone!( @weak self as this, @strong dialog => move |_, resp| { - let imp = imp::FurtheranceWindow::from_instance(&this); + let imp = imp::FurtheranceWindow::from_obj(&this); if resp == gtk::ResponseType::Reject { imp.start_button.set_icon_name("media-playback-start-symbolic"); this.refresh_timer(); @@ -647,7 +650,7 @@ impl FurtheranceWindow { } })); - let imp2 = imp::FurtheranceWindow::from_instance(self); + let imp2 = imp::FurtheranceWindow::from_obj(self); imp2.idle_dialog.lock().unwrap().close(); dialog.show(); @@ -686,7 +689,7 @@ impl FurtheranceWindow { } fn split_tags_and_task(&self) -> (String, String) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); let task_input_text = imp.task_input.text(); let mut split_tags: Vec<&str> = task_input_text.trim().split("#").collect(); // Remove task name from tags list @@ -755,7 +758,7 @@ impl FurtheranceWindow { } pub fn reset_idle(&self) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); *imp.stored_idle.lock().unwrap() = 0; *imp.idle_notified.lock().unwrap() = false; *imp.idle_time_reached.lock().unwrap() = false; @@ -763,12 +766,12 @@ impl FurtheranceWindow { } pub fn set_subtract_idle(&self, val: bool) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); *imp.subtract_idle.lock().unwrap() = val; } pub fn duplicate_task(&self, task: database::Task) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); if !*imp.running.lock().unwrap() { let task_text: String; if task.tags.trim().is_empty() { @@ -784,7 +787,7 @@ impl FurtheranceWindow { } pub fn refresh_timer(&self) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); if settings_manager::get_bool("pomodoro") { let mut mins = settings_manager::get_int("pomodoro-time"); let mut hrs: i32 = 0; @@ -912,7 +915,7 @@ impl FurtheranceWindow { } pub fn vertical_align(&self, align: gtk::Align) { - let imp = imp::FurtheranceWindow::from_instance(self); + let imp = imp::FurtheranceWindow::from_obj(self); imp.win_box.set_valign(align); } } -- cgit 1.4.1