mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-14 15:16:01 +01:00
Add --mode option
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
76e456ef4c
commit
ace31581b4
5 changed files with 30 additions and 4 deletions
|
@ -239,7 +239,7 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
|
||||||
}
|
}
|
||||||
|
|
||||||
document_open(zathura, girara_list_nth(argument_list, 0),
|
document_open(zathura, girara_list_nth(argument_list, 0),
|
||||||
(argc == 2) ? girara_list_nth(argument_list, 1) : NULL,
|
(argc == 2) ? girara_list_nth(argument_list, 1) : NULL,
|
||||||
ZATHURA_PAGE_NUMBER_UNSPECIFIED);
|
ZATHURA_PAGE_NUMBER_UNSPECIFIED);
|
||||||
} else {
|
} else {
|
||||||
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
|
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
|
||||||
|
|
10
main.c
10
main.c
|
@ -45,6 +45,7 @@ main(int argc, char* argv[])
|
||||||
gchar* password = NULL;
|
gchar* password = NULL;
|
||||||
gchar* synctex_editor = NULL;
|
gchar* synctex_editor = NULL;
|
||||||
gchar* synctex_fwd = NULL;
|
gchar* synctex_fwd = NULL;
|
||||||
|
gchar* mode = NULL;
|
||||||
bool forkback = false;
|
bool forkback = false;
|
||||||
bool print_version = false;
|
bool print_version = false;
|
||||||
bool synctex = false;
|
bool synctex = false;
|
||||||
|
@ -66,6 +67,7 @@ main(int argc, char* argv[])
|
||||||
{ "synctex-editor-command", 'x', 0, G_OPTION_ARG_STRING, &synctex_editor, _("Synctex editor (forwarded to the synctex command)"), "cmd" },
|
{ "synctex-editor-command", 'x', 0, G_OPTION_ARG_STRING, &synctex_editor, _("Synctex editor (forwarded to the synctex command)"), "cmd" },
|
||||||
{ "synctex-forward", '\0', 0, G_OPTION_ARG_STRING, &synctex_fwd, _("Move to given synctex position"), "position" },
|
{ "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" },
|
{ "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" },
|
||||||
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
|
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -91,6 +93,7 @@ main(int argc, char* argv[])
|
||||||
girara_set_debug_level(GIRARA_ERROR);
|
girara_set_debug_level(GIRARA_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* handle synctex forward synchronization */
|
||||||
if (synctex_fwd != NULL) {
|
if (synctex_fwd != NULL) {
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
girara_error("Too many arguments or missing filename while running with --synctex-forward");
|
girara_error("Too many arguments or missing filename while running with --synctex-forward");
|
||||||
|
@ -113,6 +116,11 @@ main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check mode */
|
||||||
|
if (mode != NULL && g_strcmp0(mode, "presentation") != 0 && g_strcmp0(mode, "fullscreen") != 0) {
|
||||||
|
girara_error("Invalid argument for --mode: %s", mode);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Fork into the background if the user really wants to ... */
|
/* Fork into the background if the user really wants to ... */
|
||||||
if (forkback == true) {
|
if (forkback == true) {
|
||||||
|
@ -164,7 +172,7 @@ main(int argc, char* argv[])
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if (page_number > 0)
|
if (page_number > 0)
|
||||||
--page_number;
|
--page_number;
|
||||||
document_open_idle(zathura, argv[1], password, page_number);
|
document_open_idle(zathura, argv[1], password, page_number, mode);
|
||||||
|
|
||||||
/* open additional files */
|
/* open additional files */
|
||||||
for (int i = 2; i < argc; i++) {
|
for (int i = 2; i < argc; i++) {
|
||||||
|
|
|
@ -67,6 +67,9 @@ OPTIONS
|
||||||
If not -1, forward synctex input to process with the given pid. Otherwise, try
|
If not -1, forward synctex input to process with the given pid. Otherwise, try
|
||||||
all zathura process to find the correct one.
|
all zathura process to find the correct one.
|
||||||
|
|
||||||
|
--mode [mode]
|
||||||
|
Switch to mode (presentation, fullscreen) after opening a document.
|
||||||
|
|
||||||
MOUSE AND KEY BINDINGS
|
MOUSE AND KEY BINDINGS
|
||||||
======================
|
======================
|
||||||
|
|
||||||
|
|
16
zathura.c
16
zathura.c
|
@ -41,6 +41,7 @@ typedef struct zathura_document_info_s {
|
||||||
const char* path;
|
const char* path;
|
||||||
const char* password;
|
const char* password;
|
||||||
int page_number;
|
int page_number;
|
||||||
|
const char* mode;
|
||||||
} zathura_document_info_t;
|
} zathura_document_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -481,6 +482,18 @@ document_info_open(gpointer data)
|
||||||
document_open(document_info->zathura, file, document_info->password,
|
document_open(document_info->zathura, file, document_info->password,
|
||||||
document_info->page_number);
|
document_info->page_number);
|
||||||
g_free(file);
|
g_free(file);
|
||||||
|
|
||||||
|
if (document_info->mode != NULL) {
|
||||||
|
if (g_strcmp0(document_info->mode, "presentation") == 0) {
|
||||||
|
sc_toggle_presentation(document_info->zathura->ui.session, NULL, NULL,
|
||||||
|
0);
|
||||||
|
} else if (g_strcmp0(document_info->mode, "fullscreen") == 0) {
|
||||||
|
sc_toggle_fullscreen(document_info->zathura->ui.session, NULL, NULL,
|
||||||
|
0);
|
||||||
|
} else {
|
||||||
|
girara_error("Unknown mode: %s", document_info->mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -819,7 +832,7 @@ error_out:
|
||||||
|
|
||||||
void
|
void
|
||||||
document_open_idle(zathura_t* zathura, const char* path, const char* password,
|
document_open_idle(zathura_t* zathura, const char* path, const char* password,
|
||||||
int page_number)
|
int page_number, const char* mode)
|
||||||
{
|
{
|
||||||
if (zathura == NULL || path == NULL) {
|
if (zathura == NULL || path == NULL) {
|
||||||
return;
|
return;
|
||||||
|
@ -834,6 +847,7 @@ document_open_idle(zathura_t* zathura, const char* path, const char* password,
|
||||||
document_info->path = path;
|
document_info->path = path;
|
||||||
document_info->password = password;
|
document_info->password = password;
|
||||||
document_info->page_number = page_number;
|
document_info->page_number = page_number;
|
||||||
|
document_info->mode = mode;
|
||||||
|
|
||||||
gdk_threads_add_idle(document_info_open, document_info);
|
gdk_threads_add_idle(document_info_open, document_info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,7 +304,8 @@ bool document_open(zathura_t* zathura, const char* path, const char* password,
|
||||||
* @param password The password of the file
|
* @param password The password of the file
|
||||||
*/
|
*/
|
||||||
void document_open_idle(zathura_t* zathura, const char* path,
|
void document_open_idle(zathura_t* zathura, const char* path,
|
||||||
const char* password, int page_number);
|
const char* password, int page_number,
|
||||||
|
const char* mode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a open file
|
* Save a open file
|
||||||
|
|
Loading…
Reference in a new issue