summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2011-12-05 19:05:25 +0100
committerClaudio Saavedra <csaavedra@igalia.com>2011-12-05 21:21:00 +0100
commitbf80fa05a8620375dc1c7e0be1616719fed78b3e (patch)
tree7ecf073043a816044a89494b74797dabeb591197
parent7f83baef9da80a4a4fd630418618d5619d0cadeb (diff)
downloadepiphany-overlay-progressbar.tar.gz
Use an overlay progress bar for the loading progress.overlay-progressbar
The theming was done by Lapo Calamandrei. https://bugzilla.gnome.org/show_bug.cgi?id=665470
-rw-r--r--data/ui/epiphany.css24
-rw-r--r--embed/ephy-embed.c30
-rw-r--r--src/ephy-window.c70
3 files changed, 54 insertions, 70 deletions
diff --git a/data/ui/epiphany.css b/data/ui/epiphany.css
index 867d31045..1d2527a18 100644
--- a/data/ui/epiphany.css
+++ b/data/ui/epiphany.css
@@ -14,3 +14,27 @@
padding: 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;
+}
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 1a801fba0..7a869b0ed 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -77,6 +77,7 @@ struct _EphyEmbedPrivate
guint is_setting_zoom : 1;
GSList *destroy_on_transition_list;
GtkWidget *statusbar_label;
+ GtkWidget *progress;
GSList *messages;
GSList *keys;
@@ -525,6 +526,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;
@@ -560,9 +582,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 3dcf58f47..9a22c6565 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -458,8 +458,6 @@ struct _EphyWindowPrivate
GtkWidget *entry;
GtkWidget *downloads_box;
- guint clear_progress_timeout_id;
-
guint menubar_accel_keyval;
guint menubar_accel_modifier;
@@ -1712,64 +1710,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,
@@ -2773,9 +2713,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,
@@ -2811,7 +2748,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);
@@ -2874,9 +2810,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
@@ -3574,9 +3507,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);