Replace window-object-cleared with context-ready
Introduce MidoriBrowser::load-status and also midori_view_execute_script while we are at it.
This commit is contained in:
parent
f2e6e3579a
commit
4b06ec3c1f
5 changed files with 110 additions and 172 deletions
|
@ -1033,6 +1033,7 @@ midori_app_add_browser_cb (MidoriApp* app,
|
||||||
gtk_widget_show (toolbar);
|
gtk_widget_show (toolbar);
|
||||||
midori_panel_append_page (MIDORI_PANEL (panel), addon, toolbar,
|
midori_panel_append_page (MIDORI_PANEL (panel), addon, toolbar,
|
||||||
STOCK_SCRIPTS, _("Userscripts"));
|
STOCK_SCRIPTS, _("Userscripts"));
|
||||||
|
|
||||||
/* Userstyles */
|
/* Userstyles */
|
||||||
addon = midori_addons_new (MIDORI_ADDON_USER_STYLES, GTK_WIDGET (browser));
|
addon = midori_addons_new (MIDORI_ADDON_USER_STYLES, GTK_WIDGET (browser));
|
||||||
gtk_widget_show (addon);
|
gtk_widget_show (addon);
|
||||||
|
@ -1043,8 +1044,7 @@ midori_app_add_browser_cb (MidoriApp* app,
|
||||||
|
|
||||||
/* Extensions */
|
/* Extensions */
|
||||||
#if 0
|
#if 0
|
||||||
addon = midori_addons_new (MIDORI_ADDON_EXTENSIONS,
|
addon = midori_addons_new (MIDORI_ADDON_EXTENSIONS);
|
||||||
katze_object_get_object (app, "extensions"), NULL);
|
|
||||||
gtk_widget_show (addon);
|
gtk_widget_show (addon);
|
||||||
toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (addon));
|
toolbar = midori_addons_get_toolbar (MIDORI_ADDONS (addon));
|
||||||
gtk_widget_show (toolbar);
|
gtk_widget_show (toolbar);
|
||||||
|
|
|
@ -813,11 +813,9 @@ _js_style_from_file (JSContextRef js_context,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_web_widget_window_object_cleared_cb (GtkWidget* web_widget,
|
midori_web_widget_context_ready_cb (GtkWidget* web_widget,
|
||||||
WebKitWebFrame* web_frame,
|
JSGlobalContextRef js_context,
|
||||||
JSGlobalContextRef js_context,
|
MidoriAddons* addons)
|
||||||
JSObjectRef js_window,
|
|
||||||
MidoriAddons* addons)
|
|
||||||
{
|
{
|
||||||
const gchar* uri;
|
const gchar* uri;
|
||||||
GSList* elements;
|
GSList* elements;
|
||||||
|
@ -826,7 +824,7 @@ midori_web_widget_window_object_cleared_cb (GtkWidget* web_widget,
|
||||||
gchar* exception;
|
gchar* exception;
|
||||||
gchar* message;
|
gchar* message;
|
||||||
|
|
||||||
uri = webkit_web_frame_get_uri (web_frame);
|
uri = katze_object_get_string (web_widget, "uri");
|
||||||
if (!uri)
|
if (!uri)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -904,8 +902,8 @@ midori_addons_new (MidoriAddonKind kind,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (kind == MIDORI_ADDON_USER_SCRIPTS || kind == MIDORI_ADDON_USER_STYLES)
|
if (kind == MIDORI_ADDON_USER_SCRIPTS || kind == MIDORI_ADDON_USER_STYLES)
|
||||||
g_signal_connect (addons->web_widget, "window-object-cleared",
|
g_signal_connect (addons->web_widget, "context-ready",
|
||||||
G_CALLBACK (midori_web_widget_window_object_cleared_cb), addons);
|
G_CALLBACK (midori_web_widget_context_ready_cb), addons);
|
||||||
|
|
||||||
midori_addons_update_elements (addons);
|
midori_addons_update_elements (addons);
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ enum
|
||||||
PROP_PANEL,
|
PROP_PANEL,
|
||||||
PROP_URI,
|
PROP_URI,
|
||||||
PROP_TAB,
|
PROP_TAB,
|
||||||
|
PROP_LOAD_STATUS,
|
||||||
PROP_STATUSBAR,
|
PROP_STATUSBAR,
|
||||||
PROP_STATUSBAR_TEXT,
|
PROP_STATUSBAR_TEXT,
|
||||||
PROP_SETTINGS,
|
PROP_SETTINGS,
|
||||||
|
@ -100,12 +101,11 @@ enum
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
WINDOW_OBJECT_CLEARED,
|
|
||||||
NEW_WINDOW,
|
NEW_WINDOW,
|
||||||
|
|
||||||
ADD_TAB,
|
ADD_TAB,
|
||||||
REMOVE_TAB,
|
REMOVE_TAB,
|
||||||
ACTIVATE_ACTION,
|
ACTIVATE_ACTION,
|
||||||
|
CONTEXT_READY,
|
||||||
QUIT,
|
QUIT,
|
||||||
|
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
|
@ -392,6 +392,8 @@ midori_view_notify_load_status_cb (GtkWidget* view,
|
||||||
_midori_browser_update_interface (browser);
|
_midori_browser_update_interface (browser);
|
||||||
_midori_browser_set_statusbar_text (browser, NULL);
|
_midori_browser_set_statusbar_text (browser, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_object_notify (G_OBJECT (browser), "load-status");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -404,14 +406,11 @@ midori_view_notify_progress_cb (GtkWidget* view,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_view_window_object_cleared_cb (GtkWidget* view,
|
midori_view_context_ready_cb (GtkWidget* view,
|
||||||
WebKitWebFrame* web_frame,
|
JSContextRef js_context,
|
||||||
JSContextRef js_context,
|
MidoriBrowser* browser)
|
||||||
JSObjectRef js_window,
|
|
||||||
MidoriBrowser* browser)
|
|
||||||
{
|
{
|
||||||
g_signal_emit (browser, signals[WINDOW_OBJECT_CLEARED], 0,
|
g_signal_emit (browser, signals[CONTEXT_READY], 0, js_context);
|
||||||
web_frame, js_context, js_window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -866,8 +865,8 @@ _midori_browser_add_tab (MidoriBrowser* browser,
|
||||||
midori_view_notify_load_status_cb, browser,
|
midori_view_notify_load_status_cb, browser,
|
||||||
"signal::notify::progress",
|
"signal::notify::progress",
|
||||||
midori_view_notify_progress_cb, browser,
|
midori_view_notify_progress_cb, browser,
|
||||||
"signal::window-object-cleared",
|
"signal::context-ready",
|
||||||
midori_view_window_object_cleared_cb, browser,
|
midori_view_context_ready_cb, browser,
|
||||||
/* "signal::news-feed-ready",
|
/* "signal::news-feed-ready",
|
||||||
midori_view_news_feed_ready_cb, browser, */
|
midori_view_news_feed_ready_cb, browser, */
|
||||||
"signal::notify::title",
|
"signal::notify::title",
|
||||||
|
@ -930,64 +929,12 @@ _midori_browser_quit (MidoriBrowser* browser)
|
||||||
/* Nothing to do */
|
/* Nothing to do */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
midori_cclosure_marshal_VOID__OBJECT_POINTER_POINTER (GClosure* closure,
|
|
||||||
GValue* return_value,
|
|
||||||
guint n_param_values,
|
|
||||||
const GValue* param_values,
|
|
||||||
gpointer invocation_hint,
|
|
||||||
gpointer marshal_data)
|
|
||||||
{
|
|
||||||
typedef gboolean(*GMarshalFunc_VOID__OBJECT_POINTER_POINTER) (gpointer data1,
|
|
||||||
gpointer arg_1,
|
|
||||||
gpointer arg_2,
|
|
||||||
gpointer arg_3,
|
|
||||||
gpointer data2);
|
|
||||||
register GMarshalFunc_VOID__OBJECT_POINTER_POINTER callback;
|
|
||||||
register GCClosure* cc = (GCClosure*) closure;
|
|
||||||
register gpointer data1, data2;
|
|
||||||
|
|
||||||
g_return_if_fail (n_param_values == 4);
|
|
||||||
|
|
||||||
if (G_CCLOSURE_SWAP_DATA (closure))
|
|
||||||
{
|
|
||||||
data1 = closure->data;
|
|
||||||
data2 = g_value_peek_pointer (param_values + 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data1 = g_value_peek_pointer (param_values + 0);
|
|
||||||
data2 = closure->data;
|
|
||||||
}
|
|
||||||
callback = (GMarshalFunc_VOID__OBJECT_POINTER_POINTER) (marshal_data
|
|
||||||
? marshal_data : cc->callback);
|
|
||||||
|
|
||||||
callback (data1,
|
|
||||||
g_value_get_object (param_values + 1),
|
|
||||||
g_value_get_pointer (param_values + 2),
|
|
||||||
g_value_get_pointer (param_values + 3),
|
|
||||||
data2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_browser_class_init (MidoriBrowserClass* class)
|
midori_browser_class_init (MidoriBrowserClass* class)
|
||||||
{
|
{
|
||||||
GObjectClass* gobject_class;
|
GObjectClass* gobject_class;
|
||||||
GParamFlags flags;
|
GParamFlags flags;
|
||||||
|
|
||||||
signals[WINDOW_OBJECT_CLEARED] = g_signal_new (
|
|
||||||
"window-object-cleared",
|
|
||||||
G_TYPE_FROM_CLASS (class),
|
|
||||||
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
||||||
G_STRUCT_OFFSET (MidoriBrowserClass, window_object_cleared),
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
midori_cclosure_marshal_VOID__OBJECT_POINTER_POINTER,
|
|
||||||
G_TYPE_NONE, 3,
|
|
||||||
WEBKIT_TYPE_WEB_FRAME,
|
|
||||||
G_TYPE_POINTER,
|
|
||||||
G_TYPE_POINTER);
|
|
||||||
|
|
||||||
signals[NEW_WINDOW] = g_signal_new (
|
signals[NEW_WINDOW] = g_signal_new (
|
||||||
"new-window",
|
"new-window",
|
||||||
G_TYPE_FROM_CLASS (class),
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
@ -1032,6 +979,17 @@ midori_browser_class_init (MidoriBrowserClass* class)
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
|
signals[CONTEXT_READY] = g_signal_new (
|
||||||
|
"context-ready",
|
||||||
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
g_cclosure_marshal_VOID__POINTER,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
G_TYPE_POINTER);
|
||||||
|
|
||||||
signals[QUIT] = g_signal_new (
|
signals[QUIT] = g_signal_new (
|
||||||
"quit",
|
"quit",
|
||||||
G_TYPE_FROM_CLASS (class),
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
@ -1109,6 +1067,16 @@ midori_browser_class_init (MidoriBrowserClass* class)
|
||||||
GTK_TYPE_WIDGET,
|
GTK_TYPE_WIDGET,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_LOAD_STATUS,
|
||||||
|
g_param_spec_enum (
|
||||||
|
"load-status",
|
||||||
|
"Load Status",
|
||||||
|
"The current load status",
|
||||||
|
MIDORI_TYPE_LOAD_STATUS,
|
||||||
|
MIDORI_LOAD_FINISHED,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_STATUSBAR,
|
PROP_STATUSBAR,
|
||||||
g_param_spec_object (
|
g_param_spec_object (
|
||||||
|
|
|
@ -15,12 +15,11 @@
|
||||||
|
|
||||||
#include "midori-view.h"
|
#include "midori-view.h"
|
||||||
#include "midori-source.h"
|
#include "midori-source.h"
|
||||||
|
|
||||||
#include "midori-stock.h"
|
#include "midori-stock.h"
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "sokoke.h"
|
#include "sokoke.h"
|
||||||
#include "gjs.h"
|
/* #include "gjs.h" */
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -48,7 +47,7 @@ struct _MidoriView
|
||||||
gchar* selected_text;
|
gchar* selected_text;
|
||||||
MidoriWebSettings* settings;
|
MidoriWebSettings* settings;
|
||||||
GtkWidget* web_view;
|
GtkWidget* web_view;
|
||||||
gboolean window_object_cleared;
|
/* KatzeArray* news_feeds; */
|
||||||
|
|
||||||
gchar* download_manager;
|
gchar* download_manager;
|
||||||
gboolean middle_click_opens_selection;
|
gboolean middle_click_opens_selection;
|
||||||
|
@ -100,6 +99,7 @@ enum
|
||||||
PROP_LOAD_STATUS,
|
PROP_LOAD_STATUS,
|
||||||
PROP_PROGRESS,
|
PROP_PROGRESS,
|
||||||
PROP_ZOOM_LEVEL,
|
PROP_ZOOM_LEVEL,
|
||||||
|
/* PROP_NEWS_FEEDS, */
|
||||||
PROP_STATUSBAR_TEXT,
|
PROP_STATUSBAR_TEXT,
|
||||||
PROP_SETTINGS,
|
PROP_SETTINGS,
|
||||||
PROP_NET
|
PROP_NET
|
||||||
|
@ -108,8 +108,8 @@ enum
|
||||||
enum {
|
enum {
|
||||||
ACTIVATE_ACTION,
|
ACTIVATE_ACTION,
|
||||||
CONSOLE_MESSAGE,
|
CONSOLE_MESSAGE,
|
||||||
|
CONTEXT_READY,
|
||||||
ATTACH_INSPECTOR,
|
ATTACH_INSPECTOR,
|
||||||
WINDOW_OBJECT_CLEARED,
|
|
||||||
NEW_TAB,
|
NEW_TAB,
|
||||||
NEW_WINDOW,
|
NEW_WINDOW,
|
||||||
SEARCH_TEXT,
|
SEARCH_TEXT,
|
||||||
|
@ -215,45 +215,6 @@ midori_cclosure_marshal_VOID__STRING_INT_STRING (GClosure* closure,
|
||||||
data2);
|
data2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
midori_cclosure_marshal_VOID__OBJECT_POINTER_POINTER (GClosure* closure,
|
|
||||||
GValue* return_value,
|
|
||||||
guint n_param_values,
|
|
||||||
const GValue* param_values,
|
|
||||||
gpointer invocation_hint,
|
|
||||||
gpointer marshal_data)
|
|
||||||
{
|
|
||||||
typedef gboolean(*GMarshalFunc_VOID__OBJECT_POINTER_POINTER) (gpointer data1,
|
|
||||||
gpointer arg_1,
|
|
||||||
gpointer arg_2,
|
|
||||||
gpointer arg_3,
|
|
||||||
gpointer data2);
|
|
||||||
register GMarshalFunc_VOID__OBJECT_POINTER_POINTER callback;
|
|
||||||
register GCClosure* cc = (GCClosure*) closure;
|
|
||||||
register gpointer data1, data2;
|
|
||||||
|
|
||||||
g_return_if_fail (n_param_values == 4);
|
|
||||||
|
|
||||||
if (G_CCLOSURE_SWAP_DATA (closure))
|
|
||||||
{
|
|
||||||
data1 = closure->data;
|
|
||||||
data2 = g_value_peek_pointer (param_values + 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
data1 = g_value_peek_pointer (param_values + 0);
|
|
||||||
data2 = closure->data;
|
|
||||||
}
|
|
||||||
callback = (GMarshalFunc_VOID__OBJECT_POINTER_POINTER) (marshal_data
|
|
||||||
? marshal_data : cc->callback);
|
|
||||||
|
|
||||||
callback (data1,
|
|
||||||
g_value_get_object (param_values + 1),
|
|
||||||
g_value_get_pointer (param_values + 2),
|
|
||||||
g_value_get_pointer (param_values + 3),
|
|
||||||
data2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_view_class_init (MidoriViewClass* class)
|
midori_view_class_init (MidoriViewClass* class)
|
||||||
{
|
{
|
||||||
|
@ -284,6 +245,17 @@ midori_view_class_init (MidoriViewClass* class)
|
||||||
G_TYPE_INT,
|
G_TYPE_INT,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
|
signals[CONTEXT_READY] = g_signal_new (
|
||||||
|
"context-ready",
|
||||||
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
g_cclosure_marshal_VOID__POINTER,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
G_TYPE_POINTER);
|
||||||
|
|
||||||
signals[ATTACH_INSPECTOR] = g_signal_new (
|
signals[ATTACH_INSPECTOR] = g_signal_new (
|
||||||
"attach-inspector",
|
"attach-inspector",
|
||||||
G_TYPE_FROM_CLASS (class),
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
@ -295,19 +267,6 @@ midori_view_class_init (MidoriViewClass* class)
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
GTK_TYPE_WIDGET);
|
GTK_TYPE_WIDGET);
|
||||||
|
|
||||||
signals[WINDOW_OBJECT_CLEARED] = g_signal_new (
|
|
||||||
"window-object-cleared",
|
|
||||||
G_TYPE_FROM_CLASS (class),
|
|
||||||
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
midori_cclosure_marshal_VOID__OBJECT_POINTER_POINTER,
|
|
||||||
G_TYPE_NONE, 3,
|
|
||||||
WEBKIT_TYPE_WEB_FRAME,
|
|
||||||
G_TYPE_POINTER,
|
|
||||||
G_TYPE_POINTER);
|
|
||||||
|
|
||||||
signals[NEW_TAB] = g_signal_new (
|
signals[NEW_TAB] = g_signal_new (
|
||||||
"new-tab",
|
"new-tab",
|
||||||
G_TYPE_FROM_CLASS (class),
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
@ -428,6 +387,15 @@ midori_view_class_init (MidoriViewClass* class)
|
||||||
1.0f,
|
1.0f,
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/* g_object_class_install_property (gobject_class,
|
||||||
|
PROP_NEWS_FEEDS,
|
||||||
|
g_param_spec_object (
|
||||||
|
"news-feeds",
|
||||||
|
"News Feeds",
|
||||||
|
"The list of available news feeds",
|
||||||
|
KATZE_TYPE_ARRAY,
|
||||||
|
G_PARAM_READWRITE)); */
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_STATUSBAR_TEXT,
|
PROP_STATUSBAR_TEXT,
|
||||||
g_param_spec_string (
|
g_param_spec_string (
|
||||||
|
@ -506,8 +474,6 @@ webkit_web_view_load_started_cb (WebKitWebView* web_view,
|
||||||
WebKitWebFrame* web_frame,
|
WebKitWebFrame* web_frame,
|
||||||
MidoriView* view)
|
MidoriView* view)
|
||||||
{
|
{
|
||||||
view->window_object_cleared = FALSE;
|
|
||||||
|
|
||||||
view->load_status = MIDORI_LOAD_PROVISIONAL;
|
view->load_status = MIDORI_LOAD_PROVISIONAL;
|
||||||
g_object_notify (G_OBJECT (view), "load-status");
|
g_object_notify (G_OBJECT (view), "load-status");
|
||||||
|
|
||||||
|
@ -546,17 +512,11 @@ webkit_web_view_progress_changed_cb (WebKitWebView* web_view,
|
||||||
g_object_notify (G_OBJECT (view), "progress");
|
g_object_notify (G_OBJECT (view), "progress");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*static void
|
||||||
static void
|
|
||||||
gjs_value_links_foreach_cb (GjsValue* link,
|
gjs_value_links_foreach_cb (GjsValue* link,
|
||||||
MidoriView* view)
|
MidoriView* view)
|
||||||
{
|
{
|
||||||
const gchar* type;
|
const gchar* type;
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
const gchar* rel;
|
|
||||||
GFile* icon_file;
|
|
||||||
GIcon* icon;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gjs_value_is_object (link) && gjs_value_has_attribute (link, "href"))
|
if (gjs_value_is_object (link) && gjs_value_has_attribute (link, "href"))
|
||||||
{
|
{
|
||||||
|
@ -568,29 +528,14 @@ gjs_value_links_foreach_cb (GjsValue* link,
|
||||||
|| !strcmp (type, "application/atom+xml"))
|
|| !strcmp (type, "application/atom+xml"))
|
||||||
{
|
{
|
||||||
katze_array_add_item (view->news_feeds, link);
|
katze_array_add_item (view->news_feeds, link);
|
||||||
g_signal_emit_by_name (view, "news-feed-ready",
|
g_signal_emit (view, signals[NEWS_FEED_READY],
|
||||||
gjs_value_get_attribute_string (link, "href"), type,
|
gjs_value_get_attribute_string (link, "href"), type,
|
||||||
gjs_value_has_attribute (link, "title")
|
gjs_value_has_attribute (link, "title")
|
||||||
? gjs_value_get_attribute_string (link, "title") : NULL);
|
? gjs_value_get_attribute_string (link, "title") : NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
|
||||||
if (gjs_value_has_attribute (link, "rel"))
|
|
||||||
{
|
|
||||||
rel = gjs_value_get_attribute_string (link, "rel");
|
|
||||||
if (!strcmp (rel, "icon") || !strcmp (rel, "shortcut icon"))
|
|
||||||
{
|
|
||||||
icon_file = g_file_new_for_uri (
|
|
||||||
gjs_value_get_attribute_string (link, "href"));
|
|
||||||
icon = g_file_icon_new (icon_file);
|
|
||||||
g_loadable_icon_load_async (G_LOADABLE_ICON (icon),
|
|
||||||
0, NULL, (GAsyncReadyCallback)loadable_icon_finish_cb, view);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
*/
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
webkit_web_frame_load_done_cb (WebKitWebFrame* web_frame,
|
webkit_web_frame_load_done_cb (WebKitWebFrame* web_frame,
|
||||||
|
@ -598,11 +543,6 @@ webkit_web_frame_load_done_cb (WebKitWebFrame* web_frame,
|
||||||
MidoriView* view)
|
MidoriView* view)
|
||||||
{
|
{
|
||||||
gchar* data;
|
gchar* data;
|
||||||
/*JSContextRef js_context;
|
|
||||||
JSValueRef js_window;
|
|
||||||
GjsValue* value;
|
|
||||||
GjsValue* document;
|
|
||||||
GjsValue* links; */
|
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
|
@ -622,16 +562,6 @@ webkit_web_frame_load_done_cb (WebKitWebFrame* web_frame,
|
||||||
g_free (data);
|
g_free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* js_context = webkit_web_frame_get_global_context (web_frame);
|
|
||||||
value = gjs_value_new (js_context, NULL);
|
|
||||||
document = gjs_value_get_by_name (value, "document");
|
|
||||||
links = gjs_value_get_elements_by_tag_name (document, "link");
|
|
||||||
katze_array_clear (web_view->news_feeds);
|
|
||||||
gjs_value_foreach (links, (GjsCallback)gjs_value_links_foreach_cb, web_view);
|
|
||||||
g_object_unref (links);
|
|
||||||
g_object_unref (document);
|
|
||||||
g_object_unref (value); */
|
|
||||||
|
|
||||||
view->load_status = MIDORI_LOAD_FINISHED;
|
view->load_status = MIDORI_LOAD_FINISHED;
|
||||||
g_object_notify (G_OBJECT (view), "load-status");
|
g_object_notify (G_OBJECT (view), "load-status");
|
||||||
}
|
}
|
||||||
|
@ -641,8 +571,23 @@ webkit_web_view_load_finished_cb (WebKitWebView* web_view,
|
||||||
WebKitWebFrame* web_frame,
|
WebKitWebFrame* web_frame,
|
||||||
MidoriView* view)
|
MidoriView* view)
|
||||||
{
|
{
|
||||||
|
/* JSContextRef js_context;
|
||||||
|
GjsValue* value;
|
||||||
|
GjsValue* document;
|
||||||
|
GjsValue* links; */
|
||||||
|
|
||||||
view->progress = 1.0;
|
view->progress = 1.0;
|
||||||
g_object_notify (G_OBJECT (view), "progress");
|
g_object_notify (G_OBJECT (view), "progress");
|
||||||
|
|
||||||
|
/* js_context = webkit_web_frame_get_global_context (web_frame);
|
||||||
|
value = gjs_value_new (js_context, NULL);
|
||||||
|
document = gjs_value_get_by_name (value, "document");
|
||||||
|
links = gjs_value_get_elements_by_tag_name (document, "link");
|
||||||
|
katze_array_clear (view->news_feeds);
|
||||||
|
gjs_value_foreach (links, (GjsCallback)gjs_value_links_foreach_cb, view);
|
||||||
|
g_object_unref (links);
|
||||||
|
g_object_unref (document);
|
||||||
|
g_object_unref (value); */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1000,8 +945,7 @@ webkit_web_view_window_object_cleared_cb (GtkWidget* web_view,
|
||||||
JSObjectRef js_window,
|
JSObjectRef js_window,
|
||||||
MidoriView* view)
|
MidoriView* view)
|
||||||
{
|
{
|
||||||
g_signal_emit (view, signals[WINDOW_OBJECT_CLEARED], 0,
|
g_signal_emit (view, signals[CONTEXT_READY], 0, js_context);
|
||||||
web_frame, js_context, js_window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2154,3 +2098,26 @@ midori_view_set_highlight_text_matches (MidoriView* view,
|
||||||
webkit_web_view_set_highlight_text_matches (
|
webkit_web_view_set_highlight_text_matches (
|
||||||
WEBKIT_WEB_VIEW (view->web_view), highlight);
|
WEBKIT_WEB_VIEW (view->web_view), highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* midori_view_execute_script
|
||||||
|
* @view: a #MidoriView
|
||||||
|
* @script: script code
|
||||||
|
* @exception: location to store an exception message
|
||||||
|
*
|
||||||
|
* Execute a script on the view.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the script was executed successfully
|
||||||
|
**/
|
||||||
|
gboolean
|
||||||
|
midori_view_execute_script (MidoriView* view,
|
||||||
|
const gchar* script,
|
||||||
|
gchar** exception)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MIDORI_IS_VIEW (view), FALSE);
|
||||||
|
g_return_val_if_fail (script != NULL, FALSE);
|
||||||
|
|
||||||
|
/* FIXME Actually store exception. */
|
||||||
|
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (view->web_view), script);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
|
@ -171,6 +171,11 @@ void
|
||||||
midori_view_set_highlight_text_matches (MidoriView* view,
|
midori_view_set_highlight_text_matches (MidoriView* view,
|
||||||
gboolean highlight);
|
gboolean highlight);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
midori_view_execute_script (MidoriView* view,
|
||||||
|
const gchar* script,
|
||||||
|
gchar** exception);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __MIDORI_VIEW_H__ */
|
#endif /* __MIDORI_VIEW_H__ */
|
||||||
|
|
Loading…
Reference in a new issue