mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 13:16:00 +01:00
Remove GTK+2 support
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
d58fccd494
commit
f59a6f539e
4 changed files with 2 additions and 86 deletions
1
config.c
1
config.c
|
@ -15,7 +15,6 @@
|
||||||
#include <girara/shortcuts.h>
|
#include <girara/shortcuts.h>
|
||||||
#include <girara/config.h>
|
#include <girara/config.h>
|
||||||
#include <girara/commands.h>
|
#include <girara/commands.h>
|
||||||
#include <girara/gtk2-compat.h>
|
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -61,9 +61,6 @@ typedef struct zathura_page_widget_private_s {
|
||||||
zathura_page_widget_private_t))
|
zathura_page_widget_private_t))
|
||||||
|
|
||||||
static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo);
|
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_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_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);
|
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 */
|
/* overwrite methods */
|
||||||
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(class);
|
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;
|
widget_class->draw = zathura_page_widget_draw;
|
||||||
#endif
|
|
||||||
widget_class->size_allocate = zathura_page_widget_size_allocate;
|
widget_class->size_allocate = zathura_page_widget_size_allocate;
|
||||||
widget_class->button_press_event = cb_zathura_page_widget_button_press_event;
|
widget_class->button_press_event = cb_zathura_page_widget_button_press_event;
|
||||||
widget_class->button_release_event = cb_zathura_page_widget_button_release_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
|
static gboolean
|
||||||
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
||||||
{
|
{
|
||||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||||
mutex_lock(&(priv->lock));
|
mutex_lock(&(priv->lock));
|
||||||
|
|
||||||
zathura_document_t* document = zathura_page_get_document(priv->page);
|
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
|
|
||||||
const unsigned int page_height = gtk_widget_get_allocated_height(widget);
|
const unsigned int page_height = gtk_widget_get_allocated_height(widget);
|
||||||
const unsigned int page_width = gtk_widget_get_allocated_width(widget);
|
const unsigned int page_width = gtk_widget_get_allocated_width(widget);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (priv->surface != NULL) {
|
if (priv->surface != NULL) {
|
||||||
cairo_save(cairo);
|
cairo_save(cairo);
|
||||||
|
@ -620,11 +585,7 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle)
|
||||||
grect.y = rectangle->y1;
|
grect.y = rectangle->y1;
|
||||||
grect.width = (rectangle->x2 + 1) - rectangle->x1;
|
grect.width = (rectangle->x2 + 1) - rectangle->x1;
|
||||||
grect.height = (rectangle->y2 + 1) - rectangle->y1;
|
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);
|
gtk_widget_queue_draw_area(GTK_WIDGET(widget), grect.x, grect.y, grect.width, grect.height);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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 width = cairo_image_surface_get_width(surface);
|
||||||
const int height = cairo_image_surface_get_height(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);
|
GdkPixbuf* pixbuf = gdk_pixbuf_get_from_surface(surface, 0, 0, width, height);
|
||||||
#endif
|
|
||||||
g_signal_emit(page, signals[IMAGE_SELECTED], 0, pixbuf);
|
g_signal_emit(page, signals[IMAGE_SELECTED], 0, pixbuf);
|
||||||
g_object_unref(pixbuf);
|
g_object_unref(pixbuf);
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
|
|
25
zathura.c
25
zathura.c
|
@ -146,13 +146,9 @@ zathura_init(zathura_t* zathura)
|
||||||
G_CALLBACK(cb_refresh_view), zathura);
|
G_CALLBACK(cb_refresh_view), zathura);
|
||||||
|
|
||||||
/* page view */
|
/* page view */
|
||||||
#if (GTK_MAJOR_VERSION == 3)
|
|
||||||
zathura->ui.page_widget = gtk_grid_new();
|
zathura->ui.page_widget = gtk_grid_new();
|
||||||
gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE);
|
gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE);
|
||||||
gtk_grid_set_column_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) {
|
if (zathura->ui.page_widget == NULL) {
|
||||||
goto error_free;
|
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);
|
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_set(zathura->ui.page_widget_alignment, TRUE);
|
||||||
gtk_widget_set_hexpand(zathura->ui.page_widget_alignment, FALSE);
|
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_set(zathura->ui.page_widget_alignment, TRUE);
|
||||||
gtk_widget_set_vexpand(zathura->ui.page_widget_alignment, FALSE);
|
gtk_widget_set_vexpand(zathura->ui.page_widget_alignment, FALSE);
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_show(zathura->ui.page_widget);
|
gtk_widget_show(zathura->ui.page_widget);
|
||||||
|
|
||||||
|
@ -325,11 +318,7 @@ zathura_free(zathura_t* zathura)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
#if (GTK_MAJOR_VERSION == 2)
|
|
||||||
zathura_set_xid(zathura_t* zathura, GdkNativeWindow xid)
|
|
||||||
#else
|
|
||||||
zathura_set_xid(zathura_t* zathura, Window xid)
|
zathura_set_xid(zathura_t* zathura, Window xid)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
g_return_if_fail(zathura != NULL);
|
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);
|
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_row_spacing(GTK_GRID(zathura->ui.page_widget), page_padding);
|
||||||
gtk_grid_set_column_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++) {
|
for (unsigned int i = 0; i < number_of_pages; i++) {
|
||||||
int x = (i + first_page_column - 1) % pages_per_row;
|
int x = (i + first_page_column - 1) % pages_per_row;
|
||||||
int y = (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);
|
zathura_page_t* page = zathura_document_get_page(zathura->document, i);
|
||||||
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
|
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);
|
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);
|
gtk_widget_show_all(zathura->ui.page_widget);
|
||||||
|
|
|
@ -6,13 +6,10 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <girara/types.h>
|
#include <girara/types.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gtk/gtkx.h>
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
#if (GTK_MAJOR_VERSION == 3)
|
|
||||||
#include <gtk/gtkx.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
|
enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
|
||||||
DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP,
|
DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP,
|
||||||
PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD,
|
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 zathura The zathura session
|
||||||
* @param xid The window id
|
* @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);
|
void zathura_set_xid(zathura_t* zathura, Window xid);
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the path to the configuration directory
|
* Set the path to the configuration directory
|
||||||
|
|
Loading…
Reference in a new issue