Commit ace31581 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Add --mode option

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 76e456ef
......@@ -239,7 +239,7 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
}
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);
} else {
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
......
......@@ -45,6 +45,7 @@ main(int argc, char* argv[])
gchar* password = NULL;
gchar* synctex_editor = NULL;
gchar* synctex_fwd = NULL;
gchar* mode = NULL;
bool forkback = false;
bool print_version = 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-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" },
{ NULL, '\0', 0, 0, NULL, NULL, NULL }
};
......@@ -91,6 +93,7 @@ main(int argc, char* argv[])
girara_set_debug_level(GIRARA_ERROR);
}
/* handle synctex forward synchronization */
if (synctex_fwd != NULL) {
if (argc != 2) {
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 ... */
if (forkback == true) {
......@@ -164,7 +172,7 @@ main(int argc, char* argv[])
if (argc > 1) {
if (page_number > 0)
--page_number;
document_open_idle(zathura, argv[1], password, page_number);
document_open_idle(zathura, argv[1], password, page_number, mode);
/* open additional files */
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
all zathura process to find the correct one.
--mode [mode]
Switch to mode (presentation, fullscreen) after opening a document.
MOUSE AND KEY BINDINGS
======================
......
......@@ -41,6 +41,7 @@ typedef struct zathura_document_info_s {
const char* path;
const char* password;
int page_number;
const char* mode;
} zathura_document_info_t;
......@@ -481,6 +482,18 @@ document_info_open(gpointer data)
document_open(document_info->zathura, file, document_info->password,
document_info->page_number);
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
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) {
return;
......@@ -834,6 +847,7 @@ document_open_idle(zathura_t* zathura, const char* path, const char* password,
document_info->path = path;
document_info->password = password;
document_info->page_number = page_number;
document_info->mode = mode;
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
*/
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
......
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