Revamp the loading signals of MidoriWebView
This commit is contained in:
parent
6be7e2ec92
commit
28141e8bac
3 changed files with 152 additions and 206 deletions
|
@ -241,7 +241,8 @@ _midori_browser_update_interface (MidoriBrowser* browser)
|
||||||
widget = midori_browser_get_current_tab (browser);
|
widget = midori_browser_get_current_tab (browser);
|
||||||
web_view = widget && MIDORI_IS_WEB_VIEW (widget) ? widget : NULL;
|
web_view = widget && MIDORI_IS_WEB_VIEW (widget) ? widget : NULL;
|
||||||
loading = web_view != NULL
|
loading = web_view != NULL
|
||||||
&& midori_web_view_is_loading (MIDORI_WEB_VIEW (web_view));
|
&& midori_web_view_get_load_status (MIDORI_WEB_VIEW (web_view))
|
||||||
|
!= MIDORI_LOAD_FINISHED;
|
||||||
|
|
||||||
_action_set_sensitive (browser, "Reload", web_view != NULL && !loading);
|
_action_set_sensitive (browser, "Reload", web_view != NULL && !loading);
|
||||||
_action_set_sensitive (browser, "Stop", web_view != NULL && loading);
|
_action_set_sensitive (browser, "Stop", web_view != NULL && loading);
|
||||||
|
@ -329,22 +330,26 @@ _midori_browser_set_current_page_smartly (MidoriBrowser* browser,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_midori_browser_update_progress (MidoriBrowser* browser,
|
_midori_browser_update_progress (MidoriBrowser* browser,
|
||||||
gint progress)
|
MidoriWebView* web_view)
|
||||||
{
|
{
|
||||||
if (progress > -1)
|
gdouble progress;
|
||||||
|
gchar* message;
|
||||||
|
|
||||||
|
progress = midori_web_view_get_progress (web_view);
|
||||||
|
if (progress > 0.0)
|
||||||
{
|
{
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (browser->progressbar),
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (browser->progressbar),
|
||||||
progress ? progress / 100.0 : 0);
|
progress);
|
||||||
gchar* message = g_strdup_printf (_("%d%% loaded"), progress);
|
message = g_strdup_printf (_("%d%% loaded"), (gint)(progress * 100));
|
||||||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
||||||
message);
|
message);
|
||||||
g_free (message);
|
g_free (message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (browser->progressbar));
|
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (browser->progressbar));
|
||||||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (browser->progressbar),
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,54 +365,37 @@ midori_web_view_window_object_cleared_cb (GtkWidget* web_view,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_web_view_load_started_cb (GtkWidget* web_view,
|
midori_web_view_notify_load_status_cb (GtkWidget* web_view,
|
||||||
WebKitWebFrame* web_frame,
|
GParamSpec* pspec,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
|
const gchar* uri;
|
||||||
|
|
||||||
if (web_view == midori_browser_get_current_web_view (browser))
|
if (web_view == midori_browser_get_current_web_view (browser))
|
||||||
{
|
{
|
||||||
|
if (midori_web_view_get_load_status (MIDORI_WEB_VIEW (web_view))
|
||||||
|
== MIDORI_LOAD_COMMITTED)
|
||||||
|
{
|
||||||
|
uri = midori_web_view_get_display_uri (MIDORI_WEB_VIEW (web_view));
|
||||||
|
midori_location_entry_set_text (MIDORI_LOCATION_ENTRY (
|
||||||
|
browser->location), uri);
|
||||||
|
gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (
|
||||||
|
gtk_bin_get_child (GTK_BIN (browser->location))),
|
||||||
|
GTK_ICON_ENTRY_SECONDARY, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
_midori_browser_update_interface (browser);
|
_midori_browser_update_interface (browser);
|
||||||
_midori_browser_set_statusbar_text (browser, NULL);
|
_midori_browser_set_statusbar_text (browser, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_web_view_progress_started_cb (GtkWidget* web_view,
|
midori_web_view_notify_progress_cb (GtkWidget* web_view,
|
||||||
guint progress,
|
GParamSpec* pspec,
|
||||||
MidoriBrowser* browser)
|
MidoriBrowser* browser)
|
||||||
{
|
{
|
||||||
if (web_view == midori_browser_get_current_web_view (browser))
|
if (web_view == midori_browser_get_current_web_view (browser))
|
||||||
_midori_browser_update_progress (browser, progress);
|
_midori_browser_update_progress (browser, MIDORI_WEB_VIEW (web_view));
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
midori_web_view_progress_changed_cb (GtkWidget* web_view,
|
|
||||||
guint progress,
|
|
||||||
MidoriBrowser* browser)
|
|
||||||
{
|
|
||||||
if (web_view == midori_browser_get_current_web_view (browser))
|
|
||||||
_midori_browser_update_progress (browser, progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
midori_web_view_progress_done_cb (GtkWidget* web_view,
|
|
||||||
guint progress,
|
|
||||||
MidoriBrowser* browser)
|
|
||||||
{
|
|
||||||
if (web_view == midori_browser_get_current_web_view (browser))
|
|
||||||
_midori_browser_update_progress (browser, progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
midori_web_view_load_done_cb (GtkWidget* web_view,
|
|
||||||
WebKitWebFrame* web_frame,
|
|
||||||
MidoriBrowser* browser)
|
|
||||||
{
|
|
||||||
if (web_view == midori_browser_get_current_web_view (browser))
|
|
||||||
{
|
|
||||||
_midori_browser_update_interface (browser);
|
|
||||||
_midori_browser_set_statusbar_text (browser, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -452,25 +440,6 @@ midori_web_view_element_motion_cb (MidoriWebView* web_View,
|
||||||
_midori_browser_set_statusbar_text (browser, link_uri);
|
_midori_browser_set_statusbar_text (browser, link_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
midori_web_view_load_committed_cb (GtkWidget* web_view,
|
|
||||||
WebKitWebFrame* web_frame,
|
|
||||||
MidoriBrowser* browser)
|
|
||||||
{
|
|
||||||
const gchar* uri;
|
|
||||||
|
|
||||||
if (web_view == midori_browser_get_current_web_view (browser))
|
|
||||||
{
|
|
||||||
uri = midori_web_view_get_display_uri (MIDORI_WEB_VIEW (web_view));
|
|
||||||
midori_location_entry_set_text (MIDORI_LOCATION_ENTRY (
|
|
||||||
browser->location), uri);
|
|
||||||
_midori_browser_set_statusbar_text (browser, NULL);
|
|
||||||
gtk_icon_entry_set_icon_from_pixbuf (GTK_ICON_ENTRY (
|
|
||||||
gtk_bin_get_child (GTK_BIN (browser->location))),
|
|
||||||
GTK_ICON_ENTRY_SECONDARY, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
midori_web_view_icon_ready_cb (MidoriWebView* web_view,
|
midori_web_view_icon_ready_cb (MidoriWebView* web_view,
|
||||||
GdkPixbuf* icon,
|
GdkPixbuf* icon,
|
||||||
|
@ -943,22 +912,14 @@ _midori_browser_add_tab (MidoriBrowser* browser,
|
||||||
g_object_connect (widget,
|
g_object_connect (widget,
|
||||||
"signal::window-object-cleared",
|
"signal::window-object-cleared",
|
||||||
midori_web_view_window_object_cleared_cb, browser,
|
midori_web_view_window_object_cleared_cb, browser,
|
||||||
"signal::load-started",
|
"signal::notify::progress",
|
||||||
midori_web_view_load_started_cb, browser,
|
midori_web_view_notify_progress_cb, browser,
|
||||||
"signal::load-committed",
|
"signal::notify::mload-status",
|
||||||
midori_web_view_load_committed_cb, browser,
|
midori_web_view_notify_load_status_cb, browser,
|
||||||
"signal::icon-ready",
|
"signal::icon-ready",
|
||||||
midori_web_view_icon_ready_cb, browser,
|
midori_web_view_icon_ready_cb, browser,
|
||||||
"signal::news-feed-ready",
|
"signal::news-feed-ready",
|
||||||
midori_web_view_news_feed_ready_cb, browser,
|
midori_web_view_news_feed_ready_cb, browser,
|
||||||
"signal::progress-started",
|
|
||||||
midori_web_view_progress_started_cb, browser,
|
|
||||||
"signal::progress-changed",
|
|
||||||
midori_web_view_progress_changed_cb, browser,
|
|
||||||
"signal::progress-done",
|
|
||||||
midori_web_view_progress_done_cb, browser,
|
|
||||||
"signal::load-done",
|
|
||||||
midori_web_view_load_done_cb, browser,
|
|
||||||
"signal::notify::title",
|
"signal::notify::title",
|
||||||
midori_web_view_notify_title_cb, browser,
|
midori_web_view_notify_title_cb, browser,
|
||||||
"signal::notify::zoom-level",
|
"signal::notify::zoom-level",
|
||||||
|
@ -2613,6 +2574,8 @@ gtk_notebook_switch_page_cb (GtkWidget* notebook,
|
||||||
g_free (window_title);
|
g_free (window_title);
|
||||||
_midori_browser_set_statusbar_text (browser, NULL);
|
_midori_browser_set_statusbar_text (browser, NULL);
|
||||||
_midori_browser_update_interface (browser);
|
_midori_browser_update_interface (browser);
|
||||||
|
if (MIDORI_IS_WEB_VIEW (widget))
|
||||||
|
_midori_browser_update_progress (browser, MIDORI_WEB_VIEW (widget));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -33,8 +33,8 @@ struct _MidoriWebView
|
||||||
GdkPixbuf* icon;
|
GdkPixbuf* icon;
|
||||||
gchar* uri;
|
gchar* uri;
|
||||||
gchar* title;
|
gchar* title;
|
||||||
gboolean is_loading;
|
gdouble progress;
|
||||||
gint progress;
|
MidoriLoadStatus load_status;
|
||||||
gchar* statusbar_text;
|
gchar* statusbar_text;
|
||||||
gchar* link_uri;
|
gchar* link_uri;
|
||||||
|
|
||||||
|
@ -48,12 +48,31 @@ struct _MidoriWebView
|
||||||
|
|
||||||
G_DEFINE_TYPE (MidoriWebView, midori_web_view, WEBKIT_TYPE_WEB_VIEW)
|
G_DEFINE_TYPE (MidoriWebView, midori_web_view, WEBKIT_TYPE_WEB_VIEW)
|
||||||
|
|
||||||
|
GType
|
||||||
|
midori_load_status_get_type (void)
|
||||||
|
{
|
||||||
|
static GType type = 0;
|
||||||
|
if (!type)
|
||||||
|
{
|
||||||
|
static const GEnumValue values[] = {
|
||||||
|
{ MIDORI_LOAD_PROVISIONAL, "MIDORI_LOAD_PROVISIONAL", N_("Load Provisional") },
|
||||||
|
{ MIDORI_LOAD_COMMITTED, "MIDORI_LOAD_COMMITTED", N_("Load Committed") },
|
||||||
|
{ MIDORI_LOAD_FINISHED, "MIDORI_LOAD_FINISHED", N_("Load Finished") },
|
||||||
|
{ 0, NULL, NULL }
|
||||||
|
};
|
||||||
|
type = g_enum_register_static ("MidoriLoadStatus", values);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
PROP_URI,
|
PROP_URI,
|
||||||
PROP_TITLE,
|
PROP_TITLE,
|
||||||
|
PROP_PROGRESS,
|
||||||
|
PROP_MLOAD_STATUS,
|
||||||
PROP_STATUSBAR_TEXT,
|
PROP_STATUSBAR_TEXT,
|
||||||
PROP_SETTINGS
|
PROP_SETTINGS
|
||||||
};
|
};
|
||||||
|
@ -61,10 +80,6 @@ enum
|
||||||
enum {
|
enum {
|
||||||
ICON_READY,
|
ICON_READY,
|
||||||
NEWS_FEED_READY,
|
NEWS_FEED_READY,
|
||||||
PROGRESS_STARTED,
|
|
||||||
PROGRESS_CHANGED,
|
|
||||||
PROGRESS_DONE,
|
|
||||||
LOAD_DONE,
|
|
||||||
ELEMENT_MOTION,
|
ELEMENT_MOTION,
|
||||||
NEW_TAB,
|
NEW_TAB,
|
||||||
NEW_WINDOW,
|
NEW_WINDOW,
|
||||||
|
@ -154,50 +169,6 @@ midori_web_view_class_init (MidoriWebViewClass* class)
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
signals[PROGRESS_STARTED] = g_signal_new (
|
|
||||||
"progress-started",
|
|
||||||
G_TYPE_FROM_CLASS (class),
|
|
||||||
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
||||||
G_STRUCT_OFFSET (MidoriWebViewClass, progress_started),
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
g_cclosure_marshal_VOID__INT,
|
|
||||||
G_TYPE_NONE, 1,
|
|
||||||
G_TYPE_INT);
|
|
||||||
|
|
||||||
signals[PROGRESS_CHANGED] = g_signal_new (
|
|
||||||
"progress-changed",
|
|
||||||
G_TYPE_FROM_CLASS (class),
|
|
||||||
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
||||||
G_STRUCT_OFFSET (MidoriWebViewClass, progress_changed),
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
g_cclosure_marshal_VOID__INT,
|
|
||||||
G_TYPE_NONE, 1,
|
|
||||||
G_TYPE_INT);
|
|
||||||
|
|
||||||
signals[PROGRESS_DONE] = g_signal_new (
|
|
||||||
"progress-done",
|
|
||||||
G_TYPE_FROM_CLASS (class),
|
|
||||||
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
||||||
G_STRUCT_OFFSET (MidoriWebViewClass, progress_done),
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
g_cclosure_marshal_VOID__INT,
|
|
||||||
G_TYPE_NONE, 1,
|
|
||||||
G_TYPE_INT);
|
|
||||||
|
|
||||||
signals[LOAD_DONE] = g_signal_new (
|
|
||||||
"load-done",
|
|
||||||
G_TYPE_FROM_CLASS (class),
|
|
||||||
(GSignalFlags)(G_SIGNAL_RUN_LAST),
|
|
||||||
G_STRUCT_OFFSET (MidoriWebViewClass, load_done),
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
g_cclosure_marshal_VOID__OBJECT,
|
|
||||||
G_TYPE_NONE, 1,
|
|
||||||
WEBKIT_TYPE_WEB_FRAME);
|
|
||||||
|
|
||||||
signals[ELEMENT_MOTION] = g_signal_new (
|
signals[ELEMENT_MOTION] = g_signal_new (
|
||||||
"element-motion",
|
"element-motion",
|
||||||
G_TYPE_FROM_CLASS (class),
|
G_TYPE_FROM_CLASS (class),
|
||||||
|
@ -238,6 +209,7 @@ midori_web_view_class_init (MidoriWebViewClass* class)
|
||||||
|
|
||||||
GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
|
GParamFlags flags = G_PARAM_READWRITE | G_PARAM_CONSTRUCT;
|
||||||
|
|
||||||
|
if (!g_object_class_find_property (gobject_class, "uri"))
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_URI,
|
PROP_URI,
|
||||||
g_param_spec_string (
|
g_param_spec_string (
|
||||||
|
@ -247,6 +219,7 @@ midori_web_view_class_init (MidoriWebViewClass* class)
|
||||||
"",
|
"",
|
||||||
flags));
|
flags));
|
||||||
|
|
||||||
|
if (!g_object_class_find_property (gobject_class, "title"))
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_TITLE,
|
PROP_TITLE,
|
||||||
g_param_spec_string (
|
g_param_spec_string (
|
||||||
|
@ -256,6 +229,27 @@ midori_web_view_class_init (MidoriWebViewClass* class)
|
||||||
NULL,
|
NULL,
|
||||||
flags));
|
flags));
|
||||||
|
|
||||||
|
if (!g_object_class_find_property (gobject_class, "progress"))
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_PROGRESS,
|
||||||
|
g_param_spec_double (
|
||||||
|
"progress",
|
||||||
|
"Progress",
|
||||||
|
_("The current loading progress"),
|
||||||
|
0.0, 1.0, 0.0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_MLOAD_STATUS,
|
||||||
|
g_param_spec_enum (
|
||||||
|
"mload-status",
|
||||||
|
"Load Status",
|
||||||
|
_("The current loading status"),
|
||||||
|
MIDORI_TYPE_LOAD_STATUS,
|
||||||
|
MIDORI_LOAD_FINISHED,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
if (!g_object_class_find_property (gobject_class, "statusbar-text"))
|
||||||
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 (
|
||||||
|
@ -270,26 +264,17 @@ midori_web_view_class_init (MidoriWebViewClass* class)
|
||||||
"settings");
|
"settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static void
|
static void
|
||||||
webkit_web_view_load_started (MidoriWebView* web_view,
|
webkit_web_view_load_started (MidoriWebView* web_view,
|
||||||
WebKitWebFrame* web_frame)
|
WebKitWebFrame* web_frame)
|
||||||
{
|
{
|
||||||
web_view->is_loading = TRUE;
|
web_view->load_status = MIDORI_LOAD_PROVISIONAL;
|
||||||
web_view->progress = -1;
|
g_object_notify (G_OBJECT (web_view), "mload-status");
|
||||||
katze_throbber_set_animated (KATZE_THROBBER (web_view->tab_icon), TRUE);
|
if (web_view->tab_icon)
|
||||||
}*/
|
katze_throbber_set_animated (KATZE_THROBBER (web_view->tab_icon), TRUE);
|
||||||
|
|
||||||
static void
|
web_view->progress = 0.0;
|
||||||
_midori_web_view_set_uri (MidoriWebView* web_view,
|
g_object_notify (G_OBJECT (web_view), "progress");
|
||||||
const gchar* uri)
|
|
||||||
{
|
|
||||||
katze_assign (web_view->uri, g_strdup (uri));
|
|
||||||
if (web_view->xbel_item)
|
|
||||||
{
|
|
||||||
const gchar* uri = midori_web_view_get_display_uri (web_view);
|
|
||||||
katze_xbel_bookmark_set_href (web_view->xbel_item, uri);
|
|
||||||
}
|
|
||||||
g_object_set (web_view, "title", NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GLIB_CHECK_VERSION (2, 16, 0)
|
#if GLIB_CHECK_VERSION (2, 16, 0)
|
||||||
|
@ -417,9 +402,15 @@ webkit_web_view_load_committed (MidoriWebView* web_view,
|
||||||
const gchar* uri;
|
const gchar* uri;
|
||||||
GdkPixbuf* icon;
|
GdkPixbuf* icon;
|
||||||
|
|
||||||
web_view->progress = 0;
|
|
||||||
uri = webkit_web_frame_get_uri (web_frame);
|
uri = webkit_web_frame_get_uri (web_frame);
|
||||||
_midori_web_view_set_uri (web_view, uri);
|
katze_assign (web_view->uri, g_strdup (uri));
|
||||||
|
if (web_view->xbel_item)
|
||||||
|
{
|
||||||
|
uri = midori_web_view_get_display_uri (web_view);
|
||||||
|
katze_xbel_bookmark_set_href (web_view->xbel_item, uri);
|
||||||
|
}
|
||||||
|
g_object_notify (G_OBJECT (web_view), "uri");
|
||||||
|
g_object_set (web_view, "title", NULL, NULL);
|
||||||
|
|
||||||
icon = gtk_widget_render_icon (GTK_WIDGET (web_view),
|
icon = gtk_widget_render_icon (GTK_WIDGET (web_view),
|
||||||
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
|
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
|
||||||
|
@ -434,6 +425,9 @@ webkit_web_view_load_committed (MidoriWebView* web_view,
|
||||||
gtk_image_menu_item_set_image (
|
gtk_image_menu_item_set_image (
|
||||||
GTK_IMAGE_MENU_ITEM (web_view->menu_item),
|
GTK_IMAGE_MENU_ITEM (web_view->menu_item),
|
||||||
gtk_image_new_from_pixbuf (icon));
|
gtk_image_new_from_pixbuf (icon));
|
||||||
|
|
||||||
|
web_view->load_status = MIDORI_LOAD_COMMITTED;
|
||||||
|
g_object_notify (G_OBJECT (web_view), "mload-status");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -449,31 +443,11 @@ webkit_web_view_icon_ready (MidoriWebView* web_view,
|
||||||
gtk_image_new_from_pixbuf (icon));
|
gtk_image_new_from_pixbuf (icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
webkit_web_view_load_started (MidoriWebView* web_view,
|
|
||||||
WebKitWebFrame* web_frame)
|
|
||||||
{
|
|
||||||
/* FIXME: This is a hack, until signals are fixed upstream */
|
|
||||||
web_view->is_loading = TRUE;
|
|
||||||
if (web_view->tab_icon)
|
|
||||||
katze_throbber_set_animated (KATZE_THROBBER (web_view->tab_icon), TRUE);
|
|
||||||
|
|
||||||
web_view->progress = 0;
|
|
||||||
g_signal_emit (web_view, signals[PROGRESS_STARTED], 0, web_view->progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
webkit_web_view_progress_changed (MidoriWebView* web_view, gint progress)
|
webkit_web_view_progress_changed (MidoriWebView* web_view, gint progress)
|
||||||
{
|
{
|
||||||
web_view->progress = progress;
|
web_view->progress = progress ? progress / 100.0 : 0.0;
|
||||||
g_signal_emit (web_view, signals[PROGRESS_CHANGED], 0, web_view->progress);
|
g_object_notify (G_OBJECT (web_view), "progress");
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
webkit_web_view_load_finished (MidoriWebView* web_view)
|
|
||||||
{
|
|
||||||
web_view->progress = 100;
|
|
||||||
g_signal_emit (web_view, signals[PROGRESS_DONE], 0, web_view->progress);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -513,13 +487,18 @@ webkit_web_frame_load_done (WebKitWebFrame* web_frame,
|
||||||
g_object_unref (document);
|
g_object_unref (document);
|
||||||
g_object_unref (value);
|
g_object_unref (value);
|
||||||
|
|
||||||
web_view->is_loading = FALSE;
|
|
||||||
web_view->progress = -1;
|
|
||||||
|
|
||||||
if (web_view->tab_icon)
|
if (web_view->tab_icon)
|
||||||
katze_throbber_set_animated (KATZE_THROBBER (web_view->tab_icon),
|
katze_throbber_set_animated (KATZE_THROBBER (web_view->tab_icon),
|
||||||
FALSE);
|
FALSE);
|
||||||
g_signal_emit (web_view, signals[LOAD_DONE], 0, web_frame);
|
web_view->load_status = MIDORI_LOAD_FINISHED;
|
||||||
|
g_object_notify (G_OBJECT (web_view), "mload-status");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
webkit_web_view_load_finished (MidoriWebView* web_view)
|
||||||
|
{
|
||||||
|
web_view->progress = 1.0;
|
||||||
|
g_object_notify (G_OBJECT (web_view), "progress");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -726,8 +705,8 @@ midori_web_view_init (MidoriWebView* web_view)
|
||||||
{
|
{
|
||||||
web_view->icon = gtk_widget_render_icon (GTK_WIDGET (web_view),
|
web_view->icon = gtk_widget_render_icon (GTK_WIDGET (web_view),
|
||||||
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
|
GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL);
|
||||||
web_view->is_loading = FALSE;
|
web_view->progress = 0.0;
|
||||||
web_view->progress = -1;
|
web_view->load_status = MIDORI_LOAD_FINISHED;
|
||||||
|
|
||||||
web_view->settings = midori_web_settings_new ();
|
web_view->settings = midori_web_settings_new ();
|
||||||
g_object_set (web_view, "WebKitWebView::settings", web_view->settings, NULL);
|
g_object_set (web_view, "WebKitWebView::settings", web_view->settings, NULL);
|
||||||
|
@ -736,20 +715,16 @@ midori_web_view_init (MidoriWebView* web_view)
|
||||||
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
|
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
|
||||||
|
|
||||||
g_object_connect (web_view,
|
g_object_connect (web_view,
|
||||||
/* "signal::load-started",
|
"signal::load-started",
|
||||||
webkit_web_view_load_started, NULL, */
|
webkit_web_view_load_started, NULL,
|
||||||
"signal::load-committed",
|
"signal::load-committed",
|
||||||
webkit_web_view_load_committed, NULL,
|
webkit_web_view_load_committed, NULL,
|
||||||
"signal::icon-ready",
|
"signal::icon-ready",
|
||||||
webkit_web_view_icon_ready, NULL,
|
webkit_web_view_icon_ready, NULL,
|
||||||
"signal::load-started",
|
|
||||||
webkit_web_view_load_started, NULL,
|
|
||||||
"signal::load-progress-changed",
|
"signal::load-progress-changed",
|
||||||
webkit_web_view_progress_changed, NULL,
|
webkit_web_view_progress_changed, NULL,
|
||||||
"signal::load-finished",
|
"signal::load-finished",
|
||||||
webkit_web_view_load_finished, NULL,
|
webkit_web_view_load_finished, NULL,
|
||||||
/* "signal::load-done",
|
|
||||||
webkit_web_view_load_done, NULL, */
|
|
||||||
"signal::title-changed",
|
"signal::title-changed",
|
||||||
webkit_web_view_title_changed, NULL,
|
webkit_web_view_title_changed, NULL,
|
||||||
"signal::status-bar-text-changed",
|
"signal::status-bar-text-changed",
|
||||||
|
@ -850,6 +825,12 @@ midori_web_view_get_property (GObject* object,
|
||||||
case PROP_TITLE:
|
case PROP_TITLE:
|
||||||
g_value_set_string (value, web_view->title);
|
g_value_set_string (value, web_view->title);
|
||||||
break;
|
break;
|
||||||
|
case PROP_PROGRESS:
|
||||||
|
g_value_set_double (value, web_view->progress);
|
||||||
|
break;
|
||||||
|
case PROP_MLOAD_STATUS:
|
||||||
|
g_value_set_enum (value, web_view->load_status);
|
||||||
|
break;
|
||||||
case PROP_STATUSBAR_TEXT:
|
case PROP_STATUSBAR_TEXT:
|
||||||
g_value_set_string (value, web_view->statusbar_text);
|
g_value_set_string (value, web_view->statusbar_text);
|
||||||
break;
|
break;
|
||||||
|
@ -1025,36 +1006,34 @@ midori_web_view_get_proxy_xbel_item (MidoriWebView* web_view)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_web_view_is_loading:
|
* midori_web_view_load_status:
|
||||||
* @web_view: a #MidoriWebView
|
* @web_view: a #MidoriWebView
|
||||||
*
|
*
|
||||||
* Determines whether currently a page is being loaded or not.
|
* Determines the current loading status of a page.
|
||||||
*
|
*
|
||||||
* Return value: %TRUE if a page is being loaded, %FALSE otherwise
|
* Return value: the current #MidoriLoadStatus
|
||||||
**/
|
**/
|
||||||
gint
|
MidoriLoadStatus
|
||||||
midori_web_view_is_loading (MidoriWebView* web_view)
|
midori_web_view_get_load_status (MidoriWebView* web_view)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MIDORI_IS_WEB_VIEW (web_view), -1);
|
g_return_val_if_fail (MIDORI_IS_WEB_VIEW (web_view), MIDORI_LOAD_FINISHED);
|
||||||
|
|
||||||
return web_view->is_loading;
|
return web_view->load_status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* midori_web_view_get_progress:
|
* midori_web_view_get_progress:
|
||||||
* @web_view: a #MidoriWebView
|
* @web_view: a #MidoriWebView
|
||||||
*
|
*
|
||||||
* Retrieves the current loading progress in percent or -1 if no data
|
* Retrieves the current loading progress as
|
||||||
* has been loaded so far.
|
* a fraction between 0.0 and 1.0.
|
||||||
*
|
*
|
||||||
* The value is undefined if no loading is in progress.
|
* Return value: the current loading progress
|
||||||
*
|
|
||||||
* Return value: the current loading progress or -1
|
|
||||||
**/
|
**/
|
||||||
gint
|
gdouble
|
||||||
midori_web_view_get_progress (MidoriWebView* web_view)
|
midori_web_view_get_progress (MidoriWebView* web_view)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (MIDORI_IS_WEB_VIEW (web_view), -1);
|
g_return_val_if_fail (MIDORI_IS_WEB_VIEW (web_view), 0.0);
|
||||||
|
|
||||||
return web_view->progress;
|
return web_view->progress;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,15 +49,6 @@ struct _MidoriWebViewClass
|
||||||
const gchar* type,
|
const gchar* type,
|
||||||
const gchar* title);
|
const gchar* title);
|
||||||
void
|
void
|
||||||
(*progress_started) (MidoriWebView* web_view,
|
|
||||||
guint progress);
|
|
||||||
void
|
|
||||||
(*progress_changed) (MidoriWebView* web_view,
|
|
||||||
guint progress);
|
|
||||||
void
|
|
||||||
(*progress_done) (MidoriWebView* web_view,
|
|
||||||
guint progress);
|
|
||||||
void
|
|
||||||
(*load_done) (MidoriWebView* web_view,
|
(*load_done) (MidoriWebView* web_view,
|
||||||
WebKitWebFrame* frame);
|
WebKitWebFrame* frame);
|
||||||
void
|
void
|
||||||
|
@ -73,6 +64,19 @@ struct _MidoriWebViewClass
|
||||||
const gchar* uri);
|
const gchar* uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MIDORI_LOAD_PROVISIONAL,
|
||||||
|
MIDORI_LOAD_COMMITTED,
|
||||||
|
MIDORI_LOAD_FINISHED
|
||||||
|
} MidoriLoadStatus;
|
||||||
|
|
||||||
|
GType
|
||||||
|
midori_load_status_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
#define MIDORI_TYPE_LOAD_STATUS \
|
||||||
|
(midori_load_status_get_type ())
|
||||||
|
|
||||||
GType
|
GType
|
||||||
midori_web_view_get_type (void);
|
midori_web_view_get_type (void);
|
||||||
|
|
||||||
|
@ -95,12 +99,12 @@ midori_web_view_get_proxy_tab_title (MidoriWebView* web_view);
|
||||||
KatzeXbelItem*
|
KatzeXbelItem*
|
||||||
midori_web_view_get_proxy_xbel_item (MidoriWebView* web_view);
|
midori_web_view_get_proxy_xbel_item (MidoriWebView* web_view);
|
||||||
|
|
||||||
gboolean
|
gdouble
|
||||||
midori_web_view_is_loading (MidoriWebView* web_view);
|
|
||||||
|
|
||||||
gint
|
|
||||||
midori_web_view_get_progress (MidoriWebView* web_view);
|
midori_web_view_get_progress (MidoriWebView* web_view);
|
||||||
|
|
||||||
|
MidoriLoadStatus
|
||||||
|
midori_web_view_get_load_status (MidoriWebView* web_view);
|
||||||
|
|
||||||
const gchar*
|
const gchar*
|
||||||
midori_web_view_get_display_uri (MidoriWebView* web_view);
|
midori_web_view_get_display_uri (MidoriWebView* web_view);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue