summaryrefslogtreecommitdiff
path: root/libview/ev-view.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <[email protected]>2012-09-29 16:06:39 +0200
committerraveit65 <[email protected]>2018-03-22 08:27:44 +0100
commita04ab7f1b28fd3e3f767baaa69b0c4eb06a0825a (patch)
tree8b835b9b07383ba4f3b7fb10e204ea00522e7617 /libview/ev-view.c
parent9ac0d1a788affc0307d837b8011f533d16974841 (diff)
downloadatril-a04ab7f1b28fd3e3f767baaa69b0c4eb06a0825a.tar.bz2
atril-a04ab7f1b28fd3e3f767baaa69b0c4eb06a0825a.tar.xz
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. origin commit: https://git.gnome.org/browse/evince/commit/?h=gnome-3-8&id=035c1cb
Diffstat (limited to 'libview/ev-view.c')
-rw-r--r--libview/ev-view.c130
1 files changed, 31 insertions, 99 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 6e02efce..a2f368d8 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -41,7 +41,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"
@@ -74,6 +73,7 @@ enum {
enum {
PROP_0,
+ PROP_IS_LOADING,
PROP_HADJUSTMENT,
PROP_VADJUSTMENT,
PROP_HSCROLL_POLICY,
@@ -189,12 +189,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,
@@ -751,7 +748,7 @@ view_update_range_and_current_page (EvView *view)
if (best_current_page >= 0 && 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);
}
}
@@ -4046,13 +4043,6 @@ ev_view_draw (GtkWidget *widget,
GdkRectangle *area = &clip_rect;
gint i;
- 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);
- }
-
gtk_render_background (gtk_widget_get_style_context (widget),
cr,
0, 0,
@@ -5691,81 +5681,6 @@ highlight_forward_search_results (EvView *view, cairo_t *cr, int page)
}
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),
- WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) + 1,
- HeightOfScreen (gdk_x11_screen_get_xscreen (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_surface (cairo_t *cr,
cairo_surface_t *surface,
gint x,
@@ -5894,7 +5809,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;
@@ -5906,7 +5821,7 @@ draw_one_page (EvView *view,
#endif
if (page == current_page)
- hide_loading_window (view);
+ ev_view_set_loading (view, FALSE);
ev_view_get_page_size (view, page, &width, &height);
offset_x = overlap.x - real_page_area.x;
@@ -6027,11 +5942,6 @@ ev_view_dispose (GObject *object)
view->cursor_blink_timeout_id = 0;
}
- if (view->loading_timeout) {
- g_source_remove (view->loading_timeout);
- view->loading_timeout = 0;
- }
-
g_clear_object(&view->accessible);
G_OBJECT_CLASS (ev_view_parent_class)->dispose (object);
@@ -6046,6 +5956,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;
@@ -6073,6 +5986,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:
set_scroll_adjustment (view, GTK_ORIENTATION_HORIZONTAL,
(GtkAdjustment *) g_value_get_object (value));
@@ -6309,6 +6225,15 @@ ev_view_class_init (EvViewClass *class)
class->scroll = ev_view_scroll_internal;
class->move_cursor = ev_view_move_cursor;
+ 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");
@@ -6572,7 +6497,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);
@@ -6743,10 +6668,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
@@ -6841,7 +6773,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);
}