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
fda64207
Commit
fda64207
authored
Apr 21, 2012
by
Sebastian Ramacher
Browse files
Merge branch 'develop' of pwmt.org:zathura into develop
parents
946faf59
488ab101
Changes
8
Hide whitespace changes
Inline
Side-by-side
config.c
View file @
fda64207
...
...
@@ -116,7 +116,7 @@ config_load_default(zathura_t* zathura)
girara_setting_add
(
gsession
,
"highlight-transparency"
,
&
float_value
,
FLOAT
,
false
,
_
(
"Transparency for highlighting"
),
NULL
,
NULL
);
bool_value
=
true
;
girara_setting_add
(
gsession
,
"render-loading"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Render 'Loading ...'"
),
NULL
,
NULL
);
girara_setting_add
(
gsession
,
"adjust-open"
,
"
best-fit"
,
STRING
,
false
,
_
(
"Adjust to when opening file"
),
NULL
,
NULL
);
girara_setting_add
(
gsession
,
"adjust-open"
,
"
none"
,
STRING
,
false
,
_
(
"Adjust to when opening file"
),
NULL
,
NULL
);
bool_value
=
false
;
girara_setting_add
(
gsession
,
"show-hidden"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Show hidden files and directories"
),
NULL
,
NULL
);
bool_value
=
true
;
...
...
database-plain.c
View file @
fda64207
...
...
@@ -20,6 +20,9 @@
#define KEY_OFFSET "offset"
#define KEY_SCALE "scale"
#define KEY_ROTATE "rotate"
#define KEY_PAGES_PER_ROW "pages-per-row"
#define KEY_POSITION_X "position-x"
#define KEY_POSITION_Y "position-y"
#ifdef __GNU__
#include <sys/file.h>
...
...
@@ -45,9 +48,9 @@ static bool plain_remove_bookmark(zathura_database_t* db, const char* file,
static
girara_list_t
*
plain_load_bookmarks
(
zathura_database_t
*
db
,
const
char
*
file
);
static
bool
plain_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
page
,
unsigned
int
offset
,
double
scale
,
unsigned
int
rotation
);
zathura_fileinfo_t
*
file_info
);
static
bool
plain_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
*
page
,
unsigned
int
*
offset
,
double
*
scale
,
unsigned
int
*
rotation
);
zathura_fileinfo_t
*
file_info
);
static
void
plain_set_property
(
GObject
*
object
,
guint
prop_id
,
const
GValue
*
value
,
GParamSpec
*
pspec
);
...
...
@@ -367,34 +370,49 @@ plain_load_bookmarks(zathura_database_t* db, const char* file)
}
static
bool
plain_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
page
,
unsigned
int
offset
,
double
scale
,
unsigned
int
rotation
)
plain_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
)
{
zathura_plaindatabase_private_t
*
priv
=
ZATHURA_PLAINDATABASE_GET_PRIVATE
(
db
);
if
(
priv
->
history
==
NULL
)
{
if
(
priv
->
history
==
NULL
||
file_info
==
NULL
||
file
==
NULL
)
{
return
false
;
}
char
*
tmp
=
g_strdup_printf
(
"%f"
,
scale
);
char
*
name
=
prepare_filename
(
file
);
g_key_file_set_integer
(
priv
->
history
,
name
,
KEY_PAGE
,
page
);
g_key_file_set_integer
(
priv
->
history
,
name
,
KEY_OFFSET
,
offset
);
g_key_file_set_string
(
priv
->
history
,
name
,
KEY_SCALE
,
tmp
);
g_key_file_set_integer
(
priv
->
history
,
name
,
KEY_ROTATE
,
rotation
);
g_key_file_set_integer
(
priv
->
history
,
name
,
KEY_PAGE
,
file_info
->
current_page
);
g_key_file_set_integer
(
priv
->
history
,
name
,
KEY_OFFSET
,
file_info
->
page_offset
);
g_free
(
name
);
char
*
tmp
=
g_strdup_printf
(
"%f"
,
file_info
->
scale
);
g_key_file_set_string
(
priv
->
history
,
name
,
KEY_SCALE
,
tmp
);
g_free
(
tmp
);
g_key_file_set_integer
(
priv
->
history
,
name
,
KEY_ROTATE
,
file_info
->
rotation
);
g_key_file_set_integer
(
priv
->
history
,
name
,
KEY_PAGES_PER_ROW
,
file_info
->
pages_per_row
);
tmp
=
g_strdup_printf
(
"%f"
,
file_info
->
position_x
);
g_key_file_set_string
(
priv
->
history
,
name
,
KEY_POSITION_X
,
tmp
);
g_free
(
tmp
);
tmp
=
g_strdup_printf
(
"%f"
,
file_info
->
position_y
);
g_key_file_set_string
(
priv
->
history
,
name
,
KEY_POSITION_Y
,
tmp
);
g_free
(
tmp
);
g_free
(
name
);
zathura_db_write_key_file_to_file
(
priv
->
history_path
,
priv
->
history
);
return
true
;
}
static
bool
plain_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
in
t
*
page
,
unsigned
int
*
offset
,
double
*
scale
,
unsigned
int
*
rotation
)
plain_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
zathura_fileinfo_
t
*
file_info
)
{
if
(
db
==
NULL
||
file
==
NULL
||
file_info
==
NULL
)
{
return
false
;
}
zathura_plaindatabase_private_t
*
priv
=
ZATHURA_PLAINDATABASE_GET_PRIVATE
(
db
);
if
(
priv
->
history
==
NULL
)
{
return
false
;
...
...
@@ -405,13 +423,23 @@ plain_get_fileinfo(zathura_database_t* db, const char* file, unsigned int*
return
false
;
}
*
page
=
g_key_file_get_integer
(
priv
->
history
,
name
,
KEY_PAGE
,
NULL
);
*
offset
=
g_key_file_get_integer
(
priv
->
history
,
name
,
KEY_OFFSET
,
NULL
);
*
rotation
=
g_key_file_get_integer
(
priv
->
history
,
name
,
KEY_ROTATE
,
NULL
);
file_info
->
current_page
=
g_key_file_get_integer
(
priv
->
history
,
name
,
KEY_PAGE
,
NULL
);
file_info
->
page_offset
=
g_key_file_get_integer
(
priv
->
history
,
name
,
KEY_OFFSET
,
NULL
);
file_info
->
rotation
=
g_key_file_get_integer
(
priv
->
history
,
name
,
KEY_ROTATE
,
NULL
);
file_info
->
pages_per_row
=
g_key_file_get_integer
(
priv
->
history
,
name
,
KEY_PAGES_PER_ROW
,
NULL
);
char
*
scale_string
=
g_key_file_get_string
(
priv
->
history
,
name
,
KEY_SCALE
,
NULL
);
*
scale
=
strtod
(
scale_string
,
NULL
);
file_info
->
scale
=
strtod
(
scale_string
,
NULL
);
g_free
(
scale_string
);
char
*
position_x_string
=
g_key_file_get_string
(
priv
->
history
,
name
,
KEY_POSITION_X
,
NULL
);
file_info
->
position_x
=
strtod
(
position_x_string
,
NULL
);
g_free
(
position_x_string
);
char
*
position_y_string
=
g_key_file_get_string
(
priv
->
history
,
name
,
KEY_POSITION_Y
,
NULL
);
file_info
->
position_y
=
strtod
(
position_y_string
,
NULL
);
g_free
(
position_y_string
);
g_free
(
name
);
return
true
;
...
...
database-sqlite.c
View file @
fda64207
...
...
@@ -20,9 +20,9 @@ static bool sqlite_remove_bookmark(zathura_database_t* db, const char* file,
static
girara_list_t
*
sqlite_load_bookmarks
(
zathura_database_t
*
db
,
const
char
*
file
);
static
bool
sqlite_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
page
,
unsigned
int
offset
,
double
scale
,
unsigned
int
rotation
);
zathura_fileinfo_t
*
file_info
);
static
bool
sqlite_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
*
page
,
unsigned
int
*
offset
,
double
*
scale
,
unsigned
int
*
rotation
);
zathura_fileinfo_t
*
file_info
);
static
void
sqlite_set_property
(
GObject
*
object
,
guint
prop_id
,
const
GValue
*
value
,
GParamSpec
*
pspec
);
...
...
@@ -118,7 +118,11 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
"page INTEGER,"
"offset INTEGER,"
"scale FLOAT,"
"rotation INTEGER);"
;
"rotation INTEGER,"
"pages_per_row INTEGER,"
"position_x FLOAT,"
"position_y FLOAT"
");"
;
sqlite3
*
session
=
NULL
;
if
(
sqlite3_open
(
path
,
&
session
)
!=
SQLITE_OK
)
{
...
...
@@ -272,9 +276,13 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
}
static
bool
sqlite_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
page
,
unsigned
int
offset
,
double
scale
,
unsigned
int
rotation
)
sqlite_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
)
{
if
(
db
==
NULL
||
file
==
NULL
||
file_info
==
NULL
)
{
return
false
;
}
zathura_sqldatabase_private_t
*
priv
=
ZATHURA_SQLDATABASE_GET_PRIVATE
(
db
);
static
const
char
SQL_FILEINFO_SET
[]
=
...
...
@@ -285,11 +293,14 @@ sqlite_set_fileinfo(zathura_database_t* db, const char* file, unsigned int
return
false
;
}
if
(
sqlite3_bind_text
(
stmt
,
1
,
file
,
-
1
,
NULL
)
!=
SQLITE_OK
||
sqlite3_bind_int
(
stmt
,
2
,
page
)
!=
SQLITE_OK
||
sqlite3_bind_int
(
stmt
,
3
,
offset
)
!=
SQLITE_OK
||
sqlite3_bind_double
(
stmt
,
4
,
scale
)
!=
SQLITE_OK
||
sqlite3_bind_int
(
stmt
,
5
,
rotation
)
!=
SQLITE_OK
)
{
if
(
sqlite3_bind_text
(
stmt
,
1
,
file
,
-
1
,
NULL
)
!=
SQLITE_OK
||
sqlite3_bind_int
(
stmt
,
2
,
file_info
->
current_page
)
!=
SQLITE_OK
||
sqlite3_bind_int
(
stmt
,
3
,
file_info
->
page_offset
)
!=
SQLITE_OK
||
sqlite3_bind_double
(
stmt
,
4
,
file_info
->
scale
)
!=
SQLITE_OK
||
sqlite3_bind_int
(
stmt
,
5
,
file_info
->
rotation
)
!=
SQLITE_OK
||
sqlite3_bind_int
(
stmt
,
6
,
file_info
->
pages_per_row
)
!=
SQLITE_OK
||
sqlite3_bind_double
(
stmt
,
7
,
file_info
->
position_x
)
!=
SQLITE_OK
||
sqlite3_bind_double
(
stmt
,
8
,
file_info
->
position_y
)
!=
SQLITE_OK
)
{
sqlite3_finalize
(
stmt
);
girara_error
(
"Failed to bind arguments."
);
return
false
;
...
...
@@ -302,9 +313,13 @@ sqlite_set_fileinfo(zathura_database_t* db, const char* file, unsigned int
}
static
bool
sqlite_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
*
page
,
unsigned
int
*
offset
,
double
*
scale
,
unsigned
int
*
rotation
)
sqlite_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
)
{
if
(
db
==
NULL
||
file
==
NULL
||
file_info
==
NULL
)
{
return
false
;
}
zathura_sqldatabase_private_t
*
priv
=
ZATHURA_SQLDATABASE_GET_PRIVATE
(
db
);
static
const
char
SQL_FILEINFO_GET
[]
=
...
...
@@ -312,7 +327,7 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file, unsigned int*
sqlite3_stmt
*
stmt
=
prepare_statement
(
priv
->
session
,
SQL_FILEINFO_GET
);
if
(
stmt
==
NULL
)
{
return
false
;
return
false
;
}
if
(
sqlite3_bind_text
(
stmt
,
1
,
file
,
-
1
,
NULL
)
!=
SQLITE_OK
)
{
...
...
@@ -327,10 +342,14 @@ sqlite_get_fileinfo(zathura_database_t* db, const char* file, unsigned int*
return
false
;
}
*
page
=
sqlite3_column_int
(
stmt
,
0
);
*
offset
=
sqlite3_column_int
(
stmt
,
1
);
*
scale
=
sqlite3_column_double
(
stmt
,
2
);
*
rotation
=
sqlite3_column_int
(
stmt
,
3
);
file_info
->
current_page
=
sqlite3_column_int
(
stmt
,
0
);
file_info
->
page_offset
=
sqlite3_column_int
(
stmt
,
1
);
file_info
->
scale
=
sqlite3_column_double
(
stmt
,
2
);
file_info
->
rotation
=
sqlite3_column_int
(
stmt
,
3
);
file_info
->
pages_per_row
=
sqlite3_column_int
(
stmt
,
4
);
file_info
->
position_x
=
sqlite3_column_double
(
stmt
,
5
);
file_info
->
position_y
=
sqlite3_column_double
(
stmt
,
6
);
sqlite3_finalize
(
stmt
);
return
true
;
...
...
database.c
View file @
fda64207
...
...
@@ -46,22 +46,19 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
}
bool
zathura_db_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
page
,
unsigned
int
offset
,
double
scale
,
unsigned
int
rotation
)
zathura_db_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
)
{
g_return_val_if_fail
(
ZATHURA_IS_DATABASE
(
db
)
&&
file
!=
NULL
,
false
);
g_return_val_if_fail
(
ZATHURA_IS_DATABASE
(
db
)
&&
file
!=
NULL
&&
file_info
!=
NULL
,
false
);
return
ZATHURA_DATABASE_GET_INTERFACE
(
db
)
->
set_fileinfo
(
db
,
file
,
page
,
offset
,
scale
,
rotation
);
return
ZATHURA_DATABASE_GET_INTERFACE
(
db
)
->
set_fileinfo
(
db
,
file
,
file_info
);
}
bool
zathura_db_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
*
page
,
unsigned
int
*
offset
,
double
*
scale
,
unsigned
int
*
rotation
)
zathura_db_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
)
{
g_return_val_if_fail
(
ZATHURA_IS_DATABASE
(
db
)
&&
file
!=
NULL
&&
page
!=
NULL
&&
offset
!=
NULL
&&
scale
!=
NULL
&&
rotation
!=
NULL
,
false
);
g_return_val_if_fail
(
ZATHURA_IS_DATABASE
(
db
)
&&
file
!=
NULL
&&
file_info
!=
NULL
,
false
);
return
ZATHURA_DATABASE_GET_INTERFACE
(
db
)
->
get_fileinfo
(
db
,
file
,
page
,
offset
,
scale
,
rotation
);
return
ZATHURA_DATABASE_GET_INTERFACE
(
db
)
->
get_fileinfo
(
db
,
file
,
file_info
);
}
database.h
View file @
fda64207
...
...
@@ -9,6 +9,16 @@
#include "bookmarks.h"
typedef
struct
zathura_fileinfo_s
{
unsigned
int
current_page
;
unsigned
int
page_offset
;
double
scale
;
unsigned
int
rotation
;
unsigned
int
pages_per_row
;
double
position_x
;
double
position_y
;
}
zathura_fileinfo_t
;
#define ZATHURA_TYPE_DATABASE \
(zathura_database_get_type ())
#define ZATHURA_DATABASE(obj) \
...
...
@@ -29,13 +39,12 @@ struct _ZathuraDatabaseInterface
bool
(
*
add_bookmark
)(
ZathuraDatabase
*
db
,
const
char
*
file
,
zathura_bookmark_t
*
bookmark
);
bool
(
*
remove_bookmark
)(
ZathuraDatabase
*
db
,
const
char
*
file
,
const
char
*
id
);
girara_list_t
*
(
*
load_bookmarks
)(
ZathuraDatabase
*
db
,
const
char
*
file
);
bool
(
*
set_fileinfo
)(
ZathuraDatabase
*
db
,
const
char
*
file
,
unsigned
int
page
,
unsigned
int
offset
,
double
scale
,
unsigned
int
rotation
);
bool
(
*
set_fileinfo
)(
ZathuraDatabase
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
);
bool
(
*
get_fileinfo
)(
ZathuraDatabase
*
db
,
const
char
*
file
,
unsigned
int
*
page
,
unsigned
int
*
offset
,
double
*
scale
,
unsigned
int
*
rotation
);
bool
(
*
get_fileinfo
)(
ZathuraDatabase
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
);
};
GType
zathura_database_get_type
(
void
);
...
...
@@ -84,26 +93,20 @@ girara_list_t* zathura_db_load_bookmarks(zathura_database_t* db, const char*
*
* @param db The database instance
* @param file The file to which the file info belongs to.
* @param page The last page.
* @param offset The last offset.
* @param scale The last scale.
* @param rotation The last rotation.
* @param file_info The file info
* @return true on success, false otherwise.
*/
bool
zathura_db_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
page
,
unsigned
int
offset
,
double
scale
,
unsigned
int
rotation
);
bool
zathura_db_set_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
);
/* Get file info (last site, ...) from the database.
*
* @param db The database instance
* @param file The file to which the file info belongs to.
* @param page The last page.
* @param offset The last offset.
* @param scale The last scale.
* @param rotation The rotation.
* @param file_info The file info
* @return true on success, false otherwise.
*/
bool
zathura_db_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
unsigned
int
*
page
,
unsigned
int
*
offset
,
double
*
scale
,
unsigned
int
*
rotation
);
bool
zathura_db_get_fileinfo
(
zathura_database_t
*
db
,
const
char
*
file
,
zathura_fileinfo_t
*
file_info
);
#endif // DATABASE_H
document.c
View file @
fda64207
...
...
@@ -114,10 +114,11 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
document
=
g_malloc0
(
sizeof
(
zathura_document_t
));
document
->
file_path
=
real_path
;
document
->
password
=
password
;
document
->
scale
=
1
.
0
;
document
->
plugin
=
plugin
;
document
->
file_path
=
real_path
;
document
->
password
=
password
;
document
->
scale
=
1
.
0
;
document
->
plugin
=
plugin
;
document
->
adjust_mode
=
ZATHURA_ADJUST_NONE
;
/* open document */
if
(
plugin
->
functions
.
document_open
==
NULL
)
{
...
...
shortcuts.c
View file @
fda64207
...
...
@@ -949,7 +949,8 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
int
value
=
1
;
girara_setting_get
(
zathura
->
ui
.
session
,
"zoom-step"
,
&
value
);
float
zoom_step
=
value
/
100
.
0
f
;
t
=
(
t
==
0
)
?
1
:
t
;
float
zoom_step
=
value
/
100
.
0
f
*
t
;
float
old_zoom
=
zathura_document_get_scale
(
zathura
->
document
);
/* specify new zoom value */
...
...
zathura.c
View file @
fda64207
...
...
@@ -38,8 +38,21 @@ typedef struct zathura_document_info_s
const
char
*
password
;
}
zathura_document_info_t
;
typedef
struct
page_set_delayed_s
{
zathura_t
*
zathura
;
unsigned
int
page
;
}
page_set_delayed_t
;
typedef
struct
position_set_delayed_s
{
zathura_t
*
zathura
;
zathura_fileinfo_t
file_info
;
}
position_set_delayed_t
;
static
gboolean
document_info_open
(
gpointer
data
);
static
gboolean
purge_pages
(
gpointer
data
);
static
gboolean
position_set_delayed
(
gpointer
data
);
/* function implementation */
zathura_t
*
...
...
@@ -462,41 +475,38 @@ document_open(zathura_t* zathura, const char* path, const char* password)
goto
error_out
;
}
const
char
*
file_path
=
zathura_document_get_path
(
document
);
unsigned
int
number_of_pages
=
zathura_document_get_number_of_pages
(
document
);
unsigned
int
current_page_number
=
0
;
double
scale
=
1
;
unsigned
int
page_offset
=
0
;
unsigned
int
rotate
=
0
;
const
char
*
file_path
=
zathura_document_get_path
(
document
);
unsigned
int
number_of_pages
=
zathura_document_get_number_of_pages
(
document
);
/* read history file */
zathura_
db_get_
fileinfo
(
zathura
->
database
,
file_path
,
&
current_page_number
,
&
page_off
se
t
,
&
scale
,
&
rotate
);
zathura_fileinfo
_t
file_info
=
{
0
,
0
,
1
,
0
,
1
,
0
,
0
};
zathura_db_get_fileinfo
(
zathura
->
databa
se
,
file_path
,
&
file_info
);
zathura_document_set_page_offset
(
document
,
page_offset
);
/* set page offset */
zathura_document_set_page_offset
(
document
,
file_info
.
page_offset
);
/* check for valid scale value */
if
(
scale
<=
FLT_EPSILON
)
{
if
(
file_info
.
scale
<=
FLT_EPSILON
)
{
girara_warning
(
"document info: '%s' has non positive scale"
,
file_path
);
zathura_document_set_scale
(
document
,
1
);
}
else
{
zathura_document_set_scale
(
document
,
scale
);
zathura_document_set_scale
(
document
,
file_info
.
scale
);
}
/* check current page number */
if
(
current_page
_number
>
number_of_pages
)
{
if
(
file_info
.
current_page
>
number_of_pages
)
{
girara_warning
(
"document info: '%s' has an invalid page number"
,
file_path
);
zathura_document_set_current_page_number
(
document
,
0
);
}
else
{
zathura_document_set_current_page_number
(
document
,
current_page
_number
);
zathura_document_set_current_page_number
(
document
,
file_info
.
current_page
);
}
/* check for valid rotation */
if
(
rotat
e
%
90
!=
0
)
{
if
(
file_info
.
rotat
ion
%
90
!=
0
)
{
girara_warning
(
"document info: '%s' has an invalid rotation"
,
file_path
);
zathura_document_set_rotation
(
document
,
0
);
}
else
{
zathura_document_set_rotation
(
document
,
rotat
e
%
360
);
zathura_document_set_rotation
(
document
,
file_info
.
rotat
ion
%
360
);
}
/* jump to first page if setting enabled */
...
...
@@ -508,7 +518,7 @@ document_open(zathura_t* zathura, const char* path, const char* password)
/* apply open adjustment */
char
*
adjust_open
=
"best-fit"
;
zathura_document_set_adjust_mode
(
document
,
ZATHURA_ADJUST_
BESTFIT
);
zathura_document_set_adjust_mode
(
document
,
ZATHURA_ADJUST_
NONE
);
if
(
girara_setting_get
(
zathura
->
ui
.
session
,
"adjust-open"
,
&
(
adjust_open
))
==
true
)
{
if
(
g_strcmp0
(
adjust_open
,
"best-fit"
)
==
0
)
{
zathura_document_set_adjust_mode
(
document
,
ZATHURA_ADJUST_BESTFIT
);
...
...
@@ -590,7 +600,11 @@ 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
);
if
(
file_info
.
pages_per_row
>
0
)
{
pages_per_row
=
file_info
.
pages_per_row
;
}
else
{
girara_setting_get
(
zathura
->
ui
.
session
,
"pages-per-row"
,
&
pages_per_row
);
}
page_widget_set_mode
(
zathura
,
pages_per_row
);
girara_set_view
(
zathura
->
ui
.
session
,
zathura
->
ui
.
page_widget_alignment
);
...
...
@@ -609,9 +623,6 @@ document_open(zathura_t* zathura, const char* path, const char* password)
/* bookmarks */
zathura_bookmarks_load
(
zathura
,
file_path
);
page_set_delayed
(
zathura
,
zathura_document_get_current_page_number
(
document
));
cb_view_vadjustment_value_changed
(
NULL
,
zathura
);
/* update title */
girara_set_window_title
(
zathura
->
ui
.
session
,
file_path
);
...
...
@@ -621,6 +632,18 @@ document_open(zathura_t* zathura, const char* path, const char* password)
girara_argument_t
argument
=
{
zathura_document_get_adjust_mode
(
document
),
NULL
};
sc_adjust_window
(
zathura
->
ui
.
session
,
&
argument
,
NULL
,
0
);
/* set position */
if
(
file_info
.
position_x
!=
0
||
file_info
.
position_y
!=
0
)
{
position_set_delayed_t
*
p
=
g_malloc0
(
sizeof
(
position_set_delayed_t
));
p
->
zathura
=
zathura
;
p
->
file_info
=
file_info
;
gdk_threads_add_idle
(
position_set_delayed
,
p
);
}
else
{
page_set_delayed
(
zathura
,
zathura_document_get_current_page_number
(
document
));
cb_view_vadjustment_value_changed
(
NULL
,
zathura
);
}
return
true
;
error_free:
...
...
@@ -698,22 +721,34 @@ document_close(zathura_t* zathura, bool keep_monitor)
}
}
const
char
*
path
=
zathura_document_get_path
(
zathura
->
document
);
unsigned
int
current_page_number
=
zathura_document_get_current_page_number
(
zathura
->
document
);
unsigned
int
page_offset
=
zathura_document_get_page_offset
(
zathura
->
document
);
double
scale
=
zathura_document_get_scale
(
zathura
->
document
);
unsigned
int
rotation
=
zathura_document_get_rotation
(
zathura
->
document
);
/* store file information */
const
char
*
path
=
zathura_document_get_path
(
zathura
->
document
);
zathura_fileinfo_t
file_info
=
{
0
};
file_info
.
current_page
=
zathura_document_get_current_page_number
(
zathura
->
document
);
file_info
.
page_offset
=
zathura_document_get_page_offset
(
zathura
->
document
);
file_info
.
scale
=
zathura_document_get_scale
(
zathura
->
document
);
file_info
.
rotation
=
zathura_document_get_rotation
(
zathura
->
document
);
/* store last seen page */
zathura_db_set_fileinfo
(
zathura
->
database
,
path
,
current_page_number
,
page_offset
,
scale
,
rotation
);
girara_setting_get
(
zathura
->
ui
.
session
,
"pages-per-row"
,
&
(
file_info
.
pages_per_row
));
/* get position */
GtkScrolledWindow
*
window
=
GTK_SCROLLED_WINDOW
(
zathura
->
ui
.
session
->
gtk
.
view
);
GtkAdjustment
*
vadjustment
=
gtk_scrolled_window_get_vadjustment
(
window
);
GtkAdjustment
*
hadjustment
=
gtk_scrolled_window_get_hadjustment
(
window
);
file_info
.
position_x
=
gtk_adjustment_get_value
(
hadjustment
);
file_info
.
position_y
=
gtk_adjustment_get_value
(
vadjustment
);
/* save file info */
zathura_db_set_fileinfo
(
zathura
->
database
,
path
,
&
file_info
);
/* release render thread */
render_free
(
zathura
->
sync
.
render_thread
);
zathura
->
sync
.
render_thread
=
NULL
;
/* remove widgets */
gtk_container_foreach
(
GTK_CONTAINER
(
zathura
->
ui
.
page_widget
),
remove_page_from_table
,
(
gpointer
)
1
);
gtk_container_foreach
(
GTK_CONTAINER
(
zathura
->
ui
.
page_widget
),
remove_page_from_table
,
(
gpointer
)
1
);
free
(
zathura
->
pages
);
zathura
->
pages
=
NULL
;
...
...
@@ -741,12 +776,6 @@ document_close(zathura_t* zathura, bool keep_monitor)
return
true
;
}
typedef
struct
page_set_delayed_s
{
zathura_t
*
zathura
;
unsigned
int
page
;
}
page_set_delayed_t
;
static
gboolean
page_set_delayed_impl
(
gpointer
data
)
{
...
...
@@ -876,3 +905,18 @@ gboolean purge_pages(gpointer data)
}
return
TRUE
;
}
static
gboolean
position_set_delayed
(
gpointer
data
)
{
position_set_delayed_t
*
p
=
(
position_set_delayed_t
*
)
data
;
GtkScrolledWindow
*
window
=
GTK_SCROLLED_WINDOW
(
p
->
zathura
->
ui
.
session
->
gtk
.
view
);
GtkAdjustment
*
vadjustment
=
gtk_scrolled_window_get_vadjustment
(
window
);
GtkAdjustment
*
hadjustment
=
gtk_scrolled_window_get_hadjustment
(
window
);
gtk_adjustment_set_value
(
hadjustment
,
p
->
file_info
.
position_x
);
gtk_adjustment_set_value
(
vadjustment
,
p
->
file_info
.
position_y
);
return
FALSE
;
}
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