[geary/wip/765516-gtk-widget-conversation-viewer: 54/107] Minor code clean up.



commit 8c8b03e0d611e18c3ee7b08ace6622b63c954506
Author: Michael James Gratton <mike vee net>
Date:   Sun Apr 10 10:36:08 2016 +1000

    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.

 .../conversation-viewer/conversation-message.vala  |   17 ++--
 .../conversation-viewer/conversation-web-view.vala |   99 ++++++++------------
 2 files changed, 49 insertions(+), 67 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index a84c19d..505f603 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -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;
     
diff --git a/src/client/conversation-viewer/conversation-web-view.vala 
b/src/client/conversation-viewer/conversation-web-view.vala
index 1624f19..47c130f 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -49,35 +49,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) {
@@ -105,6 +76,22 @@ 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) {
+        if (uri == null)
+            return true;
+        
+        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) {
@@ -122,18 +109,6 @@ public class ConversationWebView : StylishWebView {
         }
     }
     
-    public bool is_always_loaded(string? uri) {
-        if (uri == null)
-            return true;
-        
-        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.
         try {
@@ -178,6 +153,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();
@@ -235,19 +231,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);
@@ -266,15 +255,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);
-        }
-    }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]