[Xfce4-commits] <midori:master> Move webview into Tab class and drop unused getters

Christian Dywan noreply at xfce.org
Thu Oct 11 00:36:01 CEST 2012


Updating branch refs/heads/master
         to 2ce61c66680c8e7db1cba2b1cbc82e0b60f3f1eb (commit)
       from 5c3622797ac5aaf077d44a3dfc47ad0ed5d233aa (commit)

commit 2ce61c66680c8e7db1cba2b1cbc82e0b60f3f1eb
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Oct 10 20:05:35 2012 +0200

    Move webview into Tab class and drop unused getters

 extensions/delayed-load.vala |    3 +-
 midori/midori-browser.c      |   50 +-----
 midori/midori-tab.vala       |   55 ++++++
 midori/midori-view.c         |  405 +++---------------------------------------
 midori/midori-view.h         |   27 ---
 midori/midori.vapi           |    4 -
 tests/tab.vala               |    5 +
 toolbars/midori-findbar.c    |   10 +-
 8 files changed, 95 insertions(+), 464 deletions(-)

diff --git a/extensions/delayed-load.vala b/extensions/delayed-load.vala
index 546bdcc..066a245 100644
--- a/extensions/delayed-load.vala
+++ b/extensions/delayed-load.vala
@@ -158,8 +158,7 @@ namespace DelayedLoad {
 
                 int64 delay = item.get_meta_integer ("delay");
                 if (delay != Midori.Delay.DELAYED) {
-                    unowned WebKit.WebView web_view = view.get_web_view ();
-                    WebKit.LoadStatus load_status = web_view.load_status;
+                    WebKit.LoadStatus load_status = view.web_view.load_status;
                     if (load_status == WebKit.LoadStatus.FINISHED) {
                         if (this.timeout != 0)
                             this.tasks.set (browser, new TabShaker (browser));
diff --git a/midori/midori-browser.c b/midori/midori-browser.c
index 5fd5806..bb17895 100644
--- a/midori/midori-browser.c
+++ b/midori/midori-browser.c
@@ -322,7 +322,7 @@ _midori_browser_update_interface (MidoriBrowser* browser,
     GtkAction* action;
 
     _action_set_sensitive (browser, "Back", midori_view_can_go_back (view));
-    _action_set_sensitive (browser, "Forward", midori_view_can_go_forward (view));
+    _action_set_sensitive (browser, "Forward", midori_tab_can_go_forward (MIDORI_TAB (view)));
     _action_set_sensitive (browser, "Previous",
         midori_view_get_previous_page (view) != NULL);
     _action_set_sensitive (browser, "Next",
@@ -330,7 +330,7 @@ _midori_browser_update_interface (MidoriBrowser* browser,
 
     _action_set_sensitive (browser, "AddSpeedDial", !midori_view_is_blank (view));
     _action_set_sensitive (browser, "BookmarkAdd", !midori_view_is_blank (view));
-    _action_set_sensitive (browser, "SaveAs", midori_view_can_save (view));
+    _action_set_sensitive (browser, "SaveAs", midori_tab_can_save (MIDORI_TAB (view)));
     _action_set_sensitive (browser, "ZoomIn", midori_view_can_zoom_in (view));
     _action_set_sensitive (browser, "ZoomOut", midori_view_can_zoom_out (view));
     _action_set_sensitive (browser, "ZoomNormal",
@@ -341,7 +341,7 @@ _midori_browser_update_interface (MidoriBrowser* browser,
         midori_tab_can_view_source (MIDORI_TAB (view)));
 
     action = _action_by_name (browser, "NextForward");
-    if (midori_view_can_go_forward (view))
+    if (midori_tab_can_go_forward (MIDORI_TAB (view)))
     {
         g_object_set (action,
                       "stock-id", GTK_STOCK_GO_FORWARD,
@@ -602,7 +602,7 @@ midori_view_notify_uri_cb (GtkWidget*     widget,
         GtkAction* action = _action_by_name (browser, "Location");
         midori_location_action_set_text (MIDORI_LOCATION_ACTION (action), uri);
         _action_set_sensitive (browser, "Back", midori_view_can_go_back (view));
-        _action_set_sensitive (browser, "Forward", midori_view_can_go_forward (view));
+        _action_set_sensitive (browser, "Forward", midori_tab_can_go_forward (MIDORI_TAB (view)));
     }
 }
 
@@ -1104,15 +1104,6 @@ midori_browser_save_uri (MidoriBrowser* browser,
 }
 
 static void
-midori_view_save_as_cb (GtkWidget*   menuitem,
-                        const gchar* uri,
-                        GtkWidget*   view)
-{
-    MidoriBrowser* browser = midori_browser_get_for_widget (view);
-    midori_browser_save_uri (browser, MIDORI_VIEW (view), uri);
-}
-
-static void
 midori_browser_speed_dial_refresh_cb (MidoriSpeedDial* dial,
                                       MidoriBrowser*   browser)
 {
@@ -1138,19 +1129,6 @@ midori_browser_add_speed_dial (MidoriBrowser* browser)
     }
 }
 
-
-static void
-midori_view_add_speed_dial_cb (GtkWidget*   menuitem,
-                              const gchar* uri,
-                              GtkWidget*   view)
-{
-    MidoriBrowser* browser;
-
-    browser = midori_browser_get_for_widget (menuitem);
-    midori_browser_add_speed_dial (browser);
-}
-
-
 static gboolean
 midori_browser_tab_leave_notify_event_cb (GtkWidget*        widget,
                                           GdkEventCrossing* event,
@@ -1161,14 +1139,6 @@ midori_browser_tab_leave_notify_event_cb (GtkWidget*        widget,
 }
 
 static void
-midori_view_activate_action_cb (GtkWidget*     view,
-                                const gchar*   action,
-                                MidoriBrowser* browser)
-{
-    midori_browser_activate_action (browser, action);
-}
-
-static void
 midori_view_attach_inspector_cb (GtkWidget*     view,
                                  GtkWidget*     inspector_view,
                                  MidoriBrowser* browser)
@@ -1593,8 +1563,6 @@ midori_browser_connect_tab (MidoriBrowser* browser,
                       midori_view_notify_zoom_level_cb, browser,
                       "signal::notify::statusbar-text",
                       midori_view_notify_statusbar_text_cb, browser,
-                      "signal::activate-action",
-                      midori_view_activate_action_cb, browser,
                       "signal::attach-inspector",
                       midori_view_attach_inspector_cb, browser,
                       "signal::detach-inspector",
@@ -1609,10 +1577,6 @@ midori_browser_connect_tab (MidoriBrowser* browser,
                       midori_view_download_requested_cb, browser,
                       "signal::search-text",
                       midori_view_search_text_cb, browser,
-                      "signal::save-as",
-                      midori_view_save_as_cb, browser,
-                      "signal::add-speed-dial",
-                      midori_view_add_speed_dial_cb, browser,
                       "signal::leave-notify-event",
                       midori_browser_tab_leave_notify_event_cb, browser,
                       "signal::destroy",
@@ -3391,7 +3355,7 @@ _action_reload_stop_activate (GtkAction*     action,
         midori_view_reload (MIDORI_VIEW (view), from_cache);
     }
     else
-        midori_view_stop_loading (MIDORI_VIEW (view));
+        midori_tab_stop_loading (MIDORI_TAB (view));
     g_free (stock_id);
 }
 
@@ -3690,7 +3654,7 @@ _action_navigation_activate (GtkAction*     action,
     name = gtk_action_get_name (action);
 
     if (!strcmp (name, "NextForward"))
-        name = midori_view_can_go_forward (view) ? "Forward" : "Next";
+        name = midori_tab_can_go_forward (MIDORI_TAB (view)) ? "Forward" : "Next";
 
     if (g_str_equal (name, "Back"))
     {
@@ -3738,7 +3702,7 @@ _action_navigation_activate (GtkAction*     action,
             midori_browser_set_current_page_smartly (browser, n);
         }
         else
-          midori_view_go_forward (view);
+          midori_tab_go_forward (MIDORI_TAB (view));
 
         return TRUE;
     }
diff --git a/midori/midori-tab.vala b/midori/midori-tab.vala
index 7e09b5d..8f67657 100644
--- a/midori/midori-tab.vala
+++ b/midori/midori-tab.vala
@@ -34,6 +34,8 @@ namespace Midori {
     }
 
     public class Tab : Gtk.VBox {
+        public WebKit.WebView web_view { get; private set; }
+
         private string current_uri = "about:blank";
         public string uri { get {
             return current_uri;
@@ -69,10 +71,28 @@ namespace Midori {
         }
         }
 
+        public signal void console_message (string message, int line, string source_id);
+        public signal void attach_inspector (WebKit.WebView inspector_view);
+        /* Emitted when an open inspector that was previously
+           attached to the window is now detached again.
+           Since: 0.3.4
+         */
+        public signal void detach_inspector (WebKit.WebView inspector_view);
+
         public bool is_blank () {
             return URI.is_blank (uri);
         }
 
+        construct {
+            #if HAVE_GTK3
+            orientation = Gtk.Orientation.VERTICAL;
+            #endif
+
+            web_view = new WebKit.WebView ();
+            /* Load something to avoid a bug where WebKit might not set a main frame */
+            web_view.load_uri ("");
+        }
+
         public bool can_view_source () {
             if (is_blank () || special)
                 return false;
@@ -121,5 +141,40 @@ namespace Midori {
 
             return Pango.EllipsizeMode.END;
         }
+
+        /* Since: 0.4.3 */
+        public bool can_save () {
+            if (is_blank () || special)
+                return false;
+            if (web_view.get_view_source_mode ())
+                return false;
+            if (web_view.get_main_frame ().get_data_source ().get_data () == null)
+                return false;
+            return true;
+        }
+
+        public void stop_loading () {
+            web_view.stop_loading ();
+        }
+
+        public bool can_go_forward () {
+            return web_view.can_go_forward ();
+        }
+
+        public void go_forward () {
+            web_view.go_forward ();
+        }
+
+        public void unmark_text_matches () {
+            web_view.unmark_text_matches ();
+        }
+
+        public void mark_text_matches (string text, bool case_sensitive) {
+            web_view.mark_text_matches (text, case_sensitive, 0);
+        }
+
+        public void set_highlight_text_matches (bool highlight) {
+            web_view.set_highlight_text_matches (highlight);
+        }
     }
 }
diff --git a/midori/midori-view.c b/midori/midori-view.c
index 41a0f42..c5eabd7 100644
--- a/midori/midori-view.c
+++ b/midori/midori-view.c
@@ -61,9 +61,6 @@ webkit_web_view_get_selected_text (WebKitWebView* web_view);
 #endif
 
 static void
-midori_view_construct_web_view (MidoriView* view);
-
-static void
 midori_view_item_meta_data_changed (KatzeItem*   item,
                                     const gchar* key,
                                     MidoriView*  view);
@@ -152,18 +149,12 @@ enum
 };
 
 enum {
-    ACTIVATE_ACTION,
-    CONSOLE_MESSAGE,
-    ATTACH_INSPECTOR,
-    DETACH_INSPECTOR,
     NEW_TAB,
     NEW_WINDOW,
     NEW_VIEW,
     DOWNLOAD_REQUESTED,
     SEARCH_TEXT,
     ADD_BOOKMARK,
-    SAVE_AS,
-    ADD_SPEED_DIAL,
 
     LAST_SIGNAL
 };
@@ -194,6 +185,11 @@ midori_view_settings_notify_cb (MidoriWebSettings* settings,
                                 GParamSpec*        pspec,
                                 MidoriView*        view);
 
+static GObject*
+midori_view_constructor (GType                  type,
+                         guint                  n_construct_properties,
+                         GObjectConstructParam* construct_properties);
+
 static void
 midori_view_class_init (MidoriViewClass* class)
 {
@@ -201,61 +197,6 @@ midori_view_class_init (MidoriViewClass* class)
     GtkWidgetClass* gtkwidget_class;
     GParamFlags flags;
 
-    signals[ACTIVATE_ACTION] = g_signal_new (
-        "activate-action",
-        G_TYPE_FROM_CLASS (class),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-        0,
-        0,
-        NULL,
-        g_cclosure_marshal_VOID__STRING,
-        G_TYPE_NONE, 1,
-        G_TYPE_STRING);
-
-    signals[CONSOLE_MESSAGE] = g_signal_new (
-        "console-message",
-        G_TYPE_FROM_CLASS (class),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-        0,
-        0,
-        NULL,
-        midori_cclosure_marshal_VOID__STRING_INT_STRING,
-        G_TYPE_NONE, 3,
-        G_TYPE_STRING,
-        G_TYPE_INT,
-        G_TYPE_STRING);
-
-    signals[ATTACH_INSPECTOR] = g_signal_new (
-        "attach-inspector",
-        G_TYPE_FROM_CLASS (class),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-        0,
-        0,
-        NULL,
-        g_cclosure_marshal_VOID__OBJECT,
-        G_TYPE_NONE, 1,
-        GTK_TYPE_WIDGET);
-
-    /**
-     * MidoriView::detach-inspector:
-     * @view: the object on which the signal is emitted
-     *
-     * Emitted when an open inspector that was previously
-     * attached to the window is now detached again.
-     *
-     * Since: 0.3.4
-     */
-     signals[DETACH_INSPECTOR] = g_signal_new (
-        "detach-inspector",
-        G_TYPE_FROM_CLASS (class),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-        0,
-        0,
-        NULL,
-        g_cclosure_marshal_VOID__OBJECT,
-        G_TYPE_NONE, 1,
-        GTK_TYPE_WIDGET);
-
     signals[NEW_TAB] = g_signal_new (
         "new-tab",
         G_TYPE_FROM_CLASS (class),
@@ -381,38 +322,8 @@ midori_view_class_init (MidoriViewClass* class)
         G_TYPE_NONE, 1,
         G_TYPE_STRING);
 
-    signals[SAVE_AS] = g_signal_new (
-        "save-as",
-        G_TYPE_FROM_CLASS (class),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-        0,
-        0,
-        NULL,
-        g_cclosure_marshal_VOID__STRING,
-        G_TYPE_NONE, 1,
-        G_TYPE_STRING);
-
-    /**
-     * MidoriView::add-speed-dial:
-     * @view: the object on which the signal is emitted
-     * @uri: the URI to add to the speed dial
-     *
-     * Emitted when an URI is added to the spee dial page.
-     *
-     * Since: 0.1.7
-     */
-    signals[ADD_SPEED_DIAL] = g_signal_new (
-        "add-speed-dial",
-        G_TYPE_FROM_CLASS (class),
-        (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-        0,
-        0,
-        NULL,
-        g_cclosure_marshal_VOID__STRING,
-        G_TYPE_NONE, 1,
-        G_TYPE_STRING);
-
     gobject_class = G_OBJECT_CLASS (class);
+    gobject_class->constructor = midori_view_constructor;
     gobject_class->finalize = midori_view_finalize;
     gobject_class->set_property = midori_view_set_property;
     gobject_class->get_property = midori_view_get_property;
@@ -831,7 +742,7 @@ midori_view_web_view_navigation_decision_cb (WebKitWebView*             web_view
                     {
                         gchar* slots = g_strjoinv (" , ", (gchar**)gcr_pkcs11_get_trust_lookup_uris ());
                         gchar* title = g_strdup_printf ("Error granting trust: %s", error->message);
-                        midori_view_stop_loading (view);
+                        midori_tab_stop_loading (MIDORI_TAB (view));
                         midori_view_display_error (view, NULL, NULL, title, slots,
                             _("Trust this website"), NULL);
                         g_free (title);
@@ -964,7 +875,7 @@ webkit_web_view_load_committed_cb (WebKitWebView*  web_view,
                 GTlsCertificateFlags tls_flags;
                 midori_tab_set_security (MIDORI_TAB (view), MIDORI_SECURITY_UNKNOWN);
                 g_object_get (message, "tls-errors", &tls_flags, NULL);
-                midori_view_stop_loading (view);
+                midori_tab_stop_loading (MIDORI_TAB (view));
                 midori_view_display_error (view, NULL, NULL, _("Security unknown"),
                     midori_location_action_tls_flags_to_string (tls_flags),
                     _("Trust this website"),
@@ -1787,7 +1698,7 @@ midori_view_web_view_button_press_event_cb (WebKitWebView*  web_view,
         view->button_press_handled = TRUE;
         return TRUE;
     case 9:
-        midori_view_go_forward (view);
+        midori_tab_go_forward (MIDORI_TAB (view));
         view->button_press_handled = TRUE;
         return TRUE;
     /*
@@ -2697,12 +2608,6 @@ midori_view_populate_popup (MidoriView* view,
         else
         {
         items = gtk_container_get_children (GTK_CONTAINER (menu));
-        #if HAVE_HILDON
-        gtk_widget_hide (g_list_nth_data (items, 2));
-        gtk_widget_set_no_show_all (g_list_nth_data (items, 2), TRUE);
-        gtk_widget_hide (g_list_nth_data (items, 3));
-        gtk_widget_set_no_show_all (g_list_nth_data (items, 3), TRUE);
-        #endif
         menuitem = (GtkWidget*)g_list_nth_data (items, 3);
         /* hack to localize menu item */
         if (GTK_IS_BIN (menuitem))
@@ -2771,18 +2676,6 @@ midori_view_populate_popup (MidoriView* view,
             }
         }
 
-        #if HAVE_HILDON
-        gtk_menu_shell_append (menu_shell, gtk_separator_menu_item_new ());
-        menuitem = sokoke_action_create_popup_menu_item (
-                gtk_action_group_get_action (actions, "CompactAdd"));
-        gtk_menu_shell_append (menu_shell, menuitem);
-        menuitem = sokoke_action_create_popup_menu_item (
-                gtk_action_group_get_action (actions, "Fullscreen"));
-        gtk_menu_shell_append (menu_shell, menuitem);
-        menuitem = sokoke_action_create_popup_menu_item (
-                gtk_action_group_get_action (actions, "PrivateBrowsing"));
-        gtk_menu_shell_append (menu_shell, menuitem);
-        #else
         gtk_menu_shell_append (menu_shell, gtk_separator_menu_item_new ());
         menuitem = sokoke_action_create_popup_menu_item (
                 gtk_action_group_get_action (actions, "BookmarkAdd"));
@@ -2797,7 +2690,6 @@ midori_view_populate_popup (MidoriView* view,
         menuitem = sokoke_action_create_popup_menu_item (
                 gtk_action_group_get_action (actions, "AddDesktopShortcut"));
         gtk_menu_shell_append (menu_shell, menuitem);
-        #endif
 
         menuitem = sokoke_action_create_popup_menu_item (
                 gtk_action_group_get_action (actions, "SaveAs"));
@@ -2846,33 +2738,6 @@ webkit_web_view_populate_popup_cb (WebKitWebView* web_view,
     midori_view_populate_popup (view, menu, FALSE);
 }
 
-#if HAVE_HILDON
-static void
-midori_view_web_view_tap_and_hold_cb (GtkWidget*  web_view,
-                                      gpointer    data)
-{
-    gint x, y;
-    GdkEvent event;
-    gboolean result;
-
-    /* Emulate a pointer motion above the tap position
-      and a right click at the according position. */
-    event.any.window = gtk_widget_get_window (web_view);
-    gdk_window_get_pointer (event.any.window, &x, &y, NULL);
-    event.any.type = GDK_MOTION_NOTIFY;
-    event.motion.x = x;
-    event.motion.y = y;
-    g_signal_emit_by_name (web_view, "motion-notify-event", &event, &result);
-
-    event.any.type = GDK_BUTTON_PRESS;
-    event.button.axes = NULL;
-    event.button.x = x;
-    event.button.y = y;
-    event.button.button = 3;
-    g_signal_emit_by_name (web_view, "button-press-event", &event, &result);
-}
-#endif
-
 static gboolean
 webkit_web_view_web_view_ready_cb (GtkWidget*  web_view,
                                    MidoriView* view)
@@ -3101,7 +2966,7 @@ webkit_web_view_console_message_cb (GtkWidget*   web_view,
         }
     }
     else
-        g_signal_emit (view, signals[CONSOLE_MESSAGE], 0, message, line, source_id);
+        g_signal_emit_by_name (view, "console-message", message, line, source_id);
     return TRUE;
 }
 
@@ -3235,11 +3100,6 @@ midori_view_init (MidoriView* view)
     view->scrollh = view->scrollv = -2;
     view->back_forward_set = FALSE;
 
-    #if GTK_CHECK_VERSION (3, 2, 0)
-    gtk_orientable_set_orientation (GTK_ORIENTABLE (view), GTK_ORIENTATION_VERTICAL);
-    #endif
-
-    view->web_view = NULL;
     /* Adjustments are not created initially, but overwritten later */
     view->scrolled_window = katze_scrolled_new (NULL, NULL);
     gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (view->scrolled_window),
@@ -3277,8 +3137,6 @@ midori_view_init (MidoriView* view)
         G_CALLBACK (midori_view_notify_hadjustment_cb), view);
     g_signal_connect (view->scrolled_window, "notify::vadjustment",
         G_CALLBACK (midori_view_notify_vadjustment_cb), view);
-
-    midori_view_construct_web_view (view);
 }
 
 static void
@@ -3396,22 +3254,6 @@ midori_view_focus_in_event (GtkWidget*     widget,
     return TRUE;
 }
 
-/**
- * midori_view_new:
- * @net: %NULL
- *
- * Creates a new view.
- *
- * Return value: a new #MidoriView
- *
- * Deprecated: 0.2.8: Use midori_view_new_with_item() instead.
- **/
-GtkWidget*
-midori_view_new (KatzeNet* net)
-{
-    return g_object_new (MIDORI_TYPE_VIEW, NULL);
-}
-
 static void
 _midori_view_set_settings (MidoriView*        view,
                            MidoriWebSettings* settings)
@@ -3441,7 +3283,6 @@ _midori_view_set_settings (MidoriView*        view,
         "open-tabs-in-the-background", &view->open_tabs_in_the_background,
         NULL);
 
-    if (view->web_view)
         g_object_set (view->web_view,
                       "full-content-zoom", zoom_text_and_images, NULL);
     g_object_set (view->scrolled_window, "kinetic-scrolling", kinetic_scrolling, NULL);
@@ -3676,11 +3517,6 @@ midori_view_web_inspector_inspect_web_view_cb (gpointer       inspector,
                                                MidoriView*    view)
 {
     GtkWidget* inspector_view = webkit_web_view_new ();
-    #if HAVE_HILDON
-    gtk_widget_tap_and_hold_setup (view->web_view, NULL, NULL, 0);
-    g_signal_connect (view->web_view, "tap-and-hold",
-                      G_CALLBACK (midori_view_web_view_tap_and_hold_cb), NULL);
-    #endif
     midori_view_web_inspector_construct_window (inspector,
         web_view, inspector_view, view);
     return WEBKIT_WEB_VIEW (inspector_view);
@@ -3709,7 +3545,7 @@ midori_view_web_inspector_attach_window_cb (gpointer    inspector,
                                             MidoriView* view)
 {
     WebKitWebView* inspector_view = webkit_web_inspector_get_web_view (inspector);
-    g_signal_emit (view, signals[ATTACH_INSPECTOR], 0, inspector_view);
+    g_signal_emit_by_name (view, "attach-inspector", inspector_view);
     return TRUE;
 }
 
@@ -3723,7 +3559,7 @@ midori_view_web_inspector_detach_window_cb (gpointer    inspector,
         return FALSE;
 
     gtk_widget_hide (parent);
-    g_signal_emit (view, signals[DETACH_INSPECTOR], 0, inspector_view);
+    g_signal_emit_by_name (view, "detach-inspector", inspector_view);
     midori_view_web_inspector_construct_window (inspector,
         WEBKIT_WEB_VIEW (view->web_view), GTK_WIDGET (inspector_view), view);
     return TRUE;
@@ -3741,24 +3577,17 @@ midori_view_web_inspector_close_window_cb (gpointer    inspector,
     return TRUE;
 }
 
-static void
-midori_view_construct_web_view (MidoriView* view)
+static GObject*
+midori_view_constructor (GType                  type,
+                         guint                  n_construct_properties,
+                         GObjectConstructParam* construct_properties)
 {
     gpointer inspector;
+    GObject* object = G_OBJECT_CLASS (midori_view_parent_class)->constructor (
+        type, n_construct_properties, construct_properties);
+    MidoriView* view = MIDORI_VIEW (object);
 
-    g_return_if_fail (!view->web_view);
-
-    view->web_view = webkit_web_view_new ();
-
-    /* Load something to avoid a bug where WebKit might not set a main frame */
-    webkit_web_view_load_uri (WEBKIT_WEB_VIEW (view->web_view), "");
-
-    #if HAVE_HILDON
-    gtk_widget_tap_and_hold_setup (view->web_view, NULL, NULL, 0);
-    g_signal_connect (view->web_view, "tap-and-hold",
-                      G_CALLBACK (midori_view_web_view_tap_and_hold_cb), NULL);
-    #endif
-
+    view->web_view = GTK_WIDGET (midori_tab_get_web_view (MIDORI_TAB (view)));
     g_object_connect (view->web_view,
                       "signal::navigation-policy-decision-requested",
                       midori_view_web_view_navigation_decision_cb, view,
@@ -3843,6 +3672,7 @@ midori_view_construct_web_view (MidoriView* view)
                       "signal::close-window",
                       midori_view_web_inspector_close_window_cb, view,
                       NULL);
+    return object;
 }
 
 static void
@@ -4483,66 +4313,6 @@ midori_view_get_selected_text (MidoriView* view)
 }
 
 /**
- * midori_view_can_cut_clipboard:
- * @view: a #MidoriView
- *
- * Determines whether a selection can be cut.
- *
- * Return value: %TRUE if a selection can be cut
- **/
-gboolean
-midori_view_can_cut_clipboard (MidoriView* view)
-{
-    g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
-    if (view->web_view)
-        return webkit_web_view_can_cut_clipboard (
-            WEBKIT_WEB_VIEW (view->web_view));
-    else
-        return FALSE;
-}
-
-/**
- * midori_view_can_copy_clipboard:
- * @view: a #MidoriView
- *
- * Determines whether a selection can be copied.
- *
- * Return value: %TRUE if a selection can be copied
- **/
-gboolean
-midori_view_can_copy_clipboard (MidoriView* view)
-{
-    g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
-    if (view->web_view)
-        return webkit_web_view_can_copy_clipboard (
-            WEBKIT_WEB_VIEW (view->web_view));
-    else
-        return FALSE;
-}
-
-/**
- * midori_view_can_paste_clipboard:
- * @view: a #MidoriView
- *
- * Determines whether a selection can be pasted.
- *
- * Return value: %TRUE if a selection can be pasted
- **/
-gboolean
-midori_view_can_paste_clipboard (MidoriView* view)
-{
-    g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
-    if (view->web_view)
-        return webkit_web_view_can_paste_clipboard (
-            WEBKIT_WEB_VIEW (view->web_view));
-    else
-        return FALSE;
-}
-
-/**
  * midori_view_get_proxy_menu_item:
  * @view: a #MidoriView
  *
@@ -5106,43 +4876,6 @@ midori_view_can_zoom_out (MidoriView* view)
 }
 
 /**
- * midori_view_can_save:
- * @view: a #MidoriView
- *
- * Determines if the view can be saved to disk.
- *
- * Return value: %TRUE if the website or image can be saved
- *
- * Since: 0.4.3
- **/
-gboolean
-midori_view_can_save (MidoriView* view)
-{
-    GtkWidget* web_view;
-    WebKitWebDataSource *data_source;
-    WebKitWebFrame *frame;
-    const GString *data;
-
-    g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
-    if (midori_view_is_blank (view))
-        return FALSE;
-
-    web_view = midori_view_get_web_view (view);
-    if (webkit_web_view_get_view_source_mode (WEBKIT_WEB_VIEW (web_view)))
-        return FALSE;
-
-    frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
-    data_source = webkit_web_frame_get_data_source (frame);
-    data = webkit_web_data_source_get_data (data_source);
-
-    if (data != NULL)
-        return TRUE;
-
-    return FALSE;
-}
-
-/**
  * midori_view_save_source:
  * @view: a #MidoriView
  * @uri: an alternative destination URI, or %NULL
@@ -5234,20 +4967,6 @@ midori_view_reload (MidoriView* view,
 }
 
 /**
- * midori_view_stop_loading
- * @view: a #MidoriView
- *
- * Stops loading the view if it is currently loading.
- **/
-void
-midori_view_stop_loading (MidoriView* view)
-{
-    g_return_if_fail (MIDORI_IS_VIEW (view));
-
-    webkit_web_view_stop_loading (WEBKIT_WEB_VIEW (view->web_view));
-}
-
-/**
  * midori_view_can_go_back
  * @view: a #MidoriView
  *
@@ -5282,37 +5001,6 @@ midori_view_go_back (MidoriView* view)
 }
 
 /**
- * midori_view_can_go_forward
- * @view: a #MidoriView
- *
- * Determines whether the view can go forward.
- **/
-gboolean
-midori_view_can_go_forward (MidoriView* view)
-{
-    g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
-
-    if (view->web_view)
-        return webkit_web_view_can_go_forward (WEBKIT_WEB_VIEW (view->web_view));
-    else
-        return FALSE;
-}
-
-/**
- * midori_view_go_forward
- * @view: a #MidoriView
- *
- * Goes forward one page in the view.
- **/
-void
-midori_view_go_forward (MidoriView* view)
-{
-    g_return_if_fail (MIDORI_IS_VIEW (view));
-
-    webkit_web_view_go_forward (WEBKIT_WEB_VIEW (view->web_view));
-}
-
-/**
  * midori_view_go_back_or_forward
  * @view: a #MidoriView
  * @steps: number of steps to jump in history
@@ -5493,20 +5181,6 @@ midori_view_print (MidoriView* view)
 }
 
 /**
- * midori_view_unmark_text_matches
- * @view: a #MidoriView
- *
- * Unmarks the text matches in the view.
- **/
-void
-midori_view_unmark_text_matches (MidoriView* view)
-{
-    g_return_if_fail (MIDORI_IS_VIEW (view));
-
-    webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW (view->web_view));
-}
-
-/**
  * midori_view_search_text
  * @view: a #MidoriView
  * @text: a string
@@ -5538,42 +5212,6 @@ midori_view_search_text (MidoriView*  view,
 }
 
 /**
- * midori_view_mark_text_matches
- * @view: a #MidoriView
- * @text: a string
- * @case_sensitive: case sensitivity
- *
- * Marks all text matches within the view.
- **/
-void
-midori_view_mark_text_matches (MidoriView*  view,
-                               const gchar* text,
-                               gboolean     case_sensitive)
-{
-    g_return_if_fail (MIDORI_IS_VIEW (view));
-
-    webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW (view->web_view),
-        text, case_sensitive, 0);
-}
-
-/**
- * midori_view_set_highlight_text_matches
- * @view: a #MidoriView
- * @highlight: whether to highlight matches
- *
- * Whether to highlight all matches within the view.
- **/
-void
-midori_view_set_highlight_text_matches (MidoriView* view,
-                                        gboolean    highlight)
-{
-    g_return_if_fail (MIDORI_IS_VIEW (view));
-
-    webkit_web_view_set_highlight_text_matches (
-        WEBKIT_WEB_VIEW (view->web_view), highlight);
-}
-
-/**
  * midori_view_execute_script
  * @view: a #MidoriView
  * @script: script code
@@ -5740,6 +5378,7 @@ midori_view_web_view_get_snapshot (GtkWidget* web_view,
  * Returns: The #WebKitWebView for this view
  *
  * Since: 0.2.5
+ * Deprecated: 0.4.8: Use midori_tab_get_web_view() instead.
  **/
 GtkWidget*
 midori_view_get_web_view        (MidoriView*        view)
diff --git a/midori/midori-view.h b/midori/midori-view.h
index 1e6f9fc..bf21b12 100644
--- a/midori/midori-view.h
+++ b/midori/midori-view.h
@@ -113,15 +113,6 @@ midori_view_has_selection              (MidoriView*        view);
 const gchar*
 midori_view_get_selected_text          (MidoriView*        view);
 
-gboolean
-midori_view_can_cut_clipboard          (MidoriView*        view);
-
-gboolean
-midori_view_can_copy_clipboard         (MidoriView*        view);
-
-gboolean
-midori_view_can_paste_clipboard        (MidoriView*        view);
-
 GtkWidget*
 midori_view_get_proxy_menu_item        (MidoriView*        view);
 
@@ -163,9 +154,6 @@ void
 midori_view_reload                     (MidoriView*        view,
                                         gboolean           from_cache);
 
-void
-midori_view_stop_loading               (MidoriView*        view);
-
 gboolean
 midori_view_can_go_back                (MidoriView*        view);
 
@@ -198,32 +186,17 @@ midori_view_print                      (MidoriView*        view);
 gboolean
 midori_view_can_view_source            (MidoriView*        view);
 
-gboolean
-midori_view_can_save                   (MidoriView*        view);
-
 gchar*
 midori_view_save_source                (MidoriView*        view,
                                         const gchar*       uri,
                                         const gchar*       outfile);
 
 void
-midori_view_unmark_text_matches        (MidoriView*        view);
-
-void
 midori_view_search_text                (MidoriView*        view,
                                         const gchar*       text,
                                         gboolean           case_sensitive,
                                         gboolean           forward);
 
-void
-midori_view_mark_text_matches          (MidoriView*        view,
-                                        const gchar*       text,
-                                        gboolean           case_sensitive);
-
-void
-midori_view_set_highlight_text_matches (MidoriView*        view,
-                                        gboolean           highlight);
-
 gboolean
 midori_view_execute_script             (MidoriView*        view,
                                         const gchar*       script,
diff --git a/midori/midori.vapi b/midori/midori.vapi
index 68ca4f7..2fa7c02 100644
--- a/midori/midori.vapi
+++ b/midori/midori.vapi
@@ -133,7 +133,6 @@ namespace Midori {
     [CCode (cheader_filename = "midori/midori.h")]
     public class View : Tab {
         [CCode (type = "GtkWidget*")]
-        public View (GLib.Object net);
         public View.with_title (string? title=null, WebSettings? settings=null
             , bool append=false);
         public void set_uri (string uri);
@@ -149,11 +148,8 @@ namespace Midori {
         public Gtk.Label get_proxy_tab_label ();
         public unowned Katze.Item get_proxy_item ();
         public void search_text (string text, bool case_sensitive, bool forward);
-        public void mark_text_matches (string text, bool case_sensitive);
-        public void set_highlight_text_matches (bool highlight);
         public bool execute_script (string script, out string exception);
         public Gdk.Pixbuf get_snapshot (int width, int height);
-        public unowned WebKit.WebView get_web_view ();
         public void populate_popup (Gtk.Menu menu, bool manual);
         public void reload (bool from_cache);
 
diff --git a/tests/tab.vala b/tests/tab.vala
index b217fed..39432ee 100644
--- a/tests/tab.vala
+++ b/tests/tab.vala
@@ -89,18 +89,21 @@ void tab_special () {
     assert (tab.is_blank ());
     assert (!tab.can_view_source ());
     /* FIXME assert (tab.special); */
+    assert (!tab.can_save ());
 
     tab.set_uri ("error:nodocs file:///some/docs/path");
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     assert (!tab.is_blank ());
     assert (tab.can_view_source ());
     /* FIXME assert (tab.special); */
+    /* FIXME assert (!tab.can_save ()); */
 
     tab.set_uri ("http://.invalid");
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     assert (!tab.is_blank ());
     assert (!tab.can_view_source ());
     assert (tab.special);
+    assert (!tab.can_save ());
 
     var item = tab.get_proxy_item ();
     item.set_meta_integer ("delay", Midori.Delay.UNDELAYED);
@@ -108,6 +111,7 @@ void tab_special () {
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     /* FIXME assert (!tab.can_view_source ()); */
     /* FIXME assert (tab.special); */
+    /* FIXME assert (!tab.can_save ()); */
 
     /* FIXME use an HTTP URI that's available even offline */
     tab.set_uri ("http://example.com");
@@ -115,6 +119,7 @@ void tab_special () {
     assert (!tab.is_blank ());
     assert (tab.can_view_source ());
     assert (!tab.special);
+    assert (tab.can_save ());
 }
 
 void main (string[] args) {
diff --git a/toolbars/midori-findbar.c b/toolbars/midori-findbar.c
index 3c61795..a0b5076 100644
--- a/toolbars/midori-findbar.c
+++ b/toolbars/midori-findbar.c
@@ -68,7 +68,7 @@ midori_findbar_done (MidoriFindbar* findbar)
     MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
     GtkWidget* view = midori_browser_get_current_tab (browser);
 
-    midori_view_unmark_text_matches (MIDORI_VIEW (view));
+    midori_tab_unmark_text_matches (MIDORI_TAB (view));
     gtk_widget_hide (GTK_WIDGET (findbar));
     findbar->find_typing = FALSE;
     gtk_window_set_focus (GTK_WINDOW (browser), view);
@@ -207,7 +207,7 @@ midori_findbar_preedit_changed_cb (GtkWidget*     entry,
 {
     MidoriBrowser* browser = midori_browser_get_for_widget (entry);
     GtkWidget* view = midori_browser_get_current_tab (browser);
-    midori_view_unmark_text_matches (MIDORI_VIEW (view));
+    midori_tab_unmark_text_matches (MIDORI_TAB (view));
     if (g_utf8_strlen (preedit, -1) >= 1)
     {
         midori_findbar_set_icon (findbar, GTK_ICON_ENTRY_SECONDARY, STOCK_EDIT_CLEAR);
@@ -242,7 +242,7 @@ midori_findbar_highlight_toggled_cb (GtkToggleToolButton* toolitem,
     MidoriBrowser* browser = midori_browser_get_for_widget (GTK_WIDGET (findbar));
     GtkWidget* view = midori_browser_get_current_tab (browser);
     gboolean highlight = gtk_toggle_tool_button_get_active (toolitem);
-    midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
+    midori_tab_set_highlight_text_matches (MIDORI_TAB (view), highlight);
 }
 
 static void
@@ -365,10 +365,10 @@ midori_findbar_search_text (MidoriFindbar* findbar,
     {
         text = gtk_entry_get_text (GTK_ENTRY (findbar->find_text));
         case_sensitive = midori_findbar_case_sensitive (findbar);
-        midori_view_mark_text_matches (MIDORI_VIEW (view), text, case_sensitive);
+        midori_tab_mark_text_matches (MIDORI_TAB (view), text, case_sensitive);
         highlight = gtk_toggle_tool_button_get_active (
             GTK_TOGGLE_TOOL_BUTTON (findbar->find_highlight));
-        midori_view_set_highlight_text_matches (MIDORI_VIEW (view), highlight);
+        midori_tab_set_highlight_text_matches (MIDORI_TAB (view), highlight);
     }
 }
 


More information about the Xfce4-commits mailing list