mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-29 01:14:56 +01:00
Rename PageViewWidget to PageWidget
This commit is contained in:
parent
76323a4c3e
commit
21a65cbe34
11 changed files with 167 additions and 167 deletions
|
@ -14,7 +14,7 @@
|
|||
#include "document.h"
|
||||
#include "utils.h"
|
||||
#include "shortcuts.h"
|
||||
#include "page_view_widget.h"
|
||||
#include "page_widget.h"
|
||||
|
||||
gboolean
|
||||
cb_destroy(GtkWidget* UNUSED(widget), gpointer UNUSED(data))
|
||||
|
@ -45,7 +45,7 @@ void
|
|||
cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpointer data)
|
||||
{
|
||||
zathura_t* zathura = data;
|
||||
if (!zathura || !zathura->document || !zathura->document->pages || !zathura->ui.page_view) {
|
||||
if (!zathura || !zathura->document || !zathura->document->pages || !zathura->ui.page_widget) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ cb_pages_per_row_value_changed(girara_session_t* UNUSED(session), const char* UN
|
|||
pages_per_row = 1;
|
||||
}
|
||||
|
||||
page_view_set_mode(zathura, pages_per_row);
|
||||
page_widget_set_mode(zathura, pages_per_row);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -179,7 +179,7 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session)
|
|||
|
||||
g_object_set(page->drawing_area, "draw-links", FALSE, NULL);
|
||||
|
||||
zathura_link_t* link = zathura_page_view_link_get(ZATHURA_PAGE_VIEW(page->drawing_area), index);
|
||||
zathura_link_t* link = zathura_page_widget_link_get(ZATHURA_PAGE(page->drawing_area), index);
|
||||
if (link != NULL) {
|
||||
switch (link->type) {
|
||||
case ZATHURA_LINK_TO_PAGE:
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "print.h"
|
||||
#include "document.h"
|
||||
#include "utils.h"
|
||||
#include "page_view_widget.h"
|
||||
#include "page_widget.h"
|
||||
|
||||
|
||||
#include <girara/session.h>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "zathura.h"
|
||||
#include "render.h"
|
||||
#include "database.h"
|
||||
#include "page_view_widget.h"
|
||||
#include "page_widget.h"
|
||||
|
||||
#include <girara/datastructures.h>
|
||||
#include <girara/utils.h>
|
||||
|
@ -433,7 +433,7 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id)
|
|||
if (page != NULL) {
|
||||
page->number = page_id;
|
||||
page->visible = false;
|
||||
page->drawing_area = zathura_page_view_new(page);
|
||||
page->drawing_area = zathura_page_widget_new(page);
|
||||
page->document = document;
|
||||
|
||||
gtk_widget_set_size_request(page->drawing_area, page->width * document->scale, page->height * document->scale);
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#ifndef PAGE_VIEW_WIDGET_H
|
||||
#define PAGE_VIEW_WIDGET_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "document.h"
|
||||
|
||||
/**
|
||||
* The page view widget. The widget handles all the rendering on its own. It
|
||||
* only has to be resized. The widget also manages and handles all the
|
||||
* rectangles for highlighting.
|
||||
*
|
||||
* Before the properties contain the correct values, 'draw-links' has to be set
|
||||
* to TRUE at least one time.
|
||||
* */
|
||||
typedef struct zathura_page_view_s ZathuraPageView;
|
||||
typedef struct zathura_page_view_class_s ZathuraPageViewClass;
|
||||
|
||||
struct zathura_page_view_s {
|
||||
GtkDrawingArea parent;
|
||||
};
|
||||
|
||||
struct zathura_page_view_class_s {
|
||||
GtkDrawingAreaClass parent_class;
|
||||
};
|
||||
|
||||
#define ZATHURA_TYPE_PAGE_VIEW \
|
||||
(zathura_page_view_get_type ())
|
||||
#define ZATHURA_PAGE_VIEW(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), ZATHURA_TYPE_PAGE_VIEW, ZathuraPageView))
|
||||
#define ZATHURA_PAGE_VIEW_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((obj), ZATHURA_PAGE_VIEW, ZathuraPageViewClass))
|
||||
#define ZATHURA_IS_PAGE_VIEW(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZATHURA_PAGE_VIEW))
|
||||
#define ZATHURA_IS_PAGE_VIEW_WDIGET_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((obj), ZATHURA_TYPE_PAGE_VIEW))
|
||||
#define ZATHURA_PAGE_VIEW_GET_CLASS \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), ZATHURA_TYPE_PAGE_VIEW, ZathuraPageViewclass))
|
||||
|
||||
/**
|
||||
* Returns the type of the page view widget.
|
||||
* @return the type
|
||||
*/
|
||||
GType zathura_page_view_get_type(void);
|
||||
/**
|
||||
* Create a page view widget.
|
||||
* @param page the page to be displayed
|
||||
* @return a page view widget
|
||||
*/
|
||||
GtkWidget* zathura_page_view_new(zathura_page_t* page);
|
||||
/**
|
||||
* Update the widget's surface. This should only be called from the render
|
||||
* thread.
|
||||
* @param widget the widget
|
||||
* @param surface the new surface
|
||||
*/
|
||||
void zathura_page_view_update_surface(ZathuraPageView* widget, cairo_surface_t* surface);
|
||||
/**
|
||||
* Draw a rectangle to mark links or search results
|
||||
* @param widget the widget
|
||||
* @param rectangle the rectangle
|
||||
* @param linkid the link id if it's a link, -1 otherwise
|
||||
*/
|
||||
void zathura_page_view_draw_rectangle(ZathuraPageView* widget, zathura_rectangle_t* rectangle, int linkid);
|
||||
/**
|
||||
* Clear all rectangles.
|
||||
* @param widget the widget
|
||||
*/
|
||||
void zathura_page_view_clear_rectangles(ZathuraPageView* widget);
|
||||
|
||||
/**
|
||||
* Returns the zathura link object at the given index
|
||||
*
|
||||
* @param widget the widget
|
||||
* @param index Index of the link
|
||||
* @return Link object or NULL if an error occured
|
||||
*/
|
||||
zathura_link_t* zathura_page_view_link_get(ZathuraPageView* widget, unsigned int index);
|
||||
|
||||
#endif
|
|
@ -1,15 +1,15 @@
|
|||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#include "page_view_widget.h"
|
||||
#include "page_widget.h"
|
||||
#include "render.h"
|
||||
#include "utils.h"
|
||||
#include <girara/utils.h>
|
||||
#include <girara/settings.h>
|
||||
#include <girara/datastructures.h>
|
||||
|
||||
G_DEFINE_TYPE(ZathuraPageView, zathura_page_view, GTK_TYPE_DRAWING_AREA)
|
||||
G_DEFINE_TYPE(ZathuraPage, zathura_page_widget, GTK_TYPE_DRAWING_AREA)
|
||||
|
||||
typedef struct zathura_page_view_private_s {
|
||||
typedef struct zathura_page_widget_private_s {
|
||||
zathura_page_t* page;
|
||||
zathura_t* zathura;
|
||||
cairo_surface_t* surface; /** Cairo surface */
|
||||
|
@ -20,18 +20,18 @@ typedef struct zathura_page_view_private_s {
|
|||
girara_list_t* search_results; /** True if search results should be drawn */
|
||||
unsigned int link_offset; /**< Offset to the links */
|
||||
unsigned int number_of_links; /**< Offset to the links */
|
||||
} zathura_page_view_private_t;
|
||||
} zathura_page_widget_private_t;
|
||||
|
||||
#define ZATHURA_PAGE_VIEW_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZATHURA_TYPE_PAGE_VIEW, zathura_page_view_private_t))
|
||||
#define ZATHURA_PAGE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZATHURA_TYPE_PAGE, zathura_page_widget_private_t))
|
||||
|
||||
static gboolean zathura_page_view_expose(GtkWidget* widget, GdkEventExpose* event);
|
||||
static void zathura_page_view_finalize(GObject* object);
|
||||
static void zathura_page_view_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
|
||||
static void zathura_page_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
|
||||
static void zathura_page_view_size_allocate(GtkWidget* widget, GdkRectangle* allocation);
|
||||
static void redraw_rect(ZathuraPageView* widget, zathura_rectangle_t* rectangle);
|
||||
static void redraw_all_rects(ZathuraPageView* widget, girara_list_t* rectangles);
|
||||
static gboolean zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event);
|
||||
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);
|
||||
static void zathura_page_widget_size_allocate(GtkWidget* widget, GdkRectangle* allocation);
|
||||
static void redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle);
|
||||
static void redraw_all_rects(ZathuraPage* widget, girara_list_t* rectangles);
|
||||
|
||||
enum properties_e
|
||||
{
|
||||
|
@ -44,20 +44,20 @@ enum properties_e
|
|||
};
|
||||
|
||||
static void
|
||||
zathura_page_view_class_init(ZathuraPageViewClass* class)
|
||||
zathura_page_widget_class_init(ZathuraPageClass* class)
|
||||
{
|
||||
/* add private members */
|
||||
g_type_class_add_private(class, sizeof(zathura_page_view_private_t));
|
||||
g_type_class_add_private(class, sizeof(zathura_page_widget_private_t));
|
||||
|
||||
/* overwrite methods */
|
||||
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(class);
|
||||
widget_class->expose_event = zathura_page_view_expose;
|
||||
widget_class->size_allocate = zathura_page_view_size_allocate;
|
||||
widget_class->expose_event = zathura_page_widget_expose;
|
||||
widget_class->size_allocate = zathura_page_widget_size_allocate;
|
||||
|
||||
GObjectClass* object_class = G_OBJECT_CLASS(class);
|
||||
object_class->finalize = zathura_page_view_finalize;
|
||||
object_class->set_property = zathura_page_view_set_property;
|
||||
object_class->get_property = zathura_page_view_get_property;
|
||||
object_class->finalize = zathura_page_widget_finalize;
|
||||
object_class->set_property = zathura_page_widget_set_property;
|
||||
object_class->get_property = zathura_page_widget_get_property;
|
||||
|
||||
/* add properties */
|
||||
g_object_class_install_property(object_class, PROP_PAGE,
|
||||
|
@ -73,9 +73,9 @@ zathura_page_view_class_init(ZathuraPageViewClass* class)
|
|||
}
|
||||
|
||||
static void
|
||||
zathura_page_view_init(ZathuraPageView* widget)
|
||||
zathura_page_widget_init(ZathuraPage* widget)
|
||||
{
|
||||
zathura_page_view_private_t* priv = ZATHURA_PAGE_VIEW_GET_PRIVATE(widget);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||
priv->page = NULL;
|
||||
priv->surface = NULL;
|
||||
priv->links = NULL;
|
||||
|
@ -91,32 +91,32 @@ zathura_page_view_init(ZathuraPageView* widget)
|
|||
}
|
||||
|
||||
GtkWidget*
|
||||
zathura_page_view_new(zathura_page_t* page)
|
||||
zathura_page_widget_new(zathura_page_t* page)
|
||||
{
|
||||
g_return_val_if_fail(page != NULL, NULL);
|
||||
|
||||
return g_object_new(ZATHURA_TYPE_PAGE_VIEW, "page", page, NULL);
|
||||
return g_object_new(ZATHURA_TYPE_PAGE, "page", page, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
zathura_page_view_finalize(GObject* object)
|
||||
zathura_page_widget_finalize(GObject* object)
|
||||
{
|
||||
ZathuraPageView* widget = ZATHURA_PAGE_VIEW(object);
|
||||
zathura_page_view_private_t* priv = ZATHURA_PAGE_VIEW_GET_PRIVATE(widget);
|
||||
ZathuraPage* widget = ZATHURA_PAGE(object);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||
if (priv->surface) {
|
||||
cairo_surface_destroy(priv->surface);
|
||||
}
|
||||
g_static_mutex_free(&(priv->lock));
|
||||
girara_list_free(priv->links);
|
||||
|
||||
G_OBJECT_CLASS(zathura_page_view_parent_class)->finalize(object);
|
||||
G_OBJECT_CLASS(zathura_page_widget_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
zathura_page_view_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
|
||||
zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec)
|
||||
{
|
||||
ZathuraPageView* pageview = ZATHURA_PAGE_VIEW(object);
|
||||
zathura_page_view_private_t* priv = ZATHURA_PAGE_VIEW_GET_PRIVATE(pageview);
|
||||
ZathuraPage* pageview = ZATHURA_PAGE(object);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(pageview);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PAGE:
|
||||
|
@ -159,10 +159,10 @@ zathura_page_view_set_property(GObject* object, guint prop_id, const GValue* val
|
|||
}
|
||||
|
||||
static void
|
||||
zathura_page_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
|
||||
zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
|
||||
{
|
||||
ZathuraPageView* pageview = ZATHURA_PAGE_VIEW(object);
|
||||
zathura_page_view_private_t* priv = ZATHURA_PAGE_VIEW_GET_PRIVATE(pageview);
|
||||
ZathuraPage* pageview = ZATHURA_PAGE(object);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(pageview);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_LINKS_NUMBER:
|
||||
|
@ -174,7 +174,7 @@ zathura_page_view_get_property(GObject* object, guint prop_id, GValue* value, GP
|
|||
}
|
||||
|
||||
static gboolean
|
||||
zathura_page_view_expose(GtkWidget* widget, GdkEventExpose* event)
|
||||
zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event)
|
||||
{
|
||||
cairo_t* cairo = gdk_cairo_create(widget->window);
|
||||
if (cairo == NULL) {
|
||||
|
@ -186,7 +186,7 @@ zathura_page_view_expose(GtkWidget* widget, GdkEventExpose* event)
|
|||
cairo_rectangle(cairo, event->area.x, event->area.y, event->area.width, event->area.height);
|
||||
cairo_clip(cairo);
|
||||
|
||||
zathura_page_view_private_t* priv = ZATHURA_PAGE_VIEW_GET_PRIVATE(widget);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||
g_static_mutex_lock(&(priv->lock));
|
||||
if (priv->surface != NULL) {
|
||||
cairo_save(cairo);
|
||||
|
@ -299,16 +299,16 @@ zathura_page_view_expose(GtkWidget* widget, GdkEventExpose* event)
|
|||
}
|
||||
|
||||
static void
|
||||
zathura_page_view_redraw_canvas(ZathuraPageView* pageview)
|
||||
zathura_page_widget_redraw_canvas(ZathuraPage* pageview)
|
||||
{
|
||||
GtkWidget* widget = GTK_WIDGET(pageview);
|
||||
gtk_widget_queue_draw(widget);
|
||||
}
|
||||
|
||||
void
|
||||
zathura_page_view_update_surface(ZathuraPageView* widget, cairo_surface_t* surface)
|
||||
zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface)
|
||||
{
|
||||
zathura_page_view_private_t* priv = ZATHURA_PAGE_VIEW_GET_PRIVATE(widget);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||
g_static_mutex_lock(&(priv->lock));
|
||||
if (priv->surface != NULL) {
|
||||
cairo_surface_destroy(priv->surface);
|
||||
|
@ -316,18 +316,18 @@ zathura_page_view_update_surface(ZathuraPageView* widget, cairo_surface_t* surfa
|
|||
priv->surface = surface;
|
||||
g_static_mutex_unlock(&(priv->lock));
|
||||
/* force a redraw here */
|
||||
zathura_page_view_redraw_canvas(widget);
|
||||
zathura_page_widget_redraw_canvas(widget);
|
||||
}
|
||||
|
||||
static void
|
||||
zathura_page_view_size_allocate(GtkWidget* widget, GdkRectangle* allocation)
|
||||
zathura_page_widget_size_allocate(GtkWidget* widget, GdkRectangle* allocation)
|
||||
{
|
||||
GTK_WIDGET_CLASS(zathura_page_view_parent_class)->size_allocate(widget, allocation);
|
||||
zathura_page_view_update_surface(ZATHURA_PAGE_VIEW(widget), NULL);
|
||||
GTK_WIDGET_CLASS(zathura_page_widget_parent_class)->size_allocate(widget, allocation);
|
||||
zathura_page_widget_update_surface(ZATHURA_PAGE(widget), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
redraw_rect(ZathuraPageView* widget, zathura_rectangle_t* rectangle)
|
||||
redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle)
|
||||
{
|
||||
/* cause the rect to be drawn */
|
||||
GdkRectangle grect;
|
||||
|
@ -339,9 +339,9 @@ redraw_rect(ZathuraPageView* widget, zathura_rectangle_t* rectangle)
|
|||
}
|
||||
|
||||
static void
|
||||
redraw_all_rects(ZathuraPageView* widget, girara_list_t* rectangles)
|
||||
redraw_all_rects(ZathuraPage* widget, girara_list_t* rectangles)
|
||||
{
|
||||
zathura_page_view_private_t* priv = ZATHURA_PAGE_VIEW_GET_PRIVATE(widget);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||
|
||||
GIRARA_LIST_FOREACH(rectangles, zathura_rectangle_t*, iter, rect)
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
||||
|
@ -350,10 +350,10 @@ redraw_all_rects(ZathuraPageView* widget, girara_list_t* rectangles)
|
|||
}
|
||||
|
||||
zathura_link_t*
|
||||
zathura_page_view_link_get(ZathuraPageView* widget, unsigned int index)
|
||||
zathura_page_widget_link_get(ZathuraPage* widget, unsigned int index)
|
||||
{
|
||||
g_return_val_if_fail(widget != NULL, NULL);
|
||||
zathura_page_view_private_t* priv = ZATHURA_PAGE_VIEW_GET_PRIVATE(widget);
|
||||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||
g_return_val_if_fail(priv != NULL, NULL);
|
||||
|
||||
if (priv->links != NULL && index >= priv->link_offset &&
|
81
page_widget.h
Normal file
81
page_widget.h
Normal file
|
@ -0,0 +1,81 @@
|
|||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#ifndef PAGE_WIDGET_H
|
||||
#define PAGE_WIDGET_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include "document.h"
|
||||
|
||||
/**
|
||||
* The page view widget. The widget handles all the rendering on its own. It
|
||||
* only has to be resized. The widget also manages and handles all the
|
||||
* rectangles for highlighting.
|
||||
*
|
||||
* Before the properties contain the correct values, 'draw-links' has to be set
|
||||
* to TRUE at least one time.
|
||||
* */
|
||||
typedef struct zathura_page_widget_s ZathuraPage;
|
||||
typedef struct zathura_page_widget_class_s ZathuraPageClass;
|
||||
|
||||
struct zathura_page_widget_s {
|
||||
GtkDrawingArea parent;
|
||||
};
|
||||
|
||||
struct zathura_page_widget_class_s {
|
||||
GtkDrawingAreaClass parent_class;
|
||||
};
|
||||
|
||||
#define ZATHURA_TYPE_PAGE \
|
||||
(zathura_page_widget_get_type ())
|
||||
#define ZATHURA_PAGE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((obj), ZATHURA_TYPE_PAGE, ZathuraPage))
|
||||
#define ZATHURA_PAGE_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_CAST ((obj), ZATHURA_PAGE, ZathuraPageClass))
|
||||
#define ZATHURA_IS_PAGE(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZATHURA_PAGE))
|
||||
#define ZATHURA_IS_PAGE_WDIGET_CLASS(obj) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((obj), ZATHURA_TYPE_PAGE))
|
||||
#define ZATHURA_PAGE_GET_CLASS \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), ZATHURA_TYPE_PAGE, ZathuraPageclass))
|
||||
|
||||
/**
|
||||
* Returns the type of the page view widget.
|
||||
* @return the type
|
||||
*/
|
||||
GType zathura_page_widget_get_type(void);
|
||||
/**
|
||||
* Create a page view widget.
|
||||
* @param page the page to be displayed
|
||||
* @return a page view widget
|
||||
*/
|
||||
GtkWidget* zathura_page_widget_new(zathura_page_t* page);
|
||||
/**
|
||||
* Update the widget's surface. This should only be called from the render
|
||||
* thread.
|
||||
* @param widget the widget
|
||||
* @param surface the new surface
|
||||
*/
|
||||
void zathura_page_widget_update_surface(ZathuraPage* widget, cairo_surface_t* surface);
|
||||
/**
|
||||
* Draw a rectangle to mark links or search results
|
||||
* @param widget the widget
|
||||
* @param rectangle the rectangle
|
||||
* @param linkid the link id if it's a link, -1 otherwise
|
||||
*/
|
||||
void zathura_page_widget_draw_rectangle(ZathuraPage* widget, zathura_rectangle_t* rectangle, int linkid);
|
||||
/**
|
||||
* Clear all rectangles.
|
||||
* @param widget the widget
|
||||
*/
|
||||
void zathura_page_widget_clear_rectangles(ZathuraPage* widget);
|
||||
|
||||
/**
|
||||
* Returns the zathura link object at the given index
|
||||
*
|
||||
* @param widget the widget
|
||||
* @param index Index of the link
|
||||
* @return Link object or NULL if an error occured
|
||||
*/
|
||||
zathura_link_t* zathura_page_widget_link_get(ZathuraPage* widget, unsigned int index);
|
||||
|
||||
#endif
|
4
render.c
4
render.c
|
@ -9,7 +9,7 @@
|
|||
#include "render.h"
|
||||
#include "zathura.h"
|
||||
#include "document.h"
|
||||
#include "page_view_widget.h"
|
||||
#include "page_widget.h"
|
||||
|
||||
void* render_job(void* data);
|
||||
bool render(zathura_t* zathura, zathura_page_t* page);
|
||||
|
@ -241,7 +241,7 @@ render(zathura_t* zathura, zathura_page_t* page)
|
|||
}
|
||||
|
||||
/* update the widget */
|
||||
zathura_page_view_update_surface(ZATHURA_PAGE_VIEW(page->drawing_area), surface);
|
||||
zathura_page_widget_update_surface(ZATHURA_PAGE(page->drawing_area), surface);
|
||||
|
||||
gdk_threads_leave();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "zathura.h"
|
||||
#include "render.h"
|
||||
#include "utils.h"
|
||||
#include "page_view_widget.h"
|
||||
#include "page_widget.h"
|
||||
|
||||
bool
|
||||
sc_abort(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
|
@ -51,7 +51,7 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
|
|||
unsigned int pages_per_row = 1;
|
||||
girara_setting_get(session, "pages-per-row", &pages_per_row);
|
||||
|
||||
if (zathura->ui.page_view == NULL || zathura->document == NULL) {
|
||||
if (zathura->ui.page_widget == NULL || zathura->document == NULL) {
|
||||
goto error_ret;
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
}
|
||||
|
||||
if (gtk_widget_get_visible(GTK_WIDGET(zathura->ui.index))) {
|
||||
girara_set_view(session, zathura->ui.page_view_alignment);
|
||||
girara_set_view(session, zathura->ui.page_widget_alignment);
|
||||
gtk_widget_hide(GTK_WIDGET(zathura->ui.index));
|
||||
girara_mode_set(zathura->ui.session, zathura->modes.normal);
|
||||
} else {
|
||||
|
|
2
utils.c
2
utils.c
|
@ -186,7 +186,7 @@ page_calculate_offset(zathura_page_t* page, page_offset_t* offset)
|
|||
zathura_t* zathura = document->zathura;
|
||||
|
||||
g_return_if_fail(gtk_widget_translate_coordinates(page->drawing_area,
|
||||
zathura->ui.page_view, 0, 0, &(offset->x), &(offset->y)) == true);
|
||||
zathura->ui.page_widget, 0, 0, &(offset->x), &(offset->y)) == true);
|
||||
}
|
||||
|
||||
zathura_rectangle_t
|
||||
|
|
44
zathura.c
44
zathura.c
|
@ -126,7 +126,7 @@ zathura_init(int argc, char* argv[])
|
|||
zathura->ui.statusbar.file = NULL;
|
||||
zathura->ui.statusbar.buffer = NULL;
|
||||
zathura->ui.statusbar.page_number = NULL;
|
||||
zathura->ui.page_view = NULL;
|
||||
zathura->ui.page_widget = NULL;
|
||||
zathura->ui.index = NULL;
|
||||
|
||||
/* print settings */
|
||||
|
@ -170,8 +170,8 @@ zathura_init(int argc, char* argv[])
|
|||
zathura->ui.session->events.buffer_changed = buffer_changed;
|
||||
|
||||
/* page view */
|
||||
zathura->ui.page_view = gtk_table_new(0, 0, TRUE);
|
||||
if (!zathura->ui.page_view) {
|
||||
zathura->ui.page_widget = gtk_table_new(0, 0, TRUE);
|
||||
if (!zathura->ui.page_widget) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
|
@ -182,13 +182,13 @@ zathura_init(int argc, char* argv[])
|
|||
g_signal_connect(G_OBJECT(view_hadjustment), "value-changed", G_CALLBACK(cb_view_vadjustment_value_changed), zathura);
|
||||
|
||||
/* page view alignment */
|
||||
zathura->ui.page_view_alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
|
||||
if (!zathura->ui.page_view_alignment) {
|
||||
zathura->ui.page_widget_alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
|
||||
if (!zathura->ui.page_widget_alignment) {
|
||||
goto error_free;
|
||||
}
|
||||
gtk_container_add(GTK_CONTAINER(zathura->ui.page_view_alignment), zathura->ui.page_view);
|
||||
gtk_container_add(GTK_CONTAINER(zathura->ui.page_widget_alignment), zathura->ui.page_widget);
|
||||
|
||||
gtk_widget_show(zathura->ui.page_view);
|
||||
gtk_widget_show(zathura->ui.page_widget);
|
||||
|
||||
/* statusbar */
|
||||
zathura->ui.statusbar.file = girara_statusbar_item_add(zathura->ui.session, TRUE, TRUE, TRUE, NULL);
|
||||
|
@ -215,8 +215,8 @@ zathura_init(int argc, char* argv[])
|
|||
zathura->global.page_padding = 1;
|
||||
girara_setting_get(zathura->ui.session, "page-padding", &zathura->global.page_padding);
|
||||
|
||||
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_view), zathura->global.page_padding);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_view), zathura->global.page_padding);
|
||||
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), zathura->global.page_padding);
|
||||
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), zathura->global.page_padding);
|
||||
|
||||
/* parse colors */
|
||||
char* string_value = NULL;
|
||||
|
@ -264,12 +264,12 @@ zathura_init(int argc, char* argv[])
|
|||
|
||||
error_free:
|
||||
|
||||
if (zathura->ui.page_view) {
|
||||
g_object_unref(zathura->ui.page_view);
|
||||
if (zathura->ui.page_widget) {
|
||||
g_object_unref(zathura->ui.page_widget);
|
||||
}
|
||||
|
||||
if (zathura->ui.page_view_alignment) {
|
||||
g_object_unref(zathura->ui.page_view_alignment);
|
||||
if (zathura->ui.page_widget_alignment) {
|
||||
g_object_unref(zathura->ui.page_widget_alignment);
|
||||
}
|
||||
|
||||
error_out:
|
||||
|
@ -424,9 +424,9 @@ document_open(zathura_t* zathura, const char* path, const char* password)
|
|||
/* view mode */
|
||||
int pages_per_row = 1;
|
||||
girara_setting_get(zathura->ui.session, "pages-per-row", &pages_per_row);
|
||||
page_view_set_mode(zathura, pages_per_row);
|
||||
page_widget_set_mode(zathura, pages_per_row);
|
||||
|
||||
girara_set_view(zathura->ui.session, zathura->ui.page_view_alignment);
|
||||
girara_set_view(zathura->ui.session, zathura->ui.page_widget_alignment);
|
||||
|
||||
/* threads */
|
||||
zathura->sync.render_thread = render_init(zathura);
|
||||
|
@ -504,12 +504,12 @@ document_close(zathura_t* zathura)
|
|||
render_free(zathura->sync.render_thread);
|
||||
zathura->sync.render_thread = NULL;
|
||||
|
||||
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_view), remove_page_from_table, (gpointer)1);
|
||||
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, (gpointer)1);
|
||||
|
||||
zathura_document_free(zathura->document);
|
||||
zathura->document = NULL;
|
||||
|
||||
gtk_widget_hide(zathura->ui.page_view);
|
||||
gtk_widget_hide(zathura->ui.page_widget);
|
||||
|
||||
statusbar_page_number_update(zathura);
|
||||
|
||||
|
@ -601,7 +601,7 @@ statusbar_page_number_update(zathura_t* zathura)
|
|||
}
|
||||
|
||||
void
|
||||
page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row)
|
||||
page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row)
|
||||
{
|
||||
/* show at least one page */
|
||||
if (pages_per_row == 0) {
|
||||
|
@ -612,15 +612,15 @@ page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row)
|
|||
return;
|
||||
}
|
||||
|
||||
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_view), remove_page_from_table, (gpointer)0);
|
||||
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, (gpointer)0);
|
||||
|
||||
gtk_table_resize(GTK_TABLE(zathura->ui.page_view), zathura->document->number_of_pages / pages_per_row + 1, pages_per_row);
|
||||
gtk_table_resize(GTK_TABLE(zathura->ui.page_widget), zathura->document->number_of_pages / pages_per_row + 1, pages_per_row);
|
||||
for (unsigned int i = 0; i < zathura->document->number_of_pages; i++)
|
||||
{
|
||||
int x = i % pages_per_row;
|
||||
int y = i / pages_per_row;
|
||||
gtk_table_attach(GTK_TABLE(zathura->ui.page_view), zathura->document->pages[i]->drawing_area, x, x + 1, y, y + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
|
||||
gtk_table_attach(GTK_TABLE(zathura->ui.page_widget), zathura->document->pages[i]->drawing_area, x, x + 1, y, y + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
|
||||
}
|
||||
|
||||
gtk_widget_show_all(zathura->ui.page_view);
|
||||
gtk_widget_show_all(zathura->ui.page_widget);
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ typedef struct zathura_s
|
|||
GdkColor highlight_color; /**< Color for highlighting */
|
||||
} colors;
|
||||
|
||||
GtkWidget *page_view_alignment;
|
||||
GtkWidget *page_view; /**< Widget that contains all rendered pages */
|
||||
GtkWidget *page_widget_alignment;
|
||||
GtkWidget *page_widget; /**< Widget that contains all rendered pages */
|
||||
GtkWidget *index; /**< Widget to show the index of the document */
|
||||
} ui;
|
||||
|
||||
|
@ -178,7 +178,7 @@ bool page_set_delayed(zathura_t* zathura, unsigned int page_id);
|
|||
* @param zathura The zathura session
|
||||
* @param pages_per_row Number of shown pages per row
|
||||
*/
|
||||
void page_view_set_mode(zathura_t* zathura, unsigned int pages_per_row);
|
||||
void page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row);
|
||||
|
||||
/**
|
||||
* Updates the page number in the statusbar. Note that 1 will be added to the
|
||||
|
|
Loading…
Reference in a new issue