[geary/mjog/mutiple-main-windows: 3/14] Move MainWindow to Application package



commit 239fdce562e5629c902efa8c5945e1092bf7f28a
Author: Michael Gratton <mike vee net>
Date:   Wed Nov 13 13:46:19 2019 +1100

    Move MainWindow to Application package
    
    Move MainWindow out of the root namespace and add it to Application,
    so it can privately share internal state with the Controller. Rename
    the source and UI files to match.

 po/POTFILES.in                                     |  2 +-
 .../application-main-window.vala}                  | 63 ++++++++++---------
 .../components/components-attachment-pane.vala     |  2 +-
 src/client/components/main-toolbar.vala            |  8 ++-
 src/client/components/main-window-info-bar.vala    |  4 +-
 src/client/components/search-bar.vala              |  2 +-
 .../conversation-list-cell-renderer.vala           |  2 +-
 .../conversation-list/conversation-list-view.vala  | 70 +++++++++++++++++-----
 .../conversation-contact-popover.vala              |  6 +-
 .../conversation-viewer/conversation-email.vala    | 10 ++--
 .../conversation-viewer/conversation-message.vala  |  4 +-
 .../conversation-viewer/conversation-viewer.vala   |  4 +-
 .../dialogs/dialogs-problem-details-dialog.vala    |  3 +-
 .../folder-list/folder-list-folder-entry.vala      |  2 +-
 src/client/folder-list/folder-list-tree.vala       |  2 +-
 src/client/meson.build                             |  2 +-
 src/client/sidebar/sidebar-entry.vala              |  4 +-
 src/client/sidebar/sidebar-tree.vala               |  2 +-
 ui/{main-window.ui => application-main-window.ui}  |  3 +-
 ui/org.gnome.Geary.gresource.xml                   |  2 +-
 20 files changed, 121 insertions(+), 76 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index b8a16b80..9886e03a 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -413,6 +413,7 @@ ui/accounts_editor_edit_pane.ui
 ui/accounts_editor_list_pane.ui
 ui/accounts_editor_remove_pane.ui
 ui/accounts_editor_servers_pane.ui
+ui/application-main-window.ui
 ui/certificate_warning_dialog.glade
 ui/composer-headerbar.ui
 ui/composer-link-popover.ui
@@ -437,7 +438,6 @@ ui/folder-popover.ui
 ui/gtk/help-overlay.ui
 ui/main-toolbar.ui
 ui/main-toolbar-menus.ui
-ui/main-window.ui
 ui/main-window-info-bar.ui
 ui/password-dialog.glade
 ui/preferences-dialog.ui
diff --git a/src/client/components/main-window.vala b/src/client/application/application-main-window.vala
similarity index 97%
rename from src/client/components/main-window.vala
rename to src/client/application/application-main-window.vala
index b77bbf3d..10c84a91 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/application/application-main-window.vala
@@ -6,8 +6,9 @@
  * (version 2.1 or later). See the COPYING file in this distribution.
  */
 
-[GtkTemplate (ui = "/org/gnome/Geary/main-window.ui")]
-public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
+[GtkTemplate (ui = "/org/gnome/Geary/application-main-window.ui")]
+public class Application.MainWindow :
+    Gtk.ApplicationWindow, Geary.BaseInterface {
 
 
     // Named actions.
@@ -74,7 +75,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
     private const int MIN_CONVERSATION_COUNT = 50;
 
 
-    public static void add_accelerators(Application.Client owner) {
+    public static void add_accelerators(Client owner) {
         // Marking actions
         //
         // Unread is the primary action, so it doesn't get the <Shift>
@@ -159,8 +160,8 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
 
 
     /** Returns the window's associated client application instance. */
-    public new Application.Client application {
-        get { return (Application.Client) base.get_application(); }
+    public new Client application {
+        get { return (Client) base.get_application(); }
         set { base.set_application(value); }
     }
 
@@ -176,14 +177,12 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
     }
 
     /** The attachment manager for this window. */
-    public Application.AttachmentManager attachments { get; private set; }
+    public AttachmentManager attachments { get; private set; }
 
     /** Determines if conversations in the selected folder can be trashed. */
     public bool selected_folder_supports_trash {
         get {
-            return Application.Controller.does_folder_support_trash(
-                this.selected_folder
-            );
+            return Controller.does_folder_support_trash(this.selected_folder);
         }
     }
 
@@ -274,7 +273,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
     public signal void retry_service_problem(Geary.ClientService.Status problem);
 
 
-    public MainWindow(Application.Client application) {
+    public MainWindow(Client application) {
         Object(
             application: application,
             show_menubar: false
@@ -298,7 +297,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
         update_command_actions();
         update_conversation_actions(NONE);
 
-        this.attachments = new Application.AttachmentManager(this);
+        this.attachments = new AttachmentManager(this);
 
         this.application.engine.account_available.connect(on_account_available);
         this.application.engine.account_unavailable.connect(on_account_unavailable);
@@ -715,21 +714,21 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
         this.folder_list.remove_account(to_remove);
     }
 
-    private void load_config(Application.Configuration config) {
+    private void load_config(Configuration config) {
         // This code both loads AND saves the pane positions with live updating. This is more
         // resilient against crashes because the value in dconf changes *immediately*, and
         // stays saved in the event of a crash.
-        config.bind(Application.Configuration.MESSAGES_PANE_POSITION_KEY, this.conversations_paned, 
"position");
-        config.bind(Application.Configuration.WINDOW_WIDTH_KEY, this, "window-width");
-        config.bind(Application.Configuration.WINDOW_HEIGHT_KEY, this, "window-height");
-        config.bind(Application.Configuration.WINDOW_MAXIMIZE_KEY, this, "window-maximized");
+        config.bind(Configuration.MESSAGES_PANE_POSITION_KEY, this.conversations_paned, "position");
+        config.bind(Configuration.WINDOW_WIDTH_KEY, this, "window-width");
+        config.bind(Configuration.WINDOW_HEIGHT_KEY, this, "window-height");
+        config.bind(Configuration.WINDOW_MAXIMIZE_KEY, this, "window-maximized");
         // Update to layout
         if (config.folder_list_pane_position_horizontal == -1) {
             config.folder_list_pane_position_horizontal = config.folder_list_pane_position_old;
             config.messages_pane_position += config.folder_list_pane_position_old;
         }
         config.settings.changed[
-            Application.Configuration.FOLDER_LIST_PANE_HORIZONTAL_KEY
+            Configuration.FOLDER_LIST_PANE_HORIZONTAL_KEY
         ].connect(on_change_orientation);
     }
 
@@ -827,7 +826,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
         }
     }
 
-    private void setup_layout(Application.Configuration config) {
+    private void setup_layout(Configuration config) {
         this.notify["has-toplevel-focus"].connect(on_has_toplevel_focus);
 
         // Search bar
@@ -874,7 +873,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
                 string folder = selected_folder != null ? selected_folder.get_display_name() + " " : "";
                 string account = main_toolbar.account != null ? "(%s)".printf(main_toolbar.account) : "";
 
-                target = "%s%s - %s".printf(folder, account, Application.Client.NAME);
+                target = "%s%s - %s".printf(folder, account, Client.NAME);
 
                 return true;
             };
@@ -976,7 +975,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
 
     /** Un-does the last executed application command, if any. */
     private async void undo() {
-        Application.Controller.AccountContext? selected = this.context;
+        Controller.AccountContext? selected = this.context;
         if (selected != null) {
             selected.commands.undo.begin(
                 selected.cancellable,
@@ -993,7 +992,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
 
     /** Re-does the last undone application command, if any. */
     private async void redo() {
-        Application.Controller.AccountContext? selected = this.context;
+        Controller.AccountContext? selected = this.context;
         if (selected != null) {
             selected.commands.redo.begin(
                 selected.cancellable,
@@ -1009,7 +1008,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
     }
 
     private void update_command_actions() {
-        Application.Controller.AccountContext? selected = this.context;
+        Controller.AccountContext? selected = this.context;
         get_edit_action(Action.Edit.UNDO).set_enabled(
             selected != null && selected.commands.can_undo
         );
@@ -1132,7 +1131,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
                 this.main_toolbar.copy_folder_menu.clear();
                 this.main_toolbar.move_folder_menu.clear();
 
-                Application.Controller.AccountContext? context = this.context;
+                Controller.AccountContext? context = this.context;
                 if (context != null) {
                     context.commands.executed.disconnect(on_command_execute);
                     context.commands.undone.disconnect(on_command_undo);
@@ -1195,7 +1194,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
                 // last email was removed but the conversation monitor
                 // hasn't signalled its removal yet. In this case,
                 // just don't load it since it will soon disappear.
-                Application.Controller.AccountContext? context = this.context;
+                Controller.AccountContext? context = this.context;
                 if (context != null && convo.get_count() > 0) {
                     try {
                         yield this.conversation_viewer.load_conversation(
@@ -1386,8 +1385,8 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
 
         this.application.config.bind(
             horizontal
-            ? Application.Configuration.FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY
-            : Application.Configuration.FOLDER_LIST_PANE_POSITION_VERTICAL_KEY,
+            ? Configuration.FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY
+            : Configuration.FOLDER_LIST_PANE_POSITION_VERTICAL_KEY,
             this.folder_paned, "position");
     }
 
@@ -1485,7 +1484,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
 
         Gee.MultiMap<Geary.EmailIdentifier, Type>? selected_operations = null;
         if (this.selected_folder != null) {
-            Application.Controller.AccountContext? context =
+            Controller.AccountContext? context =
                 this.application.controller.get_context_for_account(
                     this.selected_folder.account.information
                 );
@@ -1647,8 +1646,8 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
         update_ui();
     }
 
-    private void on_command_execute(Application.Command command) {
-        if (!(command is Application.TrivialCommand)) {
+    private void on_command_execute(Command command) {
+        if (!(command is TrivialCommand)) {
             // Only show an execute notification for non-trivial
             // commands
             on_command_redo(command);
@@ -1659,9 +1658,9 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
         }
     }
 
-    private void on_command_undo(Application.Command command) {
+    private void on_command_undo(Command command) {
         update_command_actions();
-        Application.EmailCommand? email = command as Application.EmailCommand;
+        EmailCommand? email = command as EmailCommand;
         if (email != null) {
             if (email.conversations.size > 1) {
                 this.show_conversations.begin(
@@ -1681,7 +1680,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
         }
     }
 
-    private void on_command_redo(Application.Command command) {
+    private void on_command_redo(Command command) {
         update_command_actions();
         if (command.executed_label != null) {
             Components.InAppNotification ian =
diff --git a/src/client/components/components-attachment-pane.vala 
b/src/client/components/components-attachment-pane.vala
index 6ec58462..f4bb7ffc 100644
--- a/src/client/components/components-attachment-pane.vala
+++ b/src/client/components/components-attachment-pane.vala
@@ -369,7 +369,7 @@ public class Components.AttachmentPane : Gtk.Grid {
     }
 
     private void open_attachments(Gee.Collection<Geary.Attachment> attachments) {
-        MainWindow? main = this.get_toplevel() as MainWindow;
+        var main = this.get_toplevel() as Application.MainWindow;
         if (main != null) {
             Application.Client app = main.application;
             bool confirmed = true;
diff --git a/src/client/components/main-toolbar.vala b/src/client/components/main-toolbar.vala
index 554d154f..9f148b14 100644
--- a/src/client/components/main-toolbar.vala
+++ b/src/client/components/main-toolbar.vala
@@ -161,7 +161,9 @@ public class MainToolbar : Gtk.Box {
         );
 
         if (this.show_trash_button) {
-            this.trash_delete_button.action_name = "win."+MainWindow.ACTION_TRASH_CONVERSATION;
+            this.trash_delete_button.action_name = Action.Window.prefix(
+                Application.MainWindow.ACTION_TRASH_CONVERSATION
+            );
             this.trash_delete_button.image = trash_image;
             this.trash_delete_button.tooltip_text = ngettext(
                 "Move conversation to Trash",
@@ -169,7 +171,9 @@ public class MainToolbar : Gtk.Box {
                 this.selected_conversations
             );
         } else {
-            this.trash_delete_button.action_name = "win."+MainWindow.ACTION_DELETE_CONVERSATION;
+            this.trash_delete_button.action_name = Action.Window.prefix(
+                Application.MainWindow.ACTION_DELETE_CONVERSATION
+            );
             this.trash_delete_button.image = delete_image;
             this.trash_delete_button.tooltip_text = ngettext(
                 "Delete conversation",
diff --git a/src/client/components/main-window-info-bar.vala b/src/client/components/main-window-info-bar.vala
index 218851d5..1a737fc2 100644
--- a/src/client/components/main-window-info-bar.vala
+++ b/src/client/components/main-window-info-bar.vala
@@ -128,9 +128,9 @@ public class MainWindowInfoBar : Gtk.InfoBar {
     private void show_details() {
         Dialogs.ProblemDetailsDialog dialog =
             new Dialogs.ProblemDetailsDialog(
-                get_toplevel() as MainWindow,
+                get_toplevel() as Application.MainWindow,
                 this.report
-        );
+            );
         dialog.run();
         dialog.destroy();
     }
diff --git a/src/client/components/search-bar.vala b/src/client/components/search-bar.vala
index 7a2471ce..ad65de5f 100644
--- a/src/client/components/search-bar.vala
+++ b/src/client/components/search-bar.vala
@@ -110,7 +110,7 @@ public class SearchBar : Gtk.SearchBar {
     }
 
     private void on_information_changed() {
-        MainWindow? main = get_toplevel() as MainWindow;
+        var main = get_toplevel() as Application.MainWindow;
         if (main != null) {
             set_search_placeholder_text(
                 current_account == null ||
diff --git a/src/client/conversation-list/conversation-list-cell-renderer.vala 
b/src/client/conversation-list/conversation-list-cell-renderer.vala
index 98e4ddab..ea009128 100644
--- a/src/client/conversation-list/conversation-list-cell-renderer.vala
+++ b/src/client/conversation-list/conversation-list-cell-renderer.vala
@@ -46,7 +46,7 @@ public class ConversationListCellRenderer : Gtk.CellRenderer {
     // Recalculates size when the style changed.
     // Note: this must be called by the parent TreeView.
     public static void style_changed(Gtk.Widget widget) {
-        MainWindow? window = widget.get_toplevel() as MainWindow;
+        var window = widget.get_toplevel() as Application.MainWindow;
         if (window != null && example_data == null) {
             example_data = new FormattedConversationData.create_example(
                 window.application.config
diff --git a/src/client/conversation-list/conversation-list-view.vala 
b/src/client/conversation-list/conversation-list-view.vala
index e95b7284..fb90cd09 100644
--- a/src/client/conversation-list/conversation-list-view.vala
+++ b/src/client/conversation-list/conversation-list-view.vala
@@ -195,7 +195,7 @@ public class ConversationListView : Gtk.TreeView, Geary.BaseInterface {
         // composer.
         if (this.config.autoselect &&
             get_selection().count_selected_rows() == 0) {
-            MainWindow? parent = get_toplevel() as MainWindow;
+            var parent = get_toplevel() as Application.MainWindow;
             if (parent != null && !parent.has_composer) {
                 set_cursor(new Gtk.TreePath.from_indices(0, -1), null, false);
             }
@@ -296,7 +296,7 @@ public class ConversationListView : Gtk.TreeView, Geary.BaseInterface {
         // doesn't attempt to load it then close it straight away.
         if (event.type == Gdk.EventType.BUTTON_PRESS &&
             !get_selection().path_is_selected(path)) {
-            MainWindow? parent = get_toplevel() as MainWindow;
+            var parent = get_toplevel() as Application.MainWindow;
             if (parent != null && !parent.close_composer(false)) {
                 return true;
             }
@@ -306,7 +306,7 @@ public class ConversationListView : Gtk.TreeView, Geary.BaseInterface {
             Geary.App.Conversation conversation = get_model().get_conversation_at_path(path);
 
             GLib.Menu context_menu_model = new GLib.Menu();
-            MainWindow? main = get_toplevel() as MainWindow;
+            var main = get_toplevel() as Application.MainWindow;
             if (main != null) {
                 if (main.is_shift_down) {
                     context_menu_model.append(
@@ -316,7 +316,9 @@ public class ConversationListView : Gtk.TreeView, Geary.BaseInterface {
                             "Move conversations to _Trash",
                             this.selected.size
                         ),
-                        "win." + MainWindow.ACTION_ARCHIVE_CONVERSATION
+                        Action.Window.prefix(
+                            Application.MainWindow.ACTION_ARCHIVE_CONVERSATION
+                        )
                     );
                 } else {
                     context_menu_model.append(
@@ -326,26 +328,64 @@ public class ConversationListView : Gtk.TreeView, Geary.BaseInterface {
                             "_Delete conversations",
                             this.selected.size
                         ),
-                        "win." + MainWindow.ACTION_DELETE_CONVERSATION
+                        Action.Window.prefix(
+                            Application.MainWindow.ACTION_DELETE_CONVERSATION
+                        )
                     );
                 }
             }
 
             if (conversation.is_unread())
-                context_menu_model.append(_("Mark as _Read"), "win."+MainWindow.ACTION_MARK_AS_READ);
+                context_menu_model.append(
+                    _("Mark as _Read"),
+                    Action.Window.prefix(
+                        Application.MainWindow.ACTION_MARK_AS_READ
+                    )
+                );
 
             if (conversation.has_any_read_message())
-                context_menu_model.append(_("Mark as _Unread"), "win."+MainWindow.ACTION_MARK_AS_UNREAD);
-
-            if (conversation.is_flagged())
-                context_menu_model.append(_("U_nstar"), "win."+MainWindow.ACTION_MARK_AS_UNSTARRED);
-            else
-                context_menu_model.append(_("_Star"), "win."+MainWindow.ACTION_MARK_AS_STARRED);
+                context_menu_model.append(
+                    _("Mark as _Unread"),
+                    Action.Window.prefix(
+                        Application.MainWindow.ACTION_MARK_AS_UNREAD
+                    )
+                );
+
+            if (conversation.is_flagged()) {
+                context_menu_model.append(
+                    _("U_nstar"),
+                    Action.Window.prefix(
+                        Application.MainWindow.ACTION_MARK_AS_UNSTARRED
+                    )
+                );
+            } else {
+                context_menu_model.append(
+                    _("_Star"),
+                    Action.Window.prefix(
+                        Application.MainWindow.ACTION_MARK_AS_STARRED
+                    )
+                );
+            }
 
             Menu actions_section = new Menu();
-            actions_section.append(_("_Reply"), "win."+MainWindow.ACTION_REPLY_CONVERSATION);
-            actions_section.append(_("R_eply All"), "win."+MainWindow.ACTION_REPLY_ALL_CONVERSATION);
-            actions_section.append(_("_Forward"), "win."+MainWindow.ACTION_FORWARD_CONVERSATION);
+            actions_section.append(
+                _("_Reply"),
+                Action.Window.prefix(
+                    Application.MainWindow.ACTION_REPLY_CONVERSATION
+                )
+            );
+            actions_section.append(
+                _("R_eply All"),
+                Action.Window.prefix(
+                    Application.MainWindow.ACTION_REPLY_ALL_CONVERSATION
+                )
+            );
+            actions_section.append(
+                _("_Forward"),
+                Action.Window.prefix(
+                    Application.MainWindow.ACTION_FORWARD_CONVERSATION
+                )
+            );
             context_menu_model.append_section(null, actions_section);
 
             // Use a popover rather than a regular context menu since
diff --git a/src/client/conversation-viewer/conversation-contact-popover.vala 
b/src/client/conversation-viewer/conversation-contact-popover.vala
index 3f2dc10c..39dc97a3 100644
--- a/src/client/conversation-viewer/conversation-contact-popover.vala
+++ b/src/client/conversation-viewer/conversation-contact-popover.vala
@@ -105,7 +105,7 @@ public class Conversation.ContactPopover : Gtk.Popover {
      * Starts loading the avatar for the message's sender.
      */
     public async void load_avatar() {
-        MainWindow? main = this.get_toplevel() as MainWindow;
+        var main = this.get_toplevel() as Application.MainWindow;
         if (main != null) {
             Application.AvatarStore loader = main.application.controller.avatars;
             int window_scale = get_scale_factor();
@@ -238,7 +238,7 @@ public class Conversation.ContactPopover : Gtk.Popover {
     }
 
     private void on_new_conversation() {
-        MainWindow? main = this.get_toplevel() as MainWindow;
+        var main = this.get_toplevel() as Application.MainWindow;
         if (main != null) {
             main.open_composer_for_mailbox(this.mailbox);
         }
@@ -253,7 +253,7 @@ public class Conversation.ContactPopover : Gtk.Popover {
     }
 
     private void on_show_conversations() {
-        MainWindow? main = this.get_toplevel() as MainWindow;
+        var main = this.get_toplevel() as Application.MainWindow;
         if (main != null) {
             main.show_search_bar("from:%s".printf(this.mailbox.address));
         }
diff --git a/src/client/conversation-viewer/conversation-email.vala 
b/src/client/conversation-viewer/conversation-email.vala
index 8b021b3a..02ac6096 100644
--- a/src/client/conversation-viewer/conversation-email.vala
+++ b/src/client/conversation-viewer/conversation-email.vala
@@ -505,7 +505,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
 
     /** Displays the raw RFC 822 source for this email. */
     public async void view_source() {
-        MainWindow? main = get_toplevel() as MainWindow;
+        var main = get_toplevel() as Application.MainWindow;
         if (main != null) {
             Geary.Email email = this.email;
             try {
@@ -777,7 +777,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
                 this.conversation.base_folder is Geary.FolderSupport.Remove
             );
             bool is_shift_down = false;
-            MainWindow? main = get_toplevel() as MainWindow;
+            var main = get_toplevel() as Application.MainWindow;
             if (main != null) {
                 is_shift_down = main.is_shift_down;
 
@@ -835,7 +835,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
     private void update_displayed_attachments() {
         bool has_attachments = !this.displayed_attachments.is_empty;
         this.attachments_button.set_visible(has_attachments);
-        MainWindow? main = get_toplevel() as MainWindow;
+        var main = get_toplevel() as Application.MainWindow;
 
         if (has_attachments && main != null) {
             this.attachments_pane = new Components.AttachmentPane(
@@ -855,7 +855,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
         this.message_body_state = FAILED;
         this.primary_message.show_load_error_pane();
 
-        MainWindow? main = get_toplevel() as MainWindow;
+        var main = get_toplevel() as Application.MainWindow;
         if (main != null) {
             Geary.AccountInformation account = this.email_store.account.information;
             main.application.controller.report_problem(
@@ -906,7 +906,7 @@ public class ConversationEmail : Gtk.Box, Geary.BaseInterface {
     private void on_save_image(string uri,
                                string? alt_text,
                                Geary.Memory.Buffer? content) {
-        MainWindow? main = get_toplevel() as MainWindow;
+        var main = get_toplevel() as Application.MainWindow;
         if (main != null) {
             if (uri.has_prefix(ClientWebView.CID_URL_PREFIX)) {
                 string cid = uri.substring(ClientWebView.CID_URL_PREFIX.length);
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index d289fb00..f88be3de 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -639,7 +639,7 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
      */
     public async void load_contacts(GLib.Cancellable cancellable)
         throws GLib.Error {
-        MainWindow? main = this.get_toplevel() as MainWindow;
+        var main = this.get_toplevel() as Application.MainWindow;
         if (main != null && !cancellable.is_cancelled()) {
             // Load the primary contact and avatar
             if (this.primary_originator != null) {
@@ -1285,7 +1285,7 @@ public class ConversationMessage : Gtk.Grid, Geary.BaseInterface {
                     }
                 });
         } else {
-            MainWindow? main = this.get_toplevel() as MainWindow;
+            var main = this.get_toplevel() as Application.MainWindow;
             if (main != null) {
                 main.application.show_uri.begin(link);
             }
diff --git a/src/client/conversation-viewer/conversation-viewer.vala 
b/src/client/conversation-viewer/conversation-viewer.vala
index fe4909ce..126a30e2 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -146,7 +146,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
      * Puts the view into composer mode, showing a full-height composer.
      */
     public void do_compose(Composer.Widget composer) {
-        MainWindow? main_window = get_toplevel() as MainWindow;
+        var main_window = get_toplevel() as Application.MainWindow;
         if (main_window != null) {
             Composer.Box box = new Composer.Box(
                 composer, main_window.main_toolbar
@@ -486,7 +486,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
             set_visible_child(this.conversation_page);
 
             // Restore the old selection
-            MainWindow? main_window = get_toplevel() as MainWindow;
+            var main_window = get_toplevel() as Application.MainWindow;
             if (main_window != null &&
                 this.selection_while_composing != null) {
                 ConversationListView conversation_list =
diff --git a/src/client/dialogs/dialogs-problem-details-dialog.vala 
b/src/client/dialogs/dialogs-problem-details-dialog.vala
index ab0c7f6a..5f0ebb32 100644
--- a/src/client/dialogs/dialogs-problem-details-dialog.vala
+++ b/src/client/dialogs/dialogs-problem-details-dialog.vala
@@ -51,7 +51,8 @@ public class Dialogs.ProblemDetailsDialog : Hdy.Dialog {
     private Geary.ServiceInformation? service;
 
 
-    public ProblemDetailsDialog(MainWindow parent, Geary.ProblemReport report) {
+    public ProblemDetailsDialog(Application.MainWindow parent,
+                                Geary.ProblemReport report) {
         Object(
             transient_for: parent,
             use_header_bar: 1
diff --git a/src/client/folder-list/folder-list-folder-entry.vala 
b/src/client/folder-list/folder-list-folder-entry.vala
index a047ce0e..99aeacc0 100644
--- a/src/client/folder-list/folder-list-folder-entry.vala
+++ b/src/client/folder-list/folder-list-folder-entry.vala
@@ -99,7 +99,7 @@ public class FolderList.FolderEntry : FolderList.AbstractFolderEntry, Sidebar.In
         is_emphasized_changed(has_new);
     }
 
-    public bool internal_drop_received(MainWindow main_window,
+    public bool internal_drop_received(Application.MainWindow main_window,
                                        Gdk.DragContext context,
                                        Gtk.SelectionData data) {
         // Copy or move?
diff --git a/src/client/folder-list/folder-list-tree.vala b/src/client/folder-list/folder-list-tree.vala
index 69e05d50..1c164f0f 100644
--- a/src/client/folder-list/folder-list-tree.vala
+++ b/src/client/folder-list/folder-list-tree.vala
@@ -57,7 +57,7 @@ public class FolderList.Tree : Sidebar.Tree, Geary.BaseInterface {
 
     public override bool accept_cursor_changed() {
         bool can_switch = true;
-        MainWindow? parent = get_toplevel() as MainWindow;
+        var parent = get_toplevel() as Application.MainWindow;
         if (parent != null) {
             can_switch = parent.close_composer(false);
         }
diff --git a/src/client/meson.build b/src/client/meson.build
index 49097e56..3561c48e 100644
--- a/src/client/meson.build
+++ b/src/client/meson.build
@@ -9,6 +9,7 @@ geary_client_vala_sources = files(
   'application/application-contact-store.vala',
   'application/application-contact.vala',
   'application/application-controller.vala',
+  'application/application-main-window.vala',
   'application/application-notification-context.vala',
   'application/application-plugin-manager.vala',
   'application/application-startup-manager.vala',
@@ -41,7 +42,6 @@ geary_client_vala_sources = files(
   'components/folder-popover.vala',
   'components/icon-factory.vala',
   'components/main-toolbar.vala',
-  'components/main-window.vala',
   'components/main-window-info-bar.vala',
   'components/monitored-progress-bar.vala',
   'components/monitored-spinner.vala',
diff --git a/src/client/sidebar/sidebar-entry.vala b/src/client/sidebar/sidebar-entry.vala
index ae78261a..5c653f31 100644
--- a/src/client/sidebar/sidebar-entry.vala
+++ b/src/client/sidebar/sidebar-entry.vala
@@ -56,7 +56,9 @@ public interface Sidebar.DestroyableEntry : Sidebar.Entry {
 
 public interface Sidebar.InternalDropTargetEntry : Sidebar.Entry {
     // Returns true if drop was successful
-    public abstract bool internal_drop_received(MainWindow main, Gdk.DragContext context, Gtk.SelectionData 
data);
+    public abstract bool internal_drop_received(Application.MainWindow main,
+                                                Gdk.DragContext context,
+                                                Gtk.SelectionData data);
 }
 
 public interface Sidebar.InternalDragSourceEntry : Sidebar.Entry {
diff --git a/src/client/sidebar/sidebar-tree.vala b/src/client/sidebar/sidebar-tree.vala
index 58afb195..fdcd570b 100644
--- a/src/client/sidebar/sidebar-tree.vala
+++ b/src/client/sidebar/sidebar-tree.vala
@@ -1071,7 +1071,7 @@ public class Sidebar.Tree : Gtk.TreeView {
 
         bool success = false;
 
-        MainWindow? main = get_toplevel() as MainWindow;
+        var main = get_toplevel() as Application.MainWindow;
         if (main != null) {
             success = targetable.internal_drop_received(
                 main, context, selection_data
diff --git a/ui/main-window.ui b/ui/application-main-window.ui
similarity index 99%
rename from ui/main-window.ui
rename to ui/application-main-window.ui
index 2729c0fb..c2802888 100644
--- a/ui/main-window.ui
+++ b/ui/application-main-window.ui
@@ -2,8 +2,7 @@
 <!-- Generated with glade 3.22.1 -->
 <interface>
   <requires lib="gtk+" version="3.20"/>
-  <template class="MainWindow" parent="GtkApplicationWindow">
-    <property name="name">GearyMainWindow</property>
+  <template class="ApplicationMainWindow" parent="GtkApplicationWindow">
     <property name="can_focus">False</property>
     <property name="events">GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | 
GDK_STRUCTURE_MASK</property>
     <property name="show_menubar">False</property>
diff --git a/ui/org.gnome.Geary.gresource.xml b/ui/org.gnome.Geary.gresource.xml
index be5ea980..2138e029 100644
--- a/ui/org.gnome.Geary.gresource.xml
+++ b/ui/org.gnome.Geary.gresource.xml
@@ -7,6 +7,7 @@
     <file compressed="true" preprocess="xml-stripblanks">accounts_editor_list_pane.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">accounts_editor_remove_pane.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">accounts_editor_servers_pane.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">application-main-window.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">certificate_warning_dialog.glade</file>
     <file compressed="true">client-web-view.js</file>
     <file compressed="true">client-web-view-allow-remote-images.js</file>
@@ -38,7 +39,6 @@
     <file compressed="true" preprocess="xml-stripblanks">gtk/help-overlay.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">main-toolbar.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">main-toolbar-menus.ui</file>
-    <file compressed="true" preprocess="xml-stripblanks">main-window.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">main-window-info-bar.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">password-dialog.glade</file>
     <file compressed="true" preprocess="xml-stripblanks">preferences-dialog.ui</file>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]