[epiphany/overlay-progressbar: 2/2] Rough implementation of an overlay progressbar



commit 701d13b6949d3ea525e7e9eb10d1a45ee52f82e9
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Mon Dec 5 19:05:25 2011 +0100

    Rough implementation of an overlay progressbar
    
    This is hardcoded to 40% for now, to ease theming changes.

 data/ui/epiphany.css |   12 +++++
 embed/ephy-embed.c   |   30 ++++++++++++
 src/ephy-window.c    |  122 ++++++++++++++++++++++---------------------------
 3 files changed, 97 insertions(+), 67 deletions(-)
---
diff --git a/data/ui/epiphany.css b/data/ui/epiphany.css
index 867d310..47fa0af 100644
--- a/data/ui/epiphany.css
+++ b/data/ui/epiphany.css
@@ -14,3 +14,15 @@
   padding: 0;
 }
 
+#ephy-progress-bar {
+    border-radius: 0 0 0 0;
+
+    -GtkProgressBar-min-horizontal-bar-height: 3;
+    -GtkProgressBar-xspacing: 0;
+    -GtkProgressBar-yspacing: 3;
+}
+
+#ephy-progress-bar .trough .row {
+    background-image: none;
+    padding: 0;
+}
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 1a801fb..f573c47 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),
+                                 0.4 /* (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 3dcf58f..888afc0 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -458,7 +458,7 @@ struct _EphyWindowPrivate
 	GtkWidget *entry;
 	GtkWidget *downloads_box;
 
-	guint clear_progress_timeout_id;
+	/* guint clear_progress_timeout_id; */
 
 	guint menubar_accel_keyval;
 	guint menubar_accel_modifier;
@@ -1712,63 +1712,54 @@ 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_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,
@@ -2772,9 +2763,9 @@ ephy_window_set_active_tab (EphyWindow *window, EphyEmbed *new_embed)
 		g_signal_handlers_disconnect_by_func (view,
 						      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_progress), */
+		/* 				      window); */
 		g_signal_handlers_disconnect_by_func (view,
 						      G_CALLBACK (sync_tab_load_status),
 						      window);
@@ -2811,7 +2802,7 @@ 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_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 +2865,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,8 +3562,8 @@ 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);
+	/* if (priv->clear_progress_timeout_id) */
+	/* 	g_source_remove (priv->clear_progress_timeout_id); */
 
 	G_OBJECT_CLASS (ephy_window_parent_class)->finalize (object);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]