Modeless Preferences and Accounts dialog: Closes #5012
This commit is contained in:
parent
e9a27e55be
commit
80769ec5f0
3 changed files with 46 additions and 22 deletions
|
|
@ -7,6 +7,8 @@
|
|||
public class AccountDialog : Gtk.Dialog {
|
||||
private const int MARGIN = 12;
|
||||
|
||||
private static AccountDialog? account_dialog = null;
|
||||
|
||||
private Gtk.Notebook notebook = new Gtk.Notebook();
|
||||
private AccountDialogAccountListPane account_list_pane;
|
||||
private AccountDialogAddEditPane add_edit_pane;
|
||||
|
|
@ -14,7 +16,7 @@ public class AccountDialog : Gtk.Dialog {
|
|||
private AccountDialogRemoveConfirmPane remove_confirm_pane;
|
||||
private AccountDialogRemoveFailPane remove_fail_pane;
|
||||
|
||||
public AccountDialog() {
|
||||
private AccountDialog() {
|
||||
set_size_request(450, -1); // Sets min size.
|
||||
title = _("Accounts");
|
||||
get_content_area().margin_top = MARGIN;
|
||||
|
|
@ -39,6 +41,8 @@ public class AccountDialog : Gtk.Dialog {
|
|||
remove_confirm_pane.ok.connect(on_delete_account_confirmed);
|
||||
remove_confirm_pane.cancel.connect(on_cancel_back_to_list);
|
||||
remove_fail_pane.ok.connect(on_cancel_back_to_list);
|
||||
delete_event.connect(on_delete);
|
||||
response.connect(on_close);
|
||||
|
||||
// Set default page.
|
||||
account_list_pane.present();
|
||||
|
|
@ -52,8 +56,20 @@ public class AccountDialog : Gtk.Dialog {
|
|||
notebook.show_all(); // Required due to longstanding Gtk.Notebook bug
|
||||
}
|
||||
|
||||
public static void show_instance() {
|
||||
if (account_dialog == null) {
|
||||
account_dialog = new AccountDialog();
|
||||
}
|
||||
account_dialog.show_all();
|
||||
account_dialog.present();
|
||||
}
|
||||
|
||||
private bool on_delete() {
|
||||
return hide_on_delete();
|
||||
}
|
||||
|
||||
private void on_close() {
|
||||
destroy();
|
||||
hide();
|
||||
}
|
||||
|
||||
private void on_add_account() {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
|
||||
public class PreferencesDialog : Object {
|
||||
private static PreferencesDialog? preferences_dialog = null;
|
||||
|
||||
private Gtk.Dialog dialog;
|
||||
private Gtk.CheckButton autoselect;
|
||||
private Gtk.CheckButton display_preview;
|
||||
|
|
@ -14,7 +16,7 @@ public class PreferencesDialog : Object {
|
|||
private Gtk.Button close_button;
|
||||
private Configuration config;
|
||||
|
||||
public PreferencesDialog(Configuration config) {
|
||||
private PreferencesDialog(Configuration config) {
|
||||
this.config = config;
|
||||
Gtk.Builder builder = GearyApplication.instance.create_builder("preferences.glade");
|
||||
|
||||
|
|
@ -27,12 +29,7 @@ public class PreferencesDialog : Object {
|
|||
show_notifications = builder.get_object("show_notifications") as Gtk.CheckButton;
|
||||
close_button = builder.get_object("close_button") as Gtk.Button;
|
||||
|
||||
// Populate the dialog with our current settings.
|
||||
autoselect.active = config.autoselect;
|
||||
display_preview.active = config.display_preview;
|
||||
spell_check.active = config.spell_check;
|
||||
play_sounds.active = config.play_sounds;
|
||||
show_notifications.active = config.show_notifications;
|
||||
populate_preference_options();
|
||||
|
||||
// Connect to element signals.
|
||||
autoselect.toggled.connect(on_autoselect_toggled);
|
||||
|
|
@ -41,19 +38,33 @@ public class PreferencesDialog : Object {
|
|||
play_sounds.toggled.connect(on_play_sounds_toggled);
|
||||
show_notifications.toggled.connect(on_show_notifications_toggled);
|
||||
|
||||
GearyApplication.instance.exiting.connect(on_exit);
|
||||
dialog.delete_event.connect(on_delete);
|
||||
dialog.response.connect(on_close);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (dialog.run() != Gtk.ResponseType.NONE) {
|
||||
dialog.destroy();
|
||||
}
|
||||
public void populate_preference_options() {
|
||||
autoselect.active = config.autoselect;
|
||||
display_preview.active = config.display_preview;
|
||||
spell_check.active = config.spell_check;
|
||||
play_sounds.active = config.play_sounds;
|
||||
show_notifications.active = config.show_notifications;
|
||||
}
|
||||
|
||||
private bool on_exit(bool panicked) {
|
||||
dialog.destroy();
|
||||
public static void show_instance() {
|
||||
if (preferences_dialog == null)
|
||||
preferences_dialog = new PreferencesDialog(GearyApplication.instance.config);
|
||||
|
||||
return true;
|
||||
preferences_dialog.populate_preference_options();
|
||||
preferences_dialog.dialog.show_all();
|
||||
preferences_dialog.dialog.present();
|
||||
}
|
||||
|
||||
private bool on_delete() {
|
||||
return dialog.hide_on_delete(); //prevent widgets from getting destroyed
|
||||
}
|
||||
|
||||
private void on_close() {
|
||||
dialog.hide();
|
||||
}
|
||||
|
||||
private void on_autoselect_toggled() {
|
||||
|
|
|
|||
|
|
@ -1007,14 +1007,11 @@ public class GearyController {
|
|||
}
|
||||
|
||||
private void on_accounts() {
|
||||
AccountDialog dialog = new AccountDialog();
|
||||
dialog.run();
|
||||
dialog.destroy();
|
||||
AccountDialog.show_instance();
|
||||
}
|
||||
|
||||
private void on_preferences() {
|
||||
PreferencesDialog dialog = new PreferencesDialog(GearyApplication.instance.config);
|
||||
dialog.run();
|
||||
PreferencesDialog.show_instance();
|
||||
}
|
||||
|
||||
private Gee.List<Geary.EmailIdentifier> get_selected_folder_email_ids(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue