[geary/gnumdk/mark_as_read_if_expanded] client: Do not reverse variable logical
- From: Cédric Bellegarde <cbellegarde src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/gnumdk/mark_as_read_if_expanded] client: Do not reverse variable logical
- Date: Wed, 21 Sep 2022 13:36:05 +0000 (UTC)
commit ae59306612bcac2efa493baf31efac483335db9a
Author: Cédric Bellegarde <cedric bellegarde adishatz org>
Date: Wed Sep 21 11:53:49 2022 +0200
client: Do not reverse variable logical
This does not make sense to use start_mark_timer in MainWindow and
ConversationViewer and suppress_mark_timer later.
desktop/org.gnome.Geary.gschema.xml | 6 +++
.../application/application-configuration.vala | 6 +++
.../components/components-preferences-window.vala | 16 +++++++
.../conversation-viewer/conversation-list-box.vala | 49 +++++++++++-----------
.../conversation-viewer/conversation-viewer.vala | 4 +-
5 files changed, 55 insertions(+), 26 deletions(-)
---
diff --git a/desktop/org.gnome.Geary.gschema.xml b/desktop/org.gnome.Geary.gschema.xml
index 6d4711ccb..e7a7e8d06 100644
--- a/desktop/org.gnome.Geary.gschema.xml
+++ b/desktop/org.gnome.Geary.gschema.xml
@@ -103,6 +103,12 @@
<description>Images from these domains will be trusted</description>
</key>
+ <key name="smart-mark-as-read" type="b">
+ <default>true</default>
+ <summary>Smartly mark messages as read</summary>
+ <description>Only mark messages as read if fully read</description>
+ </key>
+
<key name="undo-send-delay" type="i">
<default>5</default>
<summary>Undo sending email delay</summary>
diff --git a/src/client/application/application-configuration.vala
b/src/client/application/application-configuration.vala
index 79b534962..a98fd9819 100644
--- a/src/client/application/application-configuration.vala
+++ b/src/client/application/application-configuration.vala
@@ -26,6 +26,7 @@ public class Application.Configuration : Geary.BaseObject {
public const string SPELL_CHECK_LANGUAGES = "spell-check-languages";
public const string SPELL_CHECK_VISIBLE_LANGUAGES = "spell-check-visible-languages";
public const string RUN_IN_BACKGROUND_KEY = "run-in-background";
+ public const string SMART_MARK_AS_READ = "smart-mark-as-read";
public const string UNDO_SEND_DELAY = "undo-send-delay";
public const string WINDOW_HEIGHT_KEY = "window-height";
public const string WINDOW_MAXIMIZE_KEY = "window-maximize";
@@ -106,6 +107,11 @@ public class Application.Configuration : Geary.BaseObject {
set { set_boolean(RUN_IN_BACKGROUND_KEY, value); }
}
+ public bool smart_mark_as_read {
+ get { return settings.get_boolean(SMART_MARK_AS_READ); }
+ set { set_boolean(SMART_MARK_AS_READ, value); }
+ }
+
private const string CLOCK_FORMAT_KEY = "clock-format";
public Util.Date.ClockFormat clock_format {
get {
diff --git a/src/client/components/components-preferences-window.vala
b/src/client/components/components-preferences-window.vala
index b2f7be9bb..413559bb8 100644
--- a/src/client/components/components-preferences-window.vala
+++ b/src/client/components/components-preferences-window.vala
@@ -173,6 +173,16 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
trust_images_row.activatable_widget = autoselect;
trust_images_row.add(trust_images);
+ var smart_mark_as_read = new Gtk.Switch();
+ smart_mark_as_read.valign = CENTER;
+
+ var smart_mark_as_read_row = new Hdy.ActionRow();
+ /// Translators: Preferences label
+ smart_mark_as_read_row.title = _("_Only mark messages as read if fully read");
+ smart_mark_as_read_row.use_underline = true;
+ smart_mark_as_read_row.activatable_widget = autoselect;
+ smart_mark_as_read_row.add(smart_mark_as_read);
+
var group = new Hdy.PreferencesGroup();
/// Translators: Preferences group title
//group.title = _("General");
@@ -183,6 +193,7 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
group.add(single_key_shortucts_row);
group.add(startup_notifications_row);
group.add(trust_images_row);
+ group.add(smart_mark_as_read_row);
var page = new Hdy.PreferencesPage();
/// Translators: Preferences page title
@@ -227,6 +238,11 @@ public class Components.PreferencesWindow : Hdy.PreferencesWindow {
(GLib.SettingsBindGetMappingShared) settings_trust_images_getter,
(GLib.SettingsBindSetMappingShared) settings_trust_images_setter
);
+ config.bind(
+ Application.Configuration.SMART_MARK_AS_READ,
+ smart_mark_as_read,
+ "state"
+ );
}
}
diff --git a/src/client/conversation-viewer/conversation-list-box.vala
b/src/client/conversation-viewer/conversation-list-box.vala
index 6688e2718..7ea89a27b 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -572,7 +572,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
// The id of the draft referred to by the current composer.
private Geary.EmailIdentifier? draft_id = null;
- private bool suppress_mark_timer;
+ private bool start_mark_timer;
private Geary.TimeoutManager mark_read_timer;
private GLib.SimpleActionGroup email_actions = new GLib.SimpleActionGroup();
@@ -684,7 +684,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
* Constructs a new conversation list box instance.
*/
public ConversationListBox(Geary.App.Conversation conversation,
- bool suppress_mark_timer,
+ bool start_mark_timer,
Geary.App.EmailStore email_store,
Application.ContactStore contacts,
Application.Configuration config,
@@ -697,7 +697,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
this.search = new SearchManager(this, conversation);
- this.suppress_mark_timer = suppress_mark_timer;
+ this.start_mark_timer = start_mark_timer;
this.mark_read_timer = new Geary.TimeoutManager.milliseconds(
MARK_READ_TIMEOUT_MSEC, this.check_mark_read
);
@@ -1238,15 +1238,31 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
}
+ private bool has_been_read(ConversationEmail view) {
+ Gtk.Adjustment adj = get_adjustment();
+ int top_bound = (int) adj.value;
+ int bottom_bound = top_bound + (int) adj.page_size;
+ ConversationMessage conversation_message = view.primary_message;
+ int body_top = 0;
+ int body_left = 0;
+ conversation_message.web_view_translate_coordinates(
+ this,
+ 0, 0,
+ out body_left, out body_top
+ );
+ int body_height = conversation_message.web_view_get_allocated_height();
+ int body_bottom = body_top + body_height;
+ return body_height > 0 &&
+ body_bottom > top_bound &&
+ body_top + MARK_READ_PADDING < bottom_bound;
+ }
+
/**
* Finds any currently visible messages, marks them as being read.
*/
private void check_mark_read() {
Gee.List<Geary.EmailIdentifier> email_ids =
new Gee.LinkedList<Geary.EmailIdentifier>();
- Gtk.Adjustment adj = get_adjustment();
- int top_bound = (int) adj.value;
- int bottom_bound = top_bound + (int) adj.page_size;
this.foreach((child) => {
// Don't bother with not-yet-loaded emails since the
@@ -1260,22 +1276,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
view.message_body_state == COMPLETED &&
!view.is_manually_read &&
email.is_unread().is_certain()) {
- ConversationMessage conversation_message = view.primary_message;
- int body_top = 0;
- int body_left = 0;
- conversation_message.web_view_translate_coordinates(
- this,
- 0, 0,
- out body_left, out body_top
- );
-
- int body_height = conversation_message.web_view_get_allocated_height();
- int body_bottom = body_top + body_height;
-
- // Only mark the email as read if it's actually visible
- if (body_height > 0 &&
- body_bottom > top_bound &&
- body_top + MARK_READ_PADDING < bottom_bound) {
+ if (!this.config.smart_mark_as_read || has_been_read(view)) {
email_ids.add(view.email.id);
// Since it can take some time for the new flags
@@ -1386,10 +1387,10 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
GLib.ParamSpec param) {
ConversationEmail? view = obj as ConversationEmail;
if (view != null && view.message_body_state == COMPLETED) {
- if (!this.suppress_mark_timer) {
+ if (this.start_mark_timer) {
this.mark_read_timer.start();
}
- this.suppress_mark_timer = false;
+ this.start_mark_timer = true;
}
}
diff --git a/src/client/conversation-viewer/conversation-viewer.vala
b/src/client/conversation-viewer/conversation-viewer.vala
index e3a9825e8..cbc201702 100644
--- a/src/client/conversation-viewer/conversation-viewer.vala
+++ b/src/client/conversation-viewer/conversation-viewer.vala
@@ -260,7 +260,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
ConversationListBox new_list = new ConversationListBox(
conversation,
- !start_mark_timer,
+ start_mark_timer,
store,
contacts,
this.config,
@@ -491,7 +491,7 @@ public class ConversationViewer : Gtk.Stack, Geary.BaseInterface {
}
private bool on_conversation_scroll() {
- if (this.current_list != null) {
+ if (this.config.smart_mark_as_read && this.current_list != null) {
this.current_list.mark_visible_read();
}
return Gdk.EVENT_PROPAGATE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]