diff options
-rw-r--r-- | data/ui/epiphany.css | 28 | ||||
-rw-r--r-- | embed/ephy-embed.c | 33 | ||||
-rw-r--r-- | src/ephy-window.c | 70 |
3 files changed, 60 insertions, 71 deletions
diff --git a/data/ui/epiphany.css b/data/ui/epiphany.css index d4cfc26ab..86b2fb2a5 100644 --- a/data/ui/epiphany.css +++ b/data/ui/epiphany.css @@ -19,3 +19,31 @@ padding-right: 0; } +#ephy-progress-bar { + -GtkProgressBar-xspacing: 0; + -GtkProgressBar-yspacing: 3; + -GtkProgressBar-min-horizontal-bar-height: 3; + padding: 0; +} + +.progressbar#ephy-progress-bar { + border-style: none; + background-color: @theme_selected_bg_color; + background-image: none; + border-radius: 0; + -adwaita-progressbar-pattern: none; +} + +GtkProgressBar#ephy-progress-bar.trough { + padding: 0; + border-image: none; + border-style: none; + border-width: 0; + background-image: none; + background-color: none; + border-radius: 0; +} + +#ephy-overlay { + background-color: rgba(0,0,0,0); +} diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 0f2211aed..d9cc977a2 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -75,6 +75,7 @@ struct _EphyEmbedPrivate guint is_setting_zoom : 1; GSList *destroy_on_transition_list; GtkWidget *statusbar_label; + GtkWidget *progress; GSList *messages; GSList *keys; @@ -523,6 +524,27 @@ frame_enter_notify_cb (GtkWidget *widget, } static void +progress_update (EphyWebView *view, GParamSpec *pspec, EphyEmbed *embed) +{ + gdouble progress; + gboolean loading; + + EphyEmbedPrivate *priv = embed->priv; + + progress = webkit_web_view_get_progress (priv->web_view); + loading = ephy_web_view_is_loading (EPHY_WEB_VIEW (priv->web_view)); + + if (progress == 1.0 || !loading) + { + gtk_widget_hide (priv->progress); + } else { + gtk_widget_show (priv->progress); + } + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->progress), + (loading || progress == 1.0) ? progress : 0.0); +} + +static void ephy_embed_constructed (GObject *object) { EphyEmbed *embed = (EphyEmbed*)object; @@ -540,7 +562,8 @@ ephy_embed_constructed (GObject *object) web_view = WEBKIT_WEB_VIEW (ephy_web_view_new ()); scrolled_window = GTK_WIDGET (embed->priv->scrolled_window); overlay = gtk_overlay_new (); - gtk_container_add (GTK_CONTAINER (overlay), GTK_WIDGET (scrolled_window)); + gtk_widget_set_name (overlay, "ephy-overlay"); + gtk_container_add (GTK_CONTAINER (overlay), scrolled_window); /* statusbar is hidden by default */ priv->statusbar_label = gtk_label_new (NULL); @@ -557,9 +580,17 @@ ephy_embed_constructed (GObject *object) g_signal_connect (eventbox, "enter-notify-event", G_CALLBACK (frame_enter_notify_cb), object); + embed->priv->progress = gtk_progress_bar_new (); + gtk_widget_set_name (embed->priv->progress, "ephy-progress-bar"); + gtk_widget_set_halign (embed->priv->progress, GTK_ALIGN_FILL); + gtk_widget_set_valign (embed->priv->progress, GTK_ALIGN_START); + gtk_overlay_add_overlay (GTK_OVERLAY (overlay), embed->priv->progress); + paned = GTK_WIDGET (embed->priv->paned); embed->priv->web_view = web_view; + g_signal_connect (web_view, "notify::progress", + G_CALLBACK (progress_update), object); gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view)); diff --git a/src/ephy-window.c b/src/ephy-window.c index 679b085c2..da7621ac3 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -456,8 +456,6 @@ struct _EphyWindowPrivate GtkWidget *entry; GtkWidget *downloads_box; - guint clear_progress_timeout_id; - guint menubar_accel_keyval; guint menubar_accel_modifier; @@ -1710,64 +1708,6 @@ sync_tab_icon (EphyWebView *view, ephy_toolbar_set_favicon (priv->toolbar, icon); } -static gboolean -clear_progress_cb (EphyWindow *window) -{ - gtk_entry_set_progress_fraction (GTK_ENTRY (window->priv->entry), 0.0); - window->priv->clear_progress_timeout_id = 0; - - return FALSE; -} - -static void -sync_tab_load_progress (EphyWebView *view, GParamSpec *pspec, EphyWindow *window) -{ - gdouble progress; - const char *uri; - gboolean loading; - gboolean switching_tab = pspec == NULL; - - if (window->priv->closing) return; - if (!window->priv->entry) return; - - if (window->priv->clear_progress_timeout_id) - { - g_source_remove (window->priv->clear_progress_timeout_id); - window->priv->clear_progress_timeout_id = 0; - } - - /* If we are loading about:blank do not show progress, as the - blink it causes is annoying. */ - /* FIXME: for some reason webkit_web_view_get_uri returns NULL - for about:blank until the load is finished, so assume NULL - here means we are loading about:blank. This might not be - rigt :) */ - /* All the weird checks for progress == 1.0 and !switching_tab - * are because we receive first the LOAD_FINISHED status than - * the 100% progress report, so for progress == 1.0 there's no - * sane way of knowing whether we are still loading or - * not. See https://bugs.webkit.org/show_bug.cgi?id=28851 */ - uri = webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view)); - if (!switching_tab && (!uri || strcmp (uri, "about:blank") == 0)) - return; - - progress = webkit_web_view_get_progress (WEBKIT_WEB_VIEW (view)); - loading = ephy_web_view_is_loading (view); - - if (progress == 1.0 && !switching_tab) - { - window->priv->clear_progress_timeout_id = - g_timeout_add (500, - (GSourceFunc)clear_progress_cb, - window); - } - - /* Do not set progress in the entry if the load is already - finished */ - gtk_entry_set_progress_fraction (GTK_ENTRY (window->priv->entry), - loading || (progress == 1.0 && !switching_tab) ? progress : 0.0); -} - static void sync_tab_navigation (EphyWebView *view, GParamSpec *pspec, @@ -2772,9 +2712,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) G_CALLBACK (sync_tab_document_type), window); g_signal_handlers_disconnect_by_func (view, - G_CALLBACK (sync_tab_load_progress), - window); - g_signal_handlers_disconnect_by_func (view, G_CALLBACK (sync_tab_load_status), window); g_signal_handlers_disconnect_by_func (view, @@ -2810,7 +2747,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) sync_tab_security (view, NULL, window); sync_tab_document_type (view, NULL, window); - sync_tab_load_progress (view, NULL, window); sync_tab_load_status (view, NULL, window); sync_tab_navigation (view, NULL, window); sync_tab_title (view, NULL, window); @@ -2873,9 +2809,6 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed) g_signal_connect_object (view, "notify::navigation", G_CALLBACK (sync_tab_navigation), window, 0); - g_signal_connect_object (view, "notify::progress", - G_CALLBACK (sync_tab_load_progress), - window, 0); /* We run our button-press-event after the default * handler to make sure pages have a chance to perform * their own handling - for instance, have their own @@ -3514,9 +3447,6 @@ ephy_window_finalize (GObject *object) g_hash_table_destroy (priv->tabs_to_remove); - if (priv->clear_progress_timeout_id) - g_source_remove (priv->clear_progress_timeout_id); - G_OBJECT_CLASS (ephy_window_parent_class)->finalize (object); LOG ("EphyWindow finalised %p", object); |