[geary/wip/765516-gtk-widget-conversation-viewer: 51/103] Reenable and update code for inline message quote toggling.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/765516-gtk-widget-conversation-viewer: 51/103] Reenable and update code for inline message quote toggling.
- Date: Mon, 4 Jul 2016 12:34:21 +0000 (UTC)
commit 274b1d958e567a7a0c491d15c2156980e2d39067
Author: Michael James Gratton <mike vee net>
Date: Tue Apr 12 21:54:51 2016 +1000
Reenable and update code for inline message quote toggling.
* src/client/conversation-viewer/conversation-message.vala: Reenable,
update and hook up calls to unset_controllable_quotes,
on_show_quote_clicked and on_hide_quote_clicked. Remove the show/hide
dichotomy, just use hide when the quote should be hidden.
* theming/message-viewer.css: Updated to chase style changes.
.../conversation-viewer/conversation-message.vala | 101 ++++++++++++--------
theming/message-viewer.css | 38 ++++----
2 files changed, 79 insertions(+), 60 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala
b/src/client/conversation-viewer/conversation-message.vala
index ab03435..84066a1 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -418,8 +418,24 @@ public class ConversationMessage : Gtk.Box {
web_view.notify["load-status"].connect((source, param) => {
if (web_view.load_status == WebKit.LoadStatus.FINISHED) {
+ WebKit.DOM.HTMLElement html = (
+ web_view.get_dom_document().document_element as
+ WebKit.DOM.HTMLElement
+ );
+ if (html != null) {
+ try {
+ unset_controllable_quotes(html);
+ } catch (Error error) {
+ warning("Error unsetting controllable_quotes: %s",
+ error.message);
+ }
+ }
bind_event(web_view, "body a", "click",
(Callback) on_link_clicked, this);
+ bind_event(web_view, ".quote_container > .shower", "click",
+ (Callback) on_show_quote_clicked, this);
+ bind_event(web_view, ".quote_container > .hider", "click",
+ (Callback) on_hide_quote_clicked, this);
}
});
web_view.load_string(body_text, "text/html", "UTF8", "");
@@ -608,24 +624,6 @@ public class ConversationMessage : Gtk.Box {
// return menu;
// }
- // private static void on_hide_quote_clicked(WebKit.DOM.Element element) {
- // try {
- // WebKit.DOM.Element parent = element.get_parent_element();
- // parent.set_attribute("class", "quote_container controllable hide");
- // } catch (Error error) {
- // warning("Error hiding quote: %s", error.message);
- // }
- // }
-
- // private static void on_show_quote_clicked(WebKit.DOM.Element element) {
- // try {
- // WebKit.DOM.Element parent = element.get_parent_element();
- // parent.set_attribute("class", "quote_container controllable show");
- // } catch (Error error) {
- // warning("Error hiding quote: %s", error.message);
- // }
- // }
-
// private void on_unstar_clicked() {
// unflag_message();
// }
@@ -855,28 +853,6 @@ public class ConversationMessage : Gtk.Box {
// return menu;
// }
- private WebKit.DOM.HTMLDivElement create_quote_container() throws Error {
- WebKit.DOM.HTMLDivElement quote_container = web_view.create_div();
- quote_container.set_attribute("class", "quote_container controllable hide");
- quote_container.set_inner_html(
- """<div class="shower"><input type="button" value="▼ ▼ ▼" /></div>""" +
- """<div class="hider"><input type="button" value="▲ ▲ ▲" /></div>""" +
- """<div class="quote"></div>""");
- return quote_container;
- }
-
- // private void unset_controllable_quotes(WebKit.DOM.HTMLElement element) throws GLib.Error {
- // WebKit.DOM.NodeList quote_list = element.query_selector_all(".quote_container.controllable");
- // for (int i = 0; i < quote_list.length; ++i) {
- // WebKit.DOM.Element quote_container = quote_list.item(i) as WebKit.DOM.Element;
- // long scroll_height = quote_container.query_selector(".quote").scroll_height;
- // // If the message is hidden, scroll_height will be 0.
- // if (scroll_height > 0 && scroll_height < QUOTE_SIZE_THRESHOLD) {
- // quote_container.set_attribute("class", "quote_container");
- // }
- // }
- // }
-
private string clean_html_markup(string text, Geary.RFC822.Message message, out bool remote_images) {
remote_images = false;
try {
@@ -999,6 +975,18 @@ public class ConversationMessage : Gtk.Box {
}
}
+ private WebKit.DOM.HTMLDivElement create_quote_container() throws Error {
+ WebKit.DOM.HTMLDivElement quote_container = web_view.create_div();
+ quote_container.set_attribute(
+ "class", "quote_container controllable hide"
+ );
+ quote_container.set_inner_html("""
+<div class="shower"><input type="button" value="▼ ▼ ▼" /></div>
+<div class="hider"><input type="button" value="▲ ▲ ▲" /></div>
+<div class="quote"></div>""");
+ return quote_container;
+ }
+
private void wrap_html_signature(ref WebKit.DOM.HTMLElement container) throws Error {
// Most HTML signatures fall into one of these designs which are handled by this method:
//
@@ -1038,6 +1026,19 @@ public class ConversationMessage : Gtk.Box {
parent.append_child(signature_container);
}
+ private void unset_controllable_quotes(WebKit.DOM.HTMLElement element) throws GLib.Error {
+ WebKit.DOM.NodeList quote_list = element.query_selector_all(".quote_container.controllable");
+ for (int i = 0; i < quote_list.length; ++i) {
+ WebKit.DOM.Element quote_container = quote_list.item(i) as WebKit.DOM.Element;
+ long scroll_height = quote_container.query_selector(".quote").scroll_height;
+ // If the message is hidden, scroll_height will be 0.
+ if (scroll_height > 0 && scroll_height < QUOTE_SIZE_THRESHOLD) {
+ quote_container.class_list.remove("controllable");
+ quote_container.class_list.remove("hide");
+ }
+ }
+ }
+
// private bool should_show_attachment(Geary.Attachment attachment) {
// // if displayed inline, don't include in attachment list
// if (attachment.content_id in inlined_content_ids)
@@ -1218,6 +1219,26 @@ public class ConversationMessage : Gtk.Box {
}
}
+ private static void on_show_quote_clicked(WebKit.DOM.Element element,
+ WebKit.DOM.Event event) {
+ try {
+ ((WebKit.DOM.HTMLElement) element.parent_node).class_list.remove("hide");
+ } catch (Error error) {
+ warning("Error showing quote: %s", error.message);
+ }
+ }
+
+ private static void on_hide_quote_clicked(WebKit.DOM.Element element,
+ WebKit.DOM.Event event,
+ ConversationMessage message) {
+ try {
+ ((WebKit.DOM.HTMLElement) element.parent_node).class_list.add("hide");
+ message.web_view.queue_resize();
+ } catch (Error error) {
+ warning("Error toggling quote: %s", error.message);
+ }
+ }
+
private static void on_link_clicked(WebKit.DOM.Element element,
WebKit.DOM.Event event,
ConversationMessage message) {
diff --git a/theming/message-viewer.css b/theming/message-viewer.css
index c0aebb0..cfabae6 100644
--- a/theming/message-viewer.css
+++ b/theming/message-viewer.css
@@ -100,10 +100,6 @@ blockquote {
-webkit-user-select: auto;
-webkit-user-drag: auto;
}
- .shower, .hider {
- -webkit-user-select: none;
- -webkit-user-drag: none;
- }
.replaced_inline_image {
display: block;
@@ -136,6 +132,8 @@ blockquote {
margin-right: -0.67em;
}
+ /* Inline collapsable quote blocks */
+
.quote_container {
position: relative;
margin: 5px 0;
@@ -144,27 +142,25 @@ blockquote {
background-color: #e8e8e8;/* recv-quoted */
border-radius: 4px;
}
+ .sent .quote_container {
+ background-color: #e8e8e8;/* sent-quoted */
+ }
.quote_container .quote {
overflow: hidden;
position: relative;
z-index: 0;
}
- .quote_container.controllable .quote {
+ .quote_container.controllable.hide .quote {
max-height: 6em;
}
- .quote_container.controllable.show .quote {
- max-height: none;
- }
-
- .sent .quote_container {
- background-color: #e8e8e8;/* sent-quoted */
- }
.quote_container > .shower,
.quote_container > .hider {
+ -webkit-user-select: none;
+ -webkit-user-drag: none;
position: absolute;
z-index: 1;
- bottom: -7px;
+ bottom: -8px;
left: 0;
right: 0;
display: none;
@@ -185,21 +181,23 @@ blockquote {
.quote_container.controllable {
margin-bottom: 7px;
- padding-bottom: 0;
- }
- .quote_container.controllable.show {
padding-bottom: 12px;
}
- .quote_container.controllable > .shower {
- display: block;
+ .quote_container.controllable.hide {
+ padding-bottom: 0;
}
- .quote_container.controllable.show > .shower {
+
+ .quote_container.controllable > .shower,
+ .quote_container.controllable.hide > .hider {
display: none;
}
- .quote_container.controllable.show > .hider {
+ .quote_container.controllable.hide > .shower,
+ .quote_container.controllable > .hider {
display: block;
}
+ /* Highlight search terms */
+
.search_coloring *::selection {
background-color: #00ddff;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]