mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 07:06:02 +01:00
Merge branch 'feature/remove-gtk2' into develop
This commit is contained in:
commit
08a72c46d4
6 changed files with 4 additions and 98 deletions
4
README
4
README
|
@ -5,9 +5,9 @@ girara user interface library and several document libraries.
|
|||
|
||||
Requirements
|
||||
------------
|
||||
gtk2 (>= 2.18) or gtk3
|
||||
gtk3
|
||||
glib (>= 2.28)
|
||||
girara
|
||||
girara (>= 0.1.8)
|
||||
sqlite3 (optional, >= 3.5.9)
|
||||
check (for tests)
|
||||
intltool
|
||||
|
|
1
config.c
1
config.c
|
@ -15,7 +15,6 @@
|
|||
#include <girara/shortcuts.h>
|
||||
#include <girara/config.h>
|
||||
#include <girara/commands.h>
|
||||
#include <girara/gtk2-compat.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
static void
|
||||
|
|
|
@ -20,14 +20,4 @@
|
|||
#define mutex_free(m) g_mutex_clear((m))
|
||||
#endif
|
||||
|
||||
/* g_get_real_time appeared in 2.28 */
|
||||
#if !GLIB_CHECK_VERSION(2, 27, 0)
|
||||
inline static gint64 g_get_real_time(void)
|
||||
{
|
||||
GTimeVal tv;
|
||||
g_get_current_time(&tv);
|
||||
return (((gint64) tv.tv_sec) * 1000000) + tv.tv_usec;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
@ -623,11 +588,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
|
||||
|
@ -893,19 +854,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);
|
||||
|
|
25
zathura.c
25
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);
|
||||
|
|
|
@ -6,13 +6,10 @@
|
|||
#include <stdbool.h>
|
||||
#include <girara/types.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/gtkx.h>
|
||||
#include "macros.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,
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue