summaryrefslogtreecommitdiff
path: root/libview
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-11-23 18:15:54 +0300
committermonsta <[email protected]>2016-11-23 18:15:54 +0300
commitae5f4711a21508a70d7123dbc0efb610af1289a2 (patch)
tree54d4a9de3b092aa772ed8799fcf30e11e19ff93f /libview
parent7884bbe50fe8b8c26e68b8077c18047861c2dd0c (diff)
downloadatril-ae5f4711a21508a70d7123dbc0efb610af1289a2.tar.bz2
atril-ae5f4711a21508a70d7123dbc0efb610af1289a2.tar.xz
move to GTK+3 (>= 3.14), drop GTK+2 code and --with-gtk build option
and require caja >= 1.17.1
Diffstat (limited to 'libview')
-rw-r--r--libview/Makefile.am4
-rw-r--r--libview/ev-annotation-window.c44
-rw-r--r--libview/ev-jobs.c60
-rw-r--r--libview/ev-loading-window.c48
-rw-r--r--libview/ev-pixbuf-cache.c37
-rw-r--r--libview/ev-print-operation.c34
-rw-r--r--libview/ev-timeline.c10
-rw-r--r--libview/ev-view-presentation.c134
-rw-r--r--libview/ev-view-private.h10
-rw-r--r--libview/ev-view.c406
-rw-r--r--libview/ev-web-view.c171
11 files changed, 17 insertions, 941 deletions
diff --git a/libview/Makefile.am b/libview/Makefile.am
index 6377d7ab..252f9f0e 100644
--- a/libview/Makefile.am
+++ b/libview/Makefile.am
@@ -131,9 +131,9 @@ AtrilView-$(EV_API_VERSION).gir: libatrilview.la Makefile $(INST_H_FILES) $(filt
--include=GLib-2.0 \
--include=GObject-2.0 \
--include=Gio-2.0 \
- --include=Gdk-$(GTK_API_VERSION) \
+ --include=Gdk-3.0 \
--include=GdkPixbuf-2.0 \
- --include=Gtk-$(GTK_API_VERSION) \
+ --include=Gtk-3.0 \
--include=AtrilDocument-$(EV_API_VERSION) \
--library=atrilview \
--libtool="$(LIBTOOL)" \
diff --git a/libview/ev-annotation-window.c b/libview/ev-annotation-window.c
index 69278b3e..de5c8876 100644
--- a/libview/ev-annotation-window.c
+++ b/libview/ev-annotation-window.c
@@ -28,13 +28,6 @@
#include "ev-view-marshal.h"
#include "ev-document-misc.h"
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gdk_cursor_unref g_object_unref
-#define gtk_widget_render_icon(A,B,C,D) gtk_widget_render_icon_pixbuf(A,B,C)
-#define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y)
-#define gtk_vbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_VERTICAL,Y)
-#endif
-
enum {
PROP_0,
PROP_ANNOTATION,
@@ -141,7 +134,6 @@ static void
ev_annotation_window_set_color (EvAnnotationWindow *window,
GdkColor *color)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkStyleProperties *properties;
GtkStyleProvider *provider;
GdkRGBA rgba;
@@ -167,34 +159,6 @@ ev_annotation_window_set_color (EvAnnotationWindow *window,
gtk_style_context_add_provider (gtk_widget_get_style_context (window->resize_sw),
provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (properties);
-#else
- GtkRcStyle *rc_style;
- GdkColor gcolor;
-
- gcolor = *color;
-
- /* Allocate these colors */
- gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (window)),
- &gcolor, FALSE, TRUE);
-
- /* Apply colors to style */
- rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (window));
- rc_style->base[GTK_STATE_NORMAL] = gcolor;
- rc_style->bg[GTK_STATE_PRELIGHT] = gcolor;
- rc_style->bg[GTK_STATE_NORMAL] = gcolor;
- rc_style->bg[GTK_STATE_ACTIVE] = gcolor;
- rc_style->color_flags[GTK_STATE_PRELIGHT] = GTK_RC_BG;
- rc_style->color_flags[GTK_STATE_NORMAL] = GTK_RC_BG | GTK_RC_BASE;
- rc_style->color_flags[GTK_STATE_ACTIVE] = GTK_RC_BG;
-
- /* Apply the style to the widgets */
- g_object_ref (rc_style);
- gtk_widget_modify_style (GTK_WIDGET (window), rc_style);
- gtk_widget_modify_style (window->close_button, rc_style);
- gtk_widget_modify_style (window->resize_se, rc_style);
- gtk_widget_modify_style (window->resize_sw, rc_style);
- g_object_unref (rc_style);
-#endif
}
static void
@@ -289,7 +253,7 @@ ev_annotation_window_set_resize_cursor (GtkWidget *widget,
GDK_BOTTOM_LEFT_CORNER :
GDK_BOTTOM_RIGHT_CORNER);
gdk_window_set_cursor (gdk_window, cursor);
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
} else {
gdk_window_set_cursor (gdk_window, NULL);
}
@@ -321,10 +285,10 @@ ev_annotation_window_init (EvAnnotationWindow *window)
gtk_widget_set_can_focus (GTK_WIDGET (window), TRUE);
- vbox = gtk_vbox_new (FALSE, 0);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
/* Title bar */
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
icon = gtk_image_new (); /* FIXME: use the annot icon */
gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
@@ -367,7 +331,7 @@ ev_annotation_window_init (EvAnnotationWindow *window)
gtk_widget_show (swindow);
/* Resize bar */
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
window->resize_sw = gtk_event_box_new ();
gtk_widget_add_events (window->resize_sw, GDK_BUTTON_PRESS_MASK);
diff --git a/libview/ev-jobs.c b/libview/ev-jobs.c
index f03aef2a..a7ef8f13 100644
--- a/libview/ev-jobs.c
+++ b/libview/ev-jobs.c
@@ -42,11 +42,7 @@
#include <gtk/gtk.h>
#if ENABLE_EPUB
-#if GTK_CHECK_VERSION(3, 0, 0)
#include <webkit2/webkit2.h>
-#else
-#include <webkit/webkit.h>
-#endif
#endif
#include <errno.h>
#include <glib/gstdio.h>
@@ -831,51 +827,6 @@ ev_job_thumbnail_dispose (GObject *object)
}
#if ENABLE_EPUB
-#if !GTK_CHECK_VERSION(3, 0, 0)
-static void
-web_thumbnail_get_screenshot_cb(GObject *object,
- GParamSpec *pspec,
- EvJobThumbnail *job_thumb)
-{
- WebKitWebView *webview = WEBKIT_WEB_VIEW(object);
- WebKitLoadStatus status = webkit_web_view_get_load_status (webview);
- if (status != WEBKIT_LOAD_FINISHED) {
- return;
- }
-
- ev_document_doc_mutex_lock ();
-
- EvPage *page = ev_document_get_page (EV_JOB(job_thumb)->document, job_thumb->page);
- job_thumb->surface = webkit_web_view_get_snapshot (webview);
- EvRenderContext *rc = ev_render_context_new (page, job_thumb->rotation, job_thumb->scale);
- EvPage *screenshotpage;
- screenshotpage = ev_page_new(job_thumb->page);
- screenshotpage->backend_page = (EvBackendPage)job_thumb->surface;
- screenshotpage->backend_destroy_func = (EvBackendPageDestroyFunc)cairo_surface_destroy ;
- ev_render_context_set_page(rc,screenshotpage);
-
- job_thumb->thumbnail = ev_document_thumbnails_get_thumbnail (EV_DOCUMENT_THUMBNAILS (EV_JOB(job_thumb)->document),
- rc, TRUE);
- g_object_unref(screenshotpage);
- g_object_unref(rc);
-
- ev_document_doc_mutex_unlock ();
- ev_job_succeeded (EV_JOB(job_thumb));
- return;
-}
-
-static gboolean
-webview_load_error_cb (WebKitWebView *webview,
- WebKitWebFrame *web_frame,
- gchar *uri,
- GError *web_error,
- EvJobThumbnail *job_thumb)
-{
- g_warning ("Error loading data from %s: %s", uri, web_error->message);
- ev_job_failed_from_error (EV_JOB(job_thumb), web_error);
- return TRUE;
-}
-#else
static void
snapshot_callback(WebKitWebView *webview,
GAsyncResult *results,
@@ -939,7 +890,6 @@ webview_load_failed_cb (WebKitWebView *webview,
ev_job_failed_from_error (EV_JOB(job_thumb), e);
return TRUE;
}
-#endif /* GTK_CHECK_VERSION */
#endif /* ENABLE_EPUB */
static gboolean
@@ -973,22 +923,12 @@ ev_job_thumbnail_run (EvJob *job)
if (job->document->iswebdocument == TRUE) {
if (!webview) {
webview = webkit_web_view_new();
-#if !GTK_CHECK_VERSION (3, 0, 0)
- g_object_connect(WEBKIT_WEB_VIEW(webview),"signal::notify::load-status",
- G_CALLBACK(web_thumbnail_get_screenshot_cb),
- g_object_ref (job_thumb),
- NULL);
- g_signal_connect(WEBKIT_WEB_VIEW(webview),"load-error",
- G_CALLBACK(webview_load_error_cb),
- g_object_ref (job_thumb));
-#else
g_signal_connect(WEBKIT_WEB_VIEW(webview),"load-changed",
G_CALLBACK(web_thumbnail_get_screenshot_cb),
g_object_ref (job_thumb));
g_signal_connect(WEBKIT_WEB_VIEW(webview),"load-failed",
G_CALLBACK(webview_load_failed_cb),
g_object_ref (job_thumb));
-#endif /* GTK_CHECK_VERSION */
}
if (!offscreenwindow) {
diff --git a/libview/ev-loading-window.c b/libview/ev-loading-window.c
index ff675ff1..52de665c 100644
--- a/libview/ev-loading-window.c
+++ b/libview/ev-loading-window.c
@@ -24,10 +24,6 @@
#include <glib/gi18n.h>
#include "ev-loading-window.h"
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y)
-#endif
-
enum {
PROP_0,
PROP_PARENT
@@ -75,18 +71,14 @@ ev_loading_window_init (EvLoadingWindow *window)
GtkWidget *widget = GTK_WIDGET (window);
GtkWidget *hbox;
GtkWidget *label;
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkStyleContext *context;
GdkRGBA fg, bg;
-#else
- GtkStyle *style;
- GdkColor fg, bg;
-#endif
+
const gchar *loading_text = _("Loading…");
const gchar *fg_color_name = "info_fg_color";
const gchar *bg_color_name = "info_bg_color";
- hbox = gtk_hbox_new (FALSE, 12);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
window->spinner = gtk_spinner_new ();
gtk_box_pack_start (GTK_BOX (hbox), window->spinner, FALSE, FALSE, 0);
@@ -108,7 +100,6 @@ ev_loading_window_init (EvLoadingWindow *window)
gtk_window_set_decorated (gtk_window, FALSE);
gtk_window_set_resizable (gtk_window, FALSE);
-#if GTK_CHECK_VERSION (3, 0, 0)
context = gtk_widget_get_style_context (widget);
if (!gtk_style_context_lookup_color (context, fg_color_name, &fg) ||
!gtk_style_context_lookup_color (context, bg_color_name, &bg)) {
@@ -126,27 +117,6 @@ ev_loading_window_init (EvLoadingWindow *window)
gtk_widget_override_background_color (widget, GTK_STATE_NORMAL, &bg);
gtk_widget_override_color (widget, GTK_STATE_NORMAL, &fg);
}
-#else
- style = gtk_widget_get_style (widget);
- if (!gtk_style_lookup_color (style, fg_color_name, &fg) ||
- !gtk_style_lookup_color (style, bg_color_name, &bg)) {
- fg.pixel = 0;
- fg.red = 0xb800;
- fg.green = 0xad00;
- fg.blue = 0x9d00;
-
- bg.pixel = 0;
- bg.red = 0xff00;
- bg.green = 0xff00;
- bg.blue = 0xbf00;
- }
-
- if (!gdk_color_equal (&bg, &style->bg[GTK_STATE_NORMAL]))
- gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &bg);
- if (!gdk_color_equal (&fg, &style->fg[GTK_STATE_NORMAL]))
- gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &fg);
-}
-#endif
static GObject *
ev_loading_window_constructor (GType type,
@@ -205,12 +175,8 @@ ev_loading_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
EvLoadingWindow *window = EV_LOADING_WINDOW (widget);
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_surface_t *surface;
cairo_region_t *shape;
-#else
- GdkPixmap *mask;
-#endif
cairo_t *cr;
double r;
@@ -222,13 +188,8 @@ ev_loading_window_size_allocate (GtkWidget *widget,
window->width = allocation->width;
window->height = allocation->height;
-#if GTK_CHECK_VERSION (3, 0, 0)
surface = cairo_image_surface_create (CAIRO_FORMAT_A8, window->width, window->height);
cr = cairo_create (surface);
-#else
- mask = gdk_pixmap_new (NULL, window->width, window->height, 1);
- cr = gdk_cairo_create (GDK_DRAWABLE (mask));
-#endif
cairo_save (cr);
cairo_rectangle (cr, 0, 0, window->width, window->height);
@@ -243,16 +204,11 @@ ev_loading_window_size_allocate (GtkWidget *widget,
cairo_destroy (cr);
-#if GTK_CHECK_VERSION (3, 0, 0)
shape = gdk_cairo_region_create_from_surface (surface);
cairo_surface_destroy (surface);
gtk_widget_shape_combine_region (widget, shape);
cairo_region_destroy (shape);
-#else
- gtk_widget_shape_combine_mask (widget, mask, 0, 0);
- g_object_unref (mask);
-#endif
}
static void
diff --git a/libview/ev-pixbuf-cache.c b/libview/ev-pixbuf-cache.c
index 645904ee..3c4fd31b 100644
--- a/libview/ev-pixbuf-cache.c
+++ b/libview/ev-pixbuf-cache.c
@@ -602,7 +602,6 @@ ev_pixbuf_cache_clear_job_sizes (EvPixbufCache *pixbuf_cache,
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
get_selection_colors (GtkWidget *widget, GdkColor *text, GdkColor *base)
{
GtkStyleContext *context = gtk_widget_get_style_context (widget);
@@ -623,20 +622,6 @@ get_selection_colors (GtkWidget *widget, GdkColor *text, GdkColor *base)
base->green = CLAMP ((guint) (bg.green * 65535), 0, 65535);
base->blue = CLAMP ((guint) (bg.blue * 65535), 0, 65535);
}
-#else
-get_selection_colors (GtkWidget *widget, GdkColor **text, GdkColor **base)
-{
- GtkStyle *style = gtk_widget_get_style (widget);
-
- if (gtk_widget_has_focus (widget)) {
- *text = &style->text [GTK_STATE_SELECTED];
- *base = &style->base [GTK_STATE_SELECTED];
- } else {
- *text = &style->text [GTK_STATE_ACTIVE];
- *base = &style->base [GTK_STATE_ACTIVE];
- }
-}
-#endif
static void
add_job (EvPixbufCache *pixbuf_cache,
@@ -660,22 +645,12 @@ add_job (EvPixbufCache *pixbuf_cache,
width, height);
if (new_selection_surface_needed (pixbuf_cache, job_info, page, scale)) {
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkColor text, base;
-#else
- GdkColor *text, *base;
-
- gtk_widget_ensure_style (pixbuf_cache->view);
-#endif
get_selection_colors (pixbuf_cache->view, &text, &base);
ev_job_render_set_selection_info (EV_JOB_RENDER (job_info->job),
&(job_info->target_points),
job_info->selection_style,
-#if GTK_CHECK_VERSION (3, 0, 0)
&text, &base);
-#else
- text, base);
-#endif
}
g_signal_connect (job_info->job, "finished",
@@ -983,11 +958,7 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
*/
if (ev_rect_cmp (&(job_info->target_points), &(job_info->selection_points))) {
EvRectangle *old_points;
-#if GTK_CHECK_VERSION (3, 0, 0)
GdkColor text, base;
-#else
- GdkColor *text, *base;
-#endif
EvRenderContext *rc;
EvPage *ev_page;
@@ -1012,10 +983,6 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
rc, job_info->selection_style,
&(job_info->target_points));
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_ensure_style (pixbuf_cache->view);
-#endif
-
get_selection_colors (pixbuf_cache->view, &text, &base);
ev_selection_render_selection (EV_SELECTION (pixbuf_cache->document),
@@ -1023,11 +990,7 @@ ev_pixbuf_cache_get_selection_surface (EvPixbufCache *pixbuf_cache,
&(job_info->target_points),
old_points,
job_info->selection_style,
-#if GTK_CHECK_VERSION (3, 0, 0)
&text, &base);
-#else
- text, base);
-#endif
job_info->selection_points = job_info->target_points;
g_object_unref (rc);
ev_document_doc_mutex_unlock ();
diff --git a/libview/ev-print-operation.c b/libview/ev-print-operation.c
index 822d1a84..7ca2b41e 100644
--- a/libview/ev-print-operation.c
+++ b/libview/ev-print-operation.c
@@ -872,12 +872,7 @@ export_print_done (EvPrintOperationExport *export)
app = g_app_info_create_from_commandline (cmd, NULL, 0, &error);
if (app != NULL) {
-#if GTK_CHECK_VERSION (3, 0, 0)
ctx = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (export->parent_window)));
-#else
- ctx = gdk_app_launch_context_new ();
- gdk_app_launch_context_set_display (ctx, gtk_widget_get_display (GTK_WIDGET (export->parent_window)));
-#endif
gdk_app_launch_context_set_screen (ctx, gtk_window_get_screen (export->parent_window));
g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (ctx), &error);
@@ -1873,11 +1868,7 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print,
{
GtkPrintSettings *settings;
GtkWidget *label;
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *grid;
-#else
- GtkWidget *table;
-#endif
EvPrintScale page_scale;
gboolean autorotate;
gboolean use_source_size;
@@ -1889,7 +1880,6 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print,
TRUE;
use_source_size = gtk_print_settings_get_bool (settings, EV_PRINT_SETTING_PAGE_SIZE);
-#if GTK_CHECK_VERSION (3, 0, 0)
grid = gtk_grid_new ();
gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
@@ -1897,15 +1887,6 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print,
label = gtk_label_new (_("Page Scaling:"));
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
-#else
- table = gtk_table_new (3, 2, FALSE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 6);
- gtk_table_set_col_spacings (GTK_TABLE (table), 12);
- gtk_container_set_border_width (GTK_CONTAINER (table), 12);
-
- label = gtk_label_new (_("Page Scaling:"));
- gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
-#endif
gtk_widget_show (label);
print->scale_combo = gtk_combo_box_text_new ();
@@ -1924,11 +1905,7 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print,
"\n"
"• \"Fit to Printable Area\": Document pages are enlarged or reduced as"
" required to fit the printable area of the printer page.\n"));
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_grid_attach (GTK_GRID (grid), print->scale_combo, 1, 0, 1, 1);
-#else
- gtk_table_attach (GTK_TABLE (table), print->scale_combo, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
-#endif
gtk_widget_show (print->scale_combo);
print->autorotate_button = gtk_check_button_new_with_label (_("Auto Rotate and Center"));
@@ -1936,28 +1913,17 @@ ev_print_operation_print_create_custom_widget (EvPrintOperationPrint *print,
gtk_widget_set_tooltip_text (print->autorotate_button,
_("Rotate printer page orientation of each page to match orientation of each document page. "
"Document pages will be centered within the printer page."));
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_grid_attach (GTK_GRID (grid), print->autorotate_button, 0, 1, 2, 1);
-#else
- gtk_table_attach (GTK_TABLE (table), print->autorotate_button, 0, 2, 1, 2, GTK_FILL, 0, 0, 0);
-#endif
gtk_widget_show (print->autorotate_button);
print->source_button = gtk_check_button_new_with_label (_("Select page size using document page size"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (print->source_button), use_source_size);
gtk_widget_set_tooltip_text (print->source_button, _("When enabled, each page will be printed on "
"the same size paper as the document page."));
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_grid_attach (GTK_GRID (grid), print->source_button, 0, 2, 2, 1);
gtk_widget_show (print->source_button);
return G_OBJECT (grid);
-#else
- gtk_table_attach (GTK_TABLE (table), print->source_button, 0, 2, 2, 3, GTK_FILL, 0, 0, 0);
- gtk_widget_show (print->source_button);
-
- return G_OBJECT (table);
-#endif
}
static void
diff --git a/libview/ev-timeline.c b/libview/ev-timeline.c
index 70644c22..62c97286 100644
--- a/libview/ev-timeline.c
+++ b/libview/ev-timeline.c
@@ -21,8 +21,6 @@
#include <glib.h>
#include <math.h>
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
#include "ev-timeline.h"
#define EV_TIMELINE_GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_TIMELINE, EvTimelinePriv))
@@ -151,10 +149,6 @@ ev_timeline_run_frame (EvTimeline *timeline)
gdouble progress;
guint elapsed_time;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gdk_threads_enter();
-#endif
-
priv = EV_TIMELINE_GET_PRIV (timeline);
elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000);
@@ -177,10 +171,6 @@ ev_timeline_run_frame (EvTimeline *timeline)
}
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gdk_threads_leave();
-#endif
-
return TRUE;
}
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c
index dadd0c6b..74ce60ee 100644
--- a/libview/ev-view-presentation.c
+++ b/libview/ev-view-presentation.c
@@ -32,11 +32,6 @@
#include "ev-view-cursor.h"
#include "ev-page-cache.h"
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gdk_cursor_unref g_object_unref
-#define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y)
-#endif
-
enum {
PROP_0,
PROP_DOCUMENT,
@@ -120,29 +115,19 @@ static void ev_view_presentation_set_cursor_for_location (EvViewPresentation *pv
G_DEFINE_TYPE (EvViewPresentation, ev_view_presentation, GTK_TYPE_WIDGET)
-#if GTK_CHECK_VERSION (3, 0, 0)
static GdkRGBA black = { 0., 0., 0., 1. };
static GdkRGBA white = { 1., 1., 1., 1. };
-#endif
static void
ev_view_presentation_set_normal (EvViewPresentation *pview)
{
GtkWidget *widget = GTK_WIDGET (pview);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GtkStyle *style;
-#endif
if (pview->state == EV_PRESENTATION_NORMAL)
return;
pview->state = EV_PRESENTATION_NORMAL;
-#if GTK_CHECK_VERSION (3, 0, 0)
gdk_window_set_background_rgba (gtk_widget_get_window (widget), &black);
-#else
- style = gtk_widget_get_style (widget);
- gdk_window_set_background (gtk_widget_get_window (widget), &style->black);
-#endif
gtk_widget_queue_draw (widget);
}
@@ -150,20 +135,12 @@ static void
ev_view_presentation_set_black (EvViewPresentation *pview)
{
GtkWidget *widget = GTK_WIDGET (pview);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GtkStyle *style;
-#endif
if (pview->state == EV_PRESENTATION_BLACK)
return;
pview->state = EV_PRESENTATION_BLACK;
-#if GTK_CHECK_VERSION (3, 0, 0)
gdk_window_set_background_rgba (gtk_widget_get_window (widget), &black);
-#else
- style = gtk_widget_get_style (widget);
- gdk_window_set_background (gtk_widget_get_window (widget), &style->black);
-#endif
gtk_widget_queue_draw (widget);
}
@@ -171,20 +148,12 @@ static void
ev_view_presentation_set_white (EvViewPresentation *pview)
{
GtkWidget *widget = GTK_WIDGET (pview);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GtkStyle *style;
-#endif
if (pview->state == EV_PRESENTATION_WHITE)
return;
pview->state = EV_PRESENTATION_WHITE;
-#if GTK_CHECK_VERSION (3, 0, 0)
gdk_window_set_background_rgba (gtk_widget_get_window (widget), &white);
-#else
- style = gtk_widget_get_style (widget);
- gdk_window_set_background (gtk_widget_get_window (widget), &style->white);
-#endif
gtk_widget_queue_draw (widget);
}
@@ -528,11 +497,7 @@ ev_view_presentation_update_current_page (EvViewPresentation *pview,
if (pview->cursor != EV_VIEW_CURSOR_HIDDEN) {
gint x, y;
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (GTK_WIDGET (pview), &x, &y);
-#else
- gtk_widget_get_pointer (GTK_WIDGET (pview), &x, &y);
-#endif
ev_view_presentation_set_cursor_for_location (pview, x, y);
}
@@ -719,7 +684,7 @@ ev_view_presentation_goto_window_create (EvViewPresentation *pview)
gtk_container_add (GTK_CONTAINER (pview->goto_window), frame);
gtk_widget_show (frame);
- hbox = gtk_hbox_new (FALSE, 0);
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 3);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
@@ -917,7 +882,7 @@ ev_view_presentation_set_cursor (EvViewPresentation *pview,
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
gdk_flush ();
if (cursor)
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
static void
@@ -1005,7 +970,6 @@ ev_view_presentation_dispose (GObject *object)
G_OBJECT_CLASS (ev_view_presentation_parent_class)->dispose (object);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
ev_view_presentation_get_preferred_width (GtkWidget *widget,
gint *minimum,
@@ -1021,15 +985,6 @@ ev_view_presentation_get_preferred_height (GtkWidget *widget,
{
*minimum = *natural = 0;
}
-#else
-static void
-ev_view_presentation_size_request (GtkWidget *widget,
- GtkRequisition *requisition)
-{
- requisition->width = 0;
- requisition->height = 0;
-}
-#endif
static void
ev_view_presentation_draw_end_page (EvViewPresentation *pview, cairo_t *cr)
@@ -1038,10 +993,7 @@ ev_view_presentation_draw_end_page (EvViewPresentation *pview, cairo_t *cr)
PangoLayout *layout;
PangoFontDescription *font_desc;
gchar *markup;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GtkAllocation allocation;
- GdkRectangle area = {0};
-#endif
+
const gchar *text = _("End of presentation. Click to exit.");
if (pview->state != EV_PRESENTATION_END)
@@ -1056,57 +1008,27 @@ ev_view_presentation_draw_end_page (EvViewPresentation *pview, cairo_t *cr)
pango_font_description_set_size (font_desc, 16 * PANGO_SCALE);
pango_layout_set_font_description (layout, font_desc);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gtk_widget_get_allocation (widget, &allocation);
- area.width = allocation.width;
- area.height = allocation.height;
-#endif
-
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_render_layout (gtk_widget_get_style_context (widget),
cr, 15, 15, layout);
-#else
- gtk_paint_layout (gtk_widget_get_style (widget),
- gtk_widget_get_window (widget),
- gtk_widget_get_state (widget),
- FALSE,
- &area,
- widget,
- NULL,
- 15,
- 15,
- layout);
-#endif
pango_font_description_free (font_desc);
g_object_unref (layout);
}
static gboolean
-#if GTK_CHECK_VERSION (3, 0, 0)
ev_view_presentation_draw (GtkWidget *widget,
cairo_t *cr)
-#else
-ev_view_presentation_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
-#endif
{
EvViewPresentation *pview = EV_VIEW_PRESENTATION (widget);
GdkRectangle page_area;
GdkRectangle overlap;
cairo_surface_t *surface;
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_rectangle_int_t clip_rect;
GdkRectangle *area = &clip_rect;
-#else
- cairo_t *cr;
- GdkRectangle *area = &event->area;
-#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
if (!gdk_cairo_get_clip_rectangle (cr, &clip_rect))
return FALSE;
-#endif
+
switch (pview->state) {
case EV_PRESENTATION_END:
ev_view_presentation_draw_end_page (pview, cr);
@@ -1122,10 +1044,6 @@ ev_view_presentation_expose_event (GtkWidget *widget,
if (ev_transition_animation_ready (pview->animation)) {
ev_view_presentation_get_page_area (pview, &page_area);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
-#endif
-
/* normalize to x=0, y=0 */
cairo_translate (cr, page_area.x, page_area.y);
page_area.x = page_area.y = 0;
@@ -1134,9 +1052,6 @@ ev_view_presentation_expose_event (GtkWidget *widget,
page_area.width--;
ev_transition_animation_paint (pview->animation, cr, page_area);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_destroy (cr);
-#endif
}
return TRUE;
@@ -1153,10 +1068,6 @@ ev_view_presentation_expose_event (GtkWidget *widget,
ev_view_presentation_get_page_area (pview, &page_area);
if (gdk_rectangle_intersect (&page_area, area, &overlap)) {
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cr = gdk_cairo_create (gtk_widget_get_window (widget));
-#endif
-
/* Try to fix rounding errors. See bug #438760 */
if (overlap.width == page_area.width)
overlap.width--;
@@ -1164,9 +1075,6 @@ ev_view_presentation_expose_event (GtkWidget *widget,
cairo_rectangle (cr, overlap.x, overlap.y, overlap.width, overlap.height);
cairo_set_source_surface (cr, surface, page_area.x, page_area.y);
cairo_fill (cr);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_destroy (cr);
-#endif
}
return FALSE;
@@ -1227,11 +1135,7 @@ ev_view_presentation_key_press_event (GtkWidget *widget,
ev_view_presentation_goto_window_create (pview);
ev_view_presentation_goto_window_send_key_event (pview, (GdkEvent *)event);
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (GTK_WIDGET (pview), &x, &y);
-#else
- gtk_widget_get_pointer (GTK_WIDGET (pview), &x, &y);
-#endif
gtk_window_move (GTK_WINDOW (pview->goto_window), x, y);
gtk_widget_show (pview->goto_window);
ev_view_presentation_goto_entry_grab_focus (pview);
@@ -1324,9 +1228,6 @@ static void
ev_view_presentation_realize (GtkWidget *widget)
{
GdkWindow *window;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GtkStyle *style;
-#endif
GdkWindowAttr attributes;
GtkAllocation allocation;
@@ -1335,9 +1236,6 @@ ev_view_presentation_realize (GtkWidget *widget)
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
-#if !GTK_CHECK_VERSION (3, 0, 0)
- attributes.colormap = gtk_widget_get_colormap (widget);
-#endif
gtk_widget_get_allocation (widget, &allocation);
attributes.x = allocation.x;
@@ -1357,22 +1255,13 @@ ev_view_presentation_realize (GtkWidget *widget)
window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes,
GDK_WA_X | GDK_WA_Y |
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GDK_WA_COLORMAP |
-#endif
GDK_WA_VISUAL);
gdk_window_set_user_data (window, widget);
gtk_widget_set_window (widget, window);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_style_context_set_background (gtk_widget_get_style_context (widget),
window);
-#else
- gtk_widget_style_attach (widget);
- style = gtk_widget_get_style (widget);
- gdk_window_set_background (window, &style->black);
-#endif
g_idle_add ((GSourceFunc)init_presentation, widget);
}
@@ -1413,10 +1302,8 @@ ev_view_presentation_scroll_event (GtkWidget *widget,
case GDK_SCROLL_LEFT:
ev_view_presentation_change_page (pview, GTK_SCROLL_PAGE_BACKWARD);
break;
-#if GTK_CHECK_VERSION (3, 0, 0)
case GDK_SCROLL_SMOOTH:
return FALSE;
-#endif
}
return TRUE;
@@ -1514,18 +1401,10 @@ ev_view_presentation_class_init (EvViewPresentationClass *klass)
klass->change_page = ev_view_presentation_change_page;
-#if GTK_CHECK_VERSION (3, 0, 0)
widget_class->get_preferred_width = ev_view_presentation_get_preferred_width;
widget_class->get_preferred_height = ev_view_presentation_get_preferred_height;
-#else
- widget_class->size_request = ev_view_presentation_size_request;
-#endif
widget_class->realize = ev_view_presentation_realize;
-#if GTK_CHECK_VERSION (3, 0, 0)
widget_class->draw = ev_view_presentation_draw;
-#else
- widget_class->expose_event = ev_view_presentation_expose_event;
-#endif
widget_class->key_press_event = ev_view_presentation_key_press_event;
widget_class->button_release_event = ev_view_presentation_button_release_event;
widget_class->focus_out_event = ev_view_presentation_focus_out;
@@ -1633,7 +1512,6 @@ ev_view_presentation_class_init (EvViewPresentationClass *klass)
static void
ev_view_presentation_init (EvViewPresentation *pview)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
static gsize initialization_value = 0;
gtk_widget_set_can_focus (GTK_WIDGET (pview), TRUE);
@@ -1653,10 +1531,6 @@ ev_view_presentation_init (EvViewPresentation *pview)
g_object_unref (provider);
g_once_init_leave (&initialization_value, 1);
}
-#else
- gtk_widget_set_can_focus (GTK_WIDGET (pview), TRUE);
- pview->is_constructing = TRUE;
-#endif
}
GtkWidget *
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index b6c0ea5f..b18dcc00 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -109,14 +109,10 @@ typedef struct _EvHeightToPageCache {
} EvHeightToPageCache;
struct _EvView {
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkContainer layout;
/* Container */
GList *children;
-#else
- GtkLayout layout;
-#endif
EvDocument *document;
@@ -140,12 +136,10 @@ struct _EvView {
/* Scrolling */
GtkAdjustment *hadjustment;
GtkAdjustment *vadjustment;
-#if GTK_CHECK_VERSION (3, 0, 0)
/* GtkScrollablePolicy needs to be checked when
* driving the scrollable adjustment values */
guint hscroll_policy : 1;
guint vscroll_policy : 1;
-#endif
gint scroll_x;
gint scroll_y;
@@ -211,11 +205,7 @@ struct _EvView {
};
struct _EvViewClass {
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkContainerClass parent_class;
-#else
- GtkLayoutClass parent_class;
-#endif
void (*binding_activated) (EvView *view,
GtkScrollType scroll,
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 4b503d4a..af0c3433 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -45,10 +45,6 @@
#include "ev-view-private.h"
#include "ev-view-type-builtins.h"
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gdk_cursor_unref g_object_unref
-#endif
-
#define EV_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_VIEW, EvViewClass))
#define EV_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EV_TYPE_VIEW))
#define EV_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EV_TYPE_VIEW, EvViewClass))
@@ -71,7 +67,6 @@ enum {
TARGET_DND_IMAGE
};
-#if GTK_CHECK_VERSION (3, 0, 0)
enum {
PROP_0,
PROP_HADJUSTMENT,
@@ -79,7 +74,6 @@ enum {
PROP_HSCROLL_POLICY,
PROP_VSCROLL_POLICY
};
-#endif
static guint signals[N_SIGNALS] = { 0 };
@@ -88,7 +82,6 @@ typedef enum {
EV_VIEW_FIND_PREV
} EvViewFindDirection;
-#if GTK_CHECK_VERSION (3, 0, 0)
typedef struct {
GtkWidget *widget;
@@ -100,7 +93,6 @@ typedef struct {
guint page;
EvRectangle doc_rect;
} EvViewChild;
-#endif
#define ZOOM_IN_FACTOR 1.2
#define ZOOM_OUT_FACTOR (1.0/ZOOM_IN_FACTOR)
@@ -108,17 +100,7 @@ typedef struct {
#define SCROLL_TIME 150
/*** Scrolling ***/
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void ev_view_set_scroll_adjustments (GtkLayout *layout,
- GtkAdjustment *hadjustment,
- GtkAdjustment *vadjustment);
-#endif
static void view_update_range_and_current_page (EvView *view);
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void set_scroll_adjustment (EvView *view,
- GtkOrientation orientation,
- GtkAdjustment *adjustment);
-#endif
static void add_scroll_binding_keypad (GtkBindingSet *binding_set,
guint keyval,
GdkModifierType modifiers,
@@ -185,18 +167,10 @@ static void ev_view_size_request (GtkWidget
GtkRequisition *requisition);
static void ev_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void ev_view_realize (GtkWidget *widget);
-#endif
static gboolean ev_view_scroll_event (GtkWidget *widget,
GdkEventScroll *event);
-#if GTK_CHECK_VERSION (3, 0, 0)
static gboolean ev_view_draw (GtkWidget *widget,
cairo_t *cr);
-#else
-static gboolean ev_view_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-#endif
static gboolean ev_view_popup_menu (GtkWidget *widget);
static gboolean ev_view_button_press_event (GtkWidget *widget,
GdkEventButton *event);
@@ -208,12 +182,7 @@ static gboolean ev_view_enter_notify_event (GtkWidget
GdkEventCrossing *event);
static gboolean ev_view_leave_notify_event (GtkWidget *widget,
GdkEventCrossing *event);
-#if GTK_CHECK_VERSION (3, 0, 0)
static void ev_view_style_updated (GtkWidget *widget);
-#else
-static void ev_view_style_set (GtkWidget *widget,
- GtkStyle *old_style);
-#endif
static void ev_view_remove_all (EvView *view);
static AtkObject *ev_view_get_accessible (GtkWidget *widget);
@@ -324,12 +293,8 @@ static void ev_view_primary_clear_cb (GtkClipboard
gpointer data);
static void ev_view_update_primary_selection (EvView *ev_view);
-#if GTK_CHECK_VERSION (3, 0, 0)
G_DEFINE_TYPE_WITH_CODE (EvView, ev_view, GTK_TYPE_CONTAINER,
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
-#else
-G_DEFINE_TYPE (EvView, ev_view, GTK_TYPE_LAYOUT)
-#endif
/* HeightToPage cache */
#define EV_HEIGHT_TO_PAGE_CACHE_KEY "ev-height-to-page-cache"
@@ -518,11 +483,7 @@ ev_view_get_scrollbar_size (EvView *view,
}
gtk_widget_style_get (swindow, "scrollbar_spacing", &spacing, NULL);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_get_preferred_size (sb, &req, NULL);
-#else
- gtk_widget_size_request (sb, &req);
-#endif
return (orientation == GTK_ORIENTATION_VERTICAL ? req.width : req.height) + spacing;
}
@@ -789,22 +750,15 @@ set_scroll_adjustment (EvView *view,
GtkAdjustment *adjustment)
{
GtkAdjustment **to_set;
-#if GTK_CHECK_VERSION (3, 0, 0)
const gchar *prop_name;
-#endif
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
to_set = &view->hadjustment;
-#if GTK_CHECK_VERSION (3, 0, 0)
prop_name = "hadjustment";
-#endif
} else {
to_set = &view->vadjustment;
-#if GTK_CHECK_VERSION (3, 0, 0)
prop_name = "vadjustment";
-#endif
}
-#if GTK_CHECK_VERSION (3, 0, 0)
if (adjustment && adjustment == *to_set)
return;
@@ -824,42 +778,8 @@ set_scroll_adjustment (EvView *view,
view_set_adjustment_values (view, orientation);
g_object_notify (G_OBJECT (view), prop_name);
-#else
- if (*to_set != adjustment) {
- if (*to_set) {
- g_signal_handlers_disconnect_by_func (*to_set,
- (gpointer) on_adjustment_value_changed,
- view);
- g_object_unref (*to_set);
- }
-
- *to_set = adjustment;
- view_set_adjustment_values (view, orientation);
-
- if (*to_set) {
- g_object_ref (*to_set);
- g_signal_connect (*to_set, "value_changed",
- G_CALLBACK (on_adjustment_value_changed), view);
- }
- }
-#endif
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void
-ev_view_set_scroll_adjustments (GtkLayout *layout,
- GtkAdjustment *hadjustment,
- GtkAdjustment *vadjustment)
-{
- EvView *view = EV_VIEW (layout);
-
- set_scroll_adjustment (view, GTK_ORIENTATION_HORIZONTAL, hadjustment);
- set_scroll_adjustment (view, GTK_ORIENTATION_VERTICAL, vadjustment);
-
- on_adjustment_value_changed (NULL, view);
-}
-#endif
-
static void
add_scroll_binding_keypad (GtkBindingSet *binding_set,
guint keyval,
@@ -1552,7 +1472,6 @@ ev_view_get_area_from_mapping (EvView *view,
area->y -= view->scroll_y;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
ev_view_put (EvView *view,
GtkWidget *child_widget,
@@ -1588,7 +1507,6 @@ ev_view_put_to_doc_rect (EvView *view,
area.y -= view->scroll_y;
ev_view_put (view, child_widget, area.x, area.y, page, doc_rect);
}
-#endif
/*** Hyperref ***/
static EvLink *
@@ -2510,11 +2428,7 @@ ev_view_handle_form_field (EvView *view,
{
GtkWidget *field_widget = NULL;
EvMappingList *form_field_mapping;
-#if GTK_CHECK_VERSION (3, 0, 0)
EvMapping *mapping;
-#else
- GdkRectangle view_area;
-#endif
if (field->is_read_only)
return;
@@ -2539,16 +2453,8 @@ ev_view_handle_form_field (EvView *view,
form_field_mapping = ev_page_cache_get_form_field_mapping (view->page_cache,
field->page->index);
-#if GTK_CHECK_VERSION (3, 0, 0)
mapping = ev_mapping_list_find (form_field_mapping, field);
ev_view_put_to_doc_rect (view, field_widget, field->page->index, &mapping->area);
-#else
- ev_view_get_area_from_mapping (view, field->page->index,
- form_field_mapping,
- field, &view_area);
-
- gtk_layout_put (GTK_LAYOUT (view), field_widget, view_area.x, view_area.y);
-#endif
gtk_widget_show (field_widget);
gtk_widget_grab_focus (field_widget);
}
@@ -3079,11 +2985,7 @@ ev_view_cancel_add_annotation (EvView *view)
return;
view->adding_annot = FALSE;
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
-#else
- gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
-#endif
ev_view_handle_cursor_over_xy (view, x, y);
}
@@ -3271,7 +3173,6 @@ ev_view_size_request (GtkWidget *widget,
*requisition = view->requisition;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
ev_view_get_preferred_width (GtkWidget *widget,
gint *minimum,
@@ -3295,14 +3196,12 @@ ev_view_get_preferred_height (GtkWidget *widget,
*minimum = *natural = requisition.height;
}
-#endif
static void
ev_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
EvView *view = EV_VIEW (widget);
-#if GTK_CHECK_VERSION (3, 0, 0)
GList *l;
gint root_x, root_y;
@@ -3314,12 +3213,6 @@ ev_view_size_allocate (GtkWidget *widget,
allocation->y,
allocation->width,
allocation->height);
-#else
- GList *children, *l;
- gint root_x, root_y;
-
- GTK_WIDGET_CLASS (ev_view_parent_class)->size_allocate (widget, allocation);
-#endif
if (!view->document)
return;
@@ -3347,7 +3240,6 @@ ev_view_size_allocate (GtkWidget *widget,
view->pending_point.x = 0;
view->pending_point.y = 0;
-#if GTK_CHECK_VERSION (3, 0, 0)
for (l = view->children; l && l->data; l = g_list_next (l)) {
GdkRectangle view_area;
EvViewChild *child = (EvViewChild *)l->data;
@@ -3362,43 +3254,6 @@ ev_view_size_allocate (GtkWidget *widget,
gtk_widget_set_size_request (child->widget, view_area.width, view_area.height);
gtk_widget_size_allocate (child->widget, &view_area);
}
-#else
- children = gtk_container_get_children (GTK_CONTAINER (widget));
- for (l = children; l && l->data; l = g_list_next (l)) {
- EvFormField *field;
- GdkRectangle view_area;
- EvMappingList *form_field_mapping;
- GtkAllocation child_allocation;
- GtkRequisition child_requisition;
- GtkWidget *child = (GtkWidget *)l->data;
-
- field = g_object_get_data (G_OBJECT (child), "form-field");
- if (!field)
- continue;
-
- form_field_mapping = ev_page_cache_get_form_field_mapping (view->page_cache,
- field->page->index);
- ev_view_get_area_from_mapping (view, field->page->index,
- form_field_mapping,
- field, &view_area);
-
- gtk_widget_size_request (child, &child_requisition);
- if (child_requisition.width != view_area.width ||
- child_requisition.height != view_area.height)
- gtk_widget_set_size_request (child, view_area.width, view_area.height);
-
- gtk_container_child_get (GTK_CONTAINER (widget),
- child,
- "x", &child_allocation.x,
- "y", &child_allocation.y,
- NULL);
- if (child_allocation.x != view_area.x ||
- child_allocation.y != view_area.y) {
- gtk_layout_move (GTK_LAYOUT (widget), child, view_area.x, view_area.y);
- }
- }
- g_list_free (children);
-#endif
if (view->window_children)
gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (view)),
@@ -3428,47 +3283,14 @@ ev_view_size_allocate (GtkWidget *widget,
}
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void
-ev_view_realize (GtkWidget *widget)
-{
- EvView *view = EV_VIEW (widget);
- GdkWindow *bin_window;
- GtkStyle *style;
-
- if (GTK_WIDGET_CLASS (ev_view_parent_class)->realize)
- (* GTK_WIDGET_CLASS (ev_view_parent_class)->realize) (widget);
-
- bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
- gdk_window_set_events (bin_window,
- (gdk_window_get_events (bin_window) |
- GDK_EXPOSURE_MASK |
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_SCROLL_MASK |
- GDK_KEY_PRESS_MASK |
- GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK));
-
- style = gtk_widget_get_style (widget);
- gdk_window_set_background (bin_window, &style->mid[GTK_STATE_NORMAL]);
-
- on_adjustment_value_changed (NULL, view);
-}
-#endif
-
static gboolean
ev_view_scroll_event (GtkWidget *widget, GdkEventScroll *event)
{
EvView *view = EV_VIEW (widget);
guint state;
-#if GTK_CHECK_VERSION (3, 0, 0)
if (event->direction == GDK_SCROLL_SMOOTH)
return FALSE;
-#endif
state = event->state & gtk_accelerator_get_default_mod_mask ();
@@ -3515,10 +3337,8 @@ ev_view_scroll_event (GtkWidget *widget, GdkEventScroll *event)
case GDK_SCROLL_LEFT:
ev_view_previous_page (view);
break;
-#if GTK_CHECK_VERSION (3, 0, 0)
case GDK_SCROLL_SMOOTH:
g_assert_not_reached ();
-#endif
}
return TRUE;
@@ -3545,7 +3365,6 @@ find_selection_for_page (EvView *view,
return NULL;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
ev_view_realize (GtkWidget *widget)
{
@@ -3577,26 +3396,14 @@ ev_view_realize (GtkWidget *widget)
gtk_style_context_set_background (gtk_widget_get_style_context (widget),
window);
}
-#endif
static gboolean
-#if GTK_CHECK_VERSION (3, 0, 0)
ev_view_draw (GtkWidget *widget,
cairo_t *cr)
-#else
-ev_view_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
-#endif
{
EvView *view = EV_VIEW (widget);
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_rectangle_int_t clip_rect;
GdkRectangle *area = &clip_rect;
-#else
- GdkWindow *bin_window;
- cairo_t *cr;
- GdkRectangle *area = &event->area;
-#endif
gint i;
if (view->loading) {
@@ -3606,23 +3413,17 @@ ev_view_expose_event (GtkWidget *widget,
ev_view_loading_window_move (view);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_render_background (gtk_widget_get_style_context (widget),
cr,
0, 0,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget));
-#endif
+
if (view->document == NULL)
return FALSE;
-#if GTK_CHECK_VERSION (3, 0, 0)
if (!gdk_cairo_get_clip_rectangle (cr, &clip_rect))
return FALSE;
-#else
- bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
- cr = gdk_cairo_create (bin_window);
-#endif
for (i = view->start_page; i >= 0 && i <= view->end_page; i++) {
GdkRectangle page_area;
@@ -3647,15 +3448,8 @@ ev_view_expose_event (GtkWidget *widget,
highlight_forward_search_results (view, cr, i);
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
- cairo_destroy (cr);
-
- if (GTK_WIDGET_CLASS (ev_view_parent_class)->expose_event)
- (* GTK_WIDGET_CLASS (ev_view_parent_class)->expose_event) (widget, event);
-#else
if (GTK_WIDGET_CLASS (ev_view_parent_class)->draw)
(* GTK_WIDGET_CLASS (ev_view_parent_class)->draw) (widget, cr);
-#endif
return FALSE;
}
@@ -3694,11 +3488,7 @@ ev_view_popup_menu (GtkWidget *widget)
{
gint x, y;
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (widget, &x, &y);
-#else
- gtk_widget_get_pointer (widget, &x, &y);
-#endif
return ev_view_do_popup_menu (EV_VIEW (widget), x, y);
}
@@ -3925,9 +3715,7 @@ ev_view_button_press_event (GtkWidget *widget,
static void
ev_view_remove_all (EvView *view)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_container_foreach (GTK_CONTAINER (view), (GtkCallback) gtk_widget_destroy, NULL);
-#endif
GList *children, *child;
children = gtk_container_get_children (GTK_CONTAINER (view));
@@ -4029,11 +3817,7 @@ selection_scroll_timeout_cb (EvView *view)
GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation);
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (widget, &x, &y);
-#else
- gtk_widget_get_pointer (widget, &x, &y);
-#endif
if (y > allocation.height) {
shift = (y - allocation.height) / 2;
@@ -4148,18 +3932,10 @@ ev_view_motion_notify_event (GtkWidget *widget,
if (!view->document)
return FALSE;
-#if GTK_CHECK_VERSION (3, 0, 0)
bin_window = gtk_widget_get_window (widget);
-#else
- bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
-#endif
if (event->is_hint || event->window != bin_window) {
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (widget, &x, &y);
-#else
- gtk_widget_get_pointer (widget, &x, &y);
-#endif
} else {
x = event->x;
y = event->y;
@@ -4474,21 +4250,12 @@ ev_view_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event)
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
ev_view_style_updated (GtkWidget *widget)
-#else
-ev_view_style_set (GtkWidget *widget,
- GtkStyle *old_style)
-#endif
{
if (EV_VIEW (widget)->pixbuf_cache)
ev_pixbuf_cache_style_changed (EV_VIEW (widget)->pixbuf_cache);
-#if GTK_CHECK_VERSION (3, 0, 0)
GTK_WIDGET_CLASS (ev_view_parent_class)->style_updated (widget);
-#else
- GTK_WIDGET_CLASS (ev_view_parent_class)->style_set (widget, old_style);
-#endif
}
/*** Drawing ***/
@@ -4499,31 +4266,15 @@ draw_rubberband (EvView *view,
const GdkRectangle *rect,
gdouble alpha)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkStyleContext *context;
GdkRGBA color;
context = gtk_widget_get_style_context (GTK_WIDGET (view));
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &color);
-#else
- GtkStyle *style;
- GdkColor *fill_color_gdk;
- gdouble r, g, b;
-
- style = gtk_widget_get_style (GTK_WIDGET (view));
- fill_color_gdk = gdk_color_copy (&style->base[GTK_STATE_SELECTED]);
- r = fill_color_gdk->red / 65535.;
- g = fill_color_gdk->green / 65535.;
- b = fill_color_gdk->blue / 65535.;
-#endif
cairo_save (cr);
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_set_source_rgba (cr, color.red, color.green, color.blue, alpha);
-#else
- cairo_set_source_rgba (cr, r, g, b, alpha);
-#endif
cairo_rectangle (cr,
rect->x - view->scroll_x,
rect->y - view->scroll_y,
@@ -4531,18 +4282,10 @@ draw_rubberband (EvView *view,
cairo_fill_preserve (cr);
cairo_set_line_width (cr, 0.5);
-#if GTK_CHECK_VERSION (3, 0, 0)
cairo_set_source_rgb (cr, color.red, color.green, color.blue);
-#else
- cairo_set_source_rgb (cr, r, g, b);
-#endif
cairo_stroke (cr);
cairo_restore (cr);
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gdk_color_free (fill_color_gdk);
-#endif
}
@@ -4606,21 +4349,11 @@ focus_annotation (EvView *view,
return;
doc_rect_to_view_rect (view, page, &mapping->area, &rect);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_render_focus (gtk_widget_get_style_context (widget),
cr,
rect.x - view->scroll_x,
rect.y - view->scroll_y,
rect.width + 1, rect.height + 1);
-#else
- gtk_paint_focus (gtk_widget_get_style (widget),
- gtk_layout_get_bin_window (GTK_LAYOUT (view)),
- gtk_widget_get_state (widget),
- NULL, widget, NULL,
- rect.x - view->scroll_x,
- rect.y - view->scroll_y,
- rect.width + 1, rect.height + 1);
-#endif
}
static void
@@ -4895,13 +4628,9 @@ ev_view_dispose (GObject *object)
view->loading_timeout = 0;
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
- ev_view_set_scroll_adjustments (GTK_LAYOUT (view), NULL, NULL);
-#endif
G_OBJECT_CLASS (ev_view_parent_class)->dispose (object);
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
ev_view_get_property (GObject *object,
guint prop_id,
@@ -4959,7 +4688,6 @@ ev_view_set_property (GObject *object,
break;
}
}
-#endif
/* Accessibility */
static void
@@ -5008,7 +4736,6 @@ ev_view_is_a11y_enabled (EvView *view)
return view->a11y_enabled;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
/* GtkContainer */
static void
ev_view_remove (GtkContainer *container,
@@ -5052,32 +4779,21 @@ ev_view_forall (GtkContainer *container,
(* callback) (child->widget, callback_data);
}
}
-#endif
static void
ev_view_class_init (EvViewClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (class);
-#else
- GtkLayoutClass *layout_class = GTK_LAYOUT_CLASS (class);
-#endif
GtkBindingSet *binding_set;
-#if GTK_CHECK_VERSION (3, 0, 0)
object_class->get_property = ev_view_get_property;
object_class->set_property = ev_view_set_property;
-#endif
object_class->finalize = ev_view_finalize;
-#if GTK_CHECK_VERSION (3, 0, 0)
widget_class->realize = ev_view_realize;
widget_class->draw = ev_view_draw;
-#else
- widget_class->expose_event = ev_view_expose_event;
-#endif
widget_class->button_press_event = ev_view_button_press_event;
widget_class->motion_notify_event = ev_view_motion_notify_event;
widget_class->button_release_event = ev_view_button_release_event;
@@ -5085,24 +4801,13 @@ ev_view_class_init (EvViewClass *class)
widget_class->focus_in_event = ev_view_focus_in;
widget_class->focus_out_event = ev_view_focus_out;
widget_class->get_accessible = ev_view_get_accessible;
-#if GTK_CHECK_VERSION (3, 0, 0)
widget_class->get_preferred_width = ev_view_get_preferred_width;
widget_class->get_preferred_height = ev_view_get_preferred_height;
-#else
- widget_class->size_request = ev_view_size_request;
-#endif
widget_class->size_allocate = ev_view_size_allocate;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- widget_class->realize = ev_view_realize;
-#endif
widget_class->scroll_event = ev_view_scroll_event;
widget_class->enter_notify_event = ev_view_enter_notify_event;
widget_class->leave_notify_event = ev_view_leave_notify_event;
-#if GTK_CHECK_VERSION (3, 0, 0)
widget_class->style_updated = ev_view_style_updated;
-#else
- widget_class->style_set = ev_view_style_set;
-#endif
widget_class->drag_data_get = ev_view_drag_data_get;
widget_class->drag_motion = ev_view_drag_motion;
widget_class->popup_menu = ev_view_popup_menu;
@@ -5114,22 +4819,16 @@ ev_view_class_init (EvViewClass *class)
gtk_widget_class_set_css_name (widget_class, "evview");
#endif
-#if GTK_CHECK_VERSION (3, 0, 0)
container_class->remove = ev_view_remove;
container_class->forall = ev_view_forall;
-#else
- layout_class->set_scroll_adjustments = ev_view_set_scroll_adjustments;
-#endif
class->binding_activated = ev_view_scroll;
-#if GTK_CHECK_VERSION (3, 0, 0)
/* Scrollable interface */
g_object_class_override_property (object_class, PROP_HADJUSTMENT, "hadjustment");
g_object_class_override_property (object_class, PROP_VADJUSTMENT, "vadjustment");
g_object_class_override_property (object_class, PROP_HSCROLL_POLICY, "hscroll-policy");
g_object_class_override_property (object_class, PROP_VSCROLL_POLICY, "vscroll-policy");
-#endif
signals[SIGNAL_BINDING_ACTIVATED] = g_signal_new ("binding_activated",
G_TYPE_FROM_CLASS (object_class),
@@ -5220,12 +4919,9 @@ ev_view_class_init (EvViewClass *class)
static void
ev_view_init (EvView *view)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkStyleContext *context;
-#endif
gtk_widget_set_can_focus (GTK_WIDGET (view), TRUE);
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_set_has_window (GTK_WIDGET (view), TRUE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (view), FALSE);
gtk_container_set_resize_mode (GTK_CONTAINER (view), GTK_RESIZE_QUEUE);
@@ -5244,7 +4940,6 @@ ev_view_init (EvView *view)
GDK_POINTER_MOTION_HINT_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK);
-#endif
view->start_page = -1;
view->end_page = -1;
@@ -5267,11 +4962,6 @@ ev_view_init (EvView *view)
view->pending_scroll = SCROLL_TO_KEEP_POSITION;
view->jump_to_find_result = TRUE;
view->highlight_find_results = FALSE;
-
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gtk_layout_set_hadjustment (GTK_LAYOUT (view), NULL);
- gtk_layout_set_vadjustment (GTK_LAYOUT (view), NULL);
-#endif
}
/*** Callbacks ***/
@@ -5287,11 +4977,7 @@ ev_view_change_page (EvView *view,
hide_loading_window (view);
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
-#else
- gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
-#endif
ev_view_handle_cursor_over_xy (view, x, y);
gtk_widget_queue_resize (GTK_WIDGET (view));
@@ -5303,23 +4989,7 @@ job_finished_cb (EvPixbufCache *pixbuf_cache,
EvView *view)
{
if (region) {
-#if GTK_CHECK_VERSION(3, 0, 0)
gdk_window_invalidate_region (gtk_widget_get_window (GTK_WIDGET (view)), region, TRUE);
-#else
- GdkWindow *bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
- GdkRegion *gdk_region = gdk_region_new ();
- guint n_recs = cairo_region_num_rectangles (region);
- guint i;
-
- for (i = 0; i < n_recs; i++) {
- cairo_rectangle_int_t rect;
-
- cairo_region_get_rectangle (region, i, &rect);
- gdk_region_union_with_rect (gdk_region, (GdkRectangle *)&rect);
- }
- gdk_window_invalidate_region (bin_window, gdk_region, TRUE);
- gdk_region_destroy (gdk_region);
-#endif
} else {
gtk_widget_queue_draw (GTK_WIDGET (view));
}
@@ -5347,7 +5017,6 @@ static void
on_adjustment_value_changed (GtkAdjustment *adjustment,
EvView *view)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
GtkWidget *widget = GTK_WIDGET (view);
int dx = 0, dy = 0;
gint x, y;
@@ -5355,14 +5024,6 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
GList *l;
if (!gtk_widget_get_realized (widget))
-#else
- int dx = 0, dy = 0;
- gint x, y;
- gint value;
- GList *children, *l;
-
- if (!gtk_widget_get_realized (GTK_WIDGET (view)))
-#endif
return;
if (view->hadjustment) {
@@ -5381,7 +5042,6 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
view->scroll_y = 0;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
for (l = view->children; l && l->data; l = g_list_next (l)) {
EvViewChild *child = (EvViewChild *)l->data;
@@ -5390,21 +5050,6 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
if (gtk_widget_get_visible (child->widget) && gtk_widget_get_visible (widget))
gtk_widget_queue_resize (widget);
}
-#else
- children = gtk_container_get_children (GTK_CONTAINER (view));
- for (l = children; l && l->data; l = g_list_next (l)) {
- gint child_x, child_y;
- GtkWidget *child = (GtkWidget *)l->data;
-
- gtk_container_child_get (GTK_CONTAINER (view),
- child,
- "x", &child_x,
- "y", &child_y,
- NULL);
- gtk_layout_move (GTK_LAYOUT (view), child, child_x + dx, child_y + dy);
- }
- g_list_free (children);
-#endif
for (l = view->window_children; l && l->data; l = g_list_next (l)) {
EvViewWindowChild *child;
@@ -5415,24 +5060,12 @@ on_adjustment_value_changed (GtkAdjustment *adjustment,
}
if (view->pending_resize) {
-#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_queue_draw (widget);
} else {
gdk_window_scroll (gtk_widget_get_window (widget), dx, dy);
}
ev_document_misc_get_pointer_position (widget, &x, &y);
-#else
- gtk_widget_queue_draw (GTK_WIDGET (view));
- } else {
- GdkWindow *bin_window;
-
- bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
- gdk_window_scroll (bin_window, dx, dy);
- }
-
- gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
-#endif
ev_view_handle_cursor_over_xy (view, x, y);
if (view->document)
@@ -5566,11 +5199,7 @@ ev_view_autoscroll_start (EvView *view)
g_timeout_add (20, (GSourceFunc)ev_view_autoscroll_cb,
view);
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
-#else
- gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
-#endif
ev_view_handle_cursor_over_xy (view, x, y);
}
@@ -5590,11 +5219,7 @@ ev_view_autoscroll_stop (EvView *view)
view->scroll_info.timeout_id = 0;
}
-#if GTK_CHECK_VERSION(3, 0, 0)
ev_document_misc_get_pointer_position (GTK_WIDGET (view), &x, &y);
-#else
- gtk_widget_get_pointer (GTK_WIDGET (view), &x, &y);
-#endif
ev_view_handle_cursor_over_xy (view, x, y);
}
@@ -6516,37 +6141,14 @@ merge_selection_region (EvView *view,
/* Redraw the damaged region! */
if (region) {
-#if !GTK_CHECK_VERSION (3, 0, 0)
- GdkWindow *bin_window;
-#endif
GdkRectangle page_area;
GtkBorder border;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
-#endif
ev_view_get_page_extents (view, cur_page, &page_area, &border);
cairo_region_translate (region,
page_area.x + border.left - view->scroll_x,
page_area.y + border.top - view->scroll_y);
-#if GTK_CHECK_VERSION(3, 0, 0)
gdk_window_invalidate_region (gtk_widget_get_window (GTK_WIDGET (view)), region, TRUE);
-#else
- {
- GdkRegion *gdk_region = gdk_region_new ();
- guint n_recs = cairo_region_num_rectangles (region);
- guint i;
-
- for (i = 0; i < n_recs; i++) {
- cairo_rectangle_int_t rect;
-
- cairo_region_get_rectangle (region, i, &rect);
- gdk_region_union_with_rect (gdk_region, (GdkRectangle *)&rect);
- }
- gdk_window_invalidate_region (bin_window, gdk_region, TRUE);
- gdk_region_destroy (gdk_region);
- }
-#endif
cairo_region_destroy (region);
}
}
@@ -6792,17 +6394,13 @@ ev_view_set_cursor (EvView *view, EvViewCursor new_cursor)
view->cursor = new_cursor;
-#if GTK_CHECK_VERSION (3, 0, 0)
bin_window = gtk_widget_get_window (GTK_WIDGET (view));
-#else
- bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (view));
-#endif
widget = gtk_widget_get_toplevel (GTK_WIDGET (view));
cursor = ev_view_cursor_new (gtk_widget_get_display (widget), new_cursor);
gdk_window_set_cursor (bin_window, cursor);
gdk_flush ();
if (cursor)
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
void
diff --git a/libview/ev-web-view.c b/libview/ev-web-view.c
index c995c4f4..6e302660 100644
--- a/libview/ev-web-view.c
+++ b/libview/ev-web-view.c
@@ -25,11 +25,7 @@
#include <gtk/gtk.h>
#include <stdlib.h>
-#if GTK_CHECK_VERSION (3, 0, 0)
#include <webkit2/webkit2.h>
-#else
-#include <webkit/webkit.h>
-#endif
#include "ev-web-view.h"
#include "ev-document-model.h"
@@ -62,11 +58,9 @@ struct _EvWebView
gboolean inverted_stylesheet ;
gboolean fullscreen;
SearchParams *search;
-#if GTK_CHECK_VERSION (3, 0, 0)
WebKitFindController *findcontroller;
WebKitFindOptions findoptions;
gdouble zoom_level;
-#endif
gchar *hlink;
};
@@ -180,11 +174,7 @@ ev_web_view_change_page (EvWebView *webview,
webview->current_page = new_page;
ev_document_model_set_page(webview->model,new_page);
-#if GTK_CHECK_VERSION (3, 0, 0)
webkit_find_controller_search_finish(webview->findcontroller);
-#else
- webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW(webview));
-#endif
if (webview->hlink) {
webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),(gchar*)webview->hlink);
g_free(webview->hlink);
@@ -219,14 +209,12 @@ ev_web_view_new (void)
webview = g_object_new (EV_TYPE_WEB_VIEW, NULL);
-#if GTK_CHECK_VERSION (3, 0, 0)
EV_WEB_VIEW(webview)->findcontroller = webkit_web_view_get_find_controller (WEBKIT_WEB_VIEW(webview));
EV_WEB_VIEW(webview)->findoptions = webkit_find_controller_get_options (EV_WEB_VIEW(webview)->findcontroller);
EV_WEB_VIEW(webview)->zoom_level = 1.0;
EV_WEB_VIEW(webview)->findoptions |= WEBKIT_FIND_OPTIONS_NONE;
-#endif
return webview;
}
@@ -442,36 +430,6 @@ ev_web_view_handle_link(EvWebView *webview,EvLink *link)
}
/* Searching */
-#if !GTK_CHECK_VERSION (3, 0, 0)
-static void
-jump_to_find_result_on_page(EvWebView *webview,
- EvWebViewFindDirection direction)
-{
- gboolean forward,wrap;
-
- if (direction == EV_WEB_VIEW_FIND_NEXT) {
- forward = TRUE;
- wrap = FALSE;
- }
- else {
- forward = FALSE;
- wrap = FALSE;
- }
-
- if (webview->search->search_jump) {
- wrap = TRUE;
- }
- webkit_web_view_search_text (WEBKIT_WEB_VIEW(webview),
- webview->search->search_string,
- webview->search->case_sensitive,
- forward,
- wrap);
-
- webview->search->search_jump = FALSE;
-}
-#endif
-
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
results_counted_cb(WebKitFindController *findcontroller,
guint match_count,
@@ -485,40 +443,23 @@ results_counted_cb(WebKitFindController *findcontroller,
webview->search->search_jump = FALSE;
}
}
-#endif
+
/*
* Jump to find results once we have changed the page in the webview.
*/
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
jump_to_find_results(EvWebView *webview,
WebKitLoadEvent load_event,
gpointer data)
-#else
-static void
-jump_to_find_results(EvWebView *webview,
- GParamSpec *pspec,
- gpointer data)
-#endif
{
-#if !GTK_CHECK_VERSION (3, 0, 0)
- gint n_results;
- gboolean forward ;
- gboolean wrap ;
-
- if (webkit_web_view_get_load_status(WEBKIT_WEB_VIEW(webview)) != WEBKIT_LOAD_FINISHED) {
- return;
- }
-#else
if ( load_event != WEBKIT_LOAD_FINISHED) {
return;
}
-#endif
+
if (!webview->search->search_string) {
return;
}
-#if GTK_CHECK_VERSION (3, 0, 0)
if (webview->search->direction == EV_WEB_VIEW_FIND_NEXT) {
webview->findoptions &= ~WEBKIT_FIND_OPTIONS_BACKWARDS;
webview->findoptions &= ~WEBKIT_FIND_OPTIONS_WRAP_AROUND;
@@ -532,33 +473,6 @@ jump_to_find_results(EvWebView *webview,
webview->search->search_string,
webview->findoptions,
G_MAXUINT);
-#else
- n_results = webkit_web_view_mark_text_matches (WEBKIT_WEB_VIEW(webview),
- webview->search->search_string,
- webview->search->case_sensitive,
- 0);
-
- ev_web_view_find_set_highlight_search(webview,TRUE);
-
- if (webview->search->direction == EV_WEB_VIEW_FIND_NEXT) {
- forward = TRUE ;
- wrap = FALSE;
- }
- else {
- forward = FALSE;
- wrap = TRUE ;
- }
-
- if (n_results > 0 && webview->search->on_result < n_results) {
- webkit_web_view_search_text (WEBKIT_WEB_VIEW(webview),
- webview->search->search_string,
- webview->search->case_sensitive,
- forward,
- wrap);
-
- webview->search->search_jump = FALSE;
- }
-#endif
webview->search->search_jump = FALSE;
}
@@ -599,9 +513,6 @@ jump_to_find_page (EvWebView *webview, EvWebViewFindDirection direction, gint sh
page = page + n_pages;
if (page == webview->current_page && ev_web_view_find_get_n_results(webview,page) > 0) {
-#if !GTK_CHECK_VERSION (3, 0, 0)
- jump_to_find_result_on_page(webview,EV_WEB_VIEW_FIND_NEXT);
-#else
if (direction == EV_WEB_VIEW_FIND_PREV) {
webview->findoptions |= WEBKIT_FIND_OPTIONS_WRAP_AROUND;
webview->findoptions |= WEBKIT_FIND_OPTIONS_BACKWARDS;
@@ -621,17 +532,12 @@ jump_to_find_page (EvWebView *webview, EvWebViewFindDirection direction, gint sh
/*Highlight all the results.*/
G_MAXUINT);
webview->search->search_jump = FALSE;
-#endif
break;
}
if (ev_web_view_find_get_n_results (webview, page) > 0) {
webview->search->direction = direction;
-#if !GTK_CHECK_VERSION (3, 0, 0)
- webkit_web_view_unmark_text_matches (WEBKIT_WEB_VIEW(webview));
-#else
webkit_find_controller_search_finish(webview->findcontroller);
-#endif
ev_document_model_set_page (webview->model, page);
break;
}
@@ -646,14 +552,12 @@ ev_web_view_find_changed (EvWebView *webview, guint *results, gchar *text,gboole
webview->search->search_string = g_strdup(text);
webview->search->case_sensitive = case_sensitive;
if (webview->search->search_jump == TRUE) {
-#if GTK_CHECK_VERSION (3, 0, 0)
if (!case_sensitive) {
webview->findoptions |= WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
}
else {
webview->findoptions &= ~WEBKIT_FIND_OPTIONS_CASE_INSENSITIVE;
}
-#endif
jump_to_find_page (webview, EV_WEB_VIEW_FIND_NEXT, 0);
}
}
@@ -671,11 +575,7 @@ ev_web_view_find_next (EvWebView *webview)
jump_to_find_page (webview, EV_WEB_VIEW_FIND_NEXT, 1);
}
else {
-#if GTK_CHECK_VERSION (3, 0, 0)
webkit_find_controller_search_next(webview->findcontroller);
-#else
- jump_to_find_result_on_page (webview, EV_WEB_VIEW_FIND_NEXT);
-#endif
}
}
@@ -688,11 +588,7 @@ ev_web_view_find_previous (EvWebView *webview)
jump_to_find_page (webview, EV_WEB_VIEW_FIND_PREV, -1);
webview->search->on_result = MAX (0, ev_web_view_find_get_n_results (webview, webview->current_page) - 1);
} else {
-#if GTK_CHECK_VERSION (3, 0, 0)
webkit_find_controller_search_previous(webview->findcontroller);
-#else
- jump_to_find_result_on_page (webview,EV_WEB_VIEW_FIND_PREV);
-#endif
}
}
@@ -700,93 +596,52 @@ void
ev_web_view_find_search_changed (EvWebView *webview)
{
/* search string has changed, focus on new search result */
-#if !GTK_CHECK_VERSION(3, 0, 0)
- webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(webview));
-#endif
if (webview->search->search_string) {
g_free(webview->search->search_string);
webview->search->search_string = NULL;
}
-#if GTK_CHECK_VERSION(3, 0, 0)
+
webkit_find_controller_search_finish(webview->findcontroller);
-#endif
-
webview->search->search_jump = TRUE;
}
-#if !GTK_CHECK_VERSION (3, 0, 0)
-void
-ev_web_view_find_set_highlight_search (EvWebView *webview, gboolean value)
-{
- webkit_web_view_set_highlight_text_matches (WEBKIT_WEB_VIEW(webview),value);
-}
-#endif
-
void
ev_web_view_find_cancel (EvWebView *webview)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
webkit_find_controller_search_finish (webview->findcontroller);
-#else
- webkit_web_view_unmark_text_matches(WEBKIT_WEB_VIEW(webview));
- ev_web_view_find_set_highlight_search(webview,FALSE);
-#endif
}
-
-
void
ev_web_view_set_handler(EvWebView *webview,gboolean visible)
{
if (visible) {
g_signal_connect(webview,
-#if GTK_CHECK_VERSION (3, 0, 0)
"load-changed",
-#else
- "notify::load-status",
-#endif
G_CALLBACK(jump_to_find_results),
NULL);
-#if GTK_CHECK_VERSION (3, 0, 0)
g_signal_connect(webview->findcontroller,
"counted-matches",
G_CALLBACK(results_counted_cb),
webview);
-#endif
}
else {
g_signal_handlers_disconnect_by_func(webview,
jump_to_find_results,
NULL);
-#if GTK_CHECK_VERSION (3, 0, 0)
g_signal_handlers_disconnect_by_func(webview,
results_counted_cb,
NULL);
-#endif
}
}
/* Selection and copying*/
-#if !GTK_CHECK_VERSION (3, 0, 0)
-gboolean
-ev_web_view_get_has_selection(EvWebView *webview)
-{
- return webkit_web_view_has_selection(WEBKIT_WEB_VIEW(webview));
-}
-#endif
-
void
ev_web_view_select_all(EvWebView *webview)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
webkit_web_view_execute_editing_command(WEBKIT_WEB_VIEW(webview),
WEBKIT_EDITING_COMMAND_SELECT_ALL);
-#else
- webkit_web_view_select_all(WEBKIT_WEB_VIEW(webview));
-#endif
}
-#if GTK_CHECK_VERSION (3, 0, 0)
static void
copy_text_cb(WebKitWebView *webview,
GAsyncResult *res,
@@ -801,54 +656,34 @@ copy_text_cb(WebKitWebView *webview,
WEBKIT_EDITING_COMMAND_COPY);
}
}
-#endif
void
ev_web_view_copy(EvWebView *webview)
{
-#if !GTK_CHECK_VERSION (3, 0, 0)
- /* If for some reason we don't have a selection any longer,best to be safe */
- if (ev_web_view_get_has_selection(webview) == FALSE)
- return;
- if (webkit_web_view_can_copy_clipboard(WEBKIT_WEB_VIEW(webview))) {
- webkit_web_view_copy_clipboard(WEBKIT_WEB_VIEW(webview));
- }
-#else
webkit_web_view_can_execute_editing_command(WEBKIT_WEB_VIEW(webview),
WEBKIT_EDITING_COMMAND_COPY,
NULL,
(GAsyncReadyCallback)copy_text_cb,
NULL);
-
-#endif
-
}
/*Zoom control*/
gboolean
ev_web_view_zoom_in(EvWebView *webview)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW(webview),
(webview->zoom_level+= 0.1));
-#else
- webkit_web_view_zoom_in(WEBKIT_WEB_VIEW(webview));
-#endif
return TRUE;
}
gboolean
ev_web_view_zoom_out(EvWebView *webview)
{
-#if GTK_CHECK_VERSION (3, 0, 0)
if (webview->zoom_level == 1)
return FALSE;
webkit_web_view_set_zoom_level (WEBKIT_WEB_VIEW(webview),
(webview->zoom_level -= 0.1));
-#else
- webkit_web_view_zoom_out(WEBKIT_WEB_VIEW(webview));
-#endif
return TRUE;
}