[evince] Use GtkOverlay to show the loading message



commit 035c1cbd4756d3819a6616f62acd87662abc6374
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sat Sep 29 16:06:39 2012 +0200

    Use GtkOverlay to show the loading message
    
    Remove the EvLoadingWindow from libview and move the implementation to
    the shell using a EvLoadingMessage widget and GtkOverlay. EvView has now
    a is-loading property that allows the users to implement their own
    loading notification system. This fixes several realted to the loading
    window.

 libview/Makefile.am             |    2 -
 libview/ev-loading-window.c     |  296 ---------------------------------------
 libview/ev-loading-window.h     |   49 -------
 libview/ev-view.c               |  131 ++++-------------
 libview/ev-view.h               |    2 +
 previewer/ev-previewer-window.c |    2 -
 shell/Makefile.am               |    2 +
 shell/ev-loading-message.c      |  179 +++++++++++++++++++++++
 shell/ev-loading-message.h      |   44 ++++++
 shell/ev-window.c               |   80 ++++++++++-
 shell/evince.css                |    7 +
 shell/evince.gresource.xml      |    1 +
 12 files changed, 339 insertions(+), 456 deletions(-)
---
diff --git a/libview/Makefile.am b/libview/Makefile.am
index c187ab8..a4b849b 100644
--- a/libview/Makefile.am
+++ b/libview/Makefile.am
@@ -2,7 +2,6 @@ lib_LTLIBRARIES = libevview3.la
 
 NOINST_H_SRC_FILES =			\
 	ev-annotation-window.h		\
-	ev-loading-window.h		\
 	ev-page-cache.h			\
 	ev-pixbuf-cache.h		\
 	ev-timeline.h			\
@@ -33,7 +32,6 @@ nodist_header_DATA = $(INST_H_BUILT_FILES)
 libevview3_la_SOURCES =			\
 	ev-annotation-window.c		\
 	ev-document-model.c		\
-	ev-loading-window.c		\
 	ev-jobs.c			\
 	ev-job-scheduler.c		\
 	ev-page-cache.c			\
diff --git a/libview/ev-view.c b/libview/ev-view.c
index f61691c..f2fb1b1 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -39,7 +39,6 @@
 #include "ev-view-marshal.h"
 #include "ev-document-annotations.h"
 #include "ev-annotation-window.h"
-#include "ev-loading-window.h"
 #include "ev-view.h"
 #include "ev-view-accessible.h"
 #include "ev-view-private.h"
@@ -69,6 +68,7 @@ enum {
 
 enum {
 	PROP_0,
+	PROP_IS_LOADING,
 	PROP_HADJUSTMENT,
 	PROP_VADJUSTMENT,
 	PROP_HSCROLL_POLICY,
@@ -205,13 +205,9 @@ static void       draw_one_page                              (EvView
 							      GtkBorder          *border,
 							      GdkRectangle       *expose_area,
 							      gboolean		 *page_ready);
-static void       show_loading_window                        (EvView             *view);
-static void       hide_loading_window                        (EvView             *view);
 static void       ev_view_reload_page                        (EvView             *view,
 							      gint                page,
 							      cairo_region_t     *region);
-static void       ev_view_loading_window_move                (EvView             *view);
-
 /*** Callbacks ***/
 static void       ev_view_change_page                        (EvView             *view,
 							      gint                new_page);
@@ -700,7 +696,7 @@ view_update_range_and_current_page (EvView *view)
 
 			if (view->current_page != best_current_page) {
 				view->current_page = best_current_page;
-				hide_loading_window (view);
+				ev_view_set_loading (view, FALSE);
 				ev_document_model_set_page (view->model, best_current_page);
 			}
 		}
@@ -3410,13 +3406,6 @@ ev_view_draw (GtkWidget *widget,
 	gint         i;
 	GdkRectangle clip_rect;
 
-	if (view->loading) {
-		show_loading_window (view);
-	} else if (view->loading_window &&
-		   gtk_widget_get_visible (view->loading_window)) {
-		ev_view_loading_window_move (view);
-	}
-
 	if (view->document == NULL)
 		return FALSE;
 
@@ -4350,81 +4339,6 @@ focus_annotation (EvView       *view,
 }
 
 static void
-ev_view_loading_window_move (EvView *view)
-{
-	GtkWidget       *widget = GTK_WIDGET (view);
-	EvLoadingWindow *window = EV_LOADING_WINDOW (view->loading_window);
-	gint             root_x, root_y;
-	gint             window_width;
-	GtkAllocation    allocation;
-
-	gtk_widget_get_allocation (widget, &allocation);
-	gdk_window_get_origin (gtk_widget_get_window (widget), &root_x, &root_y);
-	ev_loading_window_get_size (window, &window_width, NULL);
-
-	root_x += allocation.width - window_width - 10;
-	root_y += 10;
-
-	ev_loading_window_move (window, root_x, root_y);
-}
-
-static gboolean
-show_loading_window_cb (EvView *view)
-{
-	if (!view->loading_window) {
-		GtkWindow *parent;
-		GdkScreen *screen;
-
-		parent = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view)));
-		view->loading_window = ev_loading_window_new (parent);
-
-		/* Show the window off screen to get a valid size asap */
-		screen = gtk_widget_get_screen (GTK_WIDGET (view));
-		gtk_window_move (GTK_WINDOW (view->loading_window),
-				 gdk_screen_get_width (screen) + 1,
-				 gdk_screen_get_height (screen) + 1);
-		gtk_widget_show (view->loading_window);
-	}
-
-	ev_view_loading_window_move (view);
-
-	gtk_widget_show (view->loading_window);
-
-	view->loading_timeout = 0;
-
-	return FALSE;
-}
-
-static void
-show_loading_window (EvView *view)
-{
-	if (view->loading_window && gtk_widget_get_visible (view->loading_window)) {
-		ev_view_loading_window_move (view);
-		return;
-	}
-
-	if (!view->loading_timeout) {
-		view->loading_timeout =
-			g_timeout_add_full (G_PRIORITY_LOW,
-					    0.5, (GSourceFunc)show_loading_window_cb,
-					    view, NULL);
-	}
-}
-
-static void
-hide_loading_window (EvView *view)
-{
-	if (view->loading_timeout) {
-		g_source_remove (view->loading_timeout);
-		view->loading_timeout = 0;
-	}
-
-	if (view->loading_window && gtk_widget_get_visible (view->loading_window)) {
-		gtk_widget_hide (view->loading_window);
-	}
-}
-
-static void
 draw_one_page (EvView       *view,
 	       gint          page,
 	       cairo_t      *cr,
@@ -4471,7 +4385,7 @@ draw_one_page (EvView       *view,
 
 		if (!page_surface) {
 			if (page == current_page)
-				show_loading_window (view);
+				ev_view_set_loading (view, TRUE);
 
 			*page_ready = FALSE;
 
@@ -4479,7 +4393,7 @@ draw_one_page (EvView       *view,
 		}
 
 		if (page == current_page)
-			hide_loading_window (view);
+			ev_view_set_loading (view, FALSE);
 
 		ev_view_get_page_size (view, page, &width, &height);
 
@@ -4619,11 +4533,6 @@ ev_view_dispose (GObject *object)
 		view->drag_info.release_timeout_id = 0;
 	}
 
-	if (view->loading_timeout) {
-		g_source_remove (view->loading_timeout);
-		view->loading_timeout = 0;
-	}
-
         gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (view), NULL);
         gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (view), NULL);
 
@@ -4639,6 +4548,9 @@ ev_view_get_property (GObject     *object,
 	EvView *view = EV_VIEW (object);
 
 	switch (prop_id) {
+	case PROP_IS_LOADING:
+		g_value_set_boolean (value, view->loading);
+		break;
 	case PROP_HADJUSTMENT:
 		g_value_set_object (value, view->hadjustment);
 		break;
@@ -4666,6 +4578,9 @@ ev_view_set_property (GObject      *object,
 	EvView *view = EV_VIEW (object);
 
 	switch (prop_id) {
+	case PROP_IS_LOADING:
+		ev_view_set_loading (view, g_value_get_boolean (value));
+		break;
 	case PROP_HADJUSTMENT:
 		ev_view_set_scroll_adjustment (view, GTK_ORIENTATION_HORIZONTAL,
 					       (GtkAdjustment *) g_value_get_object (value));
@@ -4818,6 +4733,15 @@ ev_view_class_init (EvViewClass *class)
 
 	class->binding_activated = ev_view_scroll;
 
+	g_object_class_install_property (object_class,
+					 PROP_IS_LOADING,
+					 g_param_spec_boolean ("is-loading",
+							       "Is Loading",
+							       "Whether the view is loading",
+							       FALSE,
+							       G_PARAM_READABLE |
+							       G_PARAM_STATIC_STRINGS));
+
 	/* Scrollable interface */
 	g_object_class_override_property (object_class, PROP_HADJUSTMENT, "hadjustment");
 	g_object_class_override_property (object_class, PROP_VADJUSTMENT, "vadjustment");
@@ -4964,7 +4888,7 @@ ev_view_change_page (EvView *view,
 	view->current_page = new_page;
 	view->pending_scroll = SCROLL_TO_PAGE_POSITION;
 
-	hide_loading_window (view);
+	ev_view_set_loading (view, FALSE);
 
 	ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
 	ev_view_handle_cursor_over_xy (view, x, y);
@@ -5135,10 +5059,17 @@ void
 ev_view_set_loading (EvView 	  *view,
 		     gboolean      loading)
 {
-	if (view->loading && !loading)
-		hide_loading_window (view);
+	if (view->loading == loading)
+		return;
+
 	view->loading = loading;
-	gtk_widget_queue_draw (GTK_WIDGET (view));
+	g_object_notify (G_OBJECT (view), "is-loading");
+}
+
+gboolean
+ev_view_is_loading (EvView *view)
+{
+	return view->loading;
 }
 
 static gboolean
@@ -5237,7 +5168,7 @@ ev_view_document_changed_cb (EvDocumentModel *model,
 		view->find_result = 0;
 
 		if (view->document) {
-			view->loading = FALSE;
+			ev_view_set_loading (view, FALSE);
 			g_object_ref (view->document);
 			setup_caches (view);
                 }
diff --git a/libview/ev-view.h b/libview/ev-view.h
index 52cf16a..f82dc9a 100644
--- a/libview/ev-view.h
+++ b/libview/ev-view.h
@@ -49,8 +49,10 @@ GType		ev_view_get_type	    (void) G_GNUC_CONST;
 GtkWidget*	ev_view_new		    (void);
 void		ev_view_set_model	    (EvView          *view,
 					     EvDocumentModel *model);
+EV_DEPRECATED
 void 		ev_view_set_loading         (EvView 	     *view,
 					     gboolean         loading);
+gboolean        ev_view_is_loading          (EvView          *view);
 void            ev_view_reload              (EvView          *view);
 void            ev_view_set_page_cache_size (EvView          *view,
 					     gsize            cache_size);
diff --git a/previewer/ev-previewer-window.c b/previewer/ev-previewer-window.c
index 83cbe64..6840e6e 100644
--- a/previewer/ev-previewer-window.c
+++ b/previewer/ev-previewer-window.c
@@ -399,7 +399,6 @@ ev_previewer_window_set_document (EvPreviewerWindow *window,
 	g_signal_connect (model, "notify::sizing-mode",
 			  G_CALLBACK (view_sizing_mode_changed),
 			  window);
-	ev_view_set_loading (window->view, FALSE);
 	gtk_action_group_set_sensitive (window->action_group, TRUE);
 	gtk_action_group_set_sensitive (window->accels_group, TRUE);
 }
@@ -592,7 +591,6 @@ ev_previewer_window_constructor (GType                  type,
 				 window, 0);
 	ev_view_set_model (window->view, window->model);
 	ev_document_model_set_continuous (window->model, FALSE);
-	ev_view_set_loading (window->view, TRUE);
 
 	gtk_container_add (GTK_CONTAINER (window->swindow), GTK_WIDGET (window->view));
 	gtk_widget_show (GTK_WIDGET (window->view));
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 18d75fc..73c8499 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -43,6 +43,8 @@ evince_SOURCES=				\
 	ev-history.h			\
 	ev-keyring.h			\
 	ev-keyring.c			\
+	ev-loading-message.c		\
+	ev-loading-message.h		\
 	ev-message-area.c		\
 	ev-message-area.h		\
 	ev-metadata.c			\
diff --git a/shell/ev-loading-message.c b/shell/ev-loading-message.c
new file mode 100644
index 0000000..9d0203d
--- /dev/null
+++ b/shell/ev-loading-message.c
@@ -0,0 +1,179 @@
+/* ev-loading-message.c
+ *  this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2010, 2012 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "ev-loading-message.h"
+
+#include <string.h>
+#include <glib/gi18n.h>
+
+struct _EvLoadingMessage {
+        GtkBox     base_instance;
+
+        GtkWidget *spinner;
+};
+
+struct _EvLoadingMessageClass {
+        GtkBoxClass base_class;
+};
+
+G_DEFINE_TYPE (EvLoadingMessage, ev_loading_message, GTK_TYPE_BOX)
+
+static void
+ev_loading_message_init (EvLoadingMessage *message)
+{
+        GtkWidget       *widget = GTK_WIDGET (message);
+        GtkWidget       *label;
+        GtkStyleContext *context;
+
+        gtk_container_set_border_width (GTK_CONTAINER (message), 10);
+
+        message->spinner = gtk_spinner_new ();
+        gtk_box_pack_start (GTK_BOX (message), message->spinner, FALSE, FALSE, 0);
+        gtk_widget_show (message->spinner);
+
+        label = gtk_label_new (_("Loadingâ"));
+        gtk_box_pack_start (GTK_BOX (message), label, FALSE, FALSE, 0);
+        gtk_widget_show (label);
+}
+
+static void
+get_widget_padding (GtkWidget *widget,
+                    GtkBorder *padding)
+{
+        GtkStyleContext *context;
+        GtkStateFlags state;
+
+        context = gtk_widget_get_style_context (widget);
+        state = gtk_style_context_get_state (context);
+        gtk_style_context_get_padding (context, state, padding);
+}
+
+static void
+ev_loading_message_size_allocate (GtkWidget     *widget,
+                                  GtkAllocation *allocation)
+{
+        EvLoadingMessage *message = EV_LOADING_MESSAGE (widget);
+        GtkAllocation child_allocation;
+        GtkBorder padding;
+
+        get_widget_padding (widget, &padding);
+        child_allocation.y = allocation->x + padding.left;
+        child_allocation.x = allocation->y + padding.top;
+        child_allocation.width = MAX (1, allocation->width - (padding.left + padding.right));
+        child_allocation.height = MAX (1, allocation->height - (padding.top + padding.bottom));
+
+        GTK_WIDGET_CLASS (ev_loading_message_parent_class)->size_allocate (widget, &child_allocation);
+        gtk_widget_set_allocation (widget, allocation);
+}
+
+static void
+ev_loading_message_get_preferred_width (GtkWidget *widget,
+                                        gint      *minimum_size,
+                                        gint      *natural_size)
+{
+        GtkBorder padding;
+
+        GTK_WIDGET_CLASS (ev_loading_message_parent_class)->get_preferred_width (widget, minimum_size, natural_size);
+
+        get_widget_padding (widget, &padding);
+        *minimum_size += padding.left + padding.right;
+        *natural_size += padding.left + padding.right;
+}
+
+static void
+ev_loading_message_get_preferred_height (GtkWidget *widget,
+                                         gint      *minimum_size,
+                                         gint      *natural_size)
+{
+        GtkBorder padding;
+
+        GTK_WIDGET_CLASS (ev_loading_message_parent_class)->get_preferred_height (widget, minimum_size, natural_size);
+
+        get_widget_padding (widget, &padding);
+        *minimum_size += padding.top + padding.bottom;
+        *natural_size += padding.top + padding.bottom;
+}
+
+static gboolean
+ev_loading_message_draw (GtkWidget *widget,
+                         cairo_t   *cr)
+{
+        GtkStyleContext *context;
+        gint             width, height;
+
+        context = gtk_widget_get_style_context (widget);
+        width = gtk_widget_get_allocated_width (widget);
+        height = gtk_widget_get_allocated_height (widget);
+
+        gtk_render_background (context, cr, 0, 0, width, height);
+        gtk_render_frame (context, cr, 0, 0, width, height);
+
+        GTK_WIDGET_CLASS (ev_loading_message_parent_class)->draw (widget, cr);
+
+        return TRUE;
+}
+
+static void
+ev_loading_message_hide (GtkWidget *widget)
+{
+        EvLoadingMessage *message = EV_LOADING_MESSAGE (widget);
+
+        gtk_spinner_stop (GTK_SPINNER (message->spinner));
+
+        GTK_WIDGET_CLASS (ev_loading_message_parent_class)->hide (widget);
+}
+
+static void
+ev_loading_message_show (GtkWidget *widget)
+{
+        EvLoadingMessage *message = EV_LOADING_MESSAGE (widget);
+
+        gtk_spinner_start (GTK_SPINNER (message->spinner));
+
+        GTK_WIDGET_CLASS (ev_loading_message_parent_class)->show (widget);
+}
+
+static void
+ev_loading_message_class_init (EvLoadingMessageClass *klass)
+{
+        GtkWidgetClass *gtk_widget_class = GTK_WIDGET_CLASS (klass);
+
+        gtk_widget_class->size_allocate = ev_loading_message_size_allocate;
+        gtk_widget_class->get_preferred_width = ev_loading_message_get_preferred_width;
+        gtk_widget_class->get_preferred_height = ev_loading_message_get_preferred_height;
+        gtk_widget_class->draw = ev_loading_message_draw;
+        gtk_widget_class->show = ev_loading_message_show;
+        gtk_widget_class->hide = ev_loading_message_hide;
+}
+
+/* Public methods */
+GtkWidget *
+ev_loading_message_new (void)
+{
+        GtkWidget *message;
+
+        message = g_object_new (EV_TYPE_LOADING_MESSAGE,
+                                "orientation", GTK_ORIENTATION_HORIZONTAL,
+                                "spacing", 12,
+                                NULL);
+        return message;
+}
+
diff --git a/shell/ev-loading-message.h b/shell/ev-loading-message.h
new file mode 100644
index 0000000..3842864
--- /dev/null
+++ b/shell/ev-loading-message.h
@@ -0,0 +1,44 @@
+/* ev-loading-message.h
+ *  this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2010, 2012 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * Evince is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Evince is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef EV_LOADING_MESSAGE_H
+#define EV_LOADING_MESSAGE_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef struct _EvLoadingMessage      EvLoadingMessage;
+typedef struct _EvLoadingMessageClass EvLoadingMessageClass;
+
+#define EV_TYPE_LOADING_MESSAGE              (ev_loading_message_get_type())
+#define EV_LOADING_MESSAGE(object)           (G_TYPE_CHECK_INSTANCE_CAST((object), EV_TYPE_LOADING_MESSAGE, EvLoadingMessage))
+#define EV_IS_LOADING_MESSAGE(object)        (G_TYPE_CHECK_INSTANCE_TYPE((object), EV_TYPE_LOADING_MESSAGE))
+#define EV_LOADING_MESSAGE_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST((klass), EV_TYPE_LOADING_MESSAGE, EvLoadingMessageClass))
+#define EV_IS_LOADING_MESSAGE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_LOADING_MESSAGE))
+#define EV_LOADING_MESSAGE_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_LOADING_MESSAGE, EvLoadingMessageClass))
+
+GType      ev_loading_message_get_type (void) G_GNUC_CONST;
+
+GtkWidget *ev_loading_message_new      (void);
+
+G_END_DECLS
+
+#endif /* EV_LOADING_MESSAGE_H */
diff --git a/shell/ev-window.c b/shell/ev-window.c
index bcdbd25..08f7131 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -66,6 +66,7 @@
 #include "ev-image.h"
 #include "ev-job-scheduler.h"
 #include "ev-jobs.h"
+#include "ev-loading-message.h"
 #include "ev-message-area.h"
 #include "ev-metadata.h"
 #include "ev-navigation-action.h"
@@ -134,6 +135,7 @@ struct _EvWindowPrivate {
 	GtkWidget *find_bar;
 	GtkWidget *scrolled_window;
 	GtkWidget *view;
+	GtkWidget *loading_message;
 	GtkWidget *presentation_view;
 	GtkWidget *message_area;
 	GtkWidget *password_view;
@@ -157,6 +159,9 @@ struct _EvWindowPrivate {
 	guint progress_idle;
 	GCancellable *progress_cancellable;
 
+	/* Loading message */
+	guint loading_message_timeout;
+
 	/* Dialogs */
 	GtkWidget *properties;
 	GtkWidget *print_dialog;
@@ -833,6 +838,35 @@ ev_window_warning_message (EvWindow    *window,
 	ev_window_set_message_area (window, area);
 }
 
+static gboolean
+show_loading_message_cb (EvWindow *window)
+{
+	window->priv->loading_message_timeout = 0;
+	gtk_widget_show (window->priv->loading_message);
+
+	return FALSE;
+}
+
+static void
+ev_window_show_loading_message (EvWindow *window)
+{
+	if (window->priv->loading_message_timeout)
+		return;
+	window->priv->loading_message_timeout =
+		g_timeout_add_full (G_PRIORITY_LOW, 0.5, (GSourceFunc)show_loading_message_cb, window, NULL);
+}
+
+static void
+ev_window_hide_loading_message (EvWindow *window)
+{
+	if (window->priv->loading_message_timeout) {
+		g_source_remove (window->priv->loading_message_timeout);
+		window->priv->loading_message_timeout = 0;
+	}
+
+	gtk_widget_hide (window->priv->loading_message);
+}
+
 typedef struct _PageTitleData {
 	const gchar *page_label;
 	gchar       *page_title;
@@ -965,6 +999,17 @@ view_layers_changed_cb (EvView   *view,
 }
 
 static void
+view_is_loading_changed_cb (EvView     *view,
+			    GParamSpec *spec,
+			    EvWindow   *window)
+{
+	if (ev_view_is_loading (view))
+		ev_window_show_loading_message (window);
+	else
+		ev_window_hide_loading_message (window);
+}
+
+static void
 ev_window_page_changed_cb (EvWindow        *ev_window,
 			   gint             old_page,
 			   gint             new_page,
@@ -1650,7 +1695,7 @@ ev_window_load_job_cb (EvJob *job,
 
 	g_assert (job_load->uri);
 
-	ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
+	ev_window_hide_loading_message (ev_window);
 
 	/* Success! */
 	if (!ev_job_is_failed (job)) {
@@ -1916,7 +1961,7 @@ static void
 ev_window_load_remote_failed (EvWindow *ev_window,
 			      GError   *error)
 {
-	ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
+	ev_window_hide_loading_message (ev_window);
 	ev_window->priv->in_reload = FALSE;
 	ev_window_error_message (ev_window, error, 
 				 "%s", _("Unable to open document"));
@@ -2007,8 +2052,8 @@ window_open_file_copy_ready_cb (GFile        *source,
 		g_free (ev_window->priv->uri);
 		ev_window->priv->uri = NULL;
 		g_object_unref (source);
-		
-		ev_view_set_loading (EV_VIEW (ev_window->priv->view), FALSE);
+
+		ev_window_hide_loading_message (ev_window);
 	} else {
 		ev_window_load_remote_failed (ev_window, error);
 		g_object_unref (source);
@@ -2172,7 +2217,7 @@ ev_window_open_uri (EvWindow       *ev_window,
 	if (!g_file_is_native (source_file) && !ev_window->priv->local_uri) {
 		ev_window_load_file_remote (ev_window, source_file);
 	} else {
-		ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
+		ev_window_show_loading_message (ev_window);
 		g_object_unref (source_file);
 		ev_job_scheduler_push_job (ev_window->priv->load_job, EV_JOB_PRIORITY_NONE);
 	}
@@ -5591,6 +5636,11 @@ ev_window_dispose (GObject *object)
 		priv->setup_document_idle = 0;
 	}
 
+	if (priv->loading_message_timeout) {
+		g_source_remove (priv->loading_message_timeout);
+		priv->loading_message_timeout = 0;
+	}
+
 	if (priv->monitor) {
 		g_object_unref (priv->monitor);
 		priv->monitor = NULL;
@@ -7181,6 +7231,7 @@ ev_window_init (EvWindow *ev_window)
 	GError *error = NULL;
 	GtkWidget *sidebar_widget;
 	GtkWidget *menuitem;
+	GtkWidget *overlay;
 	EggToolbarsModel *toolbars_model;
 	GObject *mpkeys;
 #ifdef ENABLE_DBUS
@@ -7427,14 +7478,26 @@ ev_window_init (EvWindow *ev_window)
 			     sidebar_widget);
 
 	ev_window->priv->view_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+
+	overlay = gtk_overlay_new ();
 	ev_window->priv->scrolled_window =
 		GTK_WIDGET (g_object_new (GTK_TYPE_SCROLLED_WINDOW,
 					  "shadow-type", GTK_SHADOW_IN,
 					  NULL));
+	gtk_container_add (GTK_CONTAINER (overlay), ev_window->priv->scrolled_window);
+	gtk_widget_show (ev_window->priv->scrolled_window);
+
+	ev_window->priv->loading_message = ev_loading_message_new ();
+	gtk_widget_set_name (ev_window->priv->loading_message, "ev-loading-message");
+	gtk_widget_set_halign (ev_window->priv->loading_message, GTK_ALIGN_END);
+	gtk_widget_set_valign (ev_window->priv->loading_message, GTK_ALIGN_START);
+	gtk_widget_set_no_show_all (ev_window->priv->loading_message, TRUE);
+	gtk_overlay_add_overlay (GTK_OVERLAY (overlay), ev_window->priv->loading_message);
+
 	gtk_box_pack_start (GTK_BOX (ev_window->priv->view_box),
-			    ev_window->priv->scrolled_window,
+			    overlay,
 			    TRUE, TRUE, 0);
-	gtk_widget_show (ev_window->priv->scrolled_window);
+	gtk_widget_show (overlay);
 
 	gtk_paned_add2 (GTK_PANED (ev_window->priv->hpaned),
 			ev_window->priv->view_box);
@@ -7473,6 +7536,9 @@ ev_window_init (EvWindow *ev_window)
 	g_signal_connect_object (ev_window->priv->view, "layers-changed",
 				 G_CALLBACK (view_layers_changed_cb),
 				 ev_window, 0);
+	g_signal_connect_object (ev_window->priv->view, "notify::is-loading",
+				 G_CALLBACK (view_is_loading_changed_cb),
+				 ev_window, 0);
 #ifdef ENABLE_DBUS
 	g_signal_connect_swapped (ev_window->priv->view, "sync-source",
 				  G_CALLBACK (ev_window_sync_source),
diff --git a/shell/evince.css b/shell/evince.css
index cf70da9..0aa5a1e 100644
--- a/shell/evince.css
+++ b/shell/evince.css
@@ -1,3 +1,10 @@
 #ev-fullscreen-toolbar {
     -GtkToolbar-shadow-type: none;
 }
+
+#ev-loading-message {
+    background-color: @info_bg_color;
+    color: @info_fg_color;
+    border-radius: 10px;
+    padding: 10px;
+}
diff --git a/shell/evince.gresource.xml b/shell/evince.gresource.xml
index 2fac911..6f97114 100644
--- a/shell/evince.gresource.xml
+++ b/shell/evince.gresource.xml
@@ -19,5 +19,6 @@
   <gresource prefix="/org/gnome/evince/shell">
     <file alias="ui/evince.xml" compressed="true" preprocess="xml-stripblanks">evince-ui.xml</file>
     <file alias="ui/toolbar.xml" compressed="true" preprocess="xml-stripblanks">evince-toolbar.xml</file>
+    <file alias="ui/evince.css" compressed="true">evince.css</file>
   </gresource>
 </gresources>



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