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
111
Issues
111
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
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
c124b180
Commit
c124b180
authored
Feb 14, 2016
by
Moritz Lipp
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/0.3.5'
parents
6218ee88
c085f8b4
Changes
33
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
542 additions
and
352 deletions
+542
-352
LICENSE
LICENSE
+1
-1
README
README
+1
-1
config.mk
config.mk
+1
-1
doc/Makefile
doc/Makefile
+4
-2
doc/man/_commands.txt
doc/man/_commands.txt
+0
-3
doc/man/_options.txt
doc/man/_options.txt
+7
-1
doc/man/_synctex.txt
doc/man/_synctex.txt
+2
-2
doc/man/_synopsis.txt
doc/man/_synopsis.txt
+2
-1
doc/man/zathurarc.5.rst
doc/man/zathurarc.5.rst
+9
-2
doc/usage/index.rst
doc/usage/index.rst
+1
-1
po/Makefile
po/Makefile
+2
-2
tests/test_document.c
tests/test_document.c
+4
-3
zathura/callbacks.h
zathura/callbacks.h
+3
-3
zathura/commands.h
zathura/commands.h
+18
-18
zathura/completion.h
zathura/completion.h
+3
-3
zathura/config.c
zathura/config.c
+2
-0
zathura/content-type.c
zathura/content-type.c
+70
-28
zathura/content-type.h
zathura/content-type.h
+19
-2
zathura/dbus-interface.c
zathura/dbus-interface.c
+1
-1
zathura/document.c
zathura/document.c
+7
-7
zathura/document.h
zathura/document.h
+12
-12
zathura/main.c
zathura/main.c
+86
-55
zathura/marks.h
zathura/marks.h
+4
-4
zathura/page-widget.h
zathura/page-widget.h
+1
-1
zathura/page.h
zathura/page.h
+16
-16
zathura/plugin.h
zathura/plugin.h
+1
-1
zathura/render.h
zathura/render.h
+2
-2
zathura/shortcuts.h
zathura/shortcuts.h
+26
-26
zathura/types.h
zathura/types.h
+20
-15
zathura/utils.c
zathura/utils.c
+2
-2
zathura/utils.h
zathura/utils.h
+2
-2
zathura/zathura.c
zathura/zathura.c
+200
-128
zathura/zathura.h
zathura/zathura.h
+13
-6
No files found.
LICENSE
View file @
c124b180
Copyright (c) 2009-201
5
pwmt.org
Copyright (c) 2009-201
6
pwmt.org
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
...
...
README
View file @
c124b180
...
...
@@ -12,7 +12,7 @@ sqlite3 (optional, >= 3.5.9)
check (for tests)
intltool
libmagic from file(1) (optional, for mime-type detection)
libsynctex from TeXLive (option, for SyncTeX support)
libsynctex from TeXLive (option
al
, for SyncTeX support)
Sphinx (optional, for manpages and HTML documentation)
doxygen (optional, for HTML documentation)
breathe (optional, for HTML documentation)
...
...
config.mk
View file @
c124b180
...
...
@@ -6,7 +6,7 @@ PROJECT = zathura
ZATHURA_VERSION_MAJOR
=
0
ZATHURA_VERSION_MINOR
=
3
ZATHURA_VERSION_REV
=
4
ZATHURA_VERSION_REV
=
5
# If the API changes, the API version and the ABI version have to be bumped.
ZATHURA_API_VERSION
=
2
# If the ABI breaks for any reason, this has to be bumped.
...
...
doc/Makefile
View file @
c124b180
...
...
@@ -6,7 +6,7 @@ include ../colors.mk
include
config.mk
MAN_SOURCES
=
$(
wildcard
man/
*
.rst
)
$(
wildcard
man/
*
.txt
)
man/conf.py
DOXYGEN_SOURCES
=
$(
wildcard
../
*
.h
)
Doxyfile
DOXYGEN_SOURCES
=
$(
wildcard
../
zathura/
*
.h
)
Doxyfile
HTML_SOURCES
=
$(
wildcard
*
.rst api/
*
.rst configuration/
*
.rst installation/
*
.rst usage/
*
.rst
)
conf.py
SPHINX_OPTS
+=
-d
$(SPHINX_BUILDDIR)
/doctrees
...
...
@@ -18,15 +18,17 @@ clean:
$(QUIET)
rm
-rf
$(SPHINX_BUILDDIR)
/
$(SPHINX_BUILDDIR)/html/index.html
:
$(HTML_SOURCES) $(SPHINX_BUILDDIR)/doxygen/xml/index.xml
$(QUIET)
mkdir
-p
$(SPHINX_BUILDDIR)
/html
$(
call
colorecho,DOC,
"Build HTML documentation"
)
$(QUIET)$(SPHINX_BIN)
-b
html
$(SPHINX_OPTS)
.
$(SPHINX_BUILDDIR)
/html
$(SPHINX_BUILDDIR)/zathura.1 $(SPHINX_BUILDDIR)/zathurarc.5
:
$(MAN_SOURCES)
$(QUIET)
mkdir
-p
$(SPHINX_BUILDDIR)
$(
call
colorecho,DOC,
"Build man pages"
)
$(QUIET)$(SPHINX_BIN)
-b
man
$(SPHINX_OPTS)
man
$(SPHINX_BUILDDIR)
$(SPHINX_BUILDDIR)/doxygen/xml/index.xml
:
$(DOXYGEN_SOURCES)
$(QUIET)
mkdir
-p
$(SPHINX_BUILDDIR)
$(QUIET)
mkdir
-p
$(SPHINX_BUILDDIR)
/doxygen/xml
$(
call
colorecho,DOC,
"Run doxygen"
)
$(QUIET)$(DOXYGEN_BIN)
Doxyfile
...
...
doc/man/_commands.txt
View file @
c124b180
...
...
@@ -16,9 +16,6 @@ exec
info
Show document information
help
Show help page
open
Open a document
...
...
doc/man/_options.txt
View file @
c124b180
...
...
@@ -28,7 +28,13 @@
--synctex-forward=input
Jump to the given position. The switch expects the same format as specified
for synctex's view -i.
for synctex's view -i. If no instance is running for the specified document,
a new instance will be launched (only if --synctex-pid is not specified).
--synctex-pid=pid
Instead of looking for an instance having the correct file opened, try only
the instance with the given PID. Note that if the given PID does not have the
correct file open or does not exist, no new instance will be spanned.
--fork
Fork into background
...
...
doc/man/_synctex.txt
View file @
c124b180
Both synctex forward and backwards synchronization are supported by zathura, To
enable synctex forward synchronization, please look at the *--syn
tex* and
*--synctex-editor* options. zathura will also emit a signal via the D-Bus
enable synctex forward synchronization, please look at the *--syn
ctex-forward*
and
*--synctex-editor* options. zathura will also emit a signal via the D-Bus
interface. To support synctex backwards synchronization, zathura provides a
D-Bus interface that can be called by the editor. For convince zathura also
knows how to parse the output of the *synctex view* command. It is enough to
...
...
doc/man/_synopsis.txt
View file @
c124b180
zathura [-e XID] [-c PATH] [-d PATH] [-p PATH] [-w PASSWORD] [-P NUMBER]
[--fork] [-l LEVEL] [-s] [-x CMD] [--synctex-forward INPUT] <files>
[--fork] [-l LEVEL] [-s] [-x CMD] [--synctex-forward INPUT] [--synctex-pid PID]
<files>
doc/man/zathurarc.5.rst
View file @
c124b180
...
...
@@ -307,6 +307,13 @@ The following shortcut functions can be mapped:
Zoom in or out.
* ``mark_add``
Set a quickmark.
* ``mark_evaluate``
Go to a quickmark.
Pass arguments
^^^^^^^^^^^^^^
Some shortcut function require or have optional arguments which influence the
...
...
@@ -454,8 +461,8 @@ guioptions
Shows or hides GUI elements.
If it contains 'c', the command line is displayed.
If it contains 's', the statusbar is displayed.
If it contains 'h', the
vertic
al scrollbar is displayed.
If it contains 'v', the
horizont
al scrollbar is displayed.
If it contains 'h', the
horizont
al scrollbar is displayed.
If it contains 'v', the
vertic
al scrollbar is displayed.
* Value type: String
* Default value: s
...
...
doc/usage/index.rst
View file @
c124b180
...
...
@@ -5,4 +5,4 @@ Usage
:maxdepth: 2
:numbered:
commands
commands
po/Makefile
View file @
c124b180
...
...
@@ -19,10 +19,10 @@ all: ${MOS}
clean
:
$(QUIET)
rm
-rf
POTFILES.in POTFILES.in.tmp
$(
patsubst
%.po, %,
$(CATALOGS)
)
${PROJECT}
.pot
POTFILES.in
:
$(sort $(wildcard ../
gira
ra/*.c))
POTFILES.in
:
$(sort $(wildcard ../
zathu
ra/*.c))
$(QUIET)
set
-e
&&
rm
-f
$@
.tmp
&&
touch
$@
.tmp
&&
\
for
f
in
$
(
^F
)
;
do
\
echo
gira
ra/
$$
f
>>
$@
.tmp
;
\
echo
zathu
ra/
$$
f
>>
$@
.tmp
;
\
done
&&
\
mv
$@
.tmp
$@
...
...
tests/test_document.c
View file @
c124b180
...
...
@@ -5,9 +5,10 @@
#include "document.h"
START_TEST
(
test_open
)
{
fail_unless
(
zathura_document_open
(
NULL
,
NULL
,
NULL
,
NULL
)
==
NULL
,
"Could create document"
,
NULL
);
fail_unless
(
zathura_document_open
(
NULL
,
"fl"
,
NULL
,
NULL
)
==
NULL
,
"Could create document"
,
NULL
);
fail_unless
(
zathura_document_open
(
NULL
,
"fl"
,
"pw"
,
NULL
)
==
NULL
,
"Could create document"
,
NULL
);
fail_unless
(
zathura_document_open
(
NULL
,
NULL
,
NULL
,
NULL
,
NULL
)
==
NULL
,
"Could create document"
,
NULL
);
fail_unless
(
zathura_document_open
(
NULL
,
"fl"
,
NULL
,
NULL
,
NULL
)
==
NULL
,
"Could create document"
,
NULL
);
fail_unless
(
zathura_document_open
(
NULL
,
"fl"
,
"ur"
,
NULL
,
NULL
)
==
NULL
,
"Could create document"
,
NULL
);
fail_unless
(
zathura_document_open
(
NULL
,
"fl"
,
NULL
,
"pw"
,
NULL
)
==
NULL
,
"Could create document"
,
NULL
);
}
END_TEST
Suite
*
suite_document
()
...
...
zathura/callbacks.h
View file @
c124b180
...
...
@@ -16,7 +16,7 @@
*
* @param widget The gtk window of zathura
* @param zathura Correspondending zathura session
* @return true if no error occured and the event has been handled
* @return true if no error occur
r
ed and the event has been handled
*/
gboolean
cb_destroy
(
GtkWidget
*
widget
,
zathura_t
*
zathura
);
...
...
@@ -108,7 +108,7 @@ void cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
*
* @param entry The dialog inputbar
* @param session The girara session
* @return true if no error occured and the event has been handled
* @return true if no error occur
r
ed and the event has been handled
*/
bool
cb_sc_follow
(
GtkEntry
*
entry
,
girara_session_t
*
session
);
...
...
@@ -117,7 +117,7 @@ bool cb_sc_follow(GtkEntry* entry, girara_session_t* session);
*
* @param entry The dialog inputbar
* @param session The girara session
* @return true if no error occured and the event has been handled
* @return true if no error occur
r
ed and the event has been handled
*/
bool
cb_sc_display_link
(
GtkEntry
*
entry
,
girara_session_t
*
session
);
...
...
zathura/commands.h
View file @
c124b180
...
...
@@ -11,7 +11,7 @@
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_bookmark_create
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -20,7 +20,7 @@ bool cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_bookmark_delete
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -29,7 +29,7 @@ bool cmd_bookmark_delete(girara_session_t* session, girara_list_t* argument_list
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_bookmark_open
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -38,7 +38,7 @@ bool cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_close
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -47,7 +47,7 @@ bool cmd_close(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_info
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -56,7 +56,7 @@ bool cmd_info(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_help
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -65,7 +65,7 @@ bool cmd_help(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_hlsearch
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -74,7 +74,7 @@ bool cmd_hlsearch(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_open
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -83,7 +83,7 @@ bool cmd_open(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_print
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -92,7 +92,7 @@ bool cmd_print(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_nohlsearch
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -101,7 +101,7 @@ bool cmd_nohlsearch(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_quit
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -110,7 +110,7 @@ bool cmd_quit(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_save
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -119,7 +119,7 @@ bool cmd_save(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_savef
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -129,7 +129,7 @@ bool cmd_savef(girara_session_t* session, girara_list_t* argument_list);
* @param session The used girara session
* @param input The current input
* @param argument Passed argument
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_search
(
girara_session_t
*
session
,
const
char
*
input
,
girara_argument_t
*
argument
);
...
...
@@ -138,7 +138,7 @@ bool cmd_search(girara_session_t* session, const char* input, girara_argument_t*
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_export
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -147,7 +147,7 @@ bool cmd_export(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_exec
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -156,7 +156,7 @@ bool cmd_exec(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_offset
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
@@ -165,7 +165,7 @@ bool cmd_offset(girara_session_t* session, girara_list_t* argument_list);
*
* @param session The used girara session
* @param argument_list List of passed arguments
* @return true if no error occured
* @return true if no error occur
r
ed
*/
bool
cmd_version
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
);
...
...
zathura/completion.h
View file @
c124b180
...
...
@@ -11,7 +11,7 @@
*
* @param session The used girara session
* @param input The current input
* @return The completion object or NULL if an error occured
* @return The completion object or NULL if an error occur
r
ed
*/
girara_completion_t
*
cc_open
(
girara_session_t
*
session
,
const
char
*
input
);
...
...
@@ -21,7 +21,7 @@ girara_completion_t* cc_open(girara_session_t* session, const char* input);
*
* @param session The used girara session
* @param input The current input
* @return The completion object or NULL if an error occured
* @return The completion object or NULL if an error occur
r
ed
*/
girara_completion_t
*
cc_write
(
girara_session_t
*
session
,
const
char
*
input
);
...
...
@@ -30,7 +30,7 @@ girara_completion_t* cc_write(girara_session_t* session, const char* input);
*
* @param session The used girara session
* @param input The current input
* @return The completion object or NULL if an error occured
* @return The completion object or NULL if an error occur
r
ed
*/
girara_completion_t
*
cc_bookmarks
(
girara_session_t
*
session
,
const
char
*
input
);
...
...
zathura/config.c
View file @
c124b180
...
...
@@ -466,6 +466,8 @@ config_load_default(zathura_t* zathura)
girara_shortcut_mapping_add
(
gsession
,
"goto"
,
sc_goto
);
girara_shortcut_mapping_add
(
gsession
,
"jumplist"
,
sc_jumplist
);
girara_shortcut_mapping_add
(
gsession
,
"bisect"
,
sc_bisect
);
girara_shortcut_mapping_add
(
gsession
,
"mark_add"
,
sc_mark_add
);
girara_shortcut_mapping_add
(
gsession
,
"mark_evaluate"
,
sc_mark_evaluate
);
girara_shortcut_mapping_add
(
gsession
,
"navigate"
,
sc_navigate
);
girara_shortcut_mapping_add
(
gsession
,
"navigate_index"
,
sc_navigate_index
);
girara_shortcut_mapping_add
(
gsession
,
"print"
,
sc_print
);
...
...
zathura/content-type.c
View file @
c124b180
...
...
@@ -17,14 +17,23 @@
#include <glib.h>
#include <gio/gio.h>
/** Read a most GT_MAX_READ bytes before falling back to file. */
static
const
size_t
GT_MAX_READ
=
1
<<
16
;
struct
zathura_content_type_context_s
{
#ifdef WITH_MAGIC
static
const
char
*
guess_type_magic
(
const
char
*
path
)
{
const
char
*
mime_type
=
NULL
;
magic_t
magic
;
#endif
};
zathura_content_type_context_t
*
zathura_content_type_new
(
void
)
{
zathura_content_type_context_t
*
context
=
g_try_malloc0
(
sizeof
(
zathura_content_type_context_t
));
if
(
context
==
NULL
)
{
return
NULL
;
}
#ifdef WITH_MAGIC
/* creat magic cookie */
const
int
flags
=
MAGIC_MIME_TYPE
|
...
...
@@ -36,46 +45,78 @@ guess_type_magic(const char* path) {
magic_t
magic
=
magic_open
(
flags
);
if
(
magic
==
NULL
)
{
girara_debug
(
"failed creating the magic cookie"
);
goto
cleanup
;
return
context
;
}
/* ... and load mime database */
if
(
magic_load
(
magic
,
NULL
)
<
0
)
{
girara_debug
(
"failed loading the magic database: %s"
,
magic_error
(
magic
));
goto
cleanup
;
magic_close
(
magic
);
return
context
;
}
/* get the mime type */
mime_type
=
magic_file
(
magic
,
path
);
if
(
mime_type
==
NULL
)
{
girara_debug
(
"failed guessing filetype: %s"
,
magic_error
(
magic
));
goto
cleanup
;
context
->
magic
=
magic
;
#endif
return
context
;
}
void
zathura_content_type_free
(
zathura_content_type_context_t
*
context
)
{
if
(
context
==
NULL
)
{
return
;
}
/* dup so we own the memory */
mime_type
=
g_strdup
(
mime_type
);
girara_debug
(
"magic detected filetype: %s"
,
mime_type
);
#ifdef WITH_MAGIC
if
(
context
->
magic
!=
NULL
)
{
magic_close
(
context
->
magic
);
}
#endif
cleanup:
if
(
magic
!=
NULL
)
{
magic_close
(
magic
);
g_free
(
context
);
}
/** Read a most GT_MAX_READ bytes before falling back to file. */
static
const
size_t
GT_MAX_READ
=
1
<<
16
;
#ifdef WITH_MAGIC
static
char
*
guess_type_magic
(
zathura_content_type_context_t
*
context
,
const
char
*
path
)
{
if
(
context
==
NULL
||
context
->
magic
==
NULL
)
{
return
NULL
;
}
const
char
*
mime_type
=
NULL
;
/* get the mime type */
mime_type
=
magic_file
(
context
->
magic
,
path
);
if
(
mime_type
==
NULL
)
{
girara_debug
(
"failed guessing filetype: %s"
,
magic_error
(
context
->
magic
));
return
NULL
;
}
girara_debug
(
"magic detected filetype: %s"
,
mime_type
);
return
mime_type
;
/* dup so we own the memory */
return
g_strdup
(
mime_type
);;
}
static
c
onst
c
har
*
static
char
*
guess_type_file
(
const
char
*
UNUSED
(
path
))
{
return
NULL
;
}
#else
static
const
char
*
guess_type_magic
(
const
char
*
UNUSED
(
path
))
{
guess_type_magic
(
zathura_content_type_context_t
*
UNUSED
(
context
),
const
char
*
UNUSED
(
path
))
{
return
NULL
;
}
static
c
onst
c
har
*
static
char
*
guess_type_file
(
const
char
*
path
)
{
GString
*
command
=
g_string_new
(
"file -b --mime-type "
);
...
...
@@ -106,11 +147,11 @@ guess_type_file(const char* path)
}
#endif
static
c
onst
c
har
*
static
char
*
guess_type_glib
(
const
char
*
path
)
{
gboolean
uncertain
=
FALSE
;
c
onst
c
har
*
content_type
=
g_content_type_guess
(
path
,
NULL
,
0
,
&
uncertain
);
char
*
content_type
=
g_content_type_guess
(
path
,
NULL
,
0
,
&
uncertain
);
if
(
content_type
==
NULL
)
{
girara_debug
(
"g_content_type failed
\n
"
);
}
else
{
...
...
@@ -160,11 +201,12 @@ guess_type_glib(const char* path)
return
NULL
;
}
const
char
*
guess_content_type
(
const
char
*
path
)
char
*
zathura_content_type_guess
(
zathura_content_type_context_t
*
context
,
const
char
*
path
)
{
/* try libmagic first */
c
onst
char
*
content_type
=
guess_type_magic
(
path
);
c
har
*
content_type
=
guess_type_magic
(
context
,
path
);
if
(
content_type
!=
NULL
)
{
return
content_type
;
}
...
...
zathura/content-type.h
View file @
c124b180
...
...
@@ -3,13 +3,30 @@
#ifndef ZATHURA_CONTENT_TYPE_H
#define ZATHURA_CONTENT_TYPE_H
#include "types.h"
/**
* Create new context for MIME type detection.
*
* @return new context
*/
zathura_content_type_context_t
*
zathura_content_type_new
(
void
);
/**
* Free MIME type detection context.
*
* @param context The context.
*/
void
zathura_content_type_free
(
zathura_content_type_context_t
*
context
);
/**
* "Guess" the content type of a file. Various methods are tried depending on
* the available libraries.
*
* @param path file name
* @return content type of path
* @return content type of path
, needs to freeed with g_free.
*/
const
char
*
guess_content_type
(
const
char
*
path
);
char
*
zathura_content_type_guess
(
zathura_content_type_context_t
*
context
,
const
char
*
path
);
#endif
zathura/dbus-interface.c
View file @
c124b180
...
...
@@ -469,7 +469,7 @@ iterate_instances_call_synctex_view(const char* filename,
const
bool
ret
=
call_synctex_view
(
connection
,
filename
,
well_known_name
,
input_file
,
line
,
column
);
g_free
(
well_known_name
);
return
ret
?
1
:
0
;
return
ret
?
1
:
-
1
;
}
GVariant
*
vnames
=
g_dbus_connection_call_sync
(
...
...
zathura/document.c
View file @
c124b180
...
...
@@ -61,16 +61,16 @@ check_set_error(zathura_error_t* error, zathura_error_t code) {
}
zathura_document_t
*
zathura_document_open
(
zathura_
plugin_manager_t
*
plugin_manager
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
zathura_error_t
*
error
)
zathura_document_open
(
zathura_
t
*
zathura
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
zathura_error_t
*
error
)
{
if
(
path
==
NULL
)
{
if
(
zathura
==
NULL
||
path
==
NULL
)
{
return
NULL
;
}
GFile
*
file
=
g_file_new_for_path
(
path
);
char
*
real_path
=
NULL
;
c
onst
c
har
*
content_type
=
NULL
;
char
*
content_type
=
NULL
;
zathura_plugin_t
*
plugin
=
NULL
;
zathura_document_t
*
document
=
NULL
;
...
...
@@ -87,14 +87,14 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
goto
error_free
;
}
content_type
=
guess_content_type
(
real_path
);
content_type
=
zathura_content_type_guess
(
zathura
->
content_type_context
,
real_path
);
if
(
content_type
==
NULL
)
{
girara_error
(
"Could not determine file type."
);
check_set_error
(
error
,
ZATHURA_ERROR_UNKNOWN
);
goto
error_free
;
}
plugin
=
zathura_plugin_manager_get_plugin
(
plugin_
manager
,
content_type
);
plugin
=
zathura_plugin_manager_get_plugin
(
zathura
->
plugins
.
manager
,
content_type
);
if
(
plugin
==
NULL
)
{
girara_error
(
"Unknown file type: '%s'"
,
content_type
);
...
...
@@ -106,7 +106,7 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
goto
error_free
;
}
g_free
(
(
void
*
)
content_type
);
g_free
(
content_type
);
content_type
=
NULL
;
document
=
g_try_malloc0
(
sizeof
(
zathura_document_t
));
...
...
zathura/document.h
View file @
c124b180
...
...
@@ -11,21 +11,21 @@
/**
* Open the document
*
* @param plugin_manager The
plugin manager
* @param plugin_manager The
zathura instance
* @param path Path to the document
* @param password Password of the document or NULL
* @param error Optional error parameter
* @return The document object and NULL if an error occurs
*/
zathura_document_t
*
zathura_document_open
(
zathura_
plugin_manager_t
*
plugin_manager
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
zathura_error_t
*
zathura_document_t
*
zathura_document_open
(
zathura_
t
*
zathura
,
const
char
*
path
,
const
char
*
uri
,
const
char
*
password
,
zathura_error_t
*
error
);
/**
* Free the document
*
* @param document
* @return ZATHURA_ERROR_OK when no error occured, otherwise see
* @return ZATHURA_ERROR_OK when no error occur
r
ed, otherwise see
* zathura_error_t
*/
zathura_error_t
zathura_document_free
(
zathura_document_t
*
document
);
...
...
@@ -67,7 +67,7 @@ const char* zathura_document_get_password(zathura_document_t* document);
*
* @param document The document
* @param index The index of the page
* @return The page or NULL if an error occured
* @return The page or NULL if an error occur
r
ed
*/
zathura_page_t
*
zathura_document_get_page
(
zathura_document_t
*
document
,
unsigned
int
index
);
...
...
@@ -283,7 +283,7 @@ void zathura_document_set_page_layout(zathura_document_t* document, unsigned int
unsigned
int
pages_per_row
,
unsigned
int
first_page_column
);
/**
* Returns the padding in pixels betwen pages
* Returns the padding in pixels betwe
e
n pages
*
* @param document The document
* @return The padding in pixels between pages
...
...
@@ -311,7 +311,7 @@ unsigned int zathura_document_get_first_page_column(zathura_document_t* document
*
* @param document The document object
* @param path Path for the saved file
* @return ZATHURA_ERROR_OK when no error occured, otherwise see
* @return ZATHURA_ERROR_OK when no error occur
r
ed, otherwise see
* zathura_error_t
*/
zathura_error_t
zathura_document_save_as
(
zathura_document_t
*
document
,
const
char
*
path
);
...
...
@@ -321,7 +321,7 @@ zathura_error_t zathura_document_save_as(zathura_document_t* document, const cha
*
* @param document The document object
* @param error Set to an error value (see \ref zathura_error_t) if an
* error occured
* error occur
r
ed
* @return Generated index
*/
...
...
@@ -332,7 +332,7 @@ girara_tree_node_t* zathura_document_index_generate(zathura_document_t* document
*
* @param document The document object
* @param error Set to an error value (see \ref zathura_error_t) if an
* error occured
* error occur
r
ed
* @return List of attachments
*/
girara_list_t
*
zathura_document_attachments_get
(
zathura_document_t
*
document
,
zathura_error_t
*
error
);
...
...
@@ -343,7 +343,7 @@ girara_list_t* zathura_document_attachments_get(zathura_document_t* document, za
* @param document The document objects
* @param attachment name of the attachment
* @param file the target filename
* @return ZATHURA_ERROR_OK when no error occured, otherwise see
* @return ZATHURA_ERROR_OK when no error occur
r
ed, otherwise see
* zathura_error_t
*/
zathura_error_t
zathura_document_attachment_save
(
zathura_document_t
*
document
,
const
char
*
attachment
,
const
char
*
file
);
...
...
@@ -353,8 +353,8 @@ zathura_error_t zathura_document_attachment_save(zathura_document_t* document, c
*
* @param document The zathura document
* @param error Set to an error value (see \ref zathura_error_t) if an
* error occured
* @return List of document information entries or NULL if information could not be retr
ei
ved
* error occur
r
ed
* @return List of document information entries or NULL if information could not be retr
ie
ved
*/
girara_list_t
*
zathura_document_get_information
(
zathura_document_t
*
document
,
zathura_error_t
*
error
);
...
...
zathura/main.c
View file @
c124b180
...
...
@@ -18,6 +18,10 @@
#include "synctex.h"
#endif
#ifndef GDK_WINDOWING_X11
typedef
int
Window
;
#endif
/* Init locale */
static
void
init_locale
(
void
)
...
...
@@ -45,7 +49,7 @@ set_log_level(const char* loglevel)
#ifdef WITH_SYNCTEX
static
int
run_synctex_forward
(
const
char
*
synctex_fwd
,
const
char
*
filename
,
int
synctex_pid
)
int
synctex_pid
)
{
GFile
*
file
=
g_file_new_for_commandline_arg
(
filename
);
if
(
file
==
NULL
)
{
...
...
@@ -60,8 +64,8 @@ run_synctex_forward(const char* synctex_fwd, const char* filename,
return
-
1
;
}
int
line
=
0
;
int
column
=
0
;
int
line
=
0
;
int
column
=
0
;
char
*
input_file
=
NULL
;
if
(
synctex_parse_input
(
synctex_fwd
,
&
input_file
,
&
line
,
&
column
)
==
false
)
{
girara_error
(
"Failed to parse argument to --synctex-forward."
);
...
...
@@ -69,13 +73,15 @@ run_synctex_forward(const char* synctex_fwd, const char* filename,
return
-
1
;
}
const
int
ret
=
zathura_dbus_synctex_position
(
real_path
,
input_file
,
line
,
column
,
synctex_pid
);
const
int
ret
=
zathura_dbus_synctex_position
(
real_path
,
input_file
,
line
,
column
,
synctex_pid
);
g_free
(
input_file
);
g_free
(
real_path
);