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
b17c05c9
Commit
b17c05c9
authored
May 12, 2013
by
Moritz Lipp
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop'
parents
ce6e7351
e0efd8ab
Changes
55
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
55 changed files
with
5579 additions
and
1619 deletions
+5579
-1619
AUTHORS
AUTHORS
+5
-1
LICENSE
LICENSE
+1
-1
Makefile
Makefile
+6
-0
README
README
+10
-4
adjustment.c
adjustment.c
+56
-0
adjustment.h
adjustment.h
+49
-0
callbacks.c
callbacks.c
+90
-3
callbacks.h
callbacks.h
+47
-0
commands.c
commands.c
+5
-5
config.c
config.c
+20
-5
config.mk
config.mk
+11
-2
database-plain.c
database-plain.c
+113
-9
database-sqlite.c
database-sqlite.c
+77
-3
database.c
database.c
+0
-10
database.h
database.h
+0
-7
document.c
document.c
+59
-19
document.h
document.h
+1
-1
glib-compat.h
glib-compat.h
+33
-0
links.c
links.c
+17
-7
main.c
main.c
+7
-1
marks.c
marks.c
+0
-2
page-widget.c
page-widget.c
+36
-41
page-widget.h
page-widget.h
+0
-8
po/ca.po
po/ca.po
+461
-0
po/cs.po
po/cs.po
+117
-97
po/de.po
po/de.po
+122
-101
po/el.po
po/el.po
+462
-0
po/eo.po
po/eo.po
+117
-97
po/es.po
po/es.po
+117
-97
po/es_CL.po
po/es_CL.po
+116
-97
po/et.po
po/et.po
+115
-95
po/fr.po
po/fr.po
+126
-99
po/he.po
po/he.po
+458
-0
po/hr.po
po/hr.po
+459
-0
po/id_ID.po
po/id_ID.po
+459
-0
po/it.po
po/it.po
+117
-97
po/pl.po
po/pl.po
+117
-97
po/pt_BR.po
po/pt_BR.po
+461
-0
po/ru.po
po/ru.po
+117
-97
po/ta_IN.po
po/ta_IN.po
+116
-96
po/tr.po
po/tr.po
+135
-115
po/uk_UA.po
po/uk_UA.po
+117
-97
render.c
render.c
+13
-12
shortcuts.c
shortcuts.c
+172
-26
shortcuts.h
shortcuts.h
+12
-1
tests/Makefile
tests/Makefile
+6
-0
tests/test_utils.c
tests/test_utils.c
+41
-0
types.h
types.h
+2
-1
utils.c
utils.c
+20
-80
utils.h
utils.h
+3
-18
zathura.1.rst
zathura.1.rst
+9
-0
zathura.c
zathura.c
+241
-51
zathura.desktop
zathura.desktop
+10
-5
zathura.h
zathura.h
+48
-2
zathurarc.5.rst
zathurarc.5.rst
+50
-12
No files found.
AUTHORS
View file @
b17c05c9
zathura is written by:
Moritz Lipp <mlq@pwmt.org>
Sebastian Ramacher <s
.ramacher@gmx
.at>
Sebastian Ramacher <s
ebastian+dev@ramacher
.at>
Other contributors are (in no particular order):
...
...
@@ -20,3 +20,7 @@ Roland Schatz <roland.schatz@students.jku.at>
Abdó Roig-Maranges <abdo.roig@gmail.com>
Benoît Knecht <benoit.knecht@gmail.com>
Rob Cornish <jrmcornish@gmail.com>
Marwan Tanager <marwan.tngr@gmail.com>
Diego Joss <djego.joss@gmail.com>
Ignas Anikevicius <anikevicius@gmail.com>
oblique
LICENSE
View file @
b17c05c9
Copyright (c) 2009-201
2
pwmt.org
Copyright (c) 2009-201
3
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
...
...
Makefile
View file @
b17c05c9
...
...
@@ -17,6 +17,12 @@ else
SOURCE
=
$(
filter-out
database-sqlite.c,
$(OSOURCE)
)
endif
ifneq
($(WITH_MAGIC),0)
INCS
+=
$(MAGIC_INC)
LIBS
+=
$(MAGIC_LIB)
CPPFLAGS
+=
-DWITH_MAGIC
endif
ifneq
($(wildcard ${VALGRIND_SUPPRESSION_FILE}),)
VALGRIND_ARGUMENTS
+=
--suppressions
=
${VALGRIND_SUPPRESSION_FILE}
endif
...
...
README
View file @
b17c05c9
...
...
@@ -6,12 +6,12 @@ girara user interface library and several document libraries.
Requirements
------------
gtk2 (>= 2.28)
glib (>= 2.32)
girara
sqlite3 (>= 3.5.9)
sqlite3 (
optional,
>= 3.5.9)
check (for tests)
intltool
python-docutils (for man pages)
python-docutils (optional, for man pages)
libmagic from file(1) (optional, for mime-type detection)
Please note that you need to have a working pkg-config installation and that the
Makefile is only compatible with GNU make. If you don't have a working
...
...
@@ -23,9 +23,15 @@ If it is not installed, the man pages won't be built.
If you don't want to build with support for sqlite databases, you can set
WITH_SQLITE=0 and sqlite support won't be available. Please note that sqlite3
with metadata support is required, i.e. sqlite3 has to be built with
with meta
data support is required, i.e. sqlite3 has to be built with
SQLITE_ENABLE_COLUMN_METADATA defined.
The use of magic to detect mime types is optional and can be disabled by setting
WITH_MAGIC=0.
If you pass these flags as a command line argument to make, you have to ensure
to pass the same flags when executing the install target.
Installation
------------
To build and install zathura:
...
...
adjustment.c
0 → 100644
View file @
b17c05c9
/* See LICENSE file for license and copyright information */
#include "adjustment.h"
#include "utils.h"
GtkAdjustment
*
zathura_adjustment_clone
(
GtkAdjustment
*
adjustment
)
{
gdouble
value
=
gtk_adjustment_get_value
(
adjustment
);
gdouble
lower
=
gtk_adjustment_get_lower
(
adjustment
);
gdouble
upper
=
gtk_adjustment_get_upper
(
adjustment
);
gdouble
step_increment
=
gtk_adjustment_get_step_increment
(
adjustment
);
gdouble
page_increment
=
gtk_adjustment_get_page_increment
(
adjustment
);
gdouble
page_size
=
gtk_adjustment_get_page_size
(
adjustment
);
return
GTK_ADJUSTMENT
(
gtk_adjustment_new
(
value
,
lower
,
upper
,
step_increment
,
page_increment
,
page_size
));
}
void
zathura_adjustment_set_value
(
GtkAdjustment
*
adjustment
,
gdouble
value
)
{
gtk_adjustment_set_value
(
adjustment
,
MAX
(
gtk_adjustment_get_lower
(
adjustment
),
MIN
(
gtk_adjustment_get_upper
(
adjustment
)
-
gtk_adjustment_get_page_size
(
adjustment
),
value
)));
}
gdouble
zathura_adjustment_get_ratio
(
GtkAdjustment
*
adjustment
)
{
gdouble
lower
=
gtk_adjustment_get_lower
(
adjustment
);
gdouble
upper
=
gtk_adjustment_get_upper
(
adjustment
);
gdouble
page_size
=
gtk_adjustment_get_page_size
(
adjustment
);
gdouble
value
=
gtk_adjustment_get_value
(
adjustment
);
return
(
value
-
lower
+
page_size
/
2
.
0
)
/
(
upper
-
lower
);
}
void
zathura_adjustment_set_value_from_ratio
(
GtkAdjustment
*
adjustment
,
gdouble
ratio
)
{
if
(
ratio
==
0
.
0
)
{
return
;
}
gdouble
lower
=
gtk_adjustment_get_lower
(
adjustment
);
gdouble
upper
=
gtk_adjustment_get_upper
(
adjustment
);
gdouble
page_size
=
gtk_adjustment_get_page_size
(
adjustment
);
gdouble
value
=
(
upper
-
lower
)
*
ratio
+
lower
-
page_size
/
2
.
0
;
zathura_adjustment_set_value
(
adjustment
,
value
);
}
adjustment.h
0 → 100644
View file @
b17c05c9
/* See LICENSE file for license and copyright information */
#ifndef ZATHURA_ADJUSTMENT_H
#define ZATHURA_ADJUSTMENT_H
#include <gtk/gtk.h>
/* Clone a GtkAdjustment
*
* Creates a new adjustment with the same value, lower and upper bounds, step
* and page increments and page_size as the original adjustment.
*
* @param adjustment Adjustment instance to be cloned
* @return Pointer to the new adjustment
*/
GtkAdjustment
*
zathura_adjustment_clone
(
GtkAdjustment
*
adjustment
);
/**
* Set the adjustment value while enforcing its limits
*
* @param adjustment Adjustment instance
* @param value Adjustment value
*/
void
zathura_adjustment_set_value
(
GtkAdjustment
*
adjustment
,
gdouble
value
);
/**
* Compute the adjustment ratio
*
* That is, the ratio between the length from the lower bound to the middle of
* the slider, and the total length of the scrollbar.
*
* @param adjustment Scrollbar adjustment
* @return Adjustment ratio
*/
gdouble
zathura_adjustment_get_ratio
(
GtkAdjustment
*
adjustment
);
/**
* Set the adjustment value from ratio
*
* The ratio is usually obtained from a previous call to
* zathura_adjustment_get_ratio().
*
* @param adjustment Adjustment instance
* @param ratio Ratio from which the adjustment value will be set
*/
void
zathura_adjustment_set_value_from_ratio
(
GtkAdjustment
*
adjustment
,
gdouble
ratio
);
#endif
/* ZATHURA_ADJUSTMENT_H */
callbacks.c
View file @
b17c05c9
...
...
@@ -18,6 +18,7 @@
#include "shortcuts.h"
#include "page-widget.h"
#include "page.h"
#include "adjustment.h"
gboolean
cb_destroy
(
GtkWidget
*
UNUSED
(
widget
),
zathura_t
*
zathura
)
...
...
@@ -93,7 +94,11 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
zathura
->
ui
.
session
->
gtk
.
view
,
0
,
0
,
&
page_rect
.
x
,
&
page_rect
.
y
);
if
(
gdk_rectangle_intersect
(
&
view_rect
,
&
page_rect
,
NULL
)
==
TRUE
)
{
zathura_page_set_visibility
(
page
,
true
);
if
(
zathura_page_get_visibility
(
page
)
==
false
)
{
zathura_page_set_visibility
(
page
,
true
);
zathura_page_widget_update_view_time
(
ZATHURA_PAGE
(
page_widget
));
zathura_page_cache_add
(
zathura
,
zathura_page_get_index
(
page
));
}
if
(
zathura
->
global
.
update_page_number
==
true
&&
updated
==
false
&&
gdk_rectangle_intersect
(
&
center
,
&
page_rect
,
NULL
)
==
TRUE
)
{
zathura_document_set_current_page_number
(
zathura
->
document
,
page_id
);
...
...
@@ -102,12 +107,93 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
}
else
{
zathura_page_set_visibility
(
page
,
false
);
}
zathura_page_widget_update_view_time
(
ZATHURA_PAGE
(
page_widget
));
}
statusbar_page_number_update
(
zathura
);
}
void
cb_view_hadjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
zathura_t
*
zathura
=
data
;
g_return_if_fail
(
zathura
!=
NULL
);
zathura_adjust_mode_t
adjust_mode
=
zathura_document_get_adjust_mode
(
zathura
->
document
);
gdouble
lower
,
upper
,
page_size
,
value
,
ratio
;
bool
zoom_center
=
false
;
switch
(
adjust_mode
)
{
center:
case
ZATHURA_ADJUST_BESTFIT
:
case
ZATHURA_ADJUST_WIDTH
:
lower
=
gtk_adjustment_get_lower
(
adjustment
);
upper
=
gtk_adjustment_get_upper
(
adjustment
);
page_size
=
gtk_adjustment_get_page_size
(
adjustment
);
value
=
((
upper
-
lower
)
-
page_size
)
/
2
.
0
;
zathura_adjustment_set_value
(
adjustment
,
value
);
break
;
default:
girara_setting_get
(
zathura
->
ui
.
session
,
"zoom-center"
,
&
zoom_center
);
if
(
zoom_center
)
{
goto
center
;
}
ratio
=
zathura_adjustment_get_ratio
(
zathura
->
ui
.
hadjustment
);
zathura_adjustment_set_value_from_ratio
(
adjustment
,
ratio
);
break
;
}
}
void
cb_view_vadjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
zathura_t
*
zathura
=
data
;
g_return_if_fail
(
zathura
!=
NULL
);
zathura_adjust_mode_t
adjust_mode
=
zathura_document_get_adjust_mode
(
zathura
->
document
);
/* Don't scroll we're focusing the inputbar. */
if
(
adjust_mode
==
ZATHURA_ADJUST_INPUTBAR
)
{
return
;
}
double
ratio
=
zathura_adjustment_get_ratio
(
zathura
->
ui
.
vadjustment
);
zathura_adjustment_set_value_from_ratio
(
adjustment
,
ratio
);
}
void
cb_adjustment_track_value
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
GtkAdjustment
*
tracker
=
data
;
gdouble
lower
=
gtk_adjustment_get_lower
(
adjustment
);
gdouble
upper
=
gtk_adjustment_get_upper
(
adjustment
);
if
(
lower
!=
gtk_adjustment_get_lower
(
tracker
)
||
upper
!=
gtk_adjustment_get_upper
(
tracker
))
{
return
;
}
gdouble
value
=
gtk_adjustment_get_value
(
adjustment
);
gtk_adjustment_set_value
(
tracker
,
value
);
}
void
cb_adjustment_track_bounds
(
GtkAdjustment
*
adjustment
,
gpointer
data
)
{
GtkAdjustment
*
tracker
=
data
;
gdouble
value
=
gtk_adjustment_get_value
(
adjustment
);
gdouble
lower
=
gtk_adjustment_get_lower
(
adjustment
);
gdouble
upper
=
gtk_adjustment_get_upper
(
adjustment
);
gdouble
page_size
=
gtk_adjustment_get_page_size
(
adjustment
);
gtk_adjustment_set_value
(
tracker
,
value
);
gtk_adjustment_set_lower
(
tracker
,
lower
);
gtk_adjustment_set_upper
(
tracker
,
upper
);
gtk_adjustment_set_page_size
(
tracker
,
page_size
);
}
void
cb_pages_per_row_value_changed
(
girara_session_t
*
session
,
const
char
*
UNUSED
(
name
),
girara_setting_type_t
UNUSED
(
type
),
void
*
value
,
void
*
UNUSED
(
data
))
{
...
...
@@ -340,7 +426,8 @@ cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog)
}
/* try to open document again */
if
(
document_open
(
dialog
->
zathura
,
dialog
->
path
,
input
)
==
false
)
{
if
(
document_open
(
dialog
->
zathura
,
dialog
->
path
,
input
,
ZATHURA_PAGE_NUMBER_UNSPECIFIED
)
==
false
)
{
gdk_threads_add_idle
(
password_dialog
,
dialog
);
}
else
{
g_free
(
dialog
->
path
);
...
...
callbacks.h
View file @
b17c05c9
...
...
@@ -35,6 +35,53 @@ void cb_buffer_changed(girara_session_t* session);
* @param data NULL
*/
void
cb_view_vadjustment_value_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
);
/**
* This function gets called when the bounds or the page_size of the horizontal
* scrollbar change (e.g. when the zoom level is changed).
*
* It adjusts the value of the horizontal scrollbar, possibly based on its
* previous adjustment, stored in the tracking adjustment
* zathura->ui.hadjustment.
*
* @param adjustment The horizontal adjustment of a gtkScrolledWindow
* @param data The zathura instance
*/
void
cb_view_hadjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
);
/**
* This function gets called when the bounds or the page_size of the vertical
* scrollbar change (e.g. when the zoom level is changed).
*
* It adjusts the value of the vertical scrollbar based on its previous
* adjustment, stored in the tracking adjustment zathura->ui.hadjustment.
*
* @param adjustment The vertical adjustment of a gtkScrolledWindow
* @param data The zathura instance
*/
void
cb_view_vadjustment_changed
(
GtkAdjustment
*
adjustment
,
gpointer
data
);
/* This function gets called when the value of the adjustment changes.
*
* It updates the value of the tracking adjustment, only if the bounds of the
* adjustment have not changed (if they did change,
* cb_adjustment_track_bounds() will take care of updating everything).
*
* @param adjustment The adjustment instance
* @param data The tracking adjustment instance
*/
void
cb_adjustment_track_value
(
GtkAdjustment
*
adjustment
,
gpointer
data
);
/* This function gets called when the bounds or the page_size of the adjustment
* change.
*
* It updates the value, bounds and page_size of the tracking adjustment.
*
* @param adjustment The adjustment instance
* @param data The tracking adjustment instance
*/
void
cb_adjustment_track_bounds
(
GtkAdjustment
*
adjustment
,
gpointer
data
);
/**
* This function gets called when the value of the "pages-per-row"
* variable changes
...
...
commands.c
View file @
b17c05c9
...
...
@@ -225,7 +225,9 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
document_close
(
zathura
,
false
);
}
document_open
(
zathura
,
girara_list_nth
(
argument_list
,
0
),
(
argc
==
2
)
?
girara_list_nth
(
argument_list
,
1
)
:
NULL
);
document_open
(
zathura
,
girara_list_nth
(
argument_list
,
0
),
(
argc
==
2
)
?
girara_list_nth
(
argument_list
,
1
)
:
NULL
,
ZATHURA_PAGE_NUMBER_UNSPECIFIED
);
}
else
{
girara_notify
(
session
,
GIRARA_ERROR
,
_
(
"No arguments given."
));
return
false
;
...
...
@@ -531,7 +533,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
}
/* no argument: take current page as offset */
unsigned
int
page_offset
=
zathura_document_get_current_page_number
(
zathura
->
document
);
int
page_offset
=
zathura_document_get_current_page_number
(
zathura
->
document
);
/* retrieve offset from argument */
if
(
girara_list_size
(
argument_list
)
==
1
)
{
...
...
@@ -545,9 +547,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
}
}
if
(
page_offset
<
zathura_document_get_number_of_pages
(
zathura
->
document
))
{
zathura_document_set_page_offset
(
zathura
->
document
,
page_offset
);
}
zathura_document_set_page_offset
(
zathura
->
document
,
page_offset
);
return
true
;
}
...
...
config.c
View file @
b17c05c9
...
...
@@ -52,6 +52,10 @@ cb_color_change(girara_session_t* session, const char* name,
gdk_color_parse
(
string_value
,
&
(
zathura
->
ui
.
colors
.
recolor_dark_color
));
}
else
if
(
g_strcmp0
(
name
,
"recolor-lightcolor"
)
==
0
)
{
gdk_color_parse
(
string_value
,
&
(
zathura
->
ui
.
colors
.
recolor_light_color
));
}
else
if
(
g_strcmp0
(
name
,
"render-loading-bg"
)
==
0
)
{
gdk_color_parse
(
string_value
,
&
(
zathura
->
ui
.
colors
.
render_loading_bg
));
}
else
if
(
g_strcmp0
(
name
,
"render-loading-fg"
)
==
0
)
{
gdk_color_parse
(
string_value
,
&
(
zathura
->
ui
.
colors
.
render_loading_fg
));
}
render_all
(
zathura
);
...
...
@@ -143,7 +147,7 @@ config_load_default(zathura_t* zathura)
girara_setting_add
(
gsession
,
"first-page-column"
,
&
int_value
,
INT
,
false
,
_
(
"Column of the first page"
),
cb_first_page_column_value_changed
,
NULL
);
float_value
=
40
;
girara_setting_add
(
gsession
,
"scroll-step"
,
&
float_value
,
FLOAT
,
false
,
_
(
"Scroll step"
),
NULL
,
NULL
);
float_value
=
-
1
;
float_value
=
40
;
girara_setting_add
(
gsession
,
"scroll-hstep"
,
&
float_value
,
FLOAT
,
false
,
_
(
"Horizontal scroll step"
),
NULL
,
NULL
);
float_value
=
0
.
0
;
girara_setting_add
(
gsession
,
"scroll-full-overlap"
,
&
float_value
,
FLOAT
,
false
,
_
(
"Full page scroll overlap"
),
NULL
,
NULL
);
...
...
@@ -151,9 +155,8 @@ config_load_default(zathura_t* zathura)
girara_setting_add
(
gsession
,
"zoom-min"
,
&
int_value
,
INT
,
false
,
_
(
"Zoom minimum"
),
NULL
,
NULL
);
int_value
=
1000
;
girara_setting_add
(
gsession
,
"zoom-max"
,
&
int_value
,
INT
,
false
,
_
(
"Zoom maximum"
),
NULL
,
NULL
);
int_value
=
20
;
girara_setting_add
(
gsession
,
"page-store-threshold"
,
&
int_value
,
INT
,
false
,
_
(
"Life time (in seconds) of a hidden page"
),
NULL
,
NULL
);
girara_setting_add
(
gsession
,
"page-store-interval"
,
&
int_value
,
INT
,
true
,
_
(
"Amount of seconds between each cache purge"
),
NULL
,
NULL
);
int_value
=
ZATHURA_PAGE_CACHE_DEFAULT_SIZE
;
girara_setting_add
(
gsession
,
"page-cache-size"
,
&
int_value
,
INT
,
true
,
_
(
"Maximum number of pages to keep in the cache"
),
NULL
,
NULL
);
int_value
=
20
;
girara_setting_add
(
gsession
,
"jumplist-size"
,
&
int_value
,
INT
,
false
,
_
(
"Number of positions to remember in the jumplist"
),
cb_jumplist_change
,
NULL
);
...
...
@@ -165,6 +168,10 @@ config_load_default(zathura_t* zathura)
girara_setting_set
(
gsession
,
"highlight-color"
,
"#9FBC00"
);
girara_setting_add
(
gsession
,
"highlight-active-color"
,
NULL
,
STRING
,
false
,
_
(
"Color for highlighting (active)"
),
cb_color_change
,
NULL
);
girara_setting_set
(
gsession
,
"highlight-active-color"
,
"#00BC00"
);
girara_setting_add
(
gsession
,
"render-loading-bg"
,
NULL
,
STRING
,
false
,
_
(
"'Loading ...' background color"
),
cb_color_change
,
NULL
);
girara_setting_set
(
gsession
,
"render-loading-bg"
,
"#FFFFFF"
);
girara_setting_add
(
gsession
,
"render-loading-fg"
,
NULL
,
STRING
,
false
,
_
(
"'Loading ...' foreground color"
),
cb_color_change
,
NULL
);
girara_setting_set
(
gsession
,
"render-loading-fg"
,
"#000000"
);
bool_value
=
false
;
girara_setting_add
(
gsession
,
"recolor"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Recolor pages"
),
cb_setting_recolor_change
,
NULL
);
...
...
@@ -179,6 +186,8 @@ config_load_default(zathura_t* zathura)
bool_value
=
false
;
girara_setting_add
(
gsession
,
"zoom-center"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Horizontally centered zoom"
),
NULL
,
NULL
);
bool_value
=
true
;
girara_setting_add
(
gsession
,
"link-hadjust"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Align link target to the left"
),
NULL
,
NULL
);
bool_value
=
true
;
girara_setting_add
(
gsession
,
"search-hadjust"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Center result horizontally"
),
NULL
,
NULL
);
float_value
=
0
.
5
;
girara_setting_add
(
gsession
,
"highlight-transparency"
,
&
float_value
,
FLOAT
,
false
,
_
(
"Transparency for highlighting"
),
NULL
,
NULL
);
...
...
@@ -200,6 +209,8 @@ config_load_default(zathura_t* zathura)
bool_value
=
false
;
girara_setting_add
(
gsession
,
"window-title-basename"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Use basename of the file in the window title"
),
NULL
,
NULL
);
bool_value
=
false
;
girara_setting_add
(
gsession
,
"statusbar-basename"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Use basename of the file in the statusbar"
),
NULL
,
NULL
);
bool_value
=
false
;
girara_setting_add
(
gsession
,
"synctex"
,
&
bool_value
,
BOOLEAN
,
false
,
_
(
"Enable synctex support"
),
NULL
,
NULL
);
/* define default shortcuts */
...
...
@@ -244,6 +255,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_Up
,
NULL
,
sc_navigate
,
FULLSCREEN
,
PREVIOUS
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_Page_Up
,
NULL
,
sc_navigate
,
FULLSCREEN
,
PREVIOUS
,
NULL
);
girara_shortcut_add
(
gsession
,
GDK_SHIFT_MASK
,
GDK_KEY_space
,
NULL
,
sc_navigate
,
FULLSCREEN
,
PREVIOUS
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_BackSpace
,
NULL
,
sc_navigate
,
FULLSCREEN
,
PREVIOUS
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_k
,
NULL
,
sc_navigate_index
,
INDEX
,
UP
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_j
,
NULL
,
sc_navigate_index
,
INDEX
,
DOWN
,
NULL
);
...
...
@@ -286,7 +298,8 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add
(
gsession
,
GDK_SHIFT_MASK
,
GDK_KEY_space
,
NULL
,
sc_scroll
,
NORMAL
,
FULL_UP
,
NULL
);
girara_shortcut_add
(
gsession
,
GDK_CONTROL_MASK
,
GDK_KEY_o
,
NULL
,
sc_jumplist
,
NORMAL
,
BACKWARD
,
NULL
);
girara_shortcut_add
(
gsession
,
GDK_CONTROL_MASK
,
GDK_KEY_i
,
NULL
,
sc_jumplist
,
NORMAL
,
FORWARD
,
NULL
);
girara_shortcut_add
(
gsession
,
GDK_CONTROL_MASK
,
GDK_KEY_j
,
NULL
,
sc_bisect
,
NORMAL
,
FORWARD
,
NULL
);
girara_shortcut_add
(
gsession
,
GDK_CONTROL_MASK
,
GDK_KEY_k
,
NULL
,
sc_bisect
,
NORMAL
,
BACKWARD
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_n
,
NULL
,
sc_search
,
NORMAL
,
FORWARD
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_N
,
NULL
,
sc_search
,
NORMAL
,
BACKWARD
,
NULL
);
...
...
@@ -299,6 +312,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_d
,
NULL
,
sc_toggle_page_mode
,
NORMAL
,
0
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_q
,
NULL
,
sc_quit
,
NORMAL
,
0
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_q
,
NULL
,
sc_quit
,
FULLSCREEN
,
0
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_plus
,
NULL
,
sc_zoom
,
NORMAL
,
ZOOM_IN
,
NULL
);
girara_shortcut_add
(
gsession
,
0
,
GDK_KEY_KP_Add
,
NULL
,
sc_zoom
,
NORMAL
,
ZOOM_IN
,
NULL
);
...
...
@@ -388,6 +402,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_mapping_add
(
gsession
,
"follow"
,
sc_follow
);
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
,
"navigate"
,
sc_navigate
);
girara_shortcut_mapping_add
(
gsession
,
"navigate_index"
,
sc_navigate_index
);
girara_shortcut_mapping_add
(
gsession
,
"print"
,
sc_print
);
...
...
config.mk
View file @
b17c05c9
...
...
@@ -3,7 +3,7 @@
ZATHURA_VERSION_MAJOR
=
0
ZATHURA_VERSION_MINOR
=
2
ZATHURA_VERSION_REV
=
2
ZATHURA_VERSION_REV
=
3
# 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.
...
...
@@ -16,13 +16,17 @@ ZATHURA_GTK_VERSION ?= 2
# minimum required zathura version
# If you want to disable the check, set GIRARA_VERSION_CHECK to 0.
GIRARA_MIN_VERSION
=
0.1.
5
GIRARA_MIN_VERSION
=
0.1.
6
GIRARA_VERSION_CHECK
?=
$(
shell
pkg-config
--atleast-version
=
$(GIRARA_MIN_VERSION)
girara-gtk
${ZATHURA_GTK_VERSION}
;
echo
$$
?
)
# database
# To disable support for the sqlite backend set WITH_SQLITE to 0.
WITH_SQLITE
?=
$(
shell
(
pkg-config
--atleast-version
=
3.5.9 sqlite3
&&
echo
1
)
||
echo
0
)
# mimetype detection
# To disable support for mimetype detction with libmagic set WITH_MAGIC to 0.
WITH_MAGIC
?=
1
# paths
PREFIX
?=
/usr
MANPREFIX
?=
${PREFIX}
/share/man
...
...
@@ -56,6 +60,11 @@ SQLITE_INC ?= $(shell pkg-config --cflags sqlite3)
SQLITE_LIB
?=
$(
shell
pkg-config
--libs
sqlite3
)
endif
ifneq
(${WITH_MAGIC},0)
MAGIC_INC
?=
MAGIC_LIB
?=
-lmagic
endif
INCS
=
${GIRARA_INC}
${GTK_INC}
${GTHREAD_INC}
${GMODULE_INC}
LIBS
=
${GIRARA_LIB}
${GTK_LIB}
${GTHREAD_LIB}
${GMODULE_LIB}
-lpthread
-lm
...
...
database-plain.c
View file @
b17c05c9
/* See LICENSE file for license and copyright information */
#define _POSIX_SOURCE
#define _XOPEN_SOURCE 500
#include <glib.h>
#include <stdlib.h>
...
...
@@ -10,11 +11,13 @@
#include <unistd.h>
#include <girara/utils.h>
#include <girara/datastructures.h>
#include <girara/input-history.h>
#include "database-plain.h"
#define BOOKMARKS "bookmarks"
#define HISTORY "history"
#define INPUT_HISTORY "input-history"
#define KEY_PAGE "page"
#define KEY_OFFSET "offset"
...
...
@@ -37,9 +40,11 @@
#endif
static
void
zathura_database_interface_init
(
ZathuraDatabaseInterface
*
iface
);
static
void
io_interface_init
(
GiraraInputHistoryIOInterface
*
iface
);
G_DEFINE_TYPE_WITH_CODE
(
ZathuraPlainDatabase
,
zathura_plaindatabase
,
G_TYPE_OBJECT
,
G_IMPLEMENT_INTERFACE
(
ZATHURA_TYPE_DATABASE
,
zathura_database_interface_init
))
G_IMPLEMENT_INTERFACE
(
ZATHURA_TYPE_DATABASE
,
zathura_database_interface_init
)
G_IMPLEMENT_INTERFACE
(
GIRARA_TYPE_INPUT_HISTORY_IO
,
io_interface_init
))
static
void
plain_finalize
(
GObject
*
object
);
static
bool
plain_add_bookmark
(
zathura_database_t
*
db
,
const
char
*
file
,
...
...
@@ -54,6 +59,8 @@ static bool plain_get_fileinfo(zathura_database_t* db, const char* file,
zathura_fileinfo_t
*
file_info
);
static
void
plain_set_property
(
GObject
*
object
,
guint
prop_id
,
const
GValue
*
value
,
GParamSpec
*
pspec
);
static
void
plain_io_append
(
GiraraInputHistoryIO
*
db
,
const
char
*
);
static
girara_list_t
*
plain_io_read
(
GiraraInputHistoryIO
*
db
);
/* forward declaration */
static
bool
zathura_db_check_file
(
const
char
*
path
);
...
...
@@ -70,6 +77,8 @@ typedef struct zathura_plaindatabase_private_s {
char
*
history_path
;
GKeyFile
*
history
;
GFileMonitor
*
history_monitor
;
char
*
input_history_path
;
}
zathura_plaindatabase_private_t
;
#define ZATHURA_PLAINDATABASE_GET_PRIVATE(obj) \
...
...
@@ -105,6 +114,14 @@ zathura_database_interface_init(ZathuraDatabaseInterface* iface)
iface
->
get_fileinfo
=
plain_get_fileinfo
;
}
static
void
io_interface_init
(
GiraraInputHistoryIOInterface
*
iface
)
{
/* initialize interface */
iface
->
append
=
plain_io_append
;
iface
->
read
=
plain_io_read
;
}
static
void
zathura_plaindatabase_class_init
(
ZathuraPlainDatabaseClass
*
class
)
{
...
...
@@ -117,8 +134,8 @@ zathura_plaindatabase_class_init(ZathuraPlainDatabaseClass* class)
object_class
->
set_property
=
plain_set_property
;
g_object_class_install_property
(
object_class
,
PROP_PATH
,
g_param_spec_string
(
"path"
,
"path"
,
"path to directory where the bookmarks and history are locates"
,
NULL
,
G_PARAM_WRITABLE
|
G_PARAM_CONSTRUCT_ONLY
));
g_param_spec_string
(
"path"
,
"path"
,
"path to directory where the bookmarks and history are locates"
,
NULL
,
G_PARAM_WRITABLE
|
G_PARAM_CONSTRUCT_ONLY
|
G_PARAM_STATIC_STRINGS
));
}
static
void
...
...
@@ -126,12 +143,13 @@ zathura_plaindatabase_init(ZathuraPlainDatabase* db)
{
zathura_plaindatabase_private_t
*
priv
=
ZATHURA_PLAINDATABASE_GET_PRIVATE
(
db
);
priv
->
bookmark_path
=
NULL
;
priv
->
bookmark_monitor
=
NULL
;
priv
->
bookmarks
=
NULL
;
priv
->
history_path
=
NULL
;
priv
->
history_monitor
=
NULL
;
priv
->
history
=
NULL
;
priv
->
bookmark_path
=
NULL
;
priv
->
bookmark_monitor
=
NULL
;
priv
->
bookmarks
=
NULL
;
priv
->
history_path
=
NULL
;
priv
->
history_monitor
=
NULL
;
priv
->
history
=
NULL
;
priv
->
input_history_path
=
NULL
;
}
zathura_database_t
*
...
...
@@ -208,6 +226,12 @@ plain_db_init(ZathuraPlainDatabase* db, const char* dir)
goto
error_free
;
}
/* input history */
priv
->
input_history_path
=
g_build_filename
(
dir
,
INPUT_HISTORY
,
NULL
);
if
(
zathura_db_check_file
(
priv
->
input_history_path
)
==
false
)
{
goto
error_free
;
}
return
;
error_free:
...
...
@@ -239,6 +263,10 @@ error_free:
g_key_file_free
(
priv
->
history
);
priv
->
history
=
NULL
;
}
/* input history */
g_free
(
priv
->
input_history_path
);
priv
->
input_history_path
=
NULL
;
}
static
void
...
...
@@ -283,6 +311,9 @@ plain_finalize(GObject* object)
g_key_file_free
(
priv
->
history
);
}
/* input history */
g_free
(
priv
->
input_history_path
);
G_OBJECT_CLASS
(
zathura_plaindatabase_parent_class
)
->
finalize
(
object
);
}
...
...
@@ -595,3 +626,76 @@ cb_zathura_db_watch_file(GFileMonitor* UNUSED(monitor), GFile* file, GFile* UNUS
g_free
(
path
);
}
static
girara_list_t
*
plain_io_read
(
GiraraInputHistoryIO
*
db
)
{
zathura_plaindatabase_private_t
*
priv
=
ZATHURA_PLAINDATABASE_GET_PRIVATE
(
db
);
/* open file */
FILE
*
file
=
fopen
(
priv
->
input_history_path
,
"r"
);
if
(
file
==
NULL
)
{
return
NULL
;
}
/* read input history file */
file_lock_set
(
fileno
(
file
),
F_RDLCK
);
char
*
content
=
girara_file_read2
(
file
);
file_lock_set
(
fileno
(
file
),
F_UNLCK
);
fclose
(
file
);
girara_list_t
*
res
=
girara_list_new2
(
g_free
);
char
**
tmp
=
g_strsplit
(
content
,
"
\n
"
,
0
);
for
(
size_t
i
=
0
;
tmp
[
i
]
!=
NULL
;
++
i
)
{
if
(
strlen
(
tmp
[
i
])
==
0
||
strchr
(
":/"
,
tmp
[
i
][
0
])
==
NULL
)
{
continue
;
}
girara_list_append
(
res
,
g_strdup
(
tmp
[
i
]));
}
g_strfreev
(
tmp
);
free
(
content
);
return
res
;
}
#include <errno.h>
static
void
plain_io_append
(
GiraraInputHistoryIO
*
db
,
const
char
*
input
)
{
zathura_plaindatabase_private_t
*
priv
=
ZATHURA_PLAINDATABASE_GET_PRIVATE
(
db
);
/* open file */
FILE
*
file
=
fopen
(
priv
->
input_history_path
,
"r+"
);
if
(
file
==
NULL
)
{
return
;
}
/* read input history file */
file_lock_set
(
fileno
(
file
),
F_WRLCK
);
char
*
content
=
girara_file_read2
(
file
);
rewind
(
file
);
if
(
ftruncate
(
fileno
(
file
),
0
)
!=
0
)
{
free
(
content
);
file_lock_set
(
fileno
(
file
),
F_UNLCK
);
fclose
(
file
);
return
;
}
char
**
tmp
=
g_strsplit
(
content
,
"
\n
"
,
0
);
free
(
content
);
/* write input history file */
for
(
size_t
i
=
0
;
tmp
[
i
]
!=
NULL
;
++
i
)
{
if
(
strlen
(
tmp
[
i
])
==
0
||
strchr
(
":/"
,
tmp
[
i
][
0
])
==
NULL
||
strcmp
(
tmp
[
i
],
input
)
==
0
)
{
continue
;
}
fprintf
(
file
,
"%s
\n
"
,
tmp
[
i
]);
}
g_strfreev
(
tmp
);