mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-29 00:44:57 +01:00
Update style
This commit is contained in:
parent
41cb60e5c6
commit
89e7832047
20 changed files with 451 additions and 460 deletions
|
@ -87,7 +87,8 @@ zathura_bookmark_free(zathura_bookmark_t* bookmark)
|
|||
}
|
||||
|
||||
bool
|
||||
zathura_bookmarks_load(zathura_t* zathura, const gchar* file) {
|
||||
zathura_bookmarks_load(zathura_t* zathura, const gchar* file)
|
||||
{
|
||||
g_return_val_if_fail(zathura, false);
|
||||
g_return_val_if_fail(file, false);
|
||||
|
||||
|
|
26
callbacks.c
26
callbacks.c
|
@ -84,7 +84,7 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
|
|||
GdkRectangle page_rect;
|
||||
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
|
||||
gtk_widget_translate_coordinates(page_widget,
|
||||
zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y);
|
||||
zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y);
|
||||
page_rect.width = zathura_page_get_width(page) * scale;
|
||||
page_rect.height = zathura_page_get_height(page) * scale;
|
||||
|
||||
|
@ -156,7 +156,7 @@ cb_first_page_column_value_changed(girara_session_t* session, const char* UNUSED
|
|||
|
||||
void
|
||||
cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
|
||||
GtkTreeViewColumn* UNUSED(column), void* data)
|
||||
GtkTreeViewColumn* UNUSED(column), void* data)
|
||||
{
|
||||
zathura_t* zathura = data;
|
||||
if (tree_view == NULL || zathura == NULL || zathura->ui.session == NULL) {
|
||||
|
@ -269,13 +269,13 @@ password_dialog(gpointer data)
|
|||
|
||||
if (dialog != NULL) {
|
||||
girara_dialog(
|
||||
dialog->zathura->ui.session,
|
||||
"Incorrect password. Enter password:",
|
||||
true,
|
||||
NULL,
|
||||
(girara_callback_inputbar_activate_t) cb_password_dialog,
|
||||
dialog
|
||||
);
|
||||
dialog->zathura->ui.session,
|
||||
"Incorrect password. Enter password:",
|
||||
true,
|
||||
NULL,
|
||||
(girara_callback_inputbar_activate_t) cb_password_dialog,
|
||||
dialog
|
||||
);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
@ -323,8 +323,8 @@ cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog)
|
|||
|
||||
error_free:
|
||||
|
||||
g_free(dialog->path);
|
||||
free(dialog);
|
||||
g_free(dialog->path);
|
||||
free(dialog);
|
||||
|
||||
error_ret:
|
||||
|
||||
|
@ -355,7 +355,7 @@ cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t*
|
|||
|
||||
void
|
||||
cb_setting_recolor_change(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
|
@ -373,7 +373,7 @@ cb_setting_recolor_change(girara_session_t* session, const char* name,
|
|||
|
||||
void
|
||||
cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
|
|
34
commands.c
34
commands.c
|
@ -165,15 +165,15 @@ cmd_info(girara_session_t* session, girara_list_t* UNUSED(argument_list))
|
|||
GString* string = g_string_new(NULL);
|
||||
|
||||
GIRARA_LIST_FOREACH(information, zathura_document_information_entry_t*, iter, entry)
|
||||
if (entry != NULL) {
|
||||
for (unsigned int i = 0; i < LENGTH(meta_fields); i++) {
|
||||
if (meta_fields[i].field == entry->type) {
|
||||
char* text = g_strdup_printf("<b>%s:</b> %s\n", meta_fields[i].name, entry->value);
|
||||
g_string_append(string, text);
|
||||
g_free(text);
|
||||
}
|
||||
if (entry != NULL) {
|
||||
for (unsigned int i = 0; i < LENGTH(meta_fields); i++) {
|
||||
if (meta_fields[i].field == entry->type) {
|
||||
char* text = g_strdup_printf("<b>%s:</b> %s\n", meta_fields[i].name, entry->value);
|
||||
g_string_append(string, text);
|
||||
g_free(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(information, zathura_document_information_entry_t*, iter, entry);
|
||||
|
||||
if (strlen(string->str) > 0) {
|
||||
|
@ -190,7 +190,7 @@ cmd_info(girara_session_t* session, girara_list_t* UNUSED(argument_list))
|
|||
|
||||
bool
|
||||
cmd_help(girara_session_t* UNUSED(session), girara_list_t*
|
||||
UNUSED(argument_list))
|
||||
UNUSED(argument_list))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ cmd_export(girara_session_t* session, girara_list_t* argument_list)
|
|||
} else {
|
||||
girara_notify(session, GIRARA_INFO, _("Wrote attachment '%s' to '%s'."), file_identifier, export_path);
|
||||
}
|
||||
/* image */
|
||||
/* image */
|
||||
} else if (strncmp(file_identifier, "image-p", strlen("image-p")) == 0 && strlen(file_identifier) >= 10) {
|
||||
/* parse page id */
|
||||
const char* input = file_identifier + strlen("image-p");
|
||||
|
@ -479,7 +479,7 @@ image_error:
|
|||
|
||||
girara_notify(session, GIRARA_ERROR, _("Unknown image '%s'."), file_identifier);
|
||||
goto error_ret;
|
||||
/* unknown */
|
||||
/* unknown */
|
||||
} else {
|
||||
girara_notify(session, GIRARA_ERROR, _("Unknown attachment or image '%s'."), file_identifier);
|
||||
}
|
||||
|
@ -502,10 +502,10 @@ cmd_exec(girara_session_t* session, girara_list_t* argument_list)
|
|||
const char* path = zathura_document_get_path(zathura->document);
|
||||
|
||||
GIRARA_LIST_FOREACH(argument_list, char*, iter, value)
|
||||
char* r = NULL;
|
||||
if ((r = replace_substring(value, "$FILE", path)) != NULL) {
|
||||
girara_list_iterator_set(iter, r);
|
||||
}
|
||||
char* r = NULL;
|
||||
if ((r = replace_substring(value, "$FILE", path)) != NULL) {
|
||||
girara_list_iterator_set(iter, r);
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(argument_list, char*, iter, value);
|
||||
}
|
||||
|
||||
|
@ -553,9 +553,9 @@ cmd_version(girara_session_t* session, girara_list_t* UNUSED(argument_list))
|
|||
zathura_t* zathura = session->global.data;
|
||||
|
||||
char* string = zathura_get_version_string(zathura, true);
|
||||
if (string == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (string == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* display information */
|
||||
girara_notify(session, GIRARA_INFO, "%s", string);
|
||||
|
|
38
completion.c
38
completion.c
|
@ -32,7 +32,7 @@ compare_case_insensitive(const char* str1, const char* str2)
|
|||
|
||||
static girara_list_t*
|
||||
list_files(zathura_t* zathura, const char* current_path, const char* current_file,
|
||||
unsigned int current_file_length, bool is_dir, bool check_file_ext)
|
||||
unsigned int current_file_length, bool is_dir, bool check_file_ext)
|
||||
{
|
||||
if (zathura == NULL || zathura->ui.session == NULL || current_path == NULL) {
|
||||
return NULL;
|
||||
|
@ -45,7 +45,7 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
|
|||
}
|
||||
|
||||
girara_list_t* res = girara_sorted_list_new2((girara_compare_function_t)compare_case_insensitive,
|
||||
(girara_free_function_t)g_free);
|
||||
(girara_free_function_t)g_free);
|
||||
|
||||
bool show_hidden = false;
|
||||
girara_setting_get(zathura->ui.session, "show-hidden", &show_hidden);
|
||||
|
@ -179,7 +179,7 @@ list_files_for_cc(zathura_t* zathura, const char* input, bool check_file_ext)
|
|||
}
|
||||
|
||||
GIRARA_LIST_FOREACH(names, const char*, iter, file)
|
||||
girara_completion_group_add_element(group, file, NULL);
|
||||
girara_completion_group_add_element(group, file, NULL);
|
||||
GIRARA_LIST_FOREACH_END(names, const char*, iter, file);
|
||||
girara_list_free(names);
|
||||
}
|
||||
|
@ -246,11 +246,11 @@ cc_bookmarks(girara_session_t* session, const char* input)
|
|||
|
||||
const size_t input_length = strlen(input);
|
||||
GIRARA_LIST_FOREACH(zathura->bookmarks.bookmarks, zathura_bookmark_t*, iter, bookmark)
|
||||
if (input_length <= strlen(bookmark->id) && !strncmp(input, bookmark->id, input_length)) {
|
||||
gchar* paged = g_strdup_printf(_("Page %d"), bookmark->page);
|
||||
girara_completion_group_add_element(group, bookmark->id, paged);
|
||||
g_free(paged);
|
||||
}
|
||||
if (input_length <= strlen(bookmark->id) && !strncmp(input, bookmark->id, input_length)) {
|
||||
gchar* paged = g_strdup_printf(_("Page %d"), bookmark->page);
|
||||
girara_completion_group_add_element(group, bookmark->id, paged);
|
||||
g_free(paged);
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(zathura->bookmarks.bookmarks, zathura_bookmark_t*, iter, bookmark);
|
||||
|
||||
girara_completion_add_group(completion, group);
|
||||
|
@ -302,12 +302,12 @@ cc_export(girara_session_t* session, const char* input)
|
|||
bool added = false;
|
||||
|
||||
GIRARA_LIST_FOREACH(attachments, const char*, iter, attachment)
|
||||
if (input_length <= strlen(attachment) && !strncmp(input, attachment, input_length)) {
|
||||
char* attachment_string = g_strdup_printf("attachment-%s", attachment);
|
||||
girara_completion_group_add_element(attachment_group, attachment_string, NULL);
|
||||
g_free(attachment_string);
|
||||
added = true;
|
||||
}
|
||||
if (input_length <= strlen(attachment) && !strncmp(input, attachment, input_length)) {
|
||||
char* attachment_string = g_strdup_printf("attachment-%s", attachment);
|
||||
girara_completion_group_add_element(attachment_group, attachment_string, NULL);
|
||||
g_free(attachment_string);
|
||||
added = true;
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(zathura->bookmarks.bookmarks, zathura_bookmark_t*, iter, bookmark);
|
||||
|
||||
if (added == true) {
|
||||
|
@ -339,12 +339,12 @@ cc_export(girara_session_t* session, const char* input)
|
|||
if (images != NULL) {
|
||||
unsigned int image_number = 1;
|
||||
GIRARA_LIST_FOREACH(images, zathura_image_t*, iter, UNUSED(image))
|
||||
char* image_string = g_strdup_printf("image-p%d-%d", page_id + 1, image_number);
|
||||
girara_completion_group_add_element(image_group, image_string, NULL);
|
||||
g_free(image_string);
|
||||
char* image_string = g_strdup_printf("image-p%d-%d", page_id + 1, image_number);
|
||||
girara_completion_group_add_element(image_group, image_string, NULL);
|
||||
g_free(image_string);
|
||||
|
||||
added = true;
|
||||
image_number++;
|
||||
added = true;
|
||||
image_number++;
|
||||
GIRARA_LIST_FOREACH_END(images, zathura_image_t*, iter, image);
|
||||
girara_list_free(images);
|
||||
}
|
||||
|
|
10
config.c
10
config.c
|
@ -20,7 +20,7 @@
|
|||
|
||||
static void
|
||||
cb_jumplist_change(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
|
@ -35,7 +35,7 @@ cb_jumplist_change(girara_session_t* session, const char* name,
|
|||
|
||||
static void
|
||||
cb_color_change(girara_session_t* session, const char* name,
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
|
@ -59,7 +59,7 @@ cb_color_change(girara_session_t* session, const char* name,
|
|||
|
||||
static void
|
||||
cb_page_padding_changed(girara_session_t* session, const char* UNUSED(name),
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
|
@ -80,7 +80,7 @@ cb_page_padding_changed(girara_session_t* session, const char* UNUSED(name),
|
|||
|
||||
static void
|
||||
cb_nohlsearch_changed(girara_session_t* session, const char* UNUSED(name),
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
|
@ -93,7 +93,7 @@ cb_nohlsearch_changed(girara_session_t* session, const char* UNUSED(name),
|
|||
|
||||
static void
|
||||
cb_incsearch_changed(girara_session_t* session, const char* UNUSED(name),
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
|
||||
{
|
||||
g_return_if_fail(value != NULL);
|
||||
g_return_if_fail(session != NULL);
|
||||
|
|
|
@ -39,28 +39,28 @@
|
|||
static void zathura_database_interface_init(ZathuraDatabaseInterface* 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))
|
||||
|
||||
static void plain_finalize(GObject* object);
|
||||
static bool plain_add_bookmark(zathura_database_t* db, const char* file,
|
||||
zathura_bookmark_t* bookmark);
|
||||
zathura_bookmark_t* bookmark);
|
||||
static bool plain_remove_bookmark(zathura_database_t* db, const char* file,
|
||||
const char* id);
|
||||
const char* id);
|
||||
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,
|
||||
zathura_fileinfo_t* file_info);
|
||||
zathura_fileinfo_t* file_info);
|
||||
static bool plain_get_fileinfo(zathura_database_t* db, const char* file,
|
||||
zathura_fileinfo_t* file_info);
|
||||
zathura_fileinfo_t* file_info);
|
||||
static void plain_set_property(GObject* object, guint prop_id,
|
||||
const GValue* value, GParamSpec* pspec);
|
||||
const GValue* value, GParamSpec* pspec);
|
||||
|
||||
/* forward declaration */
|
||||
static bool zathura_db_check_file(const char* path);
|
||||
static GKeyFile* zathura_db_read_key_file_from_file(const char* path);
|
||||
static void zathura_db_write_key_file_to_file(const char* file, GKeyFile* key_file);
|
||||
static void cb_zathura_db_watch_file(GFileMonitor* monitor, GFile* file, GFile*
|
||||
other_file, GFileMonitorEvent event, zathura_database_t* database);
|
||||
other_file, GFileMonitorEvent event, zathura_database_t* database);
|
||||
|
||||
typedef struct zathura_plaindatabase_private_s {
|
||||
char* bookmark_path;
|
||||
|
@ -75,8 +75,7 @@ typedef struct zathura_plaindatabase_private_s {
|
|||
#define ZATHURA_PLAINDATABASE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZATHURA_TYPE_PLAINDATABASE, zathura_plaindatabase_private_t))
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_PATH
|
||||
};
|
||||
|
@ -118,8 +117,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));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -171,10 +170,10 @@ plain_db_init(ZathuraPlainDatabase* db, const char* dir)
|
|||
g_object_unref(bookmark_file);
|
||||
|
||||
g_signal_connect(
|
||||
G_OBJECT(priv->bookmark_monitor),
|
||||
"changed",
|
||||
G_CALLBACK(cb_zathura_db_watch_file),
|
||||
db
|
||||
G_OBJECT(priv->bookmark_monitor),
|
||||
"changed",
|
||||
G_CALLBACK(cb_zathura_db_watch_file),
|
||||
db
|
||||
);
|
||||
|
||||
priv->bookmarks = zathura_db_read_key_file_from_file(priv->bookmark_path);
|
||||
|
@ -198,10 +197,10 @@ plain_db_init(ZathuraPlainDatabase* db, const char* dir)
|
|||
g_object_unref(history_file);
|
||||
|
||||
g_signal_connect(
|
||||
G_OBJECT(priv->history_monitor),
|
||||
"changed",
|
||||
G_CALLBACK(cb_zathura_db_watch_file),
|
||||
db
|
||||
G_OBJECT(priv->history_monitor),
|
||||
"changed",
|
||||
G_CALLBACK(cb_zathura_db_watch_file),
|
||||
db
|
||||
);
|
||||
|
||||
priv->history = zathura_db_read_key_file_from_file(priv->history_path);
|
||||
|
@ -289,7 +288,7 @@ plain_finalize(GObject* object)
|
|||
|
||||
static bool
|
||||
plain_add_bookmark(zathura_database_t* db, const char* file,
|
||||
zathura_bookmark_t* bookmark)
|
||||
zathura_bookmark_t* bookmark)
|
||||
{
|
||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
||||
if (priv->bookmarks == NULL || priv->bookmark_path == NULL ||
|
||||
|
@ -308,7 +307,7 @@ plain_add_bookmark(zathura_database_t* db, const char* file,
|
|||
|
||||
static bool
|
||||
plain_remove_bookmark(zathura_database_t* db, const char* file, const char*
|
||||
GIRARA_UNUSED(id))
|
||||
GIRARA_UNUSED(id))
|
||||
{
|
||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
||||
if (priv->bookmarks == NULL || priv->bookmark_path == NULL) {
|
||||
|
@ -344,8 +343,8 @@ plain_load_bookmarks(zathura_database_t* db, const char* file)
|
|||
}
|
||||
|
||||
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t)
|
||||
zathura_bookmarks_compare, (girara_free_function_t)
|
||||
zathura_bookmark_free);
|
||||
zathura_bookmarks_compare, (girara_free_function_t)
|
||||
zathura_bookmark_free);
|
||||
|
||||
gsize length;
|
||||
char** keys = g_key_file_get_keys(priv->bookmarks, name, &length, NULL);
|
||||
|
@ -372,7 +371,7 @@ plain_load_bookmarks(zathura_database_t* db, const char* file)
|
|||
|
||||
static bool
|
||||
plain_set_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
|
||||
file_info)
|
||||
file_info)
|
||||
{
|
||||
zathura_plaindatabase_private_t* priv = ZATHURA_PLAINDATABASE_GET_PRIVATE(db);
|
||||
if (priv->history == NULL || file_info == NULL || file == NULL) {
|
||||
|
@ -409,7 +408,7 @@ plain_set_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
|
|||
|
||||
static bool
|
||||
plain_get_fileinfo(zathura_database_t* db, const char* file, zathura_fileinfo_t*
|
||||
file_info)
|
||||
file_info)
|
||||
{
|
||||
if (db == NULL || file == NULL || file_info == NULL) {
|
||||
return false;
|
||||
|
@ -519,9 +518,9 @@ zathura_db_read_key_file_from_file(const char* path)
|
|||
|
||||
GError* error = NULL;
|
||||
if (g_key_file_load_from_data(key_file, content, contentlen,
|
||||
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error) ==
|
||||
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, &error) ==
|
||||
FALSE) {
|
||||
if (error->code != 1) /* ignore empty file */ {
|
||||
if (error->code != 1) { /* ignore empty file */
|
||||
free(content);
|
||||
g_key_file_free(key_file);
|
||||
g_error_free(error);
|
||||
|
@ -568,7 +567,7 @@ zathura_db_write_key_file_to_file(const char* file, GKeyFile* key_file)
|
|||
|
||||
static void
|
||||
cb_zathura_db_watch_file(GFileMonitor* UNUSED(monitor), GFile* file, GFile* UNUSED(other_file),
|
||||
GFileMonitorEvent event, zathura_database_t* database)
|
||||
GFileMonitorEvent event, zathura_database_t* database)
|
||||
{
|
||||
if (event != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT || database == NULL) {
|
||||
return;
|
||||
|
|
|
@ -10,21 +10,21 @@
|
|||
static void zathura_database_interface_init(ZathuraDatabaseInterface* iface);
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE(ZathuraSQLDatabase, zathura_sqldatabase, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE(ZATHURA_TYPE_DATABASE, zathura_database_interface_init))
|
||||
G_IMPLEMENT_INTERFACE(ZATHURA_TYPE_DATABASE, zathura_database_interface_init))
|
||||
|
||||
static void sqlite_finalize(GObject* object);
|
||||
static bool sqlite_add_bookmark(zathura_database_t* db, const char* file,
|
||||
zathura_bookmark_t* bookmark);
|
||||
zathura_bookmark_t* bookmark);
|
||||
static bool sqlite_remove_bookmark(zathura_database_t* db, const char* file,
|
||||
const char* id);
|
||||
const char* id);
|
||||
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,
|
||||
zathura_fileinfo_t* file_info);
|
||||
zathura_fileinfo_t* file_info);
|
||||
static bool sqlite_get_fileinfo(zathura_database_t* db, const char* file,
|
||||
zathura_fileinfo_t* file_info);
|
||||
zathura_fileinfo_t* file_info);
|
||||
static void sqlite_set_property(GObject* object, guint prop_id,
|
||||
const GValue* value, GParamSpec* pspec);
|
||||
const GValue* value, GParamSpec* pspec);
|
||||
|
||||
typedef struct zathura_sqldatabase_private_s {
|
||||
sqlite3* session;
|
||||
|
@ -33,8 +33,7 @@ typedef struct zathura_sqldatabase_private_s {
|
|||
#define ZATHURA_SQLDATABASE_GET_PRIVATE(obj) \
|
||||
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZATHURA_TYPE_SQLDATABASE, zathura_sqldatabase_private_t))
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_PATH
|
||||
};
|
||||
|
@ -62,7 +61,7 @@ zathura_sqldatabase_class_init(ZathuraSQLDatabaseClass* class)
|
|||
object_class->set_property = sqlite_set_property;
|
||||
|
||||
g_object_class_install_property(object_class, PROP_PATH,
|
||||
g_param_spec_string("path", "path", "path to the database", NULL, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||
g_param_spec_string("path", "path", "path to the database", NULL, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -107,23 +106,23 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
|
|||
/* create bookmarks database */
|
||||
static const char SQL_BOOKMARK_INIT[] =
|
||||
"CREATE TABLE IF NOT EXISTS bookmarks ("
|
||||
"file TEXT,"
|
||||
"id TEXT,"
|
||||
"page INTEGER,"
|
||||
"PRIMARY KEY(file, id));";
|
||||
"file TEXT,"
|
||||
"id TEXT,"
|
||||
"page INTEGER,"
|
||||
"PRIMARY KEY(file, id));";
|
||||
|
||||
static const char SQL_FILEINFO_INIT[] =
|
||||
"CREATE TABLE IF NOT EXISTS fileinfo ("
|
||||
"file TEXT PRIMARY KEY,"
|
||||
"page INTEGER,"
|
||||
"offset INTEGER,"
|
||||
"scale FLOAT,"
|
||||
"rotation INTEGER,"
|
||||
"pages_per_row INTEGER,"
|
||||
"first_page_column INTEGER,"
|
||||
"position_x FLOAT,"
|
||||
"position_y FLOAT"
|
||||
");";
|
||||
"file TEXT PRIMARY KEY,"
|
||||
"page INTEGER,"
|
||||
"offset INTEGER,"
|
||||
"scale FLOAT,"
|
||||
"rotation INTEGER,"
|
||||
"pages_per_row INTEGER,"
|
||||
"first_page_column INTEGER,"
|
||||
"position_x FLOAT,"
|
||||
"position_y FLOAT"
|
||||
");";
|
||||
|
||||
static const char SQL_FILEINFO_ALTER[] =
|
||||
"ALTER TABLE fileinfo ADD COLUMN pages_per_row INTEGER;"
|
||||
|
@ -211,7 +210,7 @@ prepare_statement(sqlite3* session, const char* statement)
|
|||
|
||||
static bool
|
||||
sqlite_add_bookmark(zathura_database_t* db, const char* file,
|
||||
zathura_bookmark_t* bookmark)
|
||||
zathura_bookmark_t* bookmark)
|
||||
{
|
||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
||||
|
||||
|
@ -239,7 +238,7 @@ sqlite_add_bookmark(zathura_database_t* db, const char* file,
|
|||
|
||||
static bool
|
||||
sqlite_remove_bookmark(zathura_database_t* db, const char* file, const char*
|
||||
id)
|
||||
id)
|
||||
{
|
||||
zathura_sqldatabase_private_t* priv = ZATHURA_SQLDATABASE_GET_PRIVATE(db);
|
||||
|
||||
|
@ -284,7 +283,7 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
|
|||
}
|
||||
|
||||
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
|
||||
(girara_free_function_t) zathura_bookmark_free);
|
||||
(girara_free_function_t) zathura_bookmark_free);
|
||||
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
|
||||
|
@ -302,7 +301,7 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
|
|||
|
||||
static bool
|
||||
sqlite_set_fileinfo(zathura_database_t* db, const char* file,
|
||||
zathura_fileinfo_t* file_info)
|
||||
zathura_fileinfo_t* file_info)
|
||||
{
|
||||
if (db == NULL || file == NULL || file_info == NULL) {
|
||||
return false;
|
||||
|
@ -340,7 +339,7 @@ sqlite_set_fileinfo(zathura_database_t* db, const char* file,
|
|||
|
||||
static bool
|
||||
sqlite_get_fileinfo(zathura_database_t* db, const char* file,
|
||||
zathura_fileinfo_t* file_info)
|
||||
zathura_fileinfo_t* file_info)
|
||||
{
|
||||
if (db == NULL || file == NULL || file_info == NULL) {
|
||||
return false;
|
||||
|
|
10
database.c
10
database.c
|
@ -21,7 +21,7 @@ zathura_db_free(zathura_database_t* db)
|
|||
|
||||
bool
|
||||
zathura_db_add_bookmark(zathura_database_t* db, const char* file,
|
||||
zathura_bookmark_t* bookmark)
|
||||
zathura_bookmark_t* bookmark)
|
||||
{
|
||||
g_return_val_if_fail(ZATHURA_IS_DATABASE(db) && file != NULL && bookmark != NULL, false);
|
||||
|
||||
|
@ -30,7 +30,7 @@ zathura_db_add_bookmark(zathura_database_t* db, const char* file,
|
|||
|
||||
bool
|
||||
zathura_db_remove_bookmark(zathura_database_t* db, const char* file, const char*
|
||||
id)
|
||||
id)
|
||||
{
|
||||
g_return_val_if_fail(ZATHURA_IS_DATABASE(db) && file != NULL && id != NULL, false);
|
||||
|
||||
|
@ -45,9 +45,9 @@ zathura_db_load_bookmarks(zathura_database_t* db, const char* file)
|
|||
return ZATHURA_DATABASE_GET_INTERFACE(db)->load_bookmarks(db, file);
|
||||
}
|
||||
|
||||
bool
|
||||
bool
|
||||
zathura_db_set_fileinfo(zathura_database_t* db, const char* file,
|
||||
zathura_fileinfo_t* file_info)
|
||||
zathura_fileinfo_t* file_info)
|
||||
{
|
||||
g_return_val_if_fail(ZATHURA_IS_DATABASE(db) && file != NULL && file_info != NULL, false);
|
||||
|
||||
|
@ -56,7 +56,7 @@ zathura_db_set_fileinfo(zathura_database_t* db, const char* file,
|
|||
|
||||
bool
|
||||
zathura_db_get_fileinfo(zathura_database_t* db, const char* file,
|
||||
zathura_fileinfo_t* file_info)
|
||||
zathura_fileinfo_t* file_info)
|
||||
{
|
||||
g_return_val_if_fail(ZATHURA_IS_DATABASE(db) && file != NULL && file_info != NULL, false);
|
||||
|
||||
|
|
|
@ -36,8 +36,7 @@ static const gchar* guess_type(const char* path);
|
|||
/**
|
||||
* Document
|
||||
*/
|
||||
struct zathura_document_s
|
||||
{
|
||||
struct zathura_document_s {
|
||||
char* file_path; /**< File path of the document */
|
||||
const char* password; /**< Password of the document */
|
||||
unsigned int current_page_number; /**< Current page number */
|
||||
|
@ -62,7 +61,7 @@ struct zathura_document_s
|
|||
|
||||
zathura_document_t*
|
||||
zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
|
||||
path, const char* password, zathura_error_t* error)
|
||||
path, const char* password, zathura_error_t* error)
|
||||
{
|
||||
if (path == NULL) {
|
||||
return NULL;
|
||||
|
|
13
links.c
13
links.c
|
@ -10,8 +10,7 @@
|
|||
#include "document.h"
|
||||
#include "utils.h"
|
||||
|
||||
struct zathura_link_s
|
||||
{
|
||||
struct zathura_link_s {
|
||||
zathura_rectangle_t position; /**< Position of the link */
|
||||
zathura_link_type_t type; /**< Link type */
|
||||
zathura_link_target_t target; /**< Link target */
|
||||
|
@ -23,7 +22,7 @@ static void link_launch(zathura_t* zathura, zathura_link_t* link);
|
|||
|
||||
zathura_link_t*
|
||||
zathura_link_new(zathura_link_type_t type, zathura_rectangle_t position,
|
||||
zathura_link_target_t target)
|
||||
zathura_link_target_t target)
|
||||
{
|
||||
zathura_link_t* link = g_malloc0(sizeof(zathura_link_t));
|
||||
|
||||
|
@ -130,12 +129,12 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
|
|||
|
||||
/* get page */
|
||||
zathura_page_t* page = zathura_document_get_page(zathura->document,
|
||||
link->target.page_number);
|
||||
link->target.page_number);
|
||||
if (page == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
zathura_document_set_current_page_number(zathura->document, link->target.page_number);
|
||||
zathura_document_set_current_page_number(zathura->document, link->target.page_number);
|
||||
|
||||
/* get page offset */
|
||||
page_offset_t offset;
|
||||
|
@ -152,8 +151,8 @@ zathura_link_evaluate(zathura_t* zathura, zathura_link_t* link)
|
|||
position_set_delayed(zathura, offset.x, offset.y);
|
||||
statusbar_page_number_update(zathura);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
92
marks.c
92
marks.c
|
@ -28,7 +28,7 @@ struct zathura_mark_s {
|
|||
|
||||
bool
|
||||
sc_mark_add(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, FALSE);
|
||||
g_return_val_if_fail(session->gtk.view != NULL, FALSE);
|
||||
|
@ -36,14 +36,14 @@ sc_mark_add(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
/* redirect signal handler */
|
||||
g_signal_handler_disconnect(G_OBJECT(session->gtk.view), session->signals.view_key_pressed);
|
||||
session->signals.view_key_pressed = g_signal_connect(G_OBJECT(session->gtk.view), "key-press-event",
|
||||
G_CALLBACK(cb_marks_view_key_press_event_add), session);
|
||||
G_CALLBACK(cb_marks_view_key_press_event_add), session);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
sc_mark_evaluate(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, FALSE);
|
||||
g_return_val_if_fail(session->gtk.view != NULL, FALSE);
|
||||
|
@ -51,14 +51,14 @@ sc_mark_evaluate(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
/* redirect signal handler */
|
||||
g_signal_handler_disconnect(G_OBJECT(session->gtk.view), session->signals.view_key_pressed);
|
||||
session->signals.view_key_pressed = g_signal_connect(G_OBJECT(session->gtk.view), "key-press-event",
|
||||
G_CALLBACK(cb_marks_view_key_press_event_evaluate), session);
|
||||
G_CALLBACK(cb_marks_view_key_press_event_evaluate), session);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
cb_marks_view_key_press_event_add(GtkWidget* UNUSED(widget), GdkEventKey* event,
|
||||
girara_session_t* session)
|
||||
girara_session_t* session)
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, FALSE);
|
||||
g_return_val_if_fail(session->gtk.view != NULL, FALSE);
|
||||
|
@ -68,11 +68,11 @@ cb_marks_view_key_press_event_add(GtkWidget* UNUSED(widget), GdkEventKey* event,
|
|||
/* reset signal handler */
|
||||
g_signal_handler_disconnect(G_OBJECT(session->gtk.view), session->signals.view_key_pressed);
|
||||
session->signals.view_key_pressed = g_signal_connect(G_OBJECT(session->gtk.view), "key-press-event",
|
||||
G_CALLBACK(girara_callback_view_key_press_event), session);
|
||||
G_CALLBACK(girara_callback_view_key_press_event), session);
|
||||
|
||||
/* evaluate key */
|
||||
if (((event->keyval >= 0x41 && event->keyval <= 0x5A) || (event->keyval >=
|
||||
0x61 && event->keyval <= 0x7A)) == false) {
|
||||
0x61 && event->keyval <= 0x7A)) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -92,11 +92,11 @@ bool cb_marks_view_key_press_event_evaluate(GtkWidget* UNUSED(widget), GdkEventK
|
|||
/* reset signal handler */
|
||||
g_signal_handler_disconnect(G_OBJECT(session->gtk.view), session->signals.view_key_pressed);
|
||||
session->signals.view_key_pressed = g_signal_connect(G_OBJECT(session->gtk.view), "key-press-event",
|
||||
G_CALLBACK(girara_callback_view_key_press_event), session);
|
||||
G_CALLBACK(girara_callback_view_key_press_event), session);
|
||||
|
||||
/* evaluate key */
|
||||
if (((event->keyval >= 0x41 && event->keyval <= 0x5A) || (event->keyval >=
|
||||
0x61 && event->keyval <= 0x7A)) == false) {
|
||||
0x61 && event->keyval <= 0x7A)) == false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ cmd_marks_add(girara_session_t* session, girara_list_t* argument_list)
|
|||
char key = key_string[0];
|
||||
|
||||
if (((key >= 0x41 && key <= 0x5A) || (key >=
|
||||
0x61 && key <= 0x7A)) == false) {
|
||||
0x61 && key <= 0x7A)) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -154,32 +154,32 @@ cmd_marks_delete(girara_session_t* session, girara_list_t* argument_list)
|
|||
}
|
||||
|
||||
GIRARA_LIST_FOREACH(argument_list, char*, iter, key_string)
|
||||
if (key_string == NULL) {
|
||||
if (key_string == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < strlen(key_string); i++) {
|
||||
char key = key_string[i];
|
||||
if (((key >= 0x41 && key <= 0x5A) || (key >=
|
||||
0x61 && key <= 0x7A)) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < strlen(key_string); i++) {
|
||||
char key = key_string[i];
|
||||
if (((key >= 0x41 && key <= 0x5A) || (key >=
|
||||
0x61 && key <= 0x7A)) == false) {
|
||||
/* search for existing mark */
|
||||
girara_list_iterator_t* mark_iter = girara_list_iterator(zathura->global.marks);
|
||||
do {
|
||||
zathura_mark_t* mark = (zathura_mark_t*) girara_list_iterator_data(mark_iter);
|
||||
if (mark == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* search for existing mark */
|
||||
girara_list_iterator_t* mark_iter = girara_list_iterator(zathura->global.marks);
|
||||
do {
|
||||
zathura_mark_t* mark = (zathura_mark_t*) girara_list_iterator_data(mark_iter);
|
||||
if (mark == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (mark->key == key) {
|
||||
girara_list_remove(zathura->global.marks, mark);
|
||||
continue;
|
||||
}
|
||||
} while (girara_list_iterator_next(mark_iter) != NULL);
|
||||
girara_list_iterator_free(mark_iter);
|
||||
}
|
||||
if (mark->key == key) {
|
||||
girara_list_remove(zathura->global.marks, mark);
|
||||
continue;
|
||||
}
|
||||
} while (girara_list_iterator_next(mark_iter) != NULL);
|
||||
girara_list_iterator_free(mark_iter);
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(argument_list, char*, iter, key_string);
|
||||
|
||||
return true;
|
||||
|
@ -206,12 +206,12 @@ mark_add(zathura_t* zathura, int key)
|
|||
|
||||
/* search for existing mark */
|
||||
GIRARA_LIST_FOREACH(zathura->global.marks, zathura_mark_t*, iter, mark)
|
||||
if (mark->key == key) {
|
||||
mark->position_x = position_x;
|
||||
mark->position_y = position_y;
|
||||
mark->scale = scale;
|
||||
return;
|
||||
}
|
||||
if (mark->key == key) {
|
||||
mark->position_x = position_x;
|
||||
mark->position_y = position_y;
|
||||
mark->scale = scale;
|
||||
return;
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(zathura->global.marks, zathura_mark_t*, iter, mark);
|
||||
|
||||
/* add new mark */
|
||||
|
@ -234,19 +234,19 @@ mark_evaluate(zathura_t* zathura, int key)
|
|||
|
||||
/* search for existing mark */
|
||||
GIRARA_LIST_FOREACH(zathura->global.marks, zathura_mark_t*, iter, mark)
|
||||
if (mark != NULL && mark->key == key) {
|
||||
double old_scale = zathura_document_get_scale(zathura->document);
|
||||
zathura_document_set_scale(zathura->document, mark->scale);
|
||||
readjust_view_after_zooming(zathura, old_scale, true);
|
||||
render_all(zathura);
|
||||
if (mark != NULL && mark->key == key) {
|
||||
double old_scale = zathura_document_get_scale(zathura->document);
|
||||
zathura_document_set_scale(zathura->document, mark->scale);
|
||||
readjust_view_after_zooming(zathura, old_scale, true);
|
||||
render_all(zathura);
|
||||
|
||||
position_set_delayed(zathura, mark->position_x, mark->position_y);
|
||||
position_set_delayed(zathura, mark->position_x, mark->position_y);
|
||||
|
||||
cb_view_vadjustment_value_changed(NULL, zathura);
|
||||
cb_view_vadjustment_value_changed(NULL, zathura);
|
||||
|
||||
zathura->global.update_page_number = true;
|
||||
return;
|
||||
}
|
||||
zathura->global.update_page_number = true;
|
||||
return;
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(zathura->global.marks, zathura_mark_t*, iter, mark);
|
||||
}
|
||||
|
||||
|
|
127
page-widget.c
127
page-widget.c
|
@ -74,8 +74,7 @@ static gboolean cb_zathura_page_widget_popup_menu(GtkWidget* widget);
|
|||
static void cb_menu_image_copy(GtkMenuItem* item, ZathuraPage* page);
|
||||
static void cb_menu_image_save(GtkMenuItem* item, ZathuraPage* page);
|
||||
|
||||
enum properties_e
|
||||
{
|
||||
enum properties_e {
|
||||
PROP_0,
|
||||
PROP_PAGE,
|
||||
PROP_ZATHURA,
|
||||
|
@ -115,25 +114,25 @@ zathura_page_widget_class_init(ZathuraPageClass* class)
|
|||
|
||||
/* add properties */
|
||||
g_object_class_install_property(object_class, PROP_PAGE,
|
||||
g_param_spec_pointer("page", "page", "the page to draw", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||
g_param_spec_pointer("page", "page", "the page to draw", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property(object_class, PROP_ZATHURA,
|
||||
g_param_spec_pointer("zathura", "zathura", "the zathura instance", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||
g_param_spec_pointer("zathura", "zathura", "the zathura instance", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property(object_class, PROP_DRAW_LINKS,
|
||||
g_param_spec_boolean("draw-links", "draw-links", "Set to true if links should be drawn", FALSE, G_PARAM_WRITABLE));
|
||||
g_param_spec_boolean("draw-links", "draw-links", "Set to true if links should be drawn", FALSE, G_PARAM_WRITABLE));
|
||||
g_object_class_install_property(object_class, PROP_LINKS_OFFSET,
|
||||
g_param_spec_int("offset-links", "offset-links", "Offset for the link numbers", 0, INT_MAX, 0, G_PARAM_WRITABLE));
|
||||
g_param_spec_int("offset-links", "offset-links", "Offset for the link numbers", 0, INT_MAX, 0, G_PARAM_WRITABLE));
|
||||
g_object_class_install_property(object_class, PROP_LINKS_NUMBER,
|
||||
g_param_spec_int("number-of-links", "number-of-links", "Number of links", 0, INT_MAX, 0, G_PARAM_READABLE));
|
||||
g_param_spec_int("number-of-links", "number-of-links", "Number of links", 0, INT_MAX, 0, G_PARAM_READABLE));
|
||||
g_object_class_install_property(object_class, PROP_SEARCH_RESULTS,
|
||||
g_param_spec_pointer("search-results", "search-results", "Set to the list of search results", G_PARAM_WRITABLE | G_PARAM_READABLE));
|
||||
g_param_spec_pointer("search-results", "search-results", "Set to the list of search results", G_PARAM_WRITABLE | G_PARAM_READABLE));
|
||||
g_object_class_install_property(object_class, PROP_SEARCH_RESULTS_CURRENT,
|
||||
g_param_spec_int("search-current", "search-current", "The current search result", -1, INT_MAX, 0, G_PARAM_WRITABLE | G_PARAM_READABLE));
|
||||
g_param_spec_int("search-current", "search-current", "The current search result", -1, INT_MAX, 0, G_PARAM_WRITABLE | G_PARAM_READABLE));
|
||||
g_object_class_install_property(object_class, PROP_SEARCH_RESULTS_LENGTH,
|
||||
g_param_spec_int("search-length", "search-length", "The number of search results", -1, INT_MAX, 0, G_PARAM_READABLE));
|
||||
g_param_spec_int("search-length", "search-length", "The number of search results", -1, INT_MAX, 0, G_PARAM_READABLE));
|
||||
g_object_class_install_property(object_class, PROP_DRAW_SEACH_RESULTS,
|
||||
g_param_spec_boolean("draw-search-results", "draw-search-results", "Set to true if search results should be drawn", FALSE, G_PARAM_WRITABLE));
|
||||
g_param_spec_boolean("draw-search-results", "draw-search-results", "Set to true if search results should be drawn", FALSE, G_PARAM_WRITABLE));
|
||||
g_object_class_install_property(object_class, PROP_LAST_VIEW,
|
||||
g_param_spec_int("last-view", "last-view", "Last time the page has been viewed", -1, INT_MAX, 0, G_PARAM_READABLE));
|
||||
g_param_spec_int("last-view", "last-view", "Last time the page has been viewed", -1, INT_MAX, 0, G_PARAM_READABLE));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -167,7 +166,7 @@ zathura_page_widget_init(ZathuraPage* widget)
|
|||
|
||||
/* we want mouse events */
|
||||
gtk_widget_add_events(GTK_WIDGET(widget),
|
||||
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK);
|
||||
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK);
|
||||
}
|
||||
|
||||
GtkWidget*
|
||||
|
@ -225,10 +224,10 @@ zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* v
|
|||
|
||||
if (priv->links.retrieved == true && priv->links.list != NULL) {
|
||||
GIRARA_LIST_FOREACH(priv->links.list, zathura_link_t*, iter, link)
|
||||
if (link != NULL) {
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
||||
redraw_rect(pageview, &rectangle);
|
||||
}
|
||||
if (link != NULL) {
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
||||
redraw_rect(pageview, &rectangle);
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(priv->links.list, zathura_link_t*, iter, link);
|
||||
}
|
||||
break;
|
||||
|
@ -381,24 +380,24 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
|||
if (priv->links.draw == true && priv->links.n != 0) {
|
||||
unsigned int link_counter = 0;
|
||||
GIRARA_LIST_FOREACH(priv->links.list, zathura_link_t*, iter, link)
|
||||
if (link != NULL) {
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
||||
if (link != NULL) {
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
||||
|
||||
/* draw position */
|
||||
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
||||
cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency);
|
||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
||||
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
||||
cairo_fill(cairo);
|
||||
/* draw position */
|
||||
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
||||
cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency);
|
||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
||||
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
||||
cairo_fill(cairo);
|
||||
|
||||
/* draw text */
|
||||
cairo_set_source_rgba(cairo, 0, 0, 0, 1);
|
||||
cairo_set_font_size(cairo, 10);
|
||||
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
|
||||
char* link_number = g_strdup_printf("%i", priv->links.offset + ++link_counter);
|
||||
cairo_show_text(cairo, link_number);
|
||||
g_free(link_number);
|
||||
}
|
||||
/* draw text */
|
||||
cairo_set_source_rgba(cairo, 0, 0, 0, 1);
|
||||
cairo_set_font_size(cairo, 10);
|
||||
cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1);
|
||||
char* link_number = g_strdup_printf("%i", priv->links.offset + ++link_counter);
|
||||
cairo_show_text(cairo, link_number);
|
||||
g_free(link_number);
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(priv->links.list, zathura_link_t*, iter, link);
|
||||
}
|
||||
|
||||
|
@ -406,20 +405,20 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
|||
if (priv->search.list != NULL && priv->search.draw == true) {
|
||||
int idx = 0;
|
||||
GIRARA_LIST_FOREACH(priv->search.list, zathura_rectangle_t*, iter, rect)
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
||||
|
||||
/* draw position */
|
||||
if (idx == priv->search.current) {
|
||||
GdkColor color = priv->zathura->ui.colors.highlight_color_active;
|
||||
cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency);
|
||||
} else {
|
||||
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
||||
cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency);
|
||||
}
|
||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
||||
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
||||
cairo_fill(cairo);
|
||||
++idx;
|
||||
/* draw position */
|
||||
if (idx == priv->search.current) {
|
||||
GdkColor color = priv->zathura->ui.colors.highlight_color_active;
|
||||
cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency);
|
||||
} else {
|
||||
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
||||
cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency);
|
||||
}
|
||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
||||
(rectangle.x2 - rectangle.x1), (rectangle.y2 - rectangle.y1));
|
||||
cairo_fill(cairo);
|
||||
++idx;
|
||||
GIRARA_LIST_FOREACH_END(priv->search.list, zathura_rectangle_t*, iter, rect);
|
||||
}
|
||||
/* draw selection */
|
||||
|
@ -427,7 +426,7 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
|
|||
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
||||
cairo_set_source_rgba(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0, transparency);
|
||||
cairo_rectangle(cairo, priv->mouse.selection.x1, priv->mouse.selection.y1,
|
||||
(priv->mouse.selection.x2 - priv->mouse.selection.x1), (priv->mouse.selection.y2 - priv->mouse.selection.y1));
|
||||
(priv->mouse.selection.x2 - priv->mouse.selection.x1), (priv->mouse.selection.y2 - priv->mouse.selection.y1));
|
||||
cairo_fill(cairo);
|
||||
}
|
||||
} else {
|
||||
|
@ -503,7 +502,7 @@ zathura_page_widget_size_allocate(GtkWidget* widget, GdkRectangle* allocation)
|
|||
static void
|
||||
redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle)
|
||||
{
|
||||
/* cause the rect to be drawn */
|
||||
/* cause the rect to be drawn */
|
||||
GdkRectangle grect;
|
||||
grect.x = rectangle->x1;
|
||||
grect.y = rectangle->y1;
|
||||
|
@ -522,8 +521,8 @@ redraw_all_rects(ZathuraPage* widget, girara_list_t* rectangles)
|
|||
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
|
||||
|
||||
GIRARA_LIST_FOREACH(rectangles, zathura_rectangle_t*, iter, rect)
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
||||
redraw_rect(widget, &rectangle);
|
||||
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
||||
redraw_rect(widget, &rectangle);
|
||||
GIRARA_LIST_FOREACH_END(rectangles, zathura_recantgle_t*, iter, rect);
|
||||
}
|
||||
|
||||
|
@ -607,11 +606,11 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b
|
|||
|
||||
if (priv->links.list != NULL && priv->links.n > 0) {
|
||||
GIRARA_LIST_FOREACH(priv->links.list, zathura_link_t*, iter, link)
|
||||
zathura_rectangle_t rect = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
||||
if (rect.x1 <= button->x && rect.x2 >= button->x
|
||||
&& rect.y1 <= button->y && rect.y2 >= button->y) {
|
||||
zathura_link_evaluate(priv->zathura, link);
|
||||
}
|
||||
zathura_rectangle_t rect = recalc_rectangle(priv->page, zathura_link_get_position(link));
|
||||
if (rect.x1 <= button->x && rect.x2 >= button->x
|
||||
&& rect.y1 <= button->y && rect.y2 >= button->y) {
|
||||
zathura_link_evaluate(priv->zathura, link);
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(priv->links.list, zathura_link_t*, iter, link);
|
||||
}
|
||||
} else {
|
||||
|
@ -721,10 +720,10 @@ zathura_page_widget_popup_menu(GtkWidget* widget, GdkEventButton* event)
|
|||
/* search for underlaying image */
|
||||
zathura_image_t* image = NULL;
|
||||
GIRARA_LIST_FOREACH(priv->images.list, zathura_image_t*, iter, image_it)
|
||||
zathura_rectangle_t rect = recalc_rectangle(priv->page, image_it->position);
|
||||
if (rect.x1 <= event->x && rect.x2 >= event->x && rect.y1 <= event->y && rect.y2 >= event->y) {
|
||||
image = image_it;
|
||||
}
|
||||
zathura_rectangle_t rect = recalc_rectangle(priv->page, image_it->position);
|
||||
if (rect.x1 <= event->x && rect.x2 >= event->x && rect.y1 <= event->y && rect.y2 >= event->y) {
|
||||
image = image_it;
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(priv->images.list, zathura_image_t*, iter, image_it);
|
||||
|
||||
if (image == NULL) {
|
||||
|
@ -799,7 +798,7 @@ cb_menu_image_copy(GtkMenuItem* item, ZathuraPage* page)
|
|||
cairo_destroy(cairo);
|
||||
|
||||
GdkPixbuf* pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0,
|
||||
0, width, height);
|
||||
0, width, height);
|
||||
|
||||
gtk_clipboard_set_image(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD), pixbuf);
|
||||
gtk_clipboard_set_image(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pixbuf);
|
||||
|
@ -823,11 +822,11 @@ cb_menu_image_save(GtkMenuItem* item, ZathuraPage* page)
|
|||
unsigned int image_id = 1;
|
||||
|
||||
GIRARA_LIST_FOREACH(priv->images.list, zathura_image_t*, iter, image_it)
|
||||
if (image_it == priv->images.current) {
|
||||
break;
|
||||
}
|
||||
if (image_it == priv->images.current) {
|
||||
break;
|
||||
}
|
||||
|
||||
image_id++;
|
||||
image_id++;
|
||||
GIRARA_LIST_FOREACH_END(priv->images.list, zathura_image_t*, iter, image_it);
|
||||
|
||||
/* set command */
|
||||
|
|
226
plugin.c
226
plugin.c
|
@ -14,8 +14,7 @@
|
|||
/**
|
||||
* Document plugin structure
|
||||
*/
|
||||
struct zathura_plugin_s
|
||||
{
|
||||
struct zathura_plugin_s {
|
||||
girara_list_t* content_types; /**< List of supported content types */
|
||||
zathura_plugin_register_function_t register_function; /**< Document open function */
|
||||
zathura_plugin_functions_t functions; /**< Document functions */
|
||||
|
@ -28,8 +27,7 @@ struct zathura_plugin_s
|
|||
/**
|
||||
* Plugin mapping
|
||||
*/
|
||||
typedef struct zathura_type_plugin_mapping_s
|
||||
{
|
||||
typedef struct zathura_type_plugin_mapping_s {
|
||||
const gchar* type; /**< Plugin type */
|
||||
zathura_plugin_t* plugin; /**< Mapped plugin */
|
||||
} zathura_type_plugin_mapping_t;
|
||||
|
@ -37,8 +35,7 @@ typedef struct zathura_type_plugin_mapping_s
|
|||
/**
|
||||
* Plugin manager
|
||||
*/
|
||||
struct zathura_plugin_manager_s
|
||||
{
|
||||
struct zathura_plugin_manager_s {
|
||||
girara_list_t* plugins; /**< List of plugins */
|
||||
girara_list_t* path; /**< List of plugin paths */
|
||||
girara_list_t* type_plugin_mapping; /**< List of type -> plugin mappings */
|
||||
|
@ -91,120 +88,117 @@ zathura_plugin_manager_load(zathura_plugin_manager_t* plugin_manager)
|
|||
}
|
||||
|
||||
GIRARA_LIST_FOREACH(plugin_manager->path, char*, iter, plugindir)
|
||||
/* read all files in the plugin directory */
|
||||
GDir* dir = g_dir_open(plugindir, 0, NULL);
|
||||
if (dir == NULL) {
|
||||
girara_error("could not open plugin directory: %s", plugindir);
|
||||
girara_list_iterator_next(iter);
|
||||
/* read all files in the plugin directory */
|
||||
GDir* dir = g_dir_open(plugindir, 0, NULL);
|
||||
if (dir == NULL) {
|
||||
girara_error("could not open plugin directory: %s", plugindir);
|
||||
girara_list_iterator_next(iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
char* name = NULL;
|
||||
while ((name = (char*) g_dir_read_name(dir)) != NULL) {
|
||||
char* path = g_build_filename(plugindir, name, NULL);
|
||||
if (g_file_test(path, G_FILE_TEST_IS_REGULAR) == 0) {
|
||||
girara_info("%s is not a regular file. Skipping.", path);
|
||||
g_free(path);
|
||||
continue;
|
||||
}
|
||||
|
||||
char* name = NULL;
|
||||
while ((name = (char*) g_dir_read_name(dir)) != NULL) {
|
||||
char* path = g_build_filename(plugindir, name, NULL);
|
||||
if (g_file_test(path, G_FILE_TEST_IS_REGULAR) == 0) {
|
||||
girara_info("%s is not a regular file. Skipping.", path);
|
||||
g_free(path);
|
||||
continue;
|
||||
}
|
||||
zathura_plugin_t* plugin = NULL;
|
||||
|
||||
zathura_plugin_t* plugin = NULL;
|
||||
/* load plugin */
|
||||
GModule* handle = g_module_open(path, G_MODULE_BIND_LOCAL);
|
||||
if (handle == NULL) {
|
||||
girara_error("could not load plugin %s (%s)", path, g_module_error());
|
||||
g_free(path);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* load plugin */
|
||||
GModule* handle = g_module_open(path, G_MODULE_BIND_LOCAL);
|
||||
if (handle == NULL) {
|
||||
girara_error("could not load plugin %s (%s)", path, g_module_error());
|
||||
g_free(path);
|
||||
continue;
|
||||
}
|
||||
/* resolve symbols and check API and ABI version*/
|
||||
zathura_plugin_api_version_t api_version = NULL;
|
||||
if (g_module_symbol(handle, PLUGIN_API_VERSION_FUNCTION, (gpointer*) &api_version) == FALSE ||
|
||||
api_version == NULL) {
|
||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_API_VERSION_FUNCTION, path);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* resolve symbols and check API and ABI version*/
|
||||
zathura_plugin_api_version_t api_version = NULL;
|
||||
if (g_module_symbol(handle, PLUGIN_API_VERSION_FUNCTION, (gpointer*) &api_version) == FALSE ||
|
||||
api_version == NULL)
|
||||
{
|
||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_API_VERSION_FUNCTION, path);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
if (api_version() != ZATHURA_API_VERSION) {
|
||||
girara_error("plugin %s has been built againt zathura with a different API version (plugin: %d, zathura: %d)",
|
||||
path, api_version(), ZATHURA_API_VERSION);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (api_version() != ZATHURA_API_VERSION) {
|
||||
girara_error("plugin %s has been built againt zathura with a different API version (plugin: %d, zathura: %d)",
|
||||
path, api_version(), ZATHURA_API_VERSION);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
zathura_plugin_abi_version_t abi_version = NULL;
|
||||
if (g_module_symbol(handle, PLUGIN_ABI_VERSION_FUNCTION, (gpointer*) &abi_version) == FALSE ||
|
||||
abi_version == NULL) {
|
||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_ABI_VERSION_FUNCTION, path);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
zathura_plugin_abi_version_t abi_version = NULL;
|
||||
if (g_module_symbol(handle, PLUGIN_ABI_VERSION_FUNCTION, (gpointer*) &abi_version) == FALSE ||
|
||||
abi_version == NULL)
|
||||
{
|
||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_ABI_VERSION_FUNCTION, path);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
if (abi_version() != ZATHURA_ABI_VERSION) {
|
||||
girara_error("plugin %s has been built againt zathura with a different ABI version (plugin: %d, zathura: %d)",
|
||||
path, abi_version(), ZATHURA_ABI_VERSION);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (abi_version() != ZATHURA_ABI_VERSION) {
|
||||
girara_error("plugin %s has been built againt zathura with a different ABI version (plugin: %d, zathura: %d)",
|
||||
path, abi_version(), ZATHURA_ABI_VERSION);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
zathura_plugin_register_service_t register_service = NULL;
|
||||
if (g_module_symbol(handle, PLUGIN_REGISTER_FUNCTION, (gpointer*) ®ister_service) == FALSE ||
|
||||
register_service == NULL) {
|
||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_REGISTER_FUNCTION, path);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
zathura_plugin_register_service_t register_service = NULL;
|
||||
if (g_module_symbol(handle, PLUGIN_REGISTER_FUNCTION, (gpointer*) ®ister_service) == FALSE ||
|
||||
register_service == NULL)
|
||||
{
|
||||
girara_error("could not find '%s' function in plugin %s", PLUGIN_REGISTER_FUNCTION, path);
|
||||
g_free(path);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
plugin = g_malloc0(sizeof(zathura_plugin_t));
|
||||
plugin->content_types = girara_list_new2(g_free);
|
||||
plugin->handle = handle;
|
||||
|
||||
plugin = g_malloc0(sizeof(zathura_plugin_t));
|
||||
plugin->content_types = girara_list_new2(g_free);
|
||||
plugin->handle = handle;
|
||||
register_service(plugin);
|
||||
|
||||
register_service(plugin);
|
||||
/* register functions */
|
||||
if (plugin->register_function == NULL) {
|
||||
girara_error("plugin has no document functions register function");
|
||||
g_free(path);
|
||||
g_free(plugin);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* register functions */
|
||||
if (plugin->register_function == NULL) {
|
||||
girara_error("plugin has no document functions register function");
|
||||
g_free(path);
|
||||
g_free(plugin);
|
||||
g_module_close(handle);
|
||||
continue;
|
||||
}
|
||||
plugin->register_function(&(plugin->functions));
|
||||
plugin->path = path;
|
||||
|
||||
plugin->register_function(&(plugin->functions));
|
||||
plugin->path = path;
|
||||
bool ret = register_plugin(plugin_manager, plugin);
|
||||
if (ret == false) {
|
||||
girara_error("could not register plugin %s", path);
|
||||
zathura_plugin_free(plugin);
|
||||
} else {
|
||||
girara_info("successfully loaded plugin %s", path);
|
||||
|
||||
bool ret = register_plugin(plugin_manager, plugin);
|
||||
if (ret == false) {
|
||||
girara_error("could not register plugin %s", path);
|
||||
zathura_plugin_free(plugin);
|
||||
} else {
|
||||
girara_info("successfully loaded plugin %s", path);
|
||||
|
||||
zathura_plugin_version_function_t plugin_major = NULL, plugin_minor = NULL, plugin_rev = NULL;
|
||||
g_module_symbol(handle, PLUGIN_VERSION_MAJOR_FUNCTION, (gpointer*) &plugin_major);
|
||||
g_module_symbol(handle, PLUGIN_VERSION_MINOR_FUNCTION, (gpointer*) &plugin_minor);
|
||||
g_module_symbol(handle, PLUGIN_VERSION_REVISION_FUNCTION, (gpointer*) &plugin_rev);
|
||||
if (plugin_major != NULL && plugin_minor != NULL && plugin_rev != NULL) {
|
||||
plugin->version.major = plugin_major();
|
||||
plugin->version.minor = plugin_minor();
|
||||
plugin->version.rev = plugin_rev();
|
||||
girara_debug("plugin '%s': version %u.%u.%u", path,
|
||||
plugin->version.major, plugin->version.minor,
|
||||
plugin->version.rev);
|
||||
}
|
||||
zathura_plugin_version_function_t plugin_major = NULL, plugin_minor = NULL, plugin_rev = NULL;
|
||||
g_module_symbol(handle, PLUGIN_VERSION_MAJOR_FUNCTION, (gpointer*) &plugin_major);
|
||||
g_module_symbol(handle, PLUGIN_VERSION_MINOR_FUNCTION, (gpointer*) &plugin_minor);
|
||||
g_module_symbol(handle, PLUGIN_VERSION_REVISION_FUNCTION, (gpointer*) &plugin_rev);
|
||||
if (plugin_major != NULL && plugin_minor != NULL && plugin_rev != NULL) {
|
||||
plugin->version.major = plugin_major();
|
||||
plugin->version.minor = plugin_minor();
|
||||
plugin->version.rev = plugin_rev();
|
||||
girara_debug("plugin '%s': version %u.%u.%u", path,
|
||||
plugin->version.major, plugin->version.minor,
|
||||
plugin->version.rev);
|
||||
}
|
||||
}
|
||||
g_dir_close(dir);
|
||||
}
|
||||
g_dir_close(dir);
|
||||
GIRARA_LIST_FOREACH_END(zathura->plugins.path, char*, iter, plugindir);
|
||||
}
|
||||
|
||||
|
@ -217,10 +211,10 @@ zathura_plugin_manager_get_plugin(zathura_plugin_manager_t* plugin_manager, cons
|
|||
|
||||
zathura_plugin_t* plugin = NULL;
|
||||
GIRARA_LIST_FOREACH(plugin_manager->type_plugin_mapping, zathura_type_plugin_mapping_t*, iter, mapping)
|
||||
if (g_content_type_equals(type, mapping->type)) {
|
||||
plugin = mapping->plugin;
|
||||
break;
|
||||
}
|
||||
if (g_content_type_equals(type, mapping->type)) {
|
||||
plugin = mapping->plugin;
|
||||
break;
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(plugin_manager->type_plugin_mapping, zathura_type_plugin_mapping_t*, iter, mapping);
|
||||
|
||||
return plugin;
|
||||
|
@ -272,11 +266,11 @@ register_plugin(zathura_plugin_manager_t* plugin_manager, zathura_plugin_t* plug
|
|||
|
||||
bool at_least_one = false;
|
||||
GIRARA_LIST_FOREACH(plugin->content_types, gchar*, iter, type)
|
||||
if (plugin_mapping_new(plugin_manager, type, plugin) == false) {
|
||||
girara_error("plugin: already registered for filetype %s\n", type);
|
||||
} else {
|
||||
at_least_one = true;
|
||||
}
|
||||
if (plugin_mapping_new(plugin_manager, type, plugin) == false) {
|
||||
girara_error("plugin: already registered for filetype %s\n", type);
|
||||
} else {
|
||||
at_least_one = true;
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(plugin->content_types, gchar*, iter, type);
|
||||
|
||||
if (at_least_one == true) {
|
||||
|
@ -294,10 +288,10 @@ plugin_mapping_new(zathura_plugin_manager_t* plugin_manager, const gchar* type,
|
|||
g_return_val_if_fail(plugin != NULL, false);
|
||||
|
||||
GIRARA_LIST_FOREACH(plugin_manager->type_plugin_mapping, zathura_type_plugin_mapping_t*, iter, mapping)
|
||||
if (g_content_type_equals(type, mapping->type)) {
|
||||
girara_list_iterator_free(iter);
|
||||
return false;
|
||||
}
|
||||
if (g_content_type_equals(type, mapping->type)) {
|
||||
girara_list_iterator_free(iter);
|
||||
return false;
|
||||
}
|
||||
GIRARA_LIST_FOREACH_END(plugin_manager->type_plugin_mapping, zathura_type_plugin_mapping_t*, iter, mapping);
|
||||
|
||||
zathura_type_plugin_mapping_t* mapping = g_malloc(sizeof(zathura_type_plugin_mapping_t));
|
||||
|
|
22
print.c
22
print.c
|
@ -9,12 +9,12 @@
|
|||
#include <girara/statusbar.h>
|
||||
|
||||
static void cb_print_draw_page(GtkPrintOperation* print_operation,
|
||||
GtkPrintContext* context, gint page_number, zathura_t* zathura);
|
||||
GtkPrintContext* context, gint page_number, zathura_t* zathura);
|
||||
static void cb_print_end(GtkPrintOperation* print_operation, GtkPrintContext*
|
||||
context, zathura_t* zathura);
|
||||
context, zathura_t* zathura);
|
||||
static void cb_print_request_page_setup(GtkPrintOperation* print_operation,
|
||||
GtkPrintContext* context, gint page_number, GtkPageSetup* setup, zathura_t*
|
||||
zathura);
|
||||
GtkPrintContext* context, gint page_number, GtkPageSetup* setup, zathura_t*
|
||||
zathura);
|
||||
|
||||
void
|
||||
print(zathura_t* zathura)
|
||||
|
@ -45,7 +45,7 @@ print(zathura_t* zathura)
|
|||
|
||||
/* print */
|
||||
GtkPrintOperationResult result = gtk_print_operation_run(print_operation,
|
||||
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL);
|
||||
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL);
|
||||
|
||||
if (result == GTK_PRINT_OPERATION_RESULT_APPLY) {
|
||||
if (zathura->print.settings != NULL) {
|
||||
|
@ -67,7 +67,7 @@ print(zathura_t* zathura)
|
|||
|
||||
static void
|
||||
cb_print_end(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
||||
UNUSED(context), zathura_t* zathura)
|
||||
UNUSED(context), zathura_t* zathura)
|
||||
{
|
||||
if (zathura == NULL || zathura->ui.session == NULL || zathura->document == NULL) {
|
||||
return;
|
||||
|
@ -77,13 +77,13 @@ cb_print_end(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
|||
|
||||
if (file_path != NULL) {
|
||||
girara_statusbar_item_set_text(zathura->ui.session,
|
||||
zathura->ui.statusbar.file, file_path);
|
||||
zathura->ui.statusbar.file, file_path);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cb_print_draw_page(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
||||
context, gint page_number, zathura_t* zathura)
|
||||
context, gint page_number, zathura_t* zathura)
|
||||
{
|
||||
if (context == NULL || zathura == NULL || zathura->document == NULL ||
|
||||
zathura->ui.session == NULL || zathura->ui.statusbar.file == NULL) {
|
||||
|
@ -93,7 +93,7 @@ cb_print_draw_page(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
|||
/* update statusbar */
|
||||
char* tmp = g_strdup_printf("Printing %d...", page_number);
|
||||
girara_statusbar_item_set_text(zathura->ui.session,
|
||||
zathura->ui.statusbar.file, tmp);
|
||||
zathura->ui.statusbar.file, tmp);
|
||||
g_free(tmp);
|
||||
|
||||
/* render page */
|
||||
|
@ -111,8 +111,8 @@ cb_print_draw_page(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
|||
|
||||
static void
|
||||
cb_print_request_page_setup(GtkPrintOperation* UNUSED(print_operation),
|
||||
GtkPrintContext* UNUSED(context), gint page_number, GtkPageSetup* setup,
|
||||
zathura_t* zathura)
|
||||
GtkPrintContext* UNUSED(context), gint page_number, GtkPageSetup* setup,
|
||||
zathura_t* zathura)
|
||||
{
|
||||
if (zathura == NULL || zathura->document == NULL) {
|
||||
return;
|
||||
|
|
3
render.c
3
render.c
|
@ -17,8 +17,7 @@ static void render_job(void* data, void* user_data);
|
|||
static bool render(zathura_t* zathura, zathura_page_t* page);
|
||||
static gint render_thread_sort(gconstpointer a, gconstpointer b, gpointer data);
|
||||
|
||||
struct render_thread_s
|
||||
{
|
||||
struct render_thread_s {
|
||||
GThreadPool* pool; /**< Pool of threads */
|
||||
GStaticMutex mutex; /**< Render lock */
|
||||
bool about_to_close; /**< Render thread is to be freed */
|
||||
|
|
52
shortcuts.c
52
shortcuts.c
|
@ -20,7 +20,7 @@
|
|||
|
||||
bool
|
||||
sc_abort(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -52,7 +52,7 @@ sc_abort(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
|
||||
bool
|
||||
sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -173,7 +173,7 @@ error_ret:
|
|||
|
||||
bool
|
||||
sc_change_mode(girara_session_t* session, girara_argument_t* argument,
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
|
||||
|
@ -238,7 +238,7 @@ sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara
|
|||
|
||||
bool
|
||||
sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -332,14 +332,14 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e
|
|||
GtkAdjustment* y_adj = NULL;
|
||||
|
||||
switch (event->type) {
|
||||
/* scroll */
|
||||
/* scroll */
|
||||
case GIRARA_EVENT_SCROLL_UP:
|
||||
case GIRARA_EVENT_SCROLL_DOWN:
|
||||
case GIRARA_EVENT_SCROLL_LEFT:
|
||||
case GIRARA_EVENT_SCROLL_RIGHT:
|
||||
return sc_scroll(session, argument, NULL, t);
|
||||
|
||||
/* drag */
|
||||
/* drag */
|
||||
case GIRARA_EVENT_BUTTON_PRESS:
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
|
@ -360,7 +360,7 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e
|
|||
set_adjustment(y_adj, gtk_adjustment_get_value(y_adj) - (event->y - y));
|
||||
break;
|
||||
|
||||
/* unhandled events */
|
||||
/* unhandled events */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_eve
|
|||
|
||||
bool
|
||||
sc_navigate(girara_session_t* session, girara_argument_t* argument,
|
||||
girara_event_t* UNUSED(event), unsigned int t)
|
||||
girara_event_t* UNUSED(event), unsigned int t)
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -446,7 +446,7 @@ sc_navigate(girara_session_t* session, girara_argument_t* argument,
|
|||
|
||||
bool
|
||||
sc_print(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -464,7 +464,7 @@ sc_print(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
|
||||
bool
|
||||
sc_recolor(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
|
||||
|
@ -478,7 +478,7 @@ sc_recolor(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
|
||||
bool
|
||||
sc_reload(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -499,7 +499,7 @@ sc_reload(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
|
||||
bool
|
||||
sc_rotate(girara_session_t* session, girara_argument_t* argument,
|
||||
girara_event_t* UNUSED(event), unsigned int t)
|
||||
girara_event_t* UNUSED(event), unsigned int t)
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -532,7 +532,7 @@ sc_rotate(girara_session_t* session, girara_argument_t* argument,
|
|||
|
||||
bool
|
||||
sc_scroll(girara_session_t* session, girara_argument_t* argument,
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -544,7 +544,7 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
|
|||
|
||||
GtkAdjustment* adjustment = NULL;
|
||||
if ( (argument->n == LEFT) || (argument->n == FULL_LEFT) || (argument->n == HALF_LEFT) ||
|
||||
(argument->n == RIGHT) || (argument->n == FULL_RIGHT) || (argument->n == HALF_RIGHT)) {
|
||||
(argument->n == RIGHT) || (argument->n == FULL_RIGHT) || (argument->n == HALF_RIGHT)) {
|
||||
adjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
|
||||
} else {
|
||||
adjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
|
||||
|
@ -704,7 +704,7 @@ sc_jumplist(girara_session_t* session, girara_argument_t* argument, girara_event
|
|||
|
||||
bool
|
||||
sc_search(girara_session_t* session, girara_argument_t* argument,
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -730,7 +730,7 @@ sc_search(girara_session_t* session, girara_argument_t* argument,
|
|||
|
||||
int num_search_results = 0, current = -1;
|
||||
g_object_get(page_widget, "search-current", ¤t,
|
||||
"search-length", &num_search_results, NULL);
|
||||
"search-length", &num_search_results, NULL);
|
||||
if (num_search_results == 0 || current == -1) {
|
||||
continue;
|
||||
}
|
||||
|
@ -796,7 +796,7 @@ sc_search(girara_session_t* session, girara_argument_t* argument,
|
|||
|
||||
bool
|
||||
sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -833,7 +833,7 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
|
|||
gtk_tree_model_get_iter(model, &iter, path);
|
||||
/* select last child */
|
||||
gtk_tree_model_iter_nth_child(model, &child_iter, &iter,
|
||||
gtk_tree_model_iter_n_children(model, &iter)-1);
|
||||
gtk_tree_model_iter_n_children(model, &iter)-1);
|
||||
gtk_tree_path_free(path);
|
||||
path = gtk_tree_model_get_path(model, &child_iter);
|
||||
}
|
||||
|
@ -841,7 +841,7 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
|
|||
break;
|
||||
case COLLAPSE:
|
||||
if (gtk_tree_view_collapse_row(tree_view, path) == FALSE
|
||||
&& gtk_tree_path_get_depth(path) > 1) {
|
||||
&& gtk_tree_path_get_depth(path) > 1) {
|
||||
gtk_tree_path_up(path);
|
||||
gtk_tree_view_collapse_row(tree_view, path);
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
|
|||
break;
|
||||
}
|
||||
} while((is_valid_path = (gtk_tree_path_get_depth(path) > 1))
|
||||
&& gtk_tree_path_up(path));
|
||||
&& gtk_tree_path_up(path));
|
||||
}
|
||||
break;
|
||||
case EXPAND:
|
||||
|
@ -891,7 +891,7 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
|
|||
|
||||
bool
|
||||
sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -915,7 +915,7 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
}
|
||||
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(zathura->ui.index),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
|
||||
/* create index */
|
||||
document_index = zathura_document_index_generate(zathura->document, NULL);
|
||||
|
@ -1010,7 +1010,7 @@ error_ret:
|
|||
|
||||
bool
|
||||
sc_toggle_page_mode(girara_session_t* session, girara_argument_t*
|
||||
UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -1039,7 +1039,7 @@ sc_toggle_page_mode(girara_session_t* session, girara_argument_t*
|
|||
|
||||
bool
|
||||
sc_toggle_fullscreen(girara_session_t* session, girara_argument_t*
|
||||
UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
UNUSED(argument), girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
@ -1112,7 +1112,7 @@ sc_toggle_fullscreen(girara_session_t* session, girara_argument_t*
|
|||
|
||||
bool
|
||||
sc_quit(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
|
||||
|
@ -1126,7 +1126,7 @@ sc_quit(girara_session_t* session, girara_argument_t* UNUSED(argument),
|
|||
|
||||
bool
|
||||
sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
|
||||
UNUSED(event), unsigned int t)
|
||||
UNUSED(event), unsigned int t)
|
||||
{
|
||||
g_return_val_if_fail(session != NULL, false);
|
||||
g_return_val_if_fail(session->global.data != NULL, false);
|
||||
|
|
|
@ -103,7 +103,8 @@ synctex_record_hits(zathura_t* zathura, int page_idx, girara_list_t* hits, bool
|
|||
}
|
||||
|
||||
static double
|
||||
scan_float(GScanner* scanner) {
|
||||
scan_float(GScanner* scanner)
|
||||
{
|
||||
switch (g_scanner_get_next_token(scanner)) {
|
||||
case G_TOKEN_FLOAT:
|
||||
return g_scanner_cur_value(scanner).v_float;
|
||||
|
|
4
types.c
4
types.c
|
@ -72,14 +72,14 @@ girara_list_t*
|
|||
zathura_document_information_entry_list_new()
|
||||
{
|
||||
girara_list_t* list = girara_list_new2((girara_free_function_t)
|
||||
zathura_document_information_entry_free);
|
||||
zathura_document_information_entry_free);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
zathura_document_information_entry_t*
|
||||
zathura_document_information_entry_new(zathura_document_information_type_t type,
|
||||
const char* value)
|
||||
const char* value)
|
||||
{
|
||||
if (value == NULL) {
|
||||
return NULL;
|
||||
|
|
79
utils.c
79
utils.c
|
@ -34,8 +34,7 @@ file_get_extension(const char* path)
|
|||
}
|
||||
|
||||
unsigned int i = strlen(path);
|
||||
for (; i > 0; i--)
|
||||
{
|
||||
for (; i > 0; i--) {
|
||||
if (*(path + i) != '.') {
|
||||
continue;
|
||||
} else {
|
||||
|
@ -146,31 +145,31 @@ execute_command(char* const argv[], char** output)
|
|||
|
||||
void
|
||||
document_index_build(GtkTreeModel* model, GtkTreeIter* parent,
|
||||
girara_tree_node_t* tree)
|
||||
girara_tree_node_t* tree)
|
||||
{
|
||||
girara_list_t* list = girara_node_get_children(tree);
|
||||
GIRARA_LIST_FOREACH(list, girara_tree_node_t*, iter, node)
|
||||
zathura_index_element_t* index_element = (zathura_index_element_t*)girara_node_get_data(node);
|
||||
zathura_index_element_t* index_element = (zathura_index_element_t*)girara_node_get_data(node);
|
||||
|
||||
zathura_link_type_t type = zathura_link_get_type(index_element->link);
|
||||
zathura_link_target_t target = zathura_link_get_target(index_element->link);
|
||||
zathura_link_type_t type = zathura_link_get_type(index_element->link);
|
||||
zathura_link_target_t target = zathura_link_get_target(index_element->link);
|
||||
|
||||
gchar* description = NULL;
|
||||
if (type == ZATHURA_LINK_GOTO_DEST) {
|
||||
description = g_strdup_printf("Page %d", target.page_number + 1);
|
||||
} else {
|
||||
description = g_strdup(target.value);
|
||||
}
|
||||
gchar* description = NULL;
|
||||
if (type == ZATHURA_LINK_GOTO_DEST) {
|
||||
description = g_strdup_printf("Page %d", target.page_number + 1);
|
||||
} else {
|
||||
description = g_strdup(target.value);
|
||||
}
|
||||
|
||||
GtkTreeIter tree_iter;
|
||||
gtk_tree_store_append(GTK_TREE_STORE(model), &tree_iter, parent);
|
||||
gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, index_element->title, 1, description, 2, index_element, -1);
|
||||
g_object_weak_ref(G_OBJECT(model), (GWeakNotify) zathura_index_element_free, index_element);
|
||||
g_free(description);
|
||||
GtkTreeIter tree_iter;
|
||||
gtk_tree_store_append(GTK_TREE_STORE(model), &tree_iter, parent);
|
||||
gtk_tree_store_set(GTK_TREE_STORE(model), &tree_iter, 0, index_element->title, 1, description, 2, index_element, -1);
|
||||
g_object_weak_ref(G_OBJECT(model), (GWeakNotify) zathura_index_element_free, index_element);
|
||||
g_free(description);
|
||||
|
||||
if (girara_node_get_num_children(node) > 0) {
|
||||
document_index_build(model, &tree_iter, node);
|
||||
}
|
||||
if (girara_node_get_num_children(node) > 0) {
|
||||
document_index_build(model, &tree_iter, node);
|
||||
}
|
||||
|
||||
GIRARA_LIST_FOREACH_END(list, gchar*, iter, name);
|
||||
}
|
||||
|
@ -183,7 +182,7 @@ page_calculate_offset(zathura_t* zathura, zathura_page_t* page, page_offset_t* o
|
|||
GtkWidget* widget = zathura_page_get_widget(zathura, page);
|
||||
|
||||
g_return_if_fail(gtk_widget_translate_coordinates(widget,
|
||||
zathura->ui.page_widget, 0, 0, &(offset->x), &(offset->y)) == true);
|
||||
zathura->ui.page_widget, 0, 0, &(offset->x), &(offset->y)) == true);
|
||||
}
|
||||
|
||||
zathura_rectangle_t rotate_rectangle(zathura_rectangle_t rectangle, unsigned int degree, int height, int width)
|
||||
|
@ -274,7 +273,7 @@ void
|
|||
set_adjustment(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)));
|
||||
MIN(gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment), value)));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -357,9 +356,9 @@ document_draw_search_results(zathura_t* zathura, bool value)
|
|||
char*
|
||||
zathura_get_version_string(zathura_t* zathura, bool markup)
|
||||
{
|
||||
if (zathura == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (zathura == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GString* string = g_string_new(NULL);
|
||||
|
||||
|
@ -368,30 +367,30 @@ zathura_get_version_string(zathura_t* zathura, bool markup)
|
|||
g_string_append(string, zathura_version);
|
||||
g_free(zathura_version);
|
||||
|
||||
char* format = (markup == true) ? "\n<i>(plugin)</i> %s (%d.%d.%d) <i>(%s)</i>" : "\n(plugin) %s (%d.%d.%d) (%s)";
|
||||
char* format = (markup == true) ? "\n<i>(plugin)</i> %s (%d.%d.%d) <i>(%s)</i>" : "\n(plugin) %s (%d.%d.%d) (%s)";
|
||||
|
||||
/* plugin information */
|
||||
girara_list_t* plugins = zathura_plugin_manager_get_plugins(zathura->plugins.manager);
|
||||
if (plugins != NULL) {
|
||||
GIRARA_LIST_FOREACH(plugins, zathura_plugin_t*, iter, plugin)
|
||||
char* name = zathura_plugin_get_name(plugin);
|
||||
zathura_plugin_version_t version = zathura_plugin_get_version(plugin);
|
||||
char* text = g_strdup_printf(format,
|
||||
(name == NULL) ? "-" : name,
|
||||
version.major,
|
||||
version.minor,
|
||||
version.rev,
|
||||
zathura_plugin_get_path(plugin)
|
||||
);
|
||||
g_string_append(string, text);
|
||||
g_free(text);
|
||||
char* name = zathura_plugin_get_name(plugin);
|
||||
zathura_plugin_version_t version = zathura_plugin_get_version(plugin);
|
||||
char* text = g_strdup_printf(format,
|
||||
(name == NULL) ? "-" : name,
|
||||
version.major,
|
||||
version.minor,
|
||||
version.rev,
|
||||
zathura_plugin_get_path(plugin)
|
||||
);
|
||||
g_string_append(string, text);
|
||||
g_free(text);
|
||||
GIRARA_LIST_FOREACH_END(plugins, zathura_plugin_t*, iter, plugin);
|
||||
}
|
||||
|
||||
char* version = string->str;
|
||||
g_string_free(string, FALSE);
|
||||
char* version = string->str;
|
||||
g_string_free(string, FALSE);
|
||||
|
||||
return version;
|
||||
return version;
|
||||
}
|
||||
|
||||
char*
|
||||
|
|
54
zathura.c
54
zathura.c
|
@ -33,21 +33,18 @@
|
|||
#include "page-widget.h"
|
||||
#include "plugin.h"
|
||||
|
||||
typedef struct zathura_document_info_s
|
||||
{
|
||||
typedef struct zathura_document_info_s {
|
||||
zathura_t* zathura;
|
||||
const char* path;
|
||||
const char* password;
|
||||
} zathura_document_info_t;
|
||||
|
||||
typedef struct page_set_delayed_s
|
||||
{
|
||||
typedef struct page_set_delayed_s {
|
||||
zathura_t* zathura;
|
||||
unsigned int page;
|
||||
} page_set_delayed_t;
|
||||
|
||||
typedef struct position_set_delayed_s
|
||||
{
|
||||
typedef struct position_set_delayed_s {
|
||||
zathura_t* zathura;
|
||||
double position_x;
|
||||
double position_y;
|
||||
|
@ -234,7 +231,7 @@ zathura_init(zathura_t* zathura)
|
|||
|
||||
/* bookmarks */
|
||||
zathura->bookmarks.bookmarks = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
|
||||
(girara_free_function_t) zathura_bookmark_free);
|
||||
(girara_free_function_t) zathura_bookmark_free);
|
||||
|
||||
/* add even to purge old pages */
|
||||
int interval = 30;
|
||||
|
@ -368,14 +365,14 @@ zathura_set_plugin_dir(zathura_t* zathura, const char* dir)
|
|||
if (dir != NULL) {
|
||||
girara_list_t* paths = girara_split_path_array(dir);
|
||||
GIRARA_LIST_FOREACH(paths, char*, iter, path)
|
||||
zathura_plugin_manager_add_dir(zathura->plugins.manager, path);
|
||||
zathura_plugin_manager_add_dir(zathura->plugins.manager, path);
|
||||
GIRARA_LIST_FOREACH_END(paths, char*, iter, path);
|
||||
girara_list_free(paths);
|
||||
} else {
|
||||
#ifdef ZATHURA_PLUGINDIR
|
||||
girara_list_t* paths = girara_split_path_array(ZATHURA_PLUGINDIR);
|
||||
GIRARA_LIST_FOREACH(paths, char*, iter, path)
|
||||
zathura_plugin_manager_add_dir(zathura->plugins.manager, path);
|
||||
zathura_plugin_manager_add_dir(zathura->plugins.manager, path);
|
||||
GIRARA_LIST_FOREACH_END(paths, char*, iter, path);
|
||||
girara_list_free(paths);
|
||||
#endif
|
||||
|
@ -478,7 +475,7 @@ document_info_open(gpointer data)
|
|||
file = prepare_document_open_from_stdin(document_info->zathura);
|
||||
if (file == NULL) {
|
||||
girara_notify(document_info->zathura->ui.session, GIRARA_ERROR,
|
||||
"Could not read file from stdin and write it to a temporary file.");
|
||||
"Could not read file from stdin and write it to a temporary file.");
|
||||
} else {
|
||||
document_info->zathura->stdin_support.file = g_strdup(file);
|
||||
}
|
||||
|
@ -515,7 +512,7 @@ document_open(zathura_t* zathura, const char* path, const char* password)
|
|||
if (path != NULL) {
|
||||
password_dialog_info->path = g_strdup(path);
|
||||
girara_dialog(zathura->ui.session, "Enter password:", true, NULL,
|
||||
(girara_callback_inputbar_activate_t) cb_password_dialog, password_dialog_info);
|
||||
(girara_callback_inputbar_activate_t) cb_password_dialog, password_dialog_info);
|
||||
goto error_out;
|
||||
} else {
|
||||
free(password_dialog_info);
|
||||
|
@ -755,8 +752,7 @@ document_save(zathura_t* zathura, const char* path, bool overwrite)
|
|||
g_return_val_if_fail(path, false);
|
||||
|
||||
gchar* file_path = girara_fix_path(path);
|
||||
if ((overwrite == false) && g_file_test(file_path, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
if ((overwrite == false) && g_file_test(file_path, G_FILE_TEST_EXISTS)) {
|
||||
girara_error("File already exists: %s. Use :write! to overwrite it.", file_path);
|
||||
g_free(file_path);
|
||||
return false;
|
||||
|
@ -960,14 +956,14 @@ page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row, unsigned in
|
|||
pages_per_row = 1;
|
||||
}
|
||||
|
||||
/* ensure: 0 < first_page_column <= pages_per_row */
|
||||
if (first_page_column < 1) {
|
||||
first_page_column = 1;
|
||||
}
|
||||
/* ensure: 0 < first_page_column <= pages_per_row */
|
||||
if (first_page_column < 1) {
|
||||
first_page_column = 1;
|
||||
}
|
||||
|
||||
if (first_page_column > pages_per_row) {
|
||||
first_page_column = ((first_page_column - 1) % pages_per_row) + 1;
|
||||
}
|
||||
if (first_page_column > pages_per_row) {
|
||||
first_page_column = ((first_page_column - 1) % pages_per_row) + 1;
|
||||
}
|
||||
|
||||
if (zathura->document == NULL) {
|
||||
return;
|
||||
|
@ -1054,7 +1050,8 @@ position_set_delayed(zathura_t* zathura, double position_x, double position_y)
|
|||
|
||||
|
||||
zathura_jump_t*
|
||||
zathura_jumplist_current(zathura_t* zathura) {
|
||||
zathura_jumplist_current(zathura_t* zathura)
|
||||
{
|
||||
if (zathura->jumplist.cur != NULL) {
|
||||
return girara_list_iterator_data(zathura->jumplist.cur);
|
||||
} else {
|
||||
|
@ -1063,21 +1060,24 @@ zathura_jumplist_current(zathura_t* zathura) {
|
|||
}
|
||||
|
||||
void
|
||||
zathura_jumplist_forward(zathura_t* zathura) {
|
||||
zathura_jumplist_forward(zathura_t* zathura)
|
||||
{
|
||||
if (girara_list_iterator_has_next(zathura->jumplist.cur)) {
|
||||
girara_list_iterator_next(zathura->jumplist.cur);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
zathura_jumplist_backward(zathura_t* zathura) {
|
||||
zathura_jumplist_backward(zathura_t* zathura)
|
||||
{
|
||||
if (girara_list_iterator_has_previous(zathura->jumplist.cur)) {
|
||||
girara_list_iterator_previous(zathura->jumplist.cur);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
zathura_jumplist_append_jump(zathura_t* zathura) {
|
||||
zathura_jumplist_append_jump(zathura_t* zathura)
|
||||
{
|
||||
zathura_jump_t *jump = g_malloc(sizeof(zathura_jump_t));
|
||||
if (jump != NULL) {
|
||||
jump->page = 0;
|
||||
|
@ -1109,7 +1109,8 @@ zathura_jumplist_append_jump(zathura_t* zathura) {
|
|||
}
|
||||
|
||||
void
|
||||
zathura_jumplist_add(zathura_t* zathura) {
|
||||
zathura_jumplist_add(zathura_t* zathura)
|
||||
{
|
||||
if (zathura->jumplist.list != NULL) {
|
||||
unsigned int pagenum = zathura_document_get_current_page_number(zathura->document);
|
||||
zathura_jump_t* cur = zathura_jumplist_current(zathura);
|
||||
|
@ -1125,7 +1126,8 @@ zathura_jumplist_add(zathura_t* zathura) {
|
|||
|
||||
|
||||
void
|
||||
zathura_jumplist_save(zathura_t* zathura) {
|
||||
zathura_jumplist_save(zathura_t* zathura)
|
||||
{
|
||||
zathura_jump_t* cur = zathura_jumplist_current(zathura);
|
||||
|
||||
unsigned int pagenum = zathura_document_get_current_page_number(zathura->document);
|
||||
|
|
Loading…
Reference in a new issue