[geary/mjog/search-refinement: 6/14] Remove Geary.Account::search_upgrade_monitor
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/mjog/search-refinement: 6/14] Remove Geary.Account::search_upgrade_monitor
- Date: Mon, 16 Dec 2019 23:11:24 +0000 (UTC)
commit 130fd95b8633cc98173f0203ca29f9ecd1ec9bd7
Author: Michael Gratton <mike vee net>
Date: Thu Dec 12 11:19:51 2019 +1100
Remove Geary.Account::search_upgrade_monitor
Implement the upgrade call as an account operation so the background
monitor takes care of reporting its progress.
src/client/components/search-bar.vala | 49 ++--------------------
src/engine/api/geary-account.vala | 1 -
src/engine/imap-db/imap-db-account.vala | 23 +++-------
.../imap-engine/imap-engine-generic-account.vala | 40 +++++++++++-------
4 files changed, 35 insertions(+), 78 deletions(-)
---
diff --git a/src/client/components/search-bar.vala b/src/client/components/search-bar.vala
index 2966b652..53e49833 100644
--- a/src/client/components/search-bar.vala
+++ b/src/client/components/search-bar.vala
@@ -12,8 +12,6 @@ public class SearchBar : Gtk.SearchBar {
private Gtk.SearchEntry search_entry = new Gtk.SearchEntry();
private Components.EntryUndo search_undo;
- private Geary.ProgressMonitor? search_upgrade_progress_monitor = null;
- private MonitoredProgressBar search_upgrade_progress_bar = new MonitoredProgressBar();
private Geary.Account? current_account = null;
public signal void search_text_changed(string search_text);
@@ -34,12 +32,6 @@ public class SearchBar : Gtk.SearchBar {
this.notify["search-mode-enabled"].connect(on_search_mode_changed);
- // Search upgrade progress bar.
- search_upgrade_progress_bar.show_text = true;
- search_upgrade_progress_bar.visible = false;
- search_upgrade_progress_bar.no_show_all = true;
-
- add(search_upgrade_progress_bar);
add(search_entry);
set_search_placeholder_text(DEFAULT_SEARCH_TEXT);
@@ -59,33 +51,16 @@ public class SearchBar : Gtk.SearchBar {
}
public void set_account(Geary.Account? account) {
- on_search_upgrade_finished(); // Reset search box.
-
- if (search_upgrade_progress_monitor != null) {
- search_upgrade_progress_monitor.start.disconnect(on_search_upgrade_start);
- search_upgrade_progress_monitor.finish.disconnect(on_search_upgrade_finished);
- search_upgrade_progress_monitor = null;
- }
-
if (current_account != null) {
current_account.information.changed.disconnect(
- on_information_changed);
+ on_information_changed
+ );
}
if (account != null) {
- search_upgrade_progress_monitor = account.search_upgrade_monitor;
- search_upgrade_progress_bar.set_progress_monitor(search_upgrade_progress_monitor);
-
- search_upgrade_progress_monitor.start.connect(on_search_upgrade_start);
- search_upgrade_progress_monitor.finish.connect(on_search_upgrade_finished);
- if (search_upgrade_progress_monitor.is_in_progress)
- on_search_upgrade_start(); // Remove search box, we're already in progress.
-
account.information.changed.connect(
- on_information_changed);
-
- search_upgrade_progress_bar.text =
- _("Indexing %s account").printf(account.information.display_name);
+ on_information_changed
+ );
}
current_account = account;
@@ -93,22 +68,6 @@ public class SearchBar : Gtk.SearchBar {
on_information_changed(); // Set new account name.
}
- private void on_search_upgrade_start() {
- // Set the progress bar's width to match the search entry's width.
- int minimum_width = 0;
- int natural_width = 0;
- search_entry.get_preferred_width(out minimum_width, out natural_width);
- search_upgrade_progress_bar.width_request = minimum_width;
-
- search_entry.hide();
- search_upgrade_progress_bar.show();
- }
-
- private void on_search_upgrade_finished() {
- search_entry.show();
- search_upgrade_progress_bar.hide();
- }
-
private void on_information_changed() {
var main = get_toplevel() as Application.MainWindow;
if (main != null) {
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index 54b1d9db..c98a888a 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -132,7 +132,6 @@ public abstract class Geary.Account : BaseObject, Logging.Source {
public Geary.ContactStore contact_store { get; protected set; }
public ProgressMonitor background_progress { get; protected set; }
- public ProgressMonitor search_upgrade_monitor { get; protected set; }
public ProgressMonitor db_upgrade_monitor { get; protected set; }
public ProgressMonitor db_vacuum_monitor { get; protected set; }
diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala
index 6540494a..2439df06 100644
--- a/src/engine/imap-db/imap-db-account.vala
+++ b/src/engine/imap-db/imap-db-account.vala
@@ -37,13 +37,12 @@ private class Geary.ImapDB.Account : BaseObject {
get; private set; default = new Imap.FolderRoot("$geary-imap");
}
- // Only available when the Account is opened
- public IntervalProgressMonitor search_index_monitor { get; private set;
- default = new IntervalProgressMonitor(ProgressType.SEARCH_INDEX, 0, 0); }
- public SimpleProgressMonitor upgrade_monitor { get; private set; default = new SimpleProgressMonitor(
- ProgressType.DB_UPGRADE); }
- public SimpleProgressMonitor vacuum_monitor { get; private set; default = new SimpleProgressMonitor(
- ProgressType.DB_VACUUM); }
+ public SimpleProgressMonitor upgrade_monitor {
+ get; private set; default = new SimpleProgressMonitor(DB_UPGRADE);
+ }
+ public SimpleProgressMonitor vacuum_monitor {
+ get; private set; default = new SimpleProgressMonitor(DB_VACUUM);
+ }
/** The backing database for the account. */
public ImapDB.Database db { get; private set; }
@@ -918,9 +917,6 @@ private class Geary.ImapDB.Account : BaseObject {
debug("Error populating %s search table: %s", account_information.id, e.message);
}
- if (search_index_monitor.is_in_progress)
- search_index_monitor.notify_finish();
-
debug("%s: Done populating search table", account_information.id);
}
@@ -1014,13 +1010,6 @@ private class Geary.ImapDB.Account : BaseObject {
if (count > 0) {
debug("%s: Found %d/%d missing indexed messages, %d remaining...",
account_information.id, count, limit, total_unindexed);
-
- if (!search_index_monitor.is_in_progress) {
- search_index_monitor.set_interval(0, total_unindexed);
- search_index_monitor.notify_start();
- }
-
- search_index_monitor.increment(count);
}
return (count < limit);
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 86f0c877..9068da79 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -107,7 +107,6 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
);
this.background_progress = new ReentrantProgressMonitor(ACTIVITY);
- this.search_upgrade_monitor = local.search_index_monitor;
this.db_upgrade_monitor = local.upgrade_monitor;
this.db_vacuum_monitor = local.vacuum_monitor;
@@ -170,21 +169,12 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
yield this.imap.start(cancellable);
this.queue_operation(new StartPostie(this));
- // Kick off a background update of the search table, but since
- // the database is getting hammered at startup, wait a bit
- // before starting the update ... use the ordinal to stagger
- // these being fired off (important for users with many
- // accounts registered).
+ // Kick off a background update of the search table.
//
- // This is an example of an operation for which we need an
- // engine-wide operation queue, not just an account-wide
- // queue.
- const int POPULATE_DELAY_SEC = 5;
- int account_sec = this.information.ordinal.clamp(0, 10);
- Timeout.add_seconds(POPULATE_DELAY_SEC + account_sec, () => {
- this.local.populate_search_table.begin(cancellable);
- return false;
- });
+ // XXX since this hammers the database, this is an example of
+ // an operation for which we need an engine-wide operation
+ // queue, not just an account-wide queue.
+ this.queue_operation(new PopulateSearchTable(this));
}
public override async void close_async(Cancellable? cancellable = null) throws Error {
@@ -1138,6 +1128,26 @@ internal class Geary.ImapEngine.StartPostie : AccountOperation {
}
+/**
+ * Account operation for populating the full-text-search table.
+ */
+internal class Geary.ImapEngine.PopulateSearchTable : AccountOperation {
+
+
+ internal PopulateSearchTable(GenericAccount account) {
+ base(account);
+ }
+
+ public override async void execute(GLib.Cancellable cancellable)
+ throws GLib.Error {
+ yield ((GenericAccount) this.account).local.populate_search_table(
+ cancellable
+ );
+ }
+
+}
+
+
/**
* Account operation that updates folders from the remote.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]