Commit b2bd2313 authored by Michael Gratton's avatar Michael Gratton 🤞

Minor code clean up.

* src/client/conversation-viewer/conversation-message.vala
  (ConversationMessage): Make sure public members appear before private
  ones.

* src/client/conversation-viewer/conversation-web-view.vala (ConversationWebView):
  Make sure public members appear before private ones, remove unused code.
parent 103619c5
......@@ -44,6 +44,16 @@ public class ConversationMessage : Gtk.Box {
private const int MAX_INLINE_IMAGE_MAJOR_DIM = 1024;
private const int QUOTE_SIZE_THRESHOLD = 120;
// The email message being displayed
public Geary.Email email { get; private set; }
// The message being displayed
public Geary.RFC822.Message message { get; private set; }
// The HTML viewer to view the emails.
public ConversationWebView web_view { get; private set; }
[GtkChild]
private Gtk.Image avatar_image;
......@@ -83,18 +93,11 @@ public class ConversationMessage : Gtk.Box {
[GtkChild]
private Gtk.Box body_box;
// The email message being displayed
public Geary.Email email { get; private set; }
// The message being displayed
public Geary.RFC822.Message message { get; private set; }
// The folder containing the message
private Geary.Folder containing_folder = null; // XXX weak??
// The HTML viewer to view the emails.
private ConversationWebView web_view { get; private set; }
// Overlay consisting of a label in front of a webpage
private Gtk.Overlay message_overlay;
......
......@@ -59,35 +59,6 @@ public class ConversationWebView : StylishWebView {
return false;
}
private bool on_scroll_event(Gdk.EventScroll event) {
if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0) {
double dir = 0;
if (event.direction == Gdk.ScrollDirection.UP)
dir = -1;
else if (event.direction == Gdk.ScrollDirection.DOWN)
dir = 1;
else if (event.direction == Gdk.ScrollDirection.SMOOTH)
dir = event.delta_y;
if (dir < 0) {
zoom_in();
return true;
} else if (dir > 0) {
zoom_out();
return true;
}
}
return false;
}
public void hide_element_by_id(string element_id) throws Error {
get_dom_document().get_element_by_id(element_id).set_attribute("style", "display:none");
}
public void show_element_by_id(string element_id) throws Error {
get_dom_document().get_element_by_id(element_id).set_attribute("style", "display:block");
}
// Overridden to get the correct height from get_preferred_height.
public new void get_preferred_size(out Gtk.Requisition minimum_size,
out Gtk.Requisition natural_size) {
......@@ -115,6 +86,19 @@ public class ConversationWebView : StylishWebView {
minimum_height = natural_height = preferred_height;
}
public WebKit.DOM.HTMLDivElement create_div() throws Error {
return get_dom_document().create_element("div") as WebKit.DOM.HTMLDivElement;
}
public bool is_always_loaded(string uri) {
foreach (string prefix in always_loaded_prefixes) {
if (uri.has_prefix(prefix))
return true;
}
return false;
}
private void on_resource_request_starting(WebKit.WebFrame web_frame,
WebKit.WebResource web_resource, WebKit.NetworkRequest request,
WebKit.NetworkResponse? response) {
......@@ -131,15 +115,6 @@ public class ConversationWebView : StylishWebView {
request.set_uri("about:blank");
}
}
public bool is_always_loaded(string uri) {
foreach (string prefix in always_loaded_prefixes) {
if (uri.has_prefix(prefix))
return true;
}
return false;
}
private void on_load_finished(WebKit.WebFrame frame) {
// Load the style.
......@@ -185,6 +160,27 @@ public class ConversationWebView : StylishWebView {
}
}
private bool on_scroll_event(Gdk.EventScroll event) {
if ((event.state & Gdk.ModifierType.CONTROL_MASK) != 0) {
double dir = 0;
if (event.direction == Gdk.ScrollDirection.UP)
dir = -1;
else if (event.direction == Gdk.ScrollDirection.DOWN)
dir = 1;
else if (event.direction == Gdk.ScrollDirection.SMOOTH)
dir = event.delta_y;
if (dir < 0) {
zoom_in();
return true;
} else if (dir > 0) {
zoom_out();
return true;
}
}
return false;
}
private void load_user_style() {
try {
WebKit.DOM.Document document = get_dom_document();
......@@ -242,19 +238,12 @@ public class ConversationWebView : StylishWebView {
// Other policy-decisions may be requested for various reasons. The existence of an iframe,
// for example, causes a policy-decision request with an "OTHER" reason. We don't want to
// open a webpage in the browser just because an email contains an iframe.
if (navigation_action.reason == WebKit.WebNavigationReason.LINK_CLICKED)
if (navigation_action.reason == WebKit.WebNavigationReason.LINK_CLICKED) {
link_selected(request.uri);
}
return true;
}
public WebKit.DOM.HTMLDivElement create_div() throws Error {
return get_dom_document().create_element("div") as WebKit.DOM.HTMLDivElement;
}
public void scroll_to_element(WebKit.DOM.HTMLElement element) {
get_dom_document().get_default_view().scroll(element.offset_left, element.offset_top);
}
private unowned WebKit.WebView activate_inspector(WebKit.WebInspector inspector, WebKit.WebView target_view) {
Gtk.Window window = new Gtk.Window();
window.set_default_size(600, 600);
......@@ -273,15 +262,5 @@ public class ConversationWebView : StylishWebView {
return r;
}
public void allow_collapsing(bool allow) {
try {
if (allow)
get_dom_document().get_body().get_class_list().remove("nohide");
else
get_dom_document().get_body().get_class_list().add("nohide");
} catch (Error error) {
debug("Error setting body class: %s", error.message);
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment