Commit 48c93655 authored by Kristian Klausen's avatar Kristian Klausen

Remove trailing whitespace

find . -name '*.vala' -type f -exec sed -i 's/ *$//g' {} +
The following files was ignored:
test/client/composer/composer-web-view-test.vala
test/engine/util-html-test.vala

Fix #271
parent 3ed6a82e
......@@ -80,7 +80,7 @@ public abstract class Application.Command : GLib.Object {
*/
public abstract async void undo(GLib.Cancellable? cancellable)
throws GLib.Error;
/**
* Called by {@link CommandStack} to redo the executed command.
*
......
......@@ -152,13 +152,13 @@ public class GearyApplication : Gtk.Application {
public override bool local_command_line(ref unowned string[] args, out int exit_status) {
bin = args[0];
exec_dir = (File.new_for_path(Posix.realpath(Environment.find_program_in_path(bin)))).get_parent();
try {
register();
} catch (Error e) {
error("Error registering GearyApplication: %s", e.message);
}
if (!Args.parse(args)) {
exit_status = 1;
return true;
......@@ -186,10 +186,10 @@ public class GearyApplication : Gtk.Application {
exit_status = 0;
return true;
}
public override void startup() {
Configuration.init(is_installed(), GSETTINGS_DIR);
Environment.set_application_name(NAME);
Environment.set_prgname(PRGNAME);
International.init(GETTEXT_PACKAGE, bin);
......@@ -208,10 +208,10 @@ public class GearyApplication : Gtk.Application {
add_action_entries(action_entries, this);
}
public override void activate() {
base.activate();
if (!present())
create_async.begin();
}
......@@ -238,7 +238,7 @@ public class GearyApplication : Gtk.Application {
// Without this, the main loop will exit as soon as we hit the yield
// below, before we create the main window.
hold();
// do *after* parsing args, as they dicate where logging is sent to, if anywhere, and only
// after activate (which means this is only logged for the one user-visible instance, not
// the other instances called when sending commands to the app via the command-line)
......@@ -265,15 +265,15 @@ public class GearyApplication : Gtk.Application {
release();
}
private async void destroy_async() {
// see create_async() for reasoning hold/release is used
hold();
yield controller.close_async();
release();
is_destroyed = true;
}
......@@ -309,7 +309,7 @@ public class GearyApplication : Gtk.Application {
public File get_user_config_directory() {
return File.new_for_path(Environment.get_user_config_dir()).get_child("geary");
}
/**
* Returns the base directory that the application's various resource files are stored. If the
* application is running from its installed directory, this will point to
......@@ -346,25 +346,25 @@ public class GearyApplication : Gtk.Application {
File desktop_file = (install_dir != null)
? install_dir.get_child("share").get_child("applications").get_child("org.gnome.Geary.desktop")
: File.new_for_path(SOURCE_ROOT_DIR).get_child("build").get_child("desktop").get_child("org.gnome.Geary.desktop");
return desktop_file.query_exists() ? desktop_file : null;
}
public bool is_installed() {
return exec_dir.has_prefix(get_install_prefix_dir());
}
// Returns the configure installation prefix directory, which does not imply Geary is installed
// or that it's running from this directory.
public File get_install_prefix_dir() {
return File.new_for_path(INSTALL_PREFIX);
}
// Returns the installation directory, or null if we're running outside of the installation
// directory.
public File? get_install_dir() {
File prefix_dir = get_install_prefix_dir();
return exec_dir.has_prefix(prefix_dir) ? prefix_dir : null;
}
......@@ -384,17 +384,17 @@ public class GearyApplication : Gtk.Application {
public void exit(int exitcode = 0) {
if (exiting_fired)
return;
this.exitcode = exitcode;
exiting_fired = true;
if (!exiting(false)) {
exiting_fired = false;
this.exitcode = 0;
return;
}
// Give asynchronous destroy_async() a chance to complete, but to avoid bug(s) where
// Geary hangs at exit, shut the whole thing down if destroy_async() takes too long to
// complete
......@@ -402,7 +402,7 @@ public class GearyApplication : Gtk.Application {
destroy_async.begin();
while (!is_destroyed || Gtk.events_pending()) {
Gtk.main_iteration();
int64 delta_usec = get_monotonic_time() - start_usec;
if (delta_usec >= FORCE_SHUTDOWN_USEC) {
debug("Forcing shutdown of Geary, %ss passed...", (delta_usec / USEC_PER_SEC).to_string());
......@@ -422,7 +422,7 @@ public class GearyApplication : Gtk.Application {
Signal.stop_emission_by_name(this, "exiting");
return false;
}
// This call will fire "exiting" only if it's not already been fired and halt the application
// in its tracks.
public void panic() {
......@@ -430,7 +430,7 @@ public class GearyApplication : Gtk.Application {
exiting_fired = true;
exiting(true);
}
Posix.exit(1);
}
......
......@@ -55,7 +55,7 @@ public bool parse(string[] args) {
GearyApplication.COPYRIGHT_2,
_("Please report comments, suggestions and bugs to:"),
GearyApplication.BUGREPORT));
try {
context.parse(ref args);
} catch (OptionError error) {
......@@ -64,46 +64,46 @@ public bool parse(string[] args) {
stdout.printf("\n%s", context.get_help(true, null));
return false;
}
// other than the OptionEntry command-line arguments, the only acceptable arguments are
// mailto:'s
for (int ctr = 1; ctr < args.length; ctr++) {
string arg = args[ctr];
if (!arg.has_prefix(Geary.ComposedEmail.MAILTO_SCHEME)) {
stdout.printf(_("Unrecognized command line option “%s”\n").printf(arg));
stdout.printf("\n%s", context.get_help(true, null));
return false;
}
}
if (version) {
stdout.printf("%s %s\n", GearyApplication.PRGNAME, GearyApplication.VERSION);
Process.exit(0);
}
if (log_network)
Geary.Logging.enable_flags(Geary.Logging.Flag.NETWORK);
if (log_serializer)
Geary.Logging.enable_flags(Geary.Logging.Flag.SERIALIZER);
if (log_replay_queue)
Geary.Logging.enable_flags(Geary.Logging.Flag.REPLAY);
if (log_conversations)
Geary.Logging.enable_flags(Geary.Logging.Flag.CONVERSATIONS);
if (log_periodic)
Geary.Logging.enable_flags(Geary.Logging.Flag.PERIODIC);
if (log_sql)
Geary.Logging.enable_flags(Geary.Logging.Flag.SQL);
if (log_folder_normalization)
Geary.Logging.enable_flags(Geary.Logging.Flag.FOLDER_NORMALIZATION);
if (log_deserializer)
Geary.Logging.enable_flags(Geary.Logging.Flag.DESERIALIZER);
......
......@@ -67,41 +67,41 @@ public class Configuration {
public int window_width {
get { return settings.get_int(WINDOW_WIDTH_KEY); }
}
public int window_height {
get { return settings.get_int(WINDOW_HEIGHT_KEY); }
}
public bool window_maximize {
get { return settings.get_boolean(WINDOW_MAXIMIZE_KEY); }
}
public int folder_list_pane_position_old {
get { return settings.get_int(FOLDER_LIST_PANE_POSITION_KEY); }
}
public int folder_list_pane_position_horizontal {
get { return settings.get_int(FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY); }
set { settings.set_int(FOLDER_LIST_PANE_POSITION_HORIZONTAL_KEY, value); }
}
public int folder_list_pane_position_vertical {
get { return settings.get_int(FOLDER_LIST_PANE_POSITION_VERTICAL_KEY); }
}
public bool folder_list_pane_horizontal {
get { return settings.get_boolean(FOLDER_LIST_PANE_HORIZONTAL_KEY); }
}
public int messages_pane_position {
get { return settings.get_int(MESSAGES_PANE_POSITION_KEY); }
set { settings.set_int(MESSAGES_PANE_POSITION_KEY, value); }
}
public bool autoselect {
get { return settings.get_boolean(AUTOSELECT_KEY); }
}
public bool display_preview {
get { return settings.get_boolean(DISPLAY_PREVIEW_KEY); }
}
......@@ -136,7 +136,7 @@ public class Configuration {
get { return settings.get_boolean(STARTUP_NOTIFICATIONS_KEY); }
set { set_boolean(STARTUP_NOTIFICATIONS_KEY, value); }
}
private const string CLOCK_FORMAT_KEY = "clock-format";
public Date.ClockFormat clock_format {
get {
......@@ -146,12 +146,12 @@ public class Configuration {
return Date.ClockFormat.TWENTY_FOUR_HOURS;
}
}
public bool ask_open_attachment {
get { return settings.get_boolean(ASK_OPEN_ATTACHMENT_KEY); }
set { set_boolean(ASK_OPEN_ATTACHMENT_KEY, value); }
}
public bool compose_as_html {
get { return settings.get_boolean(COMPOSE_AS_HTML_KEY); }
set { set_boolean(COMPOSE_AS_HTML_KEY, value); }
......@@ -195,43 +195,43 @@ public class Configuration {
SettingsBindFlags flags = GLib.SettingsBindFlags.DEFAULT) {
settings.bind(key, object, property, flags);
}
private void set_boolean(string name, bool value) {
if (!settings.set_boolean(name, value))
message("Unable to set configuration value %s = %s", name, value.to_string());
}
public Geary.SearchQuery.Strategy get_search_strategy() {
switch (settings.get_string(SEARCH_STRATEGY_KEY).down()) {
case "exact":
return Geary.SearchQuery.Strategy.EXACT;
case "aggressive":
return Geary.SearchQuery.Strategy.AGGRESSIVE;
case "horizon":
return Geary.SearchQuery.Strategy.HORIZON;
case "conservative":
default:
return Geary.SearchQuery.Strategy.CONSERVATIVE;
}
}
public void set_search_strategy(Geary.SearchQuery.Strategy strategy) {
switch (strategy) {
case Geary.SearchQuery.Strategy.EXACT:
settings.set_string(SEARCH_STRATEGY_KEY, "exact");
break;
case Geary.SearchQuery.Strategy.AGGRESSIVE:
settings.set_string(SEARCH_STRATEGY_KEY, "aggressive");
break;
case Geary.SearchQuery.Strategy.HORIZON:
settings.set_string(SEARCH_STRATEGY_KEY, "horizon");
break;
case Geary.SearchQuery.Strategy.CONSERVATIVE:
default:
settings.set_string(SEARCH_STRATEGY_KEY, "conservative");
......
......@@ -192,17 +192,17 @@ public class GearyController : Geary.BaseObject {
* Fired when the currently selected account has changed.
*/
public signal void account_selected(Geary.Account? account);
/**
* Fired when the currently selected folder has changed.
*/
public signal void folder_selected(Geary.Folder? folder);
/**
* Fired when the number of conversations changes.
*/
public signal void conversation_count_changed(int count);
/**
* Fired when the search text is changed according to the controller. This accounts
* for a brief typmatic delay.
......@@ -866,11 +866,11 @@ public class GearyController : Geary.BaseObject {
libnotify.clear_error_notification();
}
}
private void on_sending_started() {
main_window.status_bar.activate_message(StatusBar.Message.OUTBOX_SENDING);
}
private void on_sending_finished() {
main_window.status_bar.deactivate_message(StatusBar.Message.OUTBOX_SENDING);
}
......@@ -924,7 +924,7 @@ public class GearyController : Geary.BaseObject {
// Returns true if the caller should try opening the account again
private async bool account_database_error_async(Geary.Account account) {
bool retry = true;
// give the user two options: reset the Account local store, or exit Geary. A third
// could be done to leave the Account in an unopened state, but we don't currently
// have provisions for that.
......@@ -944,11 +944,11 @@ public class GearyController : Geary.BaseObject {
_("Unable to rebuild database for “%s”").printf(account.information.id),
_("Error during rebuild:\n\n%s").printf(err.message));
errdialog.run();
retry = false;
}
break;
default:
retry = false;
break;
......@@ -1010,10 +1010,10 @@ public class GearyController : Geary.BaseObject {
} catch(Error e) {
error("Could not open accounts: %s", e.message);
}
return true;
}
/**
* Displays the main window if we're ready. Otherwise does nothing.
*/
......@@ -1024,7 +1024,7 @@ public class GearyController : Geary.BaseObject {
!Args.hidden_startup)
main_window.show();
}
/**
* Returns the number of accounts that exist in Geary. Note that not all accounts may be
* open. Zero is returned on an error.
......@@ -1035,7 +1035,7 @@ public class GearyController : Geary.BaseObject {
} catch (Error e) {
debug("Error getting number of accounts: %s", e.message);
}
return 0; // on error
}
......@@ -1110,9 +1110,9 @@ public class GearyController : Geary.BaseObject {
private async void do_select_folder(Geary.Folder folder) throws Error {
debug("Switching to %s...", folder.to_string());
closed_folder();
// This function is not reentrant. It should be, because it can be
// called reentrant-ly if you select folders quickly enough. This
// mutex lock is a bandaid solution to make the function safe to
......@@ -1121,13 +1121,13 @@ public class GearyController : Geary.BaseObject {
// clear Revokable, as Undo is only available while a folder is selected
save_revokable(null, null);
// stop monitoring for conversations and close the folder
if (current_conversations != null) {
yield current_conversations.stop_monitoring_async(null);
current_conversations = null;
}
// re-enable copy/move to the last selected folder
if (current_folder != null) {
main_window.main_toolbar.copy_folder_menu.enable_disable_folder(current_folder, true);
......@@ -1144,7 +1144,7 @@ public class GearyController : Geary.BaseObject {
if (pending_mailtos.size > 0) {
foreach(string mailto in pending_mailtos)
compose_mailto(mailto);
pending_mailtos.clear();
}
......@@ -1155,16 +1155,16 @@ public class GearyController : Geary.BaseObject {
main_window.main_toolbar.move_folder_menu.add_folder(f);
}
}
folder_selected(current_folder);
if (!(current_folder is Geary.SearchFolder))
previous_non_search_folder = current_folder;
// disable copy/move to the new folder
main_window.main_toolbar.copy_folder_menu.enable_disable_folder(current_folder, false);
main_window.main_toolbar.move_folder_menu.enable_disable_folder(current_folder, false);
update_ui();
current_conversations = new Geary.App.ConversationMonitor(
......@@ -1193,7 +1193,7 @@ public class GearyController : Geary.BaseObject {
);
select_folder_mutex.release(ref mutex_token);
debug("Switched to %s", folder.to_string());
}
......@@ -1229,10 +1229,10 @@ public class GearyController : Geary.BaseObject {
private void on_libnotify_invoked(Geary.Folder? folder, Geary.Email? email) {
new_messages_monitor.clear_all_new_messages();
if (folder == null || email == null || !can_switch_conversation_view())
return;
main_window.folder_list.select_folder(folder);
Geary.App.Conversation? conversation = current_conversations.get_by_email_identifier(email.id);
if (conversation != null)
......@@ -1252,12 +1252,12 @@ public class GearyController : Geary.BaseObject {
on_indicator_activated_application(timestamp);
main_window.folder_list.select_folder(folder);
}
private void on_load_more() {
debug("on_load_more");
current_conversations.min_window_count += MIN_CONVERSATION_COUNT;
}
private void on_select_folder_completed(Object? source, AsyncResult result) {
try {
do_select_folder.end(result);
......@@ -1474,10 +1474,10 @@ public class GearyController : Geary.BaseObject {
private void cancel_folder() {
Cancellable old_cancellable = cancellable_folder;
cancellable_folder = new Cancellable();
old_cancellable.cancel();
}
// Like cancel_folder() but doesn't cancel outstanding operations, allowing them to complete
// in the background
private void closed_folder() {
......@@ -1494,16 +1494,16 @@ public class GearyController : Geary.BaseObject {
private void cancel_context_dependent_buttons() {
Cancellable old_cancellable = cancellable_context_dependent_buttons;
cancellable_context_dependent_buttons = new Cancellable();
old_cancellable.cancel();
}
// We need to include the second parameter, or valac doesn't recognize the function as matching
// GearyApplication.exiting's signature.
private bool on_application_exiting(GearyApplication sender, bool panicked) {
if (close_composition_windows())
return true;
return sender.cancel_exit();
}
......@@ -1602,7 +1602,7 @@ public class GearyController : Geary.BaseObject {
foreach (Geary.App.Conversation conversation in selected_conversations) {
if (conversation.is_unread())
unread_selected = true;
// Only check the messages that "Mark as Unread" would mark, so we
// don't add the menu option and have it not do anything.
//
......@@ -1635,7 +1635,7 @@ public class GearyController : Geary.BaseObject {
private void on_visible_conversations_changed(Gee.Set<Geary.App.Conversation> visible) {
clear_new_messages("on_visible_conversations_changed", visible);
}
private bool should_notify_new_messages(Geary.Folder folder) {
// A monitored folder must be selected to squelch notifications;
// if conversation list is at top of display, don't display
......@@ -1644,22 +1644,22 @@ public class GearyController : Geary.BaseObject {
|| main_window.conversation_list_view.vadjustment.value != 0.0
|| !main_window.has_toplevel_focus;
}
// Clears messages if conditions are true: anything in should_notify_new_messages() is
// false and the supplied visible messages are visible in the conversation list view
private void clear_new_messages(string caller, Gee.Set<Geary.App.Conversation>? supplied) {
if (current_folder == null || !new_messages_monitor.get_folders().contains(current_folder)
|| should_notify_new_messages(current_folder))
return;
Gee.Set<Geary.App.Conversation> visible =
supplied ?? main_window.conversation_list_view.get_visible_conversations();
foreach (Geary.App.Conversation conversation in visible) {
if (new_messages_monitor.are_any_new_messages(current_folder, conversation.get_email_ids())) {
debug("Clearing new messages: %s", caller);
new_messages_monitor.clear_new_messages(current_folder);
break;
}
}
......@@ -1769,12 +1769,12 @@ public class GearyController : Geary.BaseObject {
private void on_copy_conversation(Geary.Folder destination) {
copy_email(get_selected_email_ids(false), destination.path);
}
private void on_move_conversation(Geary.Folder destination) {
// Nothing to do if nothing selected.