[geary/wip/765516-gtk-widget-conversation-viewer: 16/169] Disable some code that will break when ConversationViewer loses it web_view.



commit ec73cdc470471fa6f2b18e5833dad874b806a22a
Author: Michael James Gratton <mike vee net>
Date:   Sat Apr 9 17:12:00 2016 +1000

    Disable some code that will break when ConversationViewer loses it web_view.

 src/client/application/geary-controller.vala |    6 +-
 src/client/composer/composer-embed.vala      |  134 +++++++++++++-------------
 2 files changed, 70 insertions(+), 70 deletions(-)
---
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index 3e6d772..ce70354 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -2624,15 +2624,15 @@ public class GearyController : Geary.BaseObject {
     }
     
     private void on_zoom_in() {
-        main_window.conversation_viewer.web_view.zoom_in();
+        //main_window.conversation_viewer.web_view.zoom_in();
     }
 
     private void on_zoom_out() {
-        main_window.conversation_viewer.web_view.zoom_out();
+        //main_window.conversation_viewer.web_view.zoom_out();
     }
 
     private void on_zoom_normal() {
-        main_window.conversation_viewer.web_view.zoom_level = 1.0f;
+        //main_window.conversation_viewer.web_view.zoom_level = 1.0f;
     }
     
     private void on_search() {
diff --git a/src/client/composer/composer-embed.vala b/src/client/composer/composer-embed.vala
index e404e3a..04da374 100644
--- a/src/client/composer/composer-embed.vala
+++ b/src/client/composer/composer-embed.vala
@@ -13,7 +13,7 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
     private string embed_id;
     private bool setting_inner_scroll;
     private bool scrolled_to_bottom = false;
-    private double inner_scroll_adj_value;
+    //private double inner_scroll_adj_value;
     private int inner_view_height;
     private int min_height = MIN_EDITOR_HEIGHT;
     private bool has_accel_group = false;
@@ -30,14 +30,14 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
         valign = Gtk.Align.FILL;
         
         WebKit.DOM.HTMLElement? email_element = null;
-        email_element = conversation_viewer.web_view.get_dom_document().get_element_by_id(
-            conversation_viewer.get_div_id(referred.id)) as WebKit.DOM.HTMLElement;
-        embed_id = referred.id.to_string() + "_reply";
-        if (email_element == null) {
-            warning("Embedded composer could not find email to follow.");
-            email_element = conversation_viewer.web_view.get_dom_document().get_element_by_id(
-                "placeholder") as WebKit.DOM.HTMLElement;
-        }
+        // email_element = conversation_viewer.web_view.get_dom_document().get_element_by_id(
+        //     conversation_viewer.get_div_id(referred.id)) as WebKit.DOM.HTMLElement;
+        // embed_id = referred.id.to_string() + "_reply";
+        // if (email_element == null) {
+        //     warning("Embedded composer could not find email to follow.");
+        //     email_element = conversation_viewer.web_view.get_dom_document().get_element_by_id(
+        //         "placeholder") as WebKit.DOM.HTMLElement;
+        // }
         
         try {
             email_element.insert_adjacent_html("afterend",
@@ -138,42 +138,42 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
     
     public bool set_position(ref Gdk.Rectangle allocation, double hscroll, double vscroll,
         int view_height) {
-        WebKit.DOM.Element embed = 
conversation_viewer.web_view.get_dom_document().get_element_by_id(embed_id);
-        if (embed == null)
-            return false;
+        //WebKit.DOM.Element embed = 
conversation_viewer.web_view.get_dom_document().get_element_by_id(embed_id);
+        //if (embed == null)
+        //    return false;
         
-        int div_height = (int) embed.client_height;
-        int y_top = (int) (embed.offset_top + embed.client_top) - (int) vscroll;
-        int available_height = int.min(y_top + div_height, view_height) - int.max(y_top, 0);
+        // int div_height = (int) embed.client_height;
+        // int y_top = (int) (embed.offset_top + embed.client_top) - (int) vscroll;
+        // int available_height = int.min(y_top + div_height, view_height) - int.max(y_top, 0);
         
-        if (available_height < 0 || available_height == div_height) {
-            // It fits in the available space, or it doesn't fit at all
-            allocation.y = y_top;
-            // When offscreen, make it very small to ensure scrolling during any edit
-            allocation.height = (available_height < 0) ? 1 : div_height;
-        } else if (available_height > min_height) {
-            // There's enough room, so make sure we get the whole widget in
-            allocation.y = int.max(y_top, 0);
-            allocation.height = available_height;
-        } else {
-            // Minimum height widget, placed so as much as possible is visible
-            allocation.y = int.max(y_top, int.min(y_top + div_height - min_height, 0));
-            allocation.height = min_height;
-        }
-        allocation.x = (int) (embed.offset_left + embed.client_left) - (int) hscroll;
-        allocation.width = (int) embed.client_width;
+        // if (available_height < 0 || available_height == div_height) {
+        //     // It fits in the available space, or it doesn't fit at all
+        //     allocation.y = y_top;
+        //     // When offscreen, make it very small to ensure scrolling during any edit
+        //     allocation.height = (available_height < 0) ? 1 : div_height;
+        // } else if (available_height > min_height) {
+        //     // There's enough room, so make sure we get the whole widget in
+        //     allocation.y = int.max(y_top, 0);
+        //     allocation.height = available_height;
+        // } else {
+        //     // Minimum height widget, placed so as much as possible is visible
+        //     allocation.y = int.max(y_top, int.min(y_top + div_height - min_height, 0));
+        //     allocation.height = min_height;
+        // }
+        // allocation.x = (int) (embed.offset_left + embed.client_left) - (int) hscroll;
+        // allocation.width = (int) embed.client_width;
         
-        // Work out adjustment of composer web view
-        setting_inner_scroll = true;
-        composer.editor.vadjustment.set_value(allocation.y - y_top);
-        setting_inner_scroll = false;
-        // This sets the scroll before the widget gets resized.  Although the adjustment
-        // may be scrolled to the bottom right now, the current value may not do that
-        // once the widget is shrunk; for example, while scrolling down the page past
-        // the bottom of the editor.  So if we're at the bottom, record that fact.  When
-        // the limits of the adjustment are changed (watched by on_adjust_changed), we
-        // can keep it at the bottom.
-        scrolled_to_bottom = (y_top <= 0 && available_height < view_height);
+        // // Work out adjustment of composer web view
+        // setting_inner_scroll = true;
+        // composer.editor.vadjustment.set_value(allocation.y - y_top);
+        // setting_inner_scroll = false;
+        // // This sets the scroll before the widget gets resized.  Although the adjustment
+        // // may be scrolled to the bottom right now, the current value may not do that
+        // // once the widget is shrunk; for example, while scrolling down the page past
+        // // the bottom of the editor.  So if we're at the bottom, record that fact.  When
+        // // the limits of the adjustment are changed (watched by on_adjust_changed), we
+        // // can keep it at the bottom.
+        // scrolled_to_bottom = (y_top <= 0 && available_height < view_height);
         
         return true;
     }
@@ -193,12 +193,12 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
     }
     
     private void on_inner_scroll(Gtk.Adjustment adj) {
-        double delta = adj.value - inner_scroll_adj_value;
-        inner_scroll_adj_value = adj.value;
-        if (delta != 0 && !setting_inner_scroll) {
-            Gtk.Adjustment outer_adj = conversation_viewer.web_view.vadjustment;
-            outer_adj.set_value(outer_adj.value + delta);
-        }
+        //double delta = adj.value - inner_scroll_adj_value;
+        //inner_scroll_adj_value = adj.value;
+        //if (delta != 0 && !setting_inner_scroll) {
+        //    Gtk.Adjustment outer_adj = conversation_viewer.web_view.vadjustment;
+        //    outer_adj.set_value(outer_adj.value + delta);
+        //}
     }
     
     private void on_adjust_changed(Gtk.Adjustment adj) {
@@ -229,29 +229,29 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
             inner_view_height = view_height;
             min_height = base_height + MIN_EDITOR_HEIGHT;
             // Calculate height widget should be to avoid scrolling in editor
-            int widget_height = int.max(view_height + base_height - 2, min_height); //? about 2
-            WebKit.DOM.Element embed = conversation_viewer.web_view
-                .get_dom_document().get_element_by_id(embed_id);
-            if (embed != null) {
-                try {
-                    embed.style.set_property("height", @"$widget_height", "");
-                } catch (Error error) {
-                    debug("Error setting height of composer widget");
-                }
-            }
+            //int widget_height = int.max(view_height + base_height - 2, min_height); //? about 2
+            // WebKit.DOM.Element embed = conversation_viewer.web_view
+            //     .get_dom_document().get_element_by_id(embed_id);
+            // if (embed != null) {
+            //     try {
+            //         embed.style.set_property("height", @"$widget_height", "");
+            //     } catch (Error error) {
+            //         debug("Error setting height of composer widget");
+            //     }
+            // }
         }
         return false;
     }
     
     private bool on_inner_scroll_event(Gdk.EventScroll event) {
-        conversation_viewer.web_view.scroll_event(event);
+        //conversation_viewer.web_view.scroll_event(event);
         return true;
     }
     
     public void present() {
         top_window.present();
-        conversation_viewer.web_view.get_dom_document().get_element_by_id(embed_id)
-            .scroll_into_view_if_needed(false);
+        // conversation_viewer.web_view.get_dom_document().get_element_by_id(embed_id)
+        //     .scroll_into_view_if_needed(false);
     }
     
     public unowned Gtk.Widget get_focus() {
@@ -264,12 +264,12 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer {
         composer.editor.focus_in_event.disconnect(on_focus_in);
         composer.editor.focus_out_event.disconnect(on_focus_out);
         
-        WebKit.DOM.Element embed = 
conversation_viewer.web_view.get_dom_document().get_element_by_id(embed_id);
-        try{
-            embed.parent_element.remove_child(embed);
-        } catch (Error error) {
-            warning("Could not remove embed from WebView: %s", error.message);
-        }
+        // WebKit.DOM.Element embed = 
conversation_viewer.web_view.get_dom_document().get_element_by_id(embed_id);
+        // try{
+        //     embed.parent_element.remove_child(embed);
+        // } catch (Error error) {
+        //     warning("Could not remove embed from WebView: %s", error.message);
+        // }
     }
     
     public void close_container() {


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