[geary] Remove some uses of the deprecated GearyApplication.instance prop.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Remove some uses of the deprecated GearyApplication.instance prop.
- Date: Tue, 10 Oct 2017 21:33:45 +0000 (UTC)
commit f708218c2bf0f70d9ea1b9a622b84287b878045a
Author: Michael James Gratton <mike vee net>
Date: Wed Oct 4 17:44:41 2017 +1100
Remove some uses of the deprecated GearyApplication.instance prop.
src/client/application/autostart-manager.vala | 36 ++++++++++++++-----------
src/client/application/geary-controller.vala | 10 ++++---
src/client/application/secret-mediator.vala | 11 +++++--
3 files changed, 34 insertions(+), 23 deletions(-)
---
diff --git a/src/client/application/autostart-manager.vala b/src/client/application/autostart-manager.vala
index 93b34f8..37d1c44 100644
--- a/src/client/application/autostart-manager.vala
+++ b/src/client/application/autostart-manager.vala
@@ -9,17 +9,20 @@
* desktop file at $HOME/.config/autostart/geary.desktop
*/
public class AutostartManager : Object {
+
private const string AUTOSTART_FOLDER = "autostart";
private const string AUTOSTART_DESKTOP_FILE = "geary-autostart.desktop";
+ private GearyApplication instance;
private File startup_file; // Startup '.desktop' file
- public AutostartManager() {
- startup_file = File.new_for_path(Environment.get_user_config_dir()).get_child(AUTOSTART_FOLDER)
+ public AutostartManager(GearyApplication instance) {
+ this.instance = instance;
+ this.startup_file = File.new_for_path(Environment.get_user_config_dir()).get_child(AUTOSTART_FOLDER)
.get_child(AUTOSTART_DESKTOP_FILE);
-
+
// Connect startup-notifications option callback
- GearyApplication.instance.config.settings.changed[Configuration.STARTUP_NOTIFICATIONS_KEY].connect(
+ this.instance.config.settings.changed[Configuration.STARTUP_NOTIFICATIONS_KEY].connect(
on_startup_notification_change);
}
@@ -27,11 +30,11 @@ public class AutostartManager : Object {
* Returns the system-wide autostart desktop file
*/
public File? get_autostart_desktop_file() {
- File? install_dir = GearyApplication.instance.get_install_dir();
+ File? install_dir = this.instance.get_install_dir();
File desktop_file = (install_dir != null)
? install_dir.get_child("share").get_child("applications").get_child(AUTOSTART_DESKTOP_FILE)
:
File.new_for_path(GearyApplication.SOURCE_ROOT_DIR).get_child("build").get_child("desktop").get_child(AUTOSTART_DESKTOP_FILE);
-
+
return desktop_file.query_exists() ? desktop_file : null;
}
@@ -39,9 +42,9 @@ public class AutostartManager : Object {
* Deletes the desktop file from autostart directory.
*/
public void delete_startup_file() {
- if (startup_file.query_exists()) {
+ if (this.startup_file.query_exists()) {
try {
- startup_file.delete();
+ this.startup_file.delete();
} catch (Error err) {
message("Failed to delete startup file: %s", err.message);
}
@@ -52,39 +55,40 @@ public class AutostartManager : Object {
* Creates .desktop file in autostart directory (usually '$HOME/.config/autostart/') if no one exists.
*/
public void create_startup_file() {
- if (startup_file.query_exists())
+ if (this.startup_file.query_exists())
return;
-
+
try {
- File autostart_dir = startup_file.get_parent();
+ File autostart_dir = this.startup_file.get_parent();
if (!autostart_dir.query_exists())
autostart_dir.make_directory_with_parents();
File? autostart = get_autostart_desktop_file();
if (autostart == null) {
message("Autostart file is not installed!");
} else {
- autostart.copy(startup_file, 0);
+ autostart.copy(this.startup_file, 0);
}
} catch (Error err) {
message("Failed to create startup file: %s", err.message);
}
}
-
+
/**
* Callback for startup notification option changes.
*/
public void on_startup_notification_change() {
- if (GearyApplication.instance.config.startup_notifications)
+ if (this.instance.config.startup_notifications)
create_startup_file();
else
delete_startup_file();
}
-
+
/*
* A convenience method. The purpose of this method is to synchronize the state of startup notifications
setting
* with the actual state of the file, so it's not misleading for the user (the option is checked while
the file doesn't exist)
*/
public void sync_with_config() {
- GearyApplication.instance.config.startup_notifications = startup_file.query_exists();
+ this.instance.config.startup_notifications = this.startup_file.query_exists();
}
+
}
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 8f4e164..5ad6247 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -267,8 +267,8 @@ public class GearyController : Geary.BaseObject {
this.main_window.conversation_list_view.grab_focus();
// instantiate here to ensure that Config is initialized and ready
- autostart_manager = new AutostartManager();
-
+ this.autostart_manager = new AutostartManager(this.application);
+
// initialize revokable
save_revokable(null, null);
@@ -286,7 +286,7 @@ public class GearyController : Geary.BaseObject {
this.application.get_user_config_directory(),
this.application.get_user_data_directory(),
this.application.get_resource_directory(),
- new SecretMediator()
+ new SecretMediator(this.application)
);
if (Geary.Engine.instance.get_accounts().size == 0) {
create_account();
@@ -325,7 +325,9 @@ public class GearyController : Geary.BaseObject {
// drop the Revokable, which will commit it if necessary
save_revokable(null, null);
-
+
+ this.autostart_manager = null;
+
// close the ConversationMonitor
try {
if (current_conversations != null) {
diff --git a/src/client/application/secret-mediator.vala b/src/client/application/secret-mediator.vala
index f3d8d61..f9bbc34 100644
--- a/src/client/application/secret-mediator.vala
+++ b/src/client/application/secret-mediator.vala
@@ -20,9 +20,14 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
null
);
+ private GearyApplication instance;
private Geary.Nonblocking.Mutex dialog_mutex = new Geary.Nonblocking.Mutex();
+ public SecretMediator(GearyApplication instance) {
+ this.instance = instance;
+ }
+
public virtual async string? get_password_async(Geary.Service service,
Geary.AccountInformation account,
Cancellable? cancellable = null)
@@ -89,14 +94,14 @@ public class SecretMediator : Geary.CredentialsMediator, Object {
// to prevent multiple dialogs from popping up at the same time, use a nonblocking mutex
// to serialize the code
int token = yield dialog_mutex.claim_async(null);
-
+
// If the main window is hidden, make it visible now and present to user as transient parent
- Gtk.Window? main_window = GearyApplication.instance.controller.main_window;
+ Gtk.Window? main_window = this.instance.get_active_window();
if (main_window != null && !main_window.visible) {
main_window.show_all();
main_window.present_with_time(Gdk.CURRENT_TIME);
}
-
+
PasswordDialog password_dialog = new PasswordDialog(main_window, services.has_smtp(),
account_information, services);
bool result = password_dialog.run();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]