Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
pwmt
zathura
Commits
3d027dd7
Commit
3d027dd7
authored
Dec 12, 2010
by
Moritz Lipp
Browse files
Set page
parent
2cfe3f86
Changes
3
Hide whitespace changes
Inline
Side-by-side
shortcuts.c
View file @
3d027dd7
...
@@ -72,6 +72,22 @@ sc_goto(girara_session_t* session, girara_argument_t* argument)
...
@@ -72,6 +72,22 @@ sc_goto(girara_session_t* session, girara_argument_t* argument)
bool
bool
sc_navigate
(
girara_session_t
*
session
,
girara_argument_t
*
argument
)
sc_navigate
(
girara_session_t
*
session
,
girara_argument_t
*
argument
)
{
{
if
(
!
session
||
!
argument
||
!
Zathura
.
document
)
{
return
false
;
}
unsigned
int
number_of_pages
=
Zathura
.
document
->
number_of_pages
;
unsigned
int
new_page
=
Zathura
.
document
->
current_page_number
;
if
(
argument
->
n
==
NEXT
)
{
new_page
=
(
new_page
+
1
)
%
number_of_pages
;
}
else
if
(
argument
->
n
==
PREVIOUS
)
{
new_page
=
(
new_page
+
number_of_pages
-
1
)
%
number_of_pages
;
}
page_set
(
new_page
);
return
false
;
return
false
;
}
}
...
...
zathura.c
View file @
3d027dd7
...
@@ -51,6 +51,60 @@ init_zathura()
...
@@ -51,6 +51,60 @@ init_zathura()
return
true
;
return
true
;
}
}
bool
document_open
(
const
char
*
path
,
const
char
*
password
)
{
if
(
!
path
)
{
return
false
;
}
zathura_document_t
*
document
=
zathura_document_open
(
path
,
password
);
if
(
!
document
)
{
return
false
;
}
Zathura
.
document
=
document
;
if
(
!
page_set
(
0
))
{
return
false
;
}
return
true
;
}
bool
document_close
()
{
if
(
!
Zathura
.
document
)
{
return
false
;
}
zathura_document_free
(
Zathura
.
document
);
return
true
;
}
bool
page_set
(
unsigned
int
page_id
)
{
if
(
!
Zathura
.
document
)
{
return
false
;
}
if
(
page_id
>=
Zathura
.
document
->
number_of_pages
)
{
return
false
;
}
Zathura
.
document
->
current_page_number
=
page_id
;
char
*
page_number
=
g_strdup_printf
(
"[%d/%d]"
,
page_id
+
1
,
Zathura
.
document
->
number_of_pages
);
girara_statusbar_item_set_text
(
Zathura
.
UI
.
session
,
Zathura
.
UI
.
statusbar
.
page_number
,
page_number
);
g_free
(
page_number
);
return
true
;
}
/* main function */
/* main function */
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
...
@@ -64,21 +118,10 @@ int main(int argc, char* argv[])
...
@@ -64,21 +118,10 @@ int main(int argc, char* argv[])
}
}
if
(
argc
>
1
)
{
if
(
argc
>
1
)
{
zathura_document_t
*
document
=
zathura_document_open
(
argv
[
1
],
NULL
);
if
(
!
document_open
(
argv
[
1
],
NULL
))
{
printf
(
"error: could not open document
\n
"
);
if
(
!
document
)
{
return
-
1
;
return
-
1
;
}
}
zathura_page_t
*
page
=
zathura_page_get
(
document
,
0
);
if
(
!
page
)
{
zathura_document_free
(
document
);
return
-
2
;
}
zathura_page_free
(
page
);
zathura_document_free
(
document
);
}
}
gdk_threads_enter
();
gdk_threads_enter
();
...
...
zathura.h
View file @
3d027dd7
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
#include <stdbool.h>
#include <stdbool.h>
#include <girara.h>
#include <girara.h>
#include "ft/document.h"
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
,
...
@@ -23,7 +25,7 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
...
@@ -23,7 +25,7 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
struct
struct
{
{
struct
struct
{
{
girara_session_t
*
session
;
/**> girara interface session */
girara_session_t
*
session
;
/**> girara interface session */
...
@@ -34,6 +36,8 @@ struct
...
@@ -34,6 +36,8 @@ struct
girara_statusbar_item_t
*
page_number
;
/**> page number statusbar entry */
girara_statusbar_item_t
*
page_number
;
/**> page number statusbar entry */
}
statusbar
;
}
statusbar
;
}
UI
;
}
UI
;
zathura_document_t
*
document
;
/**> The current document */
}
Zathura
;
}
Zathura
;
/**
/**
...
@@ -44,4 +48,28 @@ struct
...
@@ -44,4 +48,28 @@ struct
bool
init_zathura
();
bool
init_zathura
();
/**
* Opens a file
*
* @param path The path to the file
* @param password The password of the file
*
* @return If no error occured true, otherwise false, is returned.
*/
bool
document_open
(
const
char
*
path
,
const
char
*
password
);
/**
* Closes the current opened document
*
* @return If no error occured true, otherwise false, is returned.
*/
bool
document_close
();
/**
* Opens the page with the given number
*
* @return If no error occured true, otherwise false, is returned.
*/
bool
page_set
(
unsigned
int
page_id
);
#endif // ZATHURA_H
#endif // ZATHURA_H
Write
Preview
Supports
Markdown
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