Skip to content

Commit 6a51add

Browse files
committed
Merge branch 'release/0.5.10'
2 parents 65e63c7 + 0b9c2ef commit 6a51add

File tree

6 files changed

+100
-63
lines changed

6 files changed

+100
-63
lines changed

meson.build

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project('zathura', 'c',
2-
version: '0.5.9',
2+
version: '0.5.10',
33
meson_version: '>=0.61',
44
default_options: ['c_std=c17', 'warning_level=3'],
55
)
@@ -32,6 +32,10 @@ metainfodir = join_paths(datadir, 'metainfo')
3232
desktopdir = join_paths(datadir, 'applications')
3333
dbusinterfacesdir = join_paths(datadir, 'dbus-1', 'interfaces')
3434
plugindir = join_paths(get_option('libdir'), 'zathura')
35+
sysconfdir = get_option('sysconfdir')
36+
if not sysconfdir.startswith('/')
37+
sysconfdir = join_paths(prefix, sysconfdir)
38+
endif
3539

3640
# required dependencies
3741
libm = cc.find_library('m', required: false)
@@ -59,6 +63,7 @@ defines = [
5963
'-DGETTEXT_PACKAGE="zathura"',
6064
'-DLOCALEDIR="@0@"'.format(join_paths(prefix, localedir)),
6165
'-DZATHURA_PLUGINDIR="@0@"'.format(join_paths(prefix, plugindir)),
66+
'-DSYSCONFDIR="@0@"'.format(sysconfdir),
6267
'-D_DEFAULT_SOURCE',
6368
]
6469

zathura/config.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <girara/utils.h>
1919
#include <glib/gi18n.h>
2020

21-
#define GLOBAL_RC "/etc/zathurarc"
2221
#define ZATHURA_RC "zathurarc"
2322

2423
static void cb_jumplist_change(girara_session_t* session, const char* UNUSED(name), girara_setting_type_t UNUSED(type),
@@ -28,12 +27,8 @@ static void cb_jumplist_change(girara_session_t* session, const char* UNUSED(nam
2827
g_return_if_fail(session->global.data != NULL);
2928
zathura_t* zathura = session->global.data;
3029

31-
const int* ivalue = value;
32-
zathura->jumplist.max_size = MAX(0, *ivalue);
33-
34-
if (zathura->jumplist.list != NULL && zathura->jumplist.size != 0) {
35-
zathura_jumplist_trim(zathura);
36-
}
30+
const int* ivalue = value;
31+
zathura_jumplist_set_max_size(zathura, MAX(0, *ivalue));
3732
}
3833

3934
static void cb_color_change(girara_session_t* session, const char* name, girara_setting_type_t UNUSED(type),
@@ -649,7 +644,7 @@ void config_load_files(zathura_t* zathura) {
649644
girara_list_free(config_dirs);
650645
g_free(config_path);
651646

652-
girara_config_parse(zathura->ui.session, GLOBAL_RC);
647+
girara_config_parse(zathura->ui.session, SYSCONFDIR "/" ZATHURA_RC);
653648

654649
/* load local configuration files */
655650
char* configuration_file = g_build_filename(zathura->config.config_dir, ZATHURA_RC, NULL);

zathura/jumplist.c

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,28 @@ void zathura_jumplist_add(zathura_t* zathura) {
121121
zathura_jumplist_save(zathura);
122122
}
123123

124+
void zathura_jumplist_set_max_size(zathura_t* zathura, size_t max_size) {
125+
zathura->jumplist.max_size = max_size;
126+
if (zathura->jumplist.list != NULL && zathura->jumplist.size != 0) {
127+
zathura_jumplist_trim(zathura);
128+
}
129+
}
130+
124131
bool zathura_jumplist_load(zathura_t* zathura, const char* file) {
125132
g_return_val_if_fail(zathura != NULL && file != NULL, false);
126133

127134
if (zathura->database == NULL) {
128135
return false;
129136
}
130137

131-
zathura->jumplist.list = zathura_db_load_jumplist(zathura->database, file);
132-
133-
if (zathura->jumplist.list == NULL) {
138+
girara_list_t* list = zathura_db_load_jumplist(zathura->database, file);
139+
if (list == NULL) {
134140
girara_error("Failed to load the jumplist from the database");
135-
136141
return false;
137142
}
138143

144+
girara_list_free(zathura->jumplist.list);
145+
zathura->jumplist.list = list;
139146
zathura->jumplist.size = girara_list_size(zathura->jumplist.list);
140147

141148
if (zathura->jumplist.size != 0) {
@@ -149,3 +156,27 @@ bool zathura_jumplist_load(zathura_t* zathura, const char* file) {
149156

150157
return true;
151158
}
159+
160+
void zathura_jumplist_init(zathura_t* zathura, size_t max_size) {
161+
zathura->jumplist.max_size = max_size;
162+
zathura->jumplist.list = girara_list_new_with_free(g_free);
163+
zathura->jumplist.size = 0;
164+
zathura->jumplist.cur = NULL;
165+
}
166+
167+
bool zathura_jumplist_is_initalized(zathura_t* zathura) {
168+
return zathura->jumplist.list != NULL;
169+
}
170+
171+
void zathura_jumplist_clear(zathura_t* zathura) {
172+
if (zathura == NULL) {
173+
return;
174+
}
175+
176+
/* remove jump list */
177+
girara_list_iterator_free(zathura->jumplist.cur);
178+
zathura->jumplist.cur = NULL;
179+
girara_list_free(zathura->jumplist.list);
180+
zathura->jumplist.list = NULL;
181+
zathura->jumplist.size = 0;
182+
}

zathura/jumplist.h

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct zathura_jumplist_s {
1919
* @param zathura The zathura session
2020
* @return true if current jump has a previous jump
2121
*/
22-
bool zathura_jumplist_has_previous(zathura_t* jumplzathura);
22+
bool zathura_jumplist_has_previous(zathura_t* zathura);
2323

2424
/**
2525
* Checks whether current jump has a next jump
@@ -65,6 +65,14 @@ void zathura_jumplist_add(zathura_t* zathura);
6565
*/
6666
void zathura_jumplist_trim(zathura_t* zathura);
6767

68+
/**
69+
* Set maximum jump list size (and trim if necessary)
70+
*
71+
* @param zathura The zathura session
72+
* @param max_size New maximum size
73+
*/
74+
void zathura_jumplist_set_max_size(zathura_t* zathura, size_t max_size);
75+
6876
/**
6977
* Load the jumplist of the specified file
7078
*
@@ -75,4 +83,26 @@ void zathura_jumplist_trim(zathura_t* zathura);
7583
*/
7684
bool zathura_jumplist_load(zathura_t* zathura, const char* file);
7785

86+
/**
87+
* Init jumplist with a maximum size
88+
*
89+
* @param zathura The zathura session
90+
* @param max_size maximum jumplist size (or 0 for unbounded lists)
91+
*/
92+
void zathura_jumplist_init(zathura_t* zathura, size_t max_size);
93+
94+
/**
95+
* Check if the jumplist is initalized
96+
*
97+
* @param zathura The zathura session
98+
*/
99+
bool zathura_jumplist_is_initalized(zathura_t* zathura);
100+
101+
/**
102+
* Clear jumplist
103+
*
104+
* @param zathura The zathura session
105+
*/
106+
void zathura_jumplist_clear(zathura_t* zathura);
107+
78108
#endif

zathura/utils.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,31 +141,29 @@ static bool find_substring(const char* source_str, const char* search_str) {
141141
return false;
142142
}
143143

144-
static gboolean search_equal_iter(GtkTreeModel* model, gint column, const gchar* key, GtkTreeIter* iter) {
145-
146-
const gchar* source_string;
147-
GValue value = G_VALUE_INIT;
148-
GValue transformed = G_VALUE_INIT;
149-
144+
static bool search_equal_iter(GtkTreeModel* model, gint column, const gchar* key, GtkTreeIter* iter) {
145+
GValue value = G_VALUE_INIT;
150146
gtk_tree_model_get_value(model, iter, column, &value);
151147

148+
GValue transformed = G_VALUE_INIT;
152149
g_value_init(&transformed, G_TYPE_STRING);
153150

154-
if (!g_value_transform(&value, &transformed)) {
155-
g_value_unset(&value);
156-
return TRUE;
151+
const gboolean ret = g_value_transform(&value, &transformed);
152+
g_value_unset(&value);
153+
if (!ret) {
154+
return true;
157155
}
158156

159-
g_value_unset(&value);
160-
source_string = g_value_get_string(&transformed);
157+
const gchar* source_string = g_value_get_string(&transformed);
161158
if (!source_string) {
162159
g_value_unset(&transformed);
163-
return TRUE;
164-
}
165-
if (find_substring(source_string, key)) {
166-
return FALSE;
160+
return true;
167161
}
168-
return TRUE;
162+
163+
const bool ret2 = find_substring(source_string, key);
164+
g_value_unset(&transformed);
165+
166+
return !ret2;
169167
}
170168

171169
gboolean search_equal_func_index(GtkTreeModel* model, gint column, const gchar* key, GtkTreeIter* iter,

zathura/zathura.c

Lines changed: 11 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -384,16 +384,6 @@ static void init_database(zathura_t* zathura) {
384384
}
385385
#endif
386386

387-
static void init_jumplist(zathura_t* zathura) {
388-
int jumplist_size = 20;
389-
girara_setting_get(zathura->ui.session, "jumplist-size", &jumplist_size);
390-
391-
zathura->jumplist.max_size = jumplist_size < 0 ? 0 : jumplist_size;
392-
zathura->jumplist.list = NULL;
393-
zathura->jumplist.size = 0;
394-
zathura->jumplist.cur = NULL;
395-
}
396-
397387
static void init_shortcut_helpers(zathura_t* zathura) {
398388
zathura->shortcut.mouse.x = 0;
399389
zathura->shortcut.mouse.y = 0;
@@ -439,7 +429,9 @@ bool zathura_init(zathura_t* zathura) {
439429
(girara_free_function_t)zathura_bookmark_free);
440430

441431
/* jumplist */
442-
init_jumplist(zathura);
432+
int jumplist_size = 20;
433+
girara_setting_get(zathura->ui.session, "jumplist-size", &jumplist_size);
434+
zathura_jumplist_init(zathura, MAX(jumplist_size, 0));
443435

444436
/* CSS for index mode */
445437
if (init_css(zathura) == false) {
@@ -524,13 +516,7 @@ void zathura_free(zathura_t* zathura) {
524516
g_free(zathura->config.cache_dir);
525517

526518
/* free jumplist */
527-
if (zathura->jumplist.cur != NULL) {
528-
girara_list_iterator_free(zathura->jumplist.cur);
529-
}
530-
531-
if (zathura->jumplist.list != NULL) {
532-
girara_list_free(zathura->jumplist.list);
533-
}
519+
zathura_jumplist_clear(zathura);
534520

535521
g_free(zathura);
536522
}
@@ -1107,11 +1093,6 @@ bool document_open(zathura_t* zathura, const char* path, const char* uri, const
11071093
const unsigned int view_height = floor(gtk_adjustment_get_page_size(vadjustment));
11081094
zathura_document_set_viewport_height(document, view_height);
11091095

1110-
zathura_update_view_ppi(zathura);
1111-
1112-
/* call screen-changed callback to connect monitors-changed signal on initial screen */
1113-
cb_widget_screen_changed(zathura->ui.session->gtk.view, NULL, zathura);
1114-
11151096
/* get initial device scale */
11161097
const int device_factor = gtk_widget_get_scale_factor(zathura->ui.session->gtk.view);
11171098
zathura_document_set_device_factors(document, device_factor, device_factor);
@@ -1197,7 +1178,6 @@ bool document_open(zathura_t* zathura, const char* path, const char* uri, const
11971178
/* jumplist */
11981179
if (zathura_jumplist_load(zathura, file_path) == false) {
11991180
girara_debug("Failed to load jumplist.");
1200-
zathura->jumplist.list = girara_list_new2(g_free);
12011181
}
12021182

12031183
/* quickmarks */
@@ -1207,11 +1187,10 @@ bool document_open(zathura_t* zathura, const char* path, const char* uri, const
12071187
}
12081188
} else {
12091189
/* create fallback lists */
1210-
zathura->jumplist.list = girara_list_new2(g_free);
1211-
zathura->global.marks = girara_list_new2(g_free);
1190+
zathura->global.marks = girara_list_new2(g_free);
12121191
}
12131192

1214-
if (zathura->jumplist.list == NULL || zathura->global.marks == NULL) {
1193+
if (zathura_jumplist_is_initalized(zathura) == false || zathura->global.marks == NULL) {
12151194
goto error_free;
12161195
}
12171196

@@ -1256,6 +1235,10 @@ bool document_open(zathura_t* zathura, const char* path, const char* uri, const
12561235
zathura_show_signature_information(zathura, show_signature_information);
12571236
update_visible_pages(zathura);
12581237

1238+
/* this needs to run at the end since it will refresh the view via zathura_view_update_ppi */
1239+
/* call screen-changed callback to connect monitors-changed signal on initial screen */
1240+
cb_widget_screen_changed(zathura->ui.session->gtk.view, NULL, zathura);
1241+
12591242
return true;
12601243

12611244
error_free:
@@ -1467,12 +1450,7 @@ bool document_close(zathura_t* zathura, bool keep_monitor) {
14671450
zathura->global.marks = NULL;
14681451
}
14691452

1470-
/* remove jump list */
1471-
girara_list_iterator_free(zathura->jumplist.cur);
1472-
zathura->jumplist.cur = NULL;
1473-
girara_list_free(zathura->jumplist.list);
1474-
zathura->jumplist.list = NULL;
1475-
zathura->jumplist.size = 0;
1453+
zathura_jumplist_clear(zathura);
14761454

14771455
/* release render thread */
14781456
g_clear_object(&zathura->sync.render_thread);

0 commit comments

Comments
 (0)