From f59a6f539e4c00dba9d5f491451cad96014933b3 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Mon, 25 Nov 2013 18:57:59 +0100 Subject: [PATCH] Remove GTK+2 support Signed-off-by: Sebastian Ramacher --- config.c | 1 - page-widget.c | 53 +-------------------------------------------------- zathura.c | 25 ------------------------ zathura.h | 9 +-------- 4 files changed, 2 insertions(+), 86 deletions(-) diff --git a/config.c b/config.c index 33c1419..72b5100 100644 --- a/config.c +++ b/config.c @@ -15,7 +15,6 @@ #include #include #include -#include #include static void diff --git a/page-widget.c b/page-widget.c index 6f328bc..720fed9 100644 --- a/page-widget.c +++ b/page-widget.c @@ -61,9 +61,6 @@ typedef struct zathura_page_widget_private_s { zathura_page_widget_private_t)) static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo); -#if GTK_MAJOR_VERSION == 2 -static gboolean zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event); -#endif static void zathura_page_widget_finalize(GObject* object); static void zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec); static void zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec); @@ -111,11 +108,7 @@ zathura_page_widget_class_init(ZathuraPageClass* class) /* overwrite methods */ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(class); -#if GTK_MAJOR_VERSION == 2 - widget_class->expose_event = zathura_page_widget_expose; -#else widget_class->draw = zathura_page_widget_draw; -#endif widget_class->size_allocate = zathura_page_widget_size_allocate; widget_class->button_press_event = cb_zathura_page_widget_button_press_event; widget_class->button_release_event = cb_zathura_page_widget_button_release_event; @@ -368,43 +361,15 @@ zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, } } -#if GTK_MAJOR_VERSION == 2 -static gboolean -zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event) -{ - cairo_t* cairo = gdk_cairo_create(gtk_widget_get_window(widget)); - if (cairo == NULL) { - girara_error("Could not retrieve cairo object"); - return FALSE; - } - - /* set clip region */ - cairo_rectangle(cairo, event->area.x, event->area.y, event->area.width, event->area.height); - cairo_clip(cairo); - - const gboolean ret = zathura_page_widget_draw(widget, cairo); - cairo_destroy(cairo); - return ret; -} -#endif - static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) { zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); mutex_lock(&(priv->lock)); - zathura_document_t* document = zathura_page_get_document(priv->page); - -#if GTK_MAJOR_VERSION == 2 - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - const unsigned int page_height = allocation.height; - const unsigned int page_width = allocation.width; -#else + zathura_document_t* document = zathura_page_get_document(priv->page); const unsigned int page_height = gtk_widget_get_allocated_height(widget); const unsigned int page_width = gtk_widget_get_allocated_width(widget); -#endif if (priv->surface != NULL) { cairo_save(cairo); @@ -620,11 +585,7 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle) grect.y = rectangle->y1; grect.width = (rectangle->x2 + 1) - rectangle->x1; grect.height = (rectangle->y2 + 1) - rectangle->y1; -#if GTK_MAJOR_VERSION == 2 - gdk_window_invalidate_rect(gtk_widget_get_window(GTK_WIDGET(widget)), &grect, TRUE); -#else gtk_widget_queue_draw_area(GTK_WIDGET(widget), grect.x, grect.y, grect.width, grect.height); -#endif } static void @@ -890,19 +851,7 @@ cb_menu_image_copy(GtkMenuItem* item, ZathuraPage* page) const int width = cairo_image_surface_get_width(surface); const int height = cairo_image_surface_get_height(surface); -#if GTK_MAJOR_VERSION == 2 - GdkPixmap* pixmap = gdk_pixmap_new(gtk_widget_get_window(GTK_WIDGET(item)), width, height, -1); - cairo_t* cairo = gdk_cairo_create(pixmap); - - cairo_set_source_surface(cairo, surface, 0, 0); - cairo_paint(cairo); - cairo_destroy(cairo); - - GdkPixbuf* pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, - 0, width, height); -#else GdkPixbuf* pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, width, height); -#endif g_signal_emit(page, signals[IMAGE_SELECTED], 0, pixbuf); g_object_unref(pixbuf); cairo_surface_destroy(surface); diff --git a/zathura.c b/zathura.c index 2449698..55b72e5 100644 --- a/zathura.c +++ b/zathura.c @@ -146,13 +146,9 @@ zathura_init(zathura_t* zathura) G_CALLBACK(cb_refresh_view), zathura); /* page view */ -#if (GTK_MAJOR_VERSION == 3) zathura->ui.page_widget = gtk_grid_new(); gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE); gtk_grid_set_column_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE); -#else - zathura->ui.page_widget = gtk_table_new(0, 0, TRUE); -#endif if (zathura->ui.page_widget == NULL) { goto error_free; } @@ -184,13 +180,10 @@ zathura_init(zathura_t* zathura) } gtk_container_add(GTK_CONTAINER(zathura->ui.page_widget_alignment), zathura->ui.page_widget); -#if (GTK_MAJOR_VERSION == 3) gtk_widget_set_hexpand_set(zathura->ui.page_widget_alignment, TRUE); gtk_widget_set_hexpand(zathura->ui.page_widget_alignment, FALSE); gtk_widget_set_vexpand_set(zathura->ui.page_widget_alignment, TRUE); gtk_widget_set_vexpand(zathura->ui.page_widget_alignment, FALSE); -#endif - gtk_widget_show(zathura->ui.page_widget); @@ -325,11 +318,7 @@ zathura_free(zathura_t* zathura) } void -#if (GTK_MAJOR_VERSION == 2) -zathura_set_xid(zathura_t* zathura, GdkNativeWindow xid) -#else zathura_set_xid(zathura_t* zathura, Window xid) -#endif { g_return_if_fail(zathura != NULL); @@ -1060,30 +1049,16 @@ page_widget_set_mode(zathura_t* zathura, unsigned int page_padding, unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document); -#if (GTK_MAJOR_VERSION == 3) gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), page_padding); gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), page_padding); -#else - gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding); - gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), page_padding); - - unsigned int ncol = pages_per_row; - unsigned int nrow = (number_of_pages + first_page_column - 1 + ncol - 1) / ncol; - gtk_table_resize(GTK_TABLE(zathura->ui.page_widget), nrow, ncol); -#endif - for (unsigned int i = 0; i < number_of_pages; i++) { int x = (i + first_page_column - 1) % pages_per_row; int y = (i + first_page_column - 1) / pages_per_row; zathura_page_t* page = zathura_document_get_page(zathura->document, i); GtkWidget* page_widget = zathura_page_get_widget(zathura, page); -#if (GTK_MAJOR_VERSION == 3) gtk_grid_attach(GTK_GRID(zathura->ui.page_widget), page_widget, x, y, 1, 1); -#else - gtk_table_attach(GTK_TABLE(zathura->ui.page_widget), page_widget, x, x + 1, y, y + 1, GTK_SHRINK, GTK_SHRINK, 0, 0); -#endif } gtk_widget_show_all(zathura->ui.page_widget); diff --git a/zathura.h b/zathura.h index 4b198ed..633e73f 100644 --- a/zathura.h +++ b/zathura.h @@ -6,13 +6,10 @@ #include #include #include +#include #include "macros.h" #include "types.h" -#if (GTK_MAJOR_VERSION == 3) -#include -#endif - enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT, DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP, PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD, @@ -190,11 +187,7 @@ void zathura_free(zathura_t* zathura); * @param zathura The zathura session * @param xid The window id */ -#if (GTK_MAJOR_VERSION == 2) -void zathura_set_xid(zathura_t* zathura, GdkNativeWindow xid); -#else void zathura_set_xid(zathura_t* zathura, Window xid); -#endif /** * Set the path to the configuration directory