Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zathura
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
110
Issues
110
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwmt
zathura
Commits
691b5c76
Commit
691b5c76
authored
Apr 26, 2011
by
Moritz Lipp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Postscript support through libspectre
parent
1806b047
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
290 additions
and
20 deletions
+290
-20
README
README
+6
-17
document.c
document.c
+4
-3
ft/ps/Makefile
ft/ps/Makefile
+57
-0
ft/ps/config.mk
ft/ps/config.mk
+21
-0
ft/ps/ps.c
ft/ps/ps.c
+180
-0
ft/ps/ps.h
ft/ps/ps.h
+22
-0
No files found.
README
View file @
691b5c76
zathura -
pdf
viewer
zathura -
a document
viewer
--------------------
zathura is a pdf viewer based on the poppler pdf rendering library
zathura is a highly customizable and functional document viewer based on the
girara user interface library and several document libraries.
Requirements
------------
poppler-glib (0.12.3)
gtk2 (2.18.6)
glib2 (2.22.4)
Configuration
-------------
You can modify some parts of zathura by editing the config.h file
gtk2 (>= 2.18.6)
girara
Installation
------------
Customise config.h according to your wishes and run the following
command to build and install zathura:
To build and install zathura:
make install
...
...
@@ -24,9 +19,3 @@ Uninstall:
To delete zathura from your system, just type:
make uninstall
Use zathura
-----------
Just run:
zathura <file>
document.c
View file @
691b5c76
...
...
@@ -131,7 +131,7 @@ zathura_document_plugins_free(zathura_t* zathura)
if
(
iter
==
NULL
)
{
return
;
}
do
{
zathura_document_plugin_t
*
plugin
=
(
zathura_document_plugin_t
*
)
girara_list_iterator_data
(
iter
);
free
(
plugin
->
file_extension
);
...
...
@@ -158,7 +158,7 @@ zathura_document_plugin_register(zathura_t* zathura, zathura_document_plugin_t*
girara_error
(
"plugin: already registered for filetype %s
\n
"
,
plugin
->
file_extension
);
girara_list_iterator_free
(
iter
);
return
false
;
}
}
}
while
(
girara_list_iterator_next
(
iter
));
girara_list_iterator_free
(
iter
);
}
...
...
@@ -237,7 +237,7 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
if
(
iter
==
NULL
)
{
goto
error_free
;
}
do
{
zathura_document_plugin_t
*
plugin
=
(
zathura_document_plugin_t
*
)
girara_list_iterator_data
(
iter
);
if
(
!
strcmp
(
file_extension
,
plugin
->
file_extension
))
{
...
...
@@ -403,6 +403,7 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id)
page
->
event_box
=
gtk_event_box_new
();
page
->
drawing_area
=
gtk_drawing_area_new
();
page
->
surface
=
NULL
;
page
->
document
=
document
;
g_signal_connect
(
page
->
drawing_area
,
"expose-event"
,
G_CALLBACK
(
page_expose_event
),
page
);
gtk_widget_set_size_request
(
page
->
drawing_area
,
page
->
width
*
document
->
scale
,
page
->
height
*
document
->
scale
);
...
...
ft/ps/Makefile
0 → 100644
View file @
691b5c76
# See LICENSE file for license and copyright information
include
config.mk
PLUGIN
=
ps
SOURCE
=
ps.c
OBJECTS
=
${SOURCE:.c=.o}
DOBJECTS
=
${SOURCE:.c=.do}
all
:
options ${PLUGIN}
options
:
@
echo
${PLUGIN}
build options:
@
echo
"CFLAGS =
${CFLAGS}
"
@
echo
"LDFLAGS =
${LDFLAGS}
"
@
echo
"DFLAGS =
${DFLAGS}
"
@
echo
"CC =
${CC}
"
%.o
:
%.c
@
echo
CC
$<
@
mkdir
-p
.depend
@
${CC}
-c
${CFLAGS}
-o
$@
$<
-MMD
-MF
.depend/
$@
.dep
%.do
:
%.c
@
echo
CC
$<
@
mkdir
-p
.depend
@
${CC}
-c
${CFLAGS}
${DFLAGS}
-o
$@
$<
-MMD
-MF
.depend/
$@
.dep
${OBJECTS}
:
config.mk
${DOBJECTS}
:
config.mk
${PLUGIN}
:
${OBJECTS}
@
echo
LD
$@
@
${CC}
-shared
${LDFLAGS}
-o
${PLUGIN}
.so
$(OBJECTS)
${LIBS}
${PLUGIN}-debug
:
${DOBJECTS}
@
echo
LD
$@
@
${CC}
-shared
${LDFLAGS}
-o
${PLUGIN}
.so
$(DOBJECTS)
${LIBS}
clean
:
@
rm
-rf
${OBJECTS}
${DOBJECTS}
$(PLUGIN)
.so .depend
debug
:
options ${PLUGIN}-debug
install
:
all
@
echo
installing
${PLUGIN}
plugin
@
mkdir
-p
${DESTDIR}${PREFIX}
/lib/zathura
@
cp
-f
${PLUGIN}
.so
${DESTDIR}${PREFIX}
/lib/zathura
uninstall
:
@
echo
uninstalling
${PLUGIN}
plugin
@
rm
-f
${DESTDIR}${PREFIX}
/lib/zathura/
${PLUGIN}
.so
@
rm
-rf
${DESTDIR}${PREFIX}
/lib/zathura
-include
$(wildcard .depend/*.dep)
.PHONY
:
all options clean debug install uninstall
ft/ps/config.mk
0 → 100644
View file @
691b5c76
# See LICENSE file for license and copyright information
# paths
PREFIX
?=
/usr
# libs
GTK_INC
=
$(
shell
pkg-config
--cflags
gtk+-2.0
)
GTK_LIB
=
$(
shell
pkg-config
--libs
gtk+-2.0
)
INCS
=
-I
.
-I
/usr/include
${GTK_INC}
LIBS
=
-lc
${GTK_LIB}
-lspectre
# flags
CFLAGS
+=
-std
=
c99
-fPIC
-pedantic
-Wall
-Wno-format-zero-length
$(INCS)
# debug
DFLAGS
=
-g
# compiler
CC
?=
gcc
LD
?=
ld
ft/ps/ps.c
0 → 100644
View file @
691b5c76
/* See LICENSE file for license and copyright information */
#include <stdlib.h>
#include "ps.h"
#include "../../zathura.h"
void
plugin_register
(
zathura_document_plugin_t
*
plugin
)
{
plugin
->
file_extension
=
"ps"
;
plugin
->
open_function
=
ps_document_open
;
}
bool
ps_document_open
(
zathura_document_t
*
document
)
{
if
(
!
document
)
{
goto
error_ret
;
}
document
->
functions
.
document_free
=
ps_document_free
;
document
->
functions
.
page_get
=
ps_page_get
;
document
->
functions
.
page_render
=
ps_page_render
;
document
->
functions
.
page_free
=
ps_page_free
;
document
->
data
=
malloc
(
sizeof
(
ps_document_t
));
if
(
!
document
->
data
)
{
goto
error_ret
;
}
ps_document_t
*
ps_document
=
(
ps_document_t
*
)
document
->
data
;
ps_document
->
document
=
spectre_document_new
();
if
(
ps_document
->
document
==
NULL
)
{
goto
error_free
;
}
spectre_document_load
(
ps_document
->
document
,
document
->
file_path
);
if
(
spectre_document_status
(
ps_document
->
document
)
!=
SPECTRE_STATUS_SUCCESS
)
{
goto
error_free
;
}
document
->
number_of_pages
=
spectre_document_get_n_pages
(
ps_document
->
document
);
return
true
;
error_free:
if
(
ps_document
->
document
!=
NULL
)
{
spectre_document_free
(
ps_document
->
document
);
}
free
(
document
->
data
);
document
->
data
=
NULL
;
error_ret:
return
false
;
}
bool
ps_document_free
(
zathura_document_t
*
document
)
{
if
(
!
document
)
{
return
false
;
}
if
(
document
->
data
!=
NULL
)
{
ps_document_t
*
ps_document
=
(
ps_document_t
*
)
document
->
data
;
spectre_document_free
(
ps_document
->
document
);
free
(
document
->
data
);
document
->
data
=
NULL
;
}
return
true
;
}
zathura_page_t
*
ps_page_get
(
zathura_document_t
*
document
,
unsigned
int
page
)
{
if
(
!
document
||
!
document
->
data
)
{
return
NULL
;
}
ps_document_t
*
ps_document
=
(
ps_document_t
*
)
document
->
data
;
zathura_page_t
*
document_page
=
malloc
(
sizeof
(
zathura_page_t
));
if
(
document_page
==
NULL
)
{
goto
error_ret
;
}
SpectrePage
*
ps_page
=
spectre_document_get_page
(
ps_document
->
document
,
page
);
if
(
ps_page
==
NULL
)
{
goto
error_free
;
}
int
page_width
;
int
page_height
;
spectre_page_get_size
(
ps_page
,
&
(
page_width
),
&
(
page_height
));
document_page
->
width
=
page_width
;
document_page
->
height
=
page_height
;
document_page
->
document
=
document
;
document_page
->
data
=
ps_page
;
return
document_page
;
error_free:
free
(
document_page
);
error_ret:
return
NULL
;
}
bool
ps_page_free
(
zathura_page_t
*
page
)
{
if
(
page
==
NULL
)
{
return
false
;
}
if
(
page
->
data
!=
NULL
)
{
SpectrePage
*
ps_page
=
(
SpectrePage
*
)
page
->
data
;
spectre_page_free
(
ps_page
);
}
free
(
page
);
return
true
;
}
zathura_image_buffer_t
*
ps_page_render
(
zathura_page_t
*
page
)
{
if
(
!
page
||
!
page
->
data
||
!
page
->
document
)
{
return
NULL
;
}
/* calculate sizes */
unsigned
int
page_width
=
page
->
document
->
scale
*
page
->
width
;
unsigned
int
page_height
=
page
->
document
->
scale
*
page
->
height
;
/* create image buffer */
zathura_image_buffer_t
*
image_buffer
=
zathura_image_buffer_create
(
page_width
,
page_height
);
if
(
image_buffer
==
NULL
)
{
return
NULL
;
}
SpectrePage
*
ps_page
=
(
SpectrePage
*
)
page
->
data
;
SpectreRenderContext
*
context
=
spectre_render_context_new
();
spectre_render_context_set_scale
(
context
,
page
->
document
->
scale
,
page
->
document
->
scale
);
spectre_render_context_set_rotation
(
context
,
0
);
unsigned
char
*
page_data
;
int
row_length
;
spectre_page_render
(
ps_page
,
context
,
&
page_data
,
&
row_length
);
for
(
unsigned
int
y
=
0
;
y
<
page_height
;
y
++
)
{
for
(
unsigned
int
x
=
0
;
x
<
page_width
;
x
++
)
{
unsigned
char
*
s
=
page_data
+
y
*
row_length
+
x
*
4
;
guchar
*
p
=
image_buffer
->
data
+
y
*
image_buffer
->
rowstride
+
x
*
3
;
p
[
0
]
=
s
[
0
];
p
[
1
]
=
s
[
1
];
p
[
2
]
=
s
[
2
];
}
}
spectre_render_context_free
(
context
);
ps_document_t
*
ps_document
=
(
ps_document_t
*
)
page
->
document
->
data
;
return
image_buffer
;
}
ft/ps/ps.h
0 → 100644
View file @
691b5c76
/* See LICENSE file for license and copyright information */
#ifndef PS_H
#define PS_H
#include <stdbool.h>
#include <libspectre/spectre.h>
#include "../../document.h"
typedef
struct
ps_document_s
{
SpectreDocument
*
document
;
}
ps_document_t
;
bool
ps_document_open
(
zathura_document_t
*
document
);
bool
ps_document_free
(
zathura_document_t
*
document
);
zathura_page_t
*
ps_page_get
(
zathura_document_t
*
document
,
unsigned
int
page
);
zathura_image_buffer_t
*
ps_page_render
(
zathura_page_t
*
page
);
bool
ps_page_free
(
zathura_page_t
*
page
);
#endif // PS_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment