Commit eb1fe0a6 authored by B E's avatar B E

Bookmark command line argument

parent 22580f24
......@@ -253,7 +253,7 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
document_open_idle(zathura, girara_list_nth(argument_list, 0),
(argc == 2) ? girara_list_nth(argument_list, 1) : NULL,
ZATHURA_PAGE_NUMBER_UNSPECIFIED, NULL, NULL, NULL);
ZATHURA_PAGE_NUMBER_UNSPECIFIED, NULL, NULL, NULL, NULL);
} else {
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
return false;
......
......@@ -222,7 +222,7 @@ handle_open_document(zathura_t* zathura, GVariant* parameters,
document_open_idle(zathura, filename,
strlen(password) > 0 ? password : NULL,
page,
NULL, NULL, NULL);
NULL, NULL, NULL, NULL);
g_free(filename);
g_free(password);
......
......@@ -135,6 +135,7 @@ main(int argc, char* argv[])
gchar* synctex_editor = NULL;
gchar* synctex_fwd = NULL;
gchar* mode = NULL;
gchar* bookmark_name = NULL;
gchar* search_string = NULL;
bool forkback = false;
bool print_version = false;
......@@ -157,6 +158,7 @@ main(int argc, char* argv[])
{ "synctex-forward", '\0', 0, G_OPTION_ARG_STRING, &synctex_fwd, _("Move to given synctex position"), "position" },
{ "synctex-pid", '\0', 0, G_OPTION_ARG_INT, &synctex_pid, _("Highlight given position in the given process"), "pid" },
{ "mode", '\0', 0, G_OPTION_ARG_STRING, &mode, _("Start in a non-default mode"), "mode" },
{ "bookmark", 'b', 0, G_OPTION_ARG_STRING, &bookmark_name, _("Bookmark to go to"), "bookmark" },
{ "find", 'f', 0, G_OPTION_ARG_STRING, &search_string, _("Search for the given phrase and display results"), "string" },
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
};
......@@ -298,8 +300,13 @@ main(int argc, char* argv[])
if (page_number > 0) {
--page_number;
}
document_open_idle(zathura, argv[file_idx], password, page_number, mode,
synctex_fwd, search_string);
document_open_idle(zathura, argv[file_idx], password, page_number,
mode, synctex_fwd, bookmark_name, search_string);
} else if (bookmark_name != NULL) {
girara_error("Can not use bookmark argument when no file is given");
ret = -1;
zathura_free(zathura);
goto free_and_ret;
} else if (search_string != NULL) {
girara_error("Can not use find argument when no file is given");
ret = -1;
......@@ -323,6 +330,7 @@ free_and_ret:
g_free(synctex_editor);
g_free(synctex_fwd);
g_free(mode);
g_free(bookmark_name);
g_free(search_string);
return ret;
......
......@@ -57,6 +57,7 @@ typedef struct zathura_document_info_s {
int page_number;
char* mode;
char* synctex;
char* bookmark_name;
char* search_string;
} zathura_document_info_t;
......@@ -78,6 +79,7 @@ free_document_info(zathura_document_info_t* document_info)
g_free(document_info->password);
g_free(document_info->mode);
g_free(document_info->synctex);
g_free(document_info->bookmark_name);
g_free(document_info->search_string);
g_free(document_info);
}
......@@ -883,6 +885,13 @@ document_info_open(gpointer data)
}
}
if (document_info->bookmark_name != NULL) {
girara_list_t* arg_list = girara_list_new();
girara_list_append(arg_list, document_info->bookmark_name);
cmd_bookmark_open(document_info->zathura->ui.session, arg_list);
girara_list_free(arg_list);
}
if (document_info->search_string != NULL) {
girara_argument_t search_arg;
search_arg.n = 1; // Forward search
......@@ -1309,7 +1318,7 @@ document_open_synctex(zathura_t* zathura, const char* path, const char* uri,
void
document_open_idle(zathura_t* zathura, const char* path, const char* password,
int page_number, const char* mode, const char* synctex,
const char *search_string)
const char* bookmark_name, const char *search_string)
{
g_return_if_fail(zathura != NULL);
g_return_if_fail(path != NULL);
......@@ -1331,6 +1340,9 @@ document_open_idle(zathura_t* zathura, const char* path, const char* password,
if (synctex != NULL) {
document_info->synctex = g_strdup(synctex);
}
if (bookmark_name != NULL) {
document_info->bookmark_name = g_strdup(bookmark_name);
}
if (search_string != NULL) {
document_info->search_string = g_strdup(search_string);
}
......
......@@ -343,7 +343,7 @@ bool document_open_synctex(zathura_t* zathura, const char* path, const char* uri
void document_open_idle(zathura_t* zathura, const char* path,
const char* password, int page_number,
const char* mode, const char* synctex,
const char* search_string);
const char* bookmark_name, const char *search_string);
/**
* Save a open file
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment