Move composer classes into their own namespace
Rename all composer classes prefixed with "Composer" so that the prefix is a namespace instead. This increases the compartmentalisation of the classes, making `internal` a useful member modifier and makes them consistent with the code style guide.
This commit is contained in:
parent
1447d1acbc
commit
29042bb2d8
17 changed files with 137 additions and 127 deletions
|
|
@ -163,11 +163,17 @@ public class Application.Controller : Geary.BaseObject {
|
|||
private PluginManager plugin_manager;
|
||||
|
||||
private Cancellable cancellable_open_account = new Cancellable();
|
||||
private Gee.LinkedList<ComposerWidget> composer_widgets = new Gee.LinkedList<ComposerWidget>();
|
||||
private Gee.List<string?> pending_mailtos = new Gee.ArrayList<string>();
|
||||
|
||||
// List of windows we're waiting to close before Geary closes.
|
||||
private Gee.List<ComposerWidget> waiting_to_close = new Gee.ArrayList<ComposerWidget>();
|
||||
// Currently open composers
|
||||
private Gee.Collection<Composer.Widget> composer_widgets =
|
||||
new Gee.LinkedList<Composer.Widget>();
|
||||
|
||||
// Composers that are in the process of closing
|
||||
private Gee.Collection<Composer.Widget> waiting_to_close =
|
||||
new Gee.LinkedList<Composer.Widget>();
|
||||
|
||||
// Requested mailto composers not yet fullfulled
|
||||
private Gee.List<string?> pending_mailtos = new Gee.ArrayList<string>();
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -204,7 +210,7 @@ public class Application.Controller : Geary.BaseObject {
|
|||
ClientWebView.load_resources(
|
||||
this.application.get_user_config_directory()
|
||||
);
|
||||
ComposerWebView.load_resources();
|
||||
Composer.WebView.load_resources();
|
||||
ConversationWebView.load_resources();
|
||||
Accounts.SignatureWebView.load_resources();
|
||||
} catch (Error err) {
|
||||
|
|
@ -409,21 +415,21 @@ public class Application.Controller : Geary.BaseObject {
|
|||
* Opens new composer with an existing message as context.
|
||||
*/
|
||||
public void compose_with_context_email(Geary.Account account,
|
||||
ComposerWidget.ComposeType type,
|
||||
Composer.Widget.ComposeType type,
|
||||
Geary.Email context,
|
||||
string? quote) {
|
||||
create_compose_widget(account, type, context, quote);
|
||||
}
|
||||
|
||||
/** Adds a new composer to be kept track of. */
|
||||
public void add_composer(ComposerWidget widget) {
|
||||
public void add_composer(Composer.Widget widget) {
|
||||
debug(@"Added composer of type $(widget.compose_type); $(this.composer_widgets.size) composers total");
|
||||
widget.destroy.connect(this.on_composer_widget_destroy);
|
||||
this.composer_widgets.add(widget);
|
||||
}
|
||||
|
||||
/** Returns a read-only collection of currently open composers .*/
|
||||
public Gee.Collection<ComposerWidget> get_composers() {
|
||||
public Gee.Collection<Composer.Widget> get_composers() {
|
||||
return this.composer_widgets.read_only_view;
|
||||
}
|
||||
|
||||
|
|
@ -1463,38 +1469,39 @@ public class Application.Controller : Geary.BaseObject {
|
|||
}
|
||||
|
||||
internal bool close_composition_windows(bool main_window_only = false) {
|
||||
Gee.List<ComposerWidget> composers_to_destroy = new Gee.ArrayList<ComposerWidget>();
|
||||
Gee.List<Composer.Widget> composers_to_destroy = new Gee.ArrayList<Composer.Widget>();
|
||||
bool quit_cancelled = false;
|
||||
|
||||
// If there's composer windows open, give the user a chance to
|
||||
// save or cancel.
|
||||
foreach(ComposerWidget cw in composer_widgets) {
|
||||
foreach(Composer.Widget cw in composer_widgets) {
|
||||
if (!main_window_only ||
|
||||
cw.state != ComposerWidget.ComposerState.DETACHED) {
|
||||
cw.state != Composer.Widget.ComposerState.DETACHED) {
|
||||
// Check if we should close the window immediately, or
|
||||
// if we need to wait.
|
||||
ComposerWidget.CloseStatus status = cw.should_close();
|
||||
if (status == ComposerWidget.CloseStatus.PENDING_CLOSE) {
|
||||
Composer.Widget.CloseStatus status = cw.should_close();
|
||||
if (status == Composer.Widget.CloseStatus.PENDING_CLOSE) {
|
||||
// Window is currently busy saving.
|
||||
waiting_to_close.add(cw);
|
||||
} else if (status == ComposerWidget.CloseStatus.CANCEL_CLOSE) {
|
||||
} else if (status == Composer.Widget.CloseStatus.CANCEL_CLOSE) {
|
||||
// User cancelled operation.
|
||||
quit_cancelled = true;
|
||||
break;
|
||||
} else if (status == ComposerWidget.CloseStatus.DO_CLOSE) {
|
||||
} else if (status == Composer.Widget.CloseStatus.DO_CLOSE) {
|
||||
// Hide any existing composer windows for the
|
||||
// moment; actually deleting the windows will
|
||||
// result in their removal from composer_windows,
|
||||
// which could crash this loop.
|
||||
composers_to_destroy.add(cw);
|
||||
((ComposerContainer) cw.parent).vanish();
|
||||
((Composer.Container) cw.parent).vanish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Safely destroy windows.
|
||||
foreach(ComposerWidget cw in composers_to_destroy)
|
||||
((ComposerContainer) cw.parent).close_container();
|
||||
foreach(Composer.Widget cw in composers_to_destroy) {
|
||||
((Composer.Container) cw.parent).close_container();
|
||||
}
|
||||
|
||||
// If we cancelled the quit we can bail here.
|
||||
if (quit_cancelled) {
|
||||
|
|
@ -1530,7 +1537,7 @@ public class Application.Controller : Geary.BaseObject {
|
|||
* a new mail (false)
|
||||
*/
|
||||
private void create_compose_widget(Geary.Account account,
|
||||
ComposerWidget.ComposeType compose_type,
|
||||
Composer.Widget.ComposeType compose_type,
|
||||
Geary.Email? referred = null,
|
||||
string? quote = null,
|
||||
string? mailto = null,
|
||||
|
|
@ -1541,7 +1548,7 @@ public class Application.Controller : Geary.BaseObject {
|
|||
if (compose_type == NEW_MESSAGE && !is_draft) {
|
||||
// We're creating a new message that isn't a draft, if
|
||||
// there's already a composer open, just use that
|
||||
ComposerWidget? existing =
|
||||
Composer.Widget? existing =
|
||||
this.main_window.conversation_viewer.current_composer;
|
||||
if (existing != null &&
|
||||
existing.state == PANED &&
|
||||
|
|
@ -1553,7 +1560,7 @@ public class Application.Controller : Geary.BaseObject {
|
|||
} else if (compose_type != NEW_MESSAGE) {
|
||||
// We're replying, see whether we already have a reply for
|
||||
// that message and if so, insert a quote into that.
|
||||
foreach (ComposerWidget existing in this.composer_widgets) {
|
||||
foreach (Composer.Widget existing in this.composer_widgets) {
|
||||
if (existing.state != DETACHED &&
|
||||
((referred != null && existing.referred_ids.contains(referred.id)) ||
|
||||
quote != null)) {
|
||||
|
|
@ -1571,13 +1578,13 @@ public class Application.Controller : Geary.BaseObject {
|
|||
}
|
||||
}
|
||||
|
||||
ComposerWidget widget;
|
||||
Composer.Widget widget;
|
||||
if (mailto != null) {
|
||||
widget = new ComposerWidget.from_mailto(
|
||||
widget = new Composer.Widget.from_mailto(
|
||||
this.application, account, mailto
|
||||
);
|
||||
} else {
|
||||
widget = new ComposerWidget(
|
||||
widget = new Composer.Widget(
|
||||
this.application,
|
||||
account,
|
||||
is_draft ? referred.id : null,
|
||||
|
|
@ -1605,7 +1612,7 @@ public class Application.Controller : Geary.BaseObject {
|
|||
}
|
||||
|
||||
private async void load_composer(Geary.Account account,
|
||||
ComposerWidget widget,
|
||||
Composer.Widget widget,
|
||||
Geary.Email? referred = null,
|
||||
string? quote = null) {
|
||||
Geary.Email? full = null;
|
||||
|
|
@ -1618,7 +1625,7 @@ public class Application.Controller : Geary.BaseObject {
|
|||
full = yield context.emails.fetch_email_async(
|
||||
referred.id,
|
||||
Geary.ComposedEmail.REQUIRED_REPLY_FIELDS |
|
||||
ComposerWidget.REQUIRED_FIELDS,
|
||||
Composer.Widget.REQUIRED_FIELDS,
|
||||
NONE,
|
||||
cancellable
|
||||
);
|
||||
|
|
@ -1636,11 +1643,11 @@ public class Application.Controller : Geary.BaseObject {
|
|||
}
|
||||
|
||||
private void on_composer_widget_destroy(Gtk.Widget sender) {
|
||||
composer_widgets.remove((ComposerWidget) sender);
|
||||
debug(@"Destroying composer of type $(((ComposerWidget) sender).compose_type); "
|
||||
composer_widgets.remove((Composer.Widget) sender);
|
||||
debug(@"Destroying composer of type $(((Composer.Widget) sender).compose_type); "
|
||||
+ @"$(composer_widgets.size) composers remaining");
|
||||
|
||||
if (waiting_to_close.remove((ComposerWidget) sender)) {
|
||||
if (waiting_to_close.remove((Composer.Widget) sender)) {
|
||||
// If we just removed the last window in the waiting to close list, it's time to exit!
|
||||
if (waiting_to_close.size == 0)
|
||||
this.application.exit();
|
||||
|
|
@ -1665,8 +1672,8 @@ public class Application.Controller : Geary.BaseObject {
|
|||
}
|
||||
|
||||
// Returns a list of composer windows for an account, or null if none.
|
||||
public Gee.List<ComposerWidget>? get_composer_widgets_for_account(Geary.AccountInformation account) {
|
||||
Gee.LinkedList<ComposerWidget> ret = Geary.traverse<ComposerWidget>(composer_widgets)
|
||||
public Gee.List<Composer.Widget>? get_composer_widgets_for_account(Geary.AccountInformation account) {
|
||||
Gee.LinkedList<Composer.Widget> ret = Geary.traverse<Composer.Widget>(composer_widgets)
|
||||
.filter(w => w.account.information == account)
|
||||
.to_linked_list();
|
||||
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ public class GearyApplication : Gtk.Application {
|
|||
add_edit_accelerators(Action.Edit.UNDO, { "<Ctrl>Z" });
|
||||
|
||||
MainWindow.add_accelerators(this);
|
||||
ComposerWidget.add_accelerators(this);
|
||||
Composer.Widget.add_accelerators(this);
|
||||
Components.Inspector.add_accelerators(this);
|
||||
Dialogs.ProblemDetailsDialog.add_accelerators(this);
|
||||
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
|
|||
/** Displays a composer addressed to a specific email address. */
|
||||
public void open_composer_for_mailbox(Geary.RFC822.MailboxAddress to) {
|
||||
Application.Controller controller = this.application.controller;
|
||||
ComposerWidget composer = new ComposerWidget(
|
||||
Composer.Widget composer = new Composer.Widget(
|
||||
this.application, this.selected_folder.account, null, NEW_MESSAGE
|
||||
);
|
||||
composer.to = to.to_full_display();
|
||||
|
|
@ -577,10 +577,10 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
|
|||
}
|
||||
|
||||
/** Displays a composer in the window if possible, else in a new window. */
|
||||
public void show_composer(ComposerWidget composer) {
|
||||
public void show_composer(Composer.Widget composer) {
|
||||
if (this.has_composer) {
|
||||
composer.state = ComposerWidget.ComposerState.DETACHED;
|
||||
new ComposerWindow(composer, this.application);
|
||||
composer.state = Composer.Widget.ComposerState.DETACHED;
|
||||
new Composer.Window(composer, this.application);
|
||||
} else {
|
||||
this.conversation_viewer.do_compose(composer);
|
||||
get_window_action(ACTION_FIND_IN_CONVERSATION).set_enabled(false);
|
||||
|
|
@ -595,7 +595,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
|
|||
*/
|
||||
public bool close_composer() {
|
||||
bool closed = true;
|
||||
ComposerWidget? composer = this.conversation_viewer.current_composer;
|
||||
Composer.Widget? composer = this.conversation_viewer.current_composer;
|
||||
if (composer != null) {
|
||||
switch (composer.should_close()) {
|
||||
case DO_CLOSE:
|
||||
|
|
@ -1242,7 +1242,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
|
|||
this.conversations = null;
|
||||
}
|
||||
|
||||
private void create_composer_from_viewer(ComposerWidget.ComposeType compose_type) {
|
||||
private void create_composer_from_viewer(Composer.Widget.ComposeType compose_type) {
|
||||
Geary.Account? account = this.selected_account;
|
||||
ConversationEmail? email_view = null;
|
||||
ConversationListBox? list_view = this.conversation_viewer.current_list;
|
||||
|
|
@ -1514,7 +1514,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
|
|||
if (event.keyval == Gdk.Key.Shift_L || event.keyval == Gdk.Key.Shift_R) {
|
||||
Gtk.Widget? focus = get_focus();
|
||||
if (focus == null ||
|
||||
(!(focus is Gtk.Entry) && !(focus is ComposerWebView))) {
|
||||
(!(focus is Gtk.Entry) && !(focus is Composer.WebView))) {
|
||||
set_shift_key_down(event.type == Gdk.EventType.KEY_PRESS);
|
||||
}
|
||||
}
|
||||
|
|
@ -1715,7 +1715,7 @@ public class MainWindow : Gtk.ApplicationWindow, Geary.BaseInterface {
|
|||
// Check all known composers since the draft may be open
|
||||
// in a detached composer
|
||||
bool already_open = false;
|
||||
foreach (ComposerWidget composer
|
||||
foreach (Composer.Widget composer
|
||||
in this.application.controller.get_composers()) {
|
||||
if (composer.draft_id != null &&
|
||||
composer.draft_id.equal_to(draft.id)) {
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@
|
|||
* A ComposerBox is a ComposerContainer that is used to compose mails in the main-window
|
||||
* (i.e. not-detached), yet separate from a conversation.
|
||||
*/
|
||||
public class ComposerBox : Gtk.Frame, ComposerContainer {
|
||||
public class Composer.Box : Gtk.Frame, Container {
|
||||
|
||||
public Gtk.ApplicationWindow top_window {
|
||||
get { return (Gtk.ApplicationWindow) get_toplevel(); }
|
||||
}
|
||||
|
||||
internal ComposerWidget composer { get; set; }
|
||||
internal Widget composer { get; set; }
|
||||
|
||||
protected Gee.MultiMap<string, string>? old_accelerators { get; set; }
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ public class ComposerBox : Gtk.Frame, ComposerContainer {
|
|||
public signal void vanished();
|
||||
|
||||
|
||||
public ComposerBox(ComposerWidget composer) {
|
||||
public Box(Widget composer) {
|
||||
this.composer = composer;
|
||||
this.composer.free_header();
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ public class ComposerBox : Gtk.Frame, ComposerContainer {
|
|||
public void vanish() {
|
||||
hide();
|
||||
this.main_toolbar.remove_conversation_header(composer.header);
|
||||
this.composer.state = ComposerWidget.ComposerState.DETACHED;
|
||||
this.composer.state = Widget.ComposerState.DETACHED;
|
||||
vanished();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
/**
|
||||
* A generic interface for widgets that have a single ComposerWidget-child.
|
||||
*/
|
||||
public interface ComposerContainer {
|
||||
public interface Composer.Container {
|
||||
|
||||
// The ComposerWidget-child.
|
||||
internal abstract ComposerWidget composer { get; set; }
|
||||
internal abstract Widget composer { get; set; }
|
||||
|
||||
// We use old_accelerators to keep track of the accelerators we temporarily disabled.
|
||||
protected abstract Gee.MultiMap<string, string>? old_accelerators { get; set; }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* A ComposerEmbed is a widget that is used to compose emails that are inlined into a
|
||||
* conversation view, e.g. for reply or forward mails.
|
||||
*/
|
||||
public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
|
||||
public class Composer.Embed : Gtk.EventBox, Container {
|
||||
|
||||
private const int MIN_EDITOR_HEIGHT = 200;
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
|
|||
get { return (Gtk.ApplicationWindow) get_toplevel(); }
|
||||
}
|
||||
|
||||
internal ComposerWidget composer { get; set; }
|
||||
internal Widget composer { get; set; }
|
||||
|
||||
protected Gee.MultiMap<string, string>? old_accelerators { get; set; }
|
||||
|
||||
|
|
@ -28,9 +28,9 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
|
|||
public signal void vanished();
|
||||
|
||||
|
||||
public ComposerEmbed(Geary.Email referred,
|
||||
ComposerWidget composer,
|
||||
Gtk.ScrolledWindow outer_scroller) {
|
||||
public Embed(Geary.Email referred,
|
||||
Widget composer,
|
||||
Gtk.ScrolledWindow outer_scroller) {
|
||||
this.referred = referred;
|
||||
this.composer = composer;
|
||||
this.outer_scroller = outer_scroller;
|
||||
|
|
@ -179,7 +179,7 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
|
|||
|
||||
public void vanish() {
|
||||
hide();
|
||||
this.composer.state = ComposerWidget.ComposerState.DETACHED;
|
||||
this.composer.state = Widget.ComposerState.DETACHED;
|
||||
vanished();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
*/
|
||||
|
||||
[GtkTemplate (ui = "/org/gnome/Geary/composer-headerbar.ui")]
|
||||
public class ComposerHeaderbar : Gtk.HeaderBar {
|
||||
public class Composer.Headerbar : Gtk.HeaderBar {
|
||||
|
||||
public Application.Configuration config { get; set; }
|
||||
|
||||
public ComposerWidget.ComposerState state { get; set; }
|
||||
public Widget.ComposerState state { get; set; }
|
||||
|
||||
public bool show_pending_attachments { get; set; default = false; }
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ public class ComposerHeaderbar : Gtk.HeaderBar {
|
|||
/** Fired when the user wants to expand a compact composer. */
|
||||
public signal void expand_composer();
|
||||
|
||||
public ComposerHeaderbar(Application.Configuration config, bool is_compact) {
|
||||
public Headerbar(Application.Configuration config, bool is_compact) {
|
||||
this.config = config;
|
||||
|
||||
this.recipients_button.set_visible(is_compact);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
* an update, delete and open buttons.
|
||||
*/
|
||||
[GtkTemplate (ui = "/org/gnome/Geary/composer-link-popover.ui")]
|
||||
public class ComposerLinkPopover : Gtk.Popover {
|
||||
public class Composer.LinkPopover : Gtk.Popover {
|
||||
|
||||
private const string[] HTTP_SCHEMES = { "http", "https" };
|
||||
private const string[] OTHER_SCHEMES = {
|
||||
|
|
@ -71,7 +71,7 @@ public class ComposerLinkPopover : Gtk.Popover {
|
|||
public signal void link_delete();
|
||||
|
||||
|
||||
public ComposerLinkPopover(Type type) {
|
||||
public LinkPopover(Type type) {
|
||||
set_default_widget(this.url);
|
||||
set_focus_child(this.url);
|
||||
switch (type) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
/**
|
||||
* A WebView for editing messages in the composer.
|
||||
*/
|
||||
public class ComposerWebView : ClientWebView {
|
||||
public class Composer.WebView : ClientWebView {
|
||||
|
||||
|
||||
// WebKit message handler names
|
||||
|
|
@ -83,10 +83,10 @@ public class ComposerWebView : ClientWebView {
|
|||
|
||||
public static new void load_resources()
|
||||
throws Error {
|
||||
ComposerWebView.app_style = ClientWebView.load_app_stylesheet(
|
||||
WebView.app_style = ClientWebView.load_app_stylesheet(
|
||||
"composer-web-view.css"
|
||||
);
|
||||
ComposerWebView.app_script = ClientWebView.load_app_script(
|
||||
WebView.app_script = ClientWebView.load_app_script(
|
||||
"composer-web-view.js"
|
||||
);
|
||||
}
|
||||
|
|
@ -115,13 +115,13 @@ public class ComposerWebView : ClientWebView {
|
|||
internal signal bool button_release_event_done(Gdk.Event event);
|
||||
|
||||
|
||||
public ComposerWebView(Application.Configuration config) {
|
||||
public WebView(Application.Configuration config) {
|
||||
base(config);
|
||||
|
||||
add_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.KEY_RELEASE_MASK);
|
||||
|
||||
this.user_content_manager.add_style_sheet(ComposerWebView.app_style);
|
||||
this.user_content_manager.add_script(ComposerWebView.app_script);
|
||||
this.user_content_manager.add_style_sheet(WebView.app_style);
|
||||
this.user_content_manager.add_script(WebView.app_script);
|
||||
|
||||
register_message_handler(CURSOR_CONTEXT_CHANGED, on_cursor_context_changed);
|
||||
register_message_handler(DRAG_DROP_RECEIVED, on_drag_drop_received);
|
||||
|
|
|
|||
|
|
@ -11,9 +11,13 @@ private errordomain AttachmentError {
|
|||
DUPLICATE
|
||||
}
|
||||
|
||||
// The actual widget for sending messages. Should be put in a ComposerContainer
|
||||
/**
|
||||
* A widget for editing an email message.
|
||||
*
|
||||
* Composers must always be placed in an instance of {@link Container}.
|
||||
*/
|
||||
[GtkTemplate (ui = "/org/gnome/Geary/composer-widget.ui")]
|
||||
public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
||||
public class Composer.Widget : Gtk.EventBox, Geary.BaseInterface {
|
||||
|
||||
|
||||
/** The email fields the composer requires for referred email. */
|
||||
|
|
@ -250,9 +254,9 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
}
|
||||
}
|
||||
|
||||
public ComposerHeaderbar header { get; private set; }
|
||||
public Headerbar header { get; private set; }
|
||||
|
||||
public ComposerWebView editor { get; private set; }
|
||||
public WebView editor { get; private set; }
|
||||
|
||||
public string window_title { get; set; }
|
||||
|
||||
|
|
@ -398,8 +402,8 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
// Is the composer closing (e.g. saving a draft or sending)?
|
||||
private bool is_closing = false;
|
||||
|
||||
private ComposerContainer container {
|
||||
get { return (ComposerContainer) parent; }
|
||||
private Container container {
|
||||
get { return (Container) parent; }
|
||||
}
|
||||
|
||||
private GearyApplication application;
|
||||
|
|
@ -415,7 +419,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
public signal void subject_changed(string new_subject);
|
||||
|
||||
|
||||
public ComposerWidget(GearyApplication application,
|
||||
public Widget(GearyApplication application,
|
||||
Geary.Account initial_account,
|
||||
Geary.EmailIdentifier? draft_id,
|
||||
ComposeType compose_type) {
|
||||
|
|
@ -442,7 +446,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
this.state = ComposerState.INLINE_COMPACT;
|
||||
}
|
||||
|
||||
this.header = new ComposerHeaderbar(
|
||||
this.header = new Headerbar(
|
||||
application.config,
|
||||
this.state == ComposerState.INLINE_COMPACT
|
||||
);
|
||||
|
|
@ -496,7 +500,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
);
|
||||
update_subject_spell_checker();
|
||||
|
||||
this.editor = new ComposerWebView(application.config);
|
||||
this.editor = new WebView(application.config);
|
||||
this.editor.set_hexpand(true);
|
||||
this.editor.set_vexpand(true);
|
||||
this.editor.content_loaded.connect(on_editor_content_loaded);
|
||||
|
|
@ -565,7 +569,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
load_entry_completions();
|
||||
}
|
||||
|
||||
~ComposerWidget() {
|
||||
~Widget() {
|
||||
base_unref();
|
||||
}
|
||||
|
||||
|
|
@ -588,9 +592,9 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
base.destroy();
|
||||
}
|
||||
|
||||
public ComposerWidget.from_mailto(GearyApplication application,
|
||||
Geary.Account initial_account,
|
||||
string mailto) {
|
||||
public Widget.from_mailto(GearyApplication application,
|
||||
Geary.Account initial_account,
|
||||
string mailto) {
|
||||
this(application, initial_account, null, ComposeType.NEW_MESSAGE);
|
||||
|
||||
Gee.HashMultiMap<string, string> headers = new Gee.HashMultiMap<string, string>();
|
||||
|
|
@ -1100,7 +1104,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
|
||||
if (this.state != ComposerState.PANED &&
|
||||
this.state != ComposerState.DETACHED) {
|
||||
this.state = ComposerWidget.ComposerState.PANED;
|
||||
this.state = Widget.ComposerState.PANED;
|
||||
// XXX move the two lines below to the controller
|
||||
this.container.remove_composer();
|
||||
GearyApplication.instance.controller.main_window.conversation_viewer.do_compose(this);
|
||||
|
|
@ -1280,7 +1284,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
|
||||
Gtk.Widget? focused_widget = this.container.top_window.get_focus();
|
||||
this.container.remove_composer();
|
||||
ComposerWindow new_window = new ComposerWindow(this, this.application);
|
||||
Window new_window = new Window(this, this.application);
|
||||
|
||||
// Workaround a GTK+ crasher, Bug 771812. When the composer is
|
||||
// re-parented, its menu_button's popover keeps a reference to
|
||||
|
|
@ -1295,15 +1299,14 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
this.application.config.compose_as_html
|
||||
);
|
||||
|
||||
this.state = ComposerWidget.ComposerState.DETACHED;
|
||||
this.state = DETACHED;
|
||||
update_composer_view();
|
||||
|
||||
// If the previously focused widget is in the new composer
|
||||
// window then focus that, else focus something useful.
|
||||
bool refocus = true;
|
||||
if (focused_widget != null) {
|
||||
ComposerWindow? focused_window =
|
||||
focused_widget.get_toplevel() as ComposerWindow;
|
||||
Window? focused_window = focused_widget.get_toplevel() as Window;
|
||||
if (new_window == focused_window) {
|
||||
focused_widget.grab_focus();
|
||||
refocus = false;
|
||||
|
|
@ -2418,15 +2421,15 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
buffer.spell_checker = checker;
|
||||
}
|
||||
|
||||
private async ComposerLinkPopover new_link_popover(ComposerLinkPopover.Type type,
|
||||
string url) {
|
||||
private async LinkPopover new_link_popover(LinkPopover.Type type,
|
||||
string url) {
|
||||
var selection_id = "";
|
||||
try {
|
||||
selection_id = yield this.editor.save_selection();
|
||||
} catch (Error err) {
|
||||
debug("Error saving selection: %s", err.message);
|
||||
}
|
||||
ComposerLinkPopover popover = new ComposerLinkPopover(type);
|
||||
LinkPopover popover = new LinkPopover(type);
|
||||
popover.set_link_url(url);
|
||||
popover.closed.connect(() => {
|
||||
this.editor.free_selection(selection_id);
|
||||
|
|
@ -2497,9 +2500,9 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
location.y = (int) button.y;
|
||||
|
||||
this.new_link_popover.begin(
|
||||
ComposerLinkPopover.Type.EXISTING_LINK, this.pointer_url,
|
||||
LinkPopover.Type.EXISTING_LINK, this.pointer_url,
|
||||
(obj, res) => {
|
||||
ComposerLinkPopover popover = this.new_link_popover.end(res);
|
||||
LinkPopover popover = this.new_link_popover.end(res);
|
||||
popover.set_relative_to(this.editor);
|
||||
popover.set_pointing_to(location);
|
||||
popover.show();
|
||||
|
|
@ -2508,7 +2511,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
return Gdk.EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
private void on_cursor_context_changed(ComposerWebView.EditContext context) {
|
||||
private void on_cursor_context_changed(WebView.EditContext context) {
|
||||
this.cursor_url = context.is_link ? context.link_url : null;
|
||||
update_cursor_actions();
|
||||
|
||||
|
|
@ -2602,15 +2605,15 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
|
|||
}
|
||||
|
||||
private void on_insert_link(SimpleAction action, Variant? param) {
|
||||
ComposerLinkPopover.Type type = ComposerLinkPopover.Type.NEW_LINK;
|
||||
LinkPopover.Type type = LinkPopover.Type.NEW_LINK;
|
||||
string url = "https://";
|
||||
if (this.cursor_url != null) {
|
||||
type = ComposerLinkPopover.Type.EXISTING_LINK;
|
||||
type = LinkPopover.Type.EXISTING_LINK;
|
||||
url = this.cursor_url;
|
||||
}
|
||||
|
||||
this.new_link_popover.begin(type, url, (obj, res) => {
|
||||
ComposerLinkPopover popover = this.new_link_popover.end(res);
|
||||
LinkPopover popover = this.new_link_popover.end(res);
|
||||
|
||||
// We have to disconnect then reconnect the selection
|
||||
// changed signal for the duration of the popover
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
* A ComposerWindow is a ComposerContainer that is used to compose mails in a separate window
|
||||
* (i.e. detached) of its own.
|
||||
*/
|
||||
public class ComposerWindow : Gtk.ApplicationWindow, ComposerContainer {
|
||||
public class Composer.Window : Gtk.ApplicationWindow, Container {
|
||||
|
||||
|
||||
private const string DEFAULT_TITLE = _("New Message");
|
||||
|
|
@ -23,13 +23,13 @@ public class ComposerWindow : Gtk.ApplicationWindow, ComposerContainer {
|
|||
get { return this; }
|
||||
}
|
||||
|
||||
internal ComposerWidget composer { get; set; }
|
||||
internal Widget composer { get; set; }
|
||||
|
||||
protected Gee.MultiMap<string, string>? old_accelerators { get; set; }
|
||||
|
||||
private bool closing = false;
|
||||
|
||||
public ComposerWindow(ComposerWidget composer, GearyApplication application) {
|
||||
public Window(Widget composer, GearyApplication application) {
|
||||
Object(application: application, type: Gtk.WindowType.TOPLEVEL);
|
||||
this.composer = composer;
|
||||
this.composer.header.detached();
|
||||
|
|
@ -111,7 +111,7 @@ public class ComposerWindow : Gtk.ApplicationWindow, ComposerContainer {
|
|||
|
||||
public override bool delete_event(Gdk.EventAny event) {
|
||||
return !(this.closing ||
|
||||
((ComposerWidget) get_child()).should_close() == ComposerWidget.CloseStatus.DO_CLOSE);
|
||||
((Widget) get_child()).should_close() == Widget.CloseStatus.DO_CLOSE);
|
||||
}
|
||||
|
||||
public void vanish() {
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ public class EmailEntry : Gtk.Entry {
|
|||
// null or valid addresses
|
||||
public Geary.RFC822.MailboxAddresses? addresses { get; set; default = null; }
|
||||
|
||||
private weak ComposerWidget composer;
|
||||
private weak Composer.Widget composer;
|
||||
|
||||
private bool updating = false;
|
||||
|
||||
public EmailEntry(ComposerWidget composer) {
|
||||
public EmailEntry(Composer.Widget composer) {
|
||||
changed.connect(on_changed);
|
||||
key_press_event.connect(on_key_press);
|
||||
this.composer = composer;
|
||||
|
|
|
|||
|
|
@ -427,10 +427,10 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
internal class ComposerRow : ConversationRow {
|
||||
|
||||
// The embedded composer for this row
|
||||
public ComposerEmbed view { get; private set; }
|
||||
public Composer.Embed view { get; private set; }
|
||||
|
||||
|
||||
public ComposerRow(ComposerEmbed view) {
|
||||
public ComposerRow(Composer.Embed view) {
|
||||
base(view.referred);
|
||||
this.view = view;
|
||||
this.is_expanded = true;
|
||||
|
|
@ -834,7 +834,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
|
|||
/**
|
||||
* Adds an an embedded composer to the view.
|
||||
*/
|
||||
public void add_embedded_composer(ComposerEmbed embed, bool is_draft) {
|
||||
public void add_embedded_composer(Composer.Embed embed, bool is_draft) {
|
||||
if (is_draft) {
|
||||
this.draft_id = embed.referred.id;
|
||||
EmailRow? draft = this.email_rows.get(embed.referred.id);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
|
|||
}
|
||||
|
||||
/** Returns the currently displayed composer if any. */
|
||||
public ComposerWidget? current_composer {
|
||||
public Composer.Widget? current_composer {
|
||||
get; private set; default = null;
|
||||
}
|
||||
|
||||
|
|
@ -145,8 +145,8 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
|
|||
/**
|
||||
* Puts the view into composer mode, showing a full-height composer.
|
||||
*/
|
||||
public void do_compose(ComposerWidget composer) {
|
||||
ComposerBox box = new ComposerBox(composer);
|
||||
public void do_compose(Composer.Widget composer) {
|
||||
Composer.Box box = new Composer.Box(composer);
|
||||
this.current_composer = composer;
|
||||
|
||||
// XXX move the ConversationListView management code into
|
||||
|
|
@ -166,10 +166,10 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
|
|||
/**
|
||||
* Puts the view into composer mode, showing an embedded composer.
|
||||
*/
|
||||
public void do_compose_embedded(ComposerWidget composer,
|
||||
public void do_compose_embedded(Composer.Widget composer,
|
||||
Geary.Email? referred) {
|
||||
this.current_composer = composer;
|
||||
ComposerEmbed embed = new ComposerEmbed(
|
||||
Composer.Embed embed = new Composer.Embed(
|
||||
referred,
|
||||
composer,
|
||||
this.conversation_scroller
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
|
||||
public class Composer.WebViewTest : ClientWebViewTestCase<Composer.WebView> {
|
||||
|
||||
|
||||
public ComposerWebViewTest() {
|
||||
base("ComposerWebViewTest");
|
||||
public WebViewTest() {
|
||||
base("Composer.WebViewTest");
|
||||
add_test("load_resources", load_resources);
|
||||
add_test("edit_context", edit_context);
|
||||
add_test("get_html", get_html);
|
||||
|
|
@ -28,22 +28,22 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
|
|||
|
||||
public void load_resources() throws Error {
|
||||
try {
|
||||
ComposerWebView.load_resources();
|
||||
WebView.load_resources();
|
||||
} catch (Error err) {
|
||||
assert_not_reached();
|
||||
}
|
||||
}
|
||||
|
||||
public void edit_context() throws Error {
|
||||
assert(!(new ComposerWebView.EditContext("0,,,").is_link));
|
||||
assert(new ComposerWebView.EditContext("1,,,").is_link);
|
||||
assert(new ComposerWebView.EditContext("1,url,,").link_url == "url");
|
||||
assert(!(new WebView.EditContext("0,,,").is_link));
|
||||
assert(new WebView.EditContext("1,,,").is_link);
|
||||
assert(new WebView.EditContext("1,url,,").link_url == "url");
|
||||
|
||||
assert(new ComposerWebView.EditContext("0,,Helvetica,").font_family == "sans");
|
||||
assert(new ComposerWebView.EditContext("0,,Times New Roman,").font_family == "serif");
|
||||
assert(new ComposerWebView.EditContext("0,,Courier,").font_family == "monospace");
|
||||
assert(new WebView.EditContext("0,,Helvetica,").font_family == "sans");
|
||||
assert(new WebView.EditContext("0,,Times New Roman,").font_family == "serif");
|
||||
assert(new WebView.EditContext("0,,Courier,").font_family == "monospace");
|
||||
|
||||
assert(new ComposerWebView.EditContext("0,,,12").font_size == 12);
|
||||
assert(new WebView.EditContext("0,,,12").font_size == 12);
|
||||
}
|
||||
|
||||
public void get_html() throws GLib.Error {
|
||||
|
|
@ -51,7 +51,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
|
|||
load_body_fixture(BODY);
|
||||
this.test_view.get_html.begin((obj, ret) => { async_complete(ret); });
|
||||
string html = this.test_view.get_html.end(async_result());
|
||||
assert_string(ComposerPageStateTest.CLEAN_BODY_TEMPLATE.printf(BODY), html);
|
||||
assert_string(PageStateTest.CLEAN_BODY_TEMPLATE.printf(BODY), html);
|
||||
}
|
||||
|
||||
public void get_html_for_draft() throws GLib.Error {
|
||||
|
|
@ -59,7 +59,7 @@ public class ComposerWebViewTest : ClientWebViewTestCase<ComposerWebView> {
|
|||
load_body_fixture(BODY);
|
||||
this.test_view.get_html_for_draft.begin((obj, ret) => { async_complete(ret); });
|
||||
string html = this.test_view.get_html.end(async_result());
|
||||
assert_string(ComposerPageStateTest.COMPLETE_BODY_TEMPLATE.printf(BODY), html);
|
||||
assert_string(PageStateTest.COMPLETE_BODY_TEMPLATE.printf(BODY), html);
|
||||
}
|
||||
|
||||
public void get_text() throws Error {
|
||||
|
|
@ -242,8 +242,8 @@ long, long, long, long, long, long, long, long, long, long,
|
|||
assert_false(SIG2 in html, "Signature 2 still present");
|
||||
}
|
||||
|
||||
protected override ComposerWebView set_up_test_view() {
|
||||
return new ComposerWebView(this.config);
|
||||
protected override Composer.WebView set_up_test_view() {
|
||||
return new Composer.WebView(this.config);
|
||||
}
|
||||
|
||||
protected override void load_body_fixture(string html = "") {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* (version 2.1 or later). See the COPYING file in this distribution.
|
||||
*/
|
||||
|
||||
class ComposerPageStateTest : ClientWebViewTestCase<ComposerWebView> {
|
||||
class Composer.PageStateTest : ClientWebViewTestCase<Composer.WebView> {
|
||||
|
||||
public const string COMPLETE_BODY_TEMPLATE =
|
||||
"""<div id="geary-body" dir="auto">%s<div><br></div><div><br></div></div><div id="geary-signature" dir="auto"></div>""";
|
||||
|
|
@ -16,8 +16,8 @@ class ComposerPageStateTest : ClientWebViewTestCase<ComposerWebView> {
|
|||
""";
|
||||
public const string CLEAN_BODY_TEMPLATE = """<div id="geary-body" dir="auto">%s<div><br></div><div><br></div></div>""";
|
||||
|
||||
public ComposerPageStateTest() {
|
||||
base("ComposerPageStateTest");
|
||||
public PageStateTest() {
|
||||
base("Composer.PageStateTest");
|
||||
add_test("html_to_text", html_to_text);
|
||||
add_test("html_to_text_with_quote", html_to_text_with_quote);
|
||||
add_test("html_to_text_with_nested_quote", html_to_text_with_nested_quote);
|
||||
|
|
@ -34,7 +34,7 @@ class ComposerPageStateTest : ClientWebViewTestCase<ComposerWebView> {
|
|||
add_test("replace_non_breaking_space", replace_non_breaking_space);
|
||||
|
||||
try {
|
||||
ComposerWebView.load_resources();
|
||||
WebView.load_resources();
|
||||
} catch (Error err) {
|
||||
assert_not_reached();
|
||||
}
|
||||
|
|
@ -418,8 +418,8 @@ I can send email through smtp.gmail.com:587 or through <a href="https://www.gmai
|
|||
}
|
||||
}
|
||||
|
||||
protected override ComposerWebView set_up_test_view() {
|
||||
return new ComposerWebView(this.config);
|
||||
protected override Composer.WebView set_up_test_view() {
|
||||
return new Composer.WebView(this.config);
|
||||
}
|
||||
|
||||
protected override void load_body_fixture(string body = "") {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ int main(string[] args) {
|
|||
client.add_suite(new Accounts.ManagerTest().get_suite());
|
||||
client.add_suite(new Application.ConfigurationTest().get_suite());
|
||||
client.add_suite(new ClientWebViewTest().get_suite());
|
||||
client.add_suite(new ComposerWebViewTest().get_suite());
|
||||
client.add_suite(new Composer.WebViewTest().get_suite());
|
||||
client.add_suite(new GearyApplicationTest().get_suite());
|
||||
client.add_suite(new Util.Avatar.Test().get_suite());
|
||||
client.add_suite(new Util.Cache.Test().get_suite());
|
||||
|
|
@ -61,7 +61,7 @@ int main(string[] args) {
|
|||
TestSuite js = new TestSuite("js");
|
||||
|
||||
js.add_suite(new ClientPageStateTest().get_suite());
|
||||
js.add_suite(new ComposerPageStateTest().get_suite());
|
||||
js.add_suite(new Composer.PageStateTest().get_suite());
|
||||
js.add_suite(new ConversationPageStateTest().get_suite());
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue