From c445b0e679656fad6a50da5c4bed47747eee8aa5 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Wed, 31 Aug 2011 00:08:33 +0200 Subject: [PATCH] implement :open --- commands.c | 21 +++++++++++++++++++++ zathura.c | 1 + 2 files changed, 22 insertions(+) diff --git a/commands.c b/commands.c index 817165d..b2353bd 100644 --- a/commands.c +++ b/commands.c @@ -47,6 +47,27 @@ cmd_info(girara_session_t* session, girara_list_t* argument_list) bool cmd_open(girara_session_t* session, girara_list_t* argument_list) { + g_return_val_if_fail(session != NULL, false); + g_return_val_if_fail(session->global.data != NULL, false); + zathura_t* zathura = session->global.data; + + if (zathura->document) { + document_close(zathura); + } + + const int argc = girara_list_size(argument_list); + if (argc > 2) { + girara_error("too many arguments"); + return false; + } + else if (argc >= 1) { + document_open(zathura, girara_list_nth(argument_list, 0), (argc == 2) ? girara_list_nth(argument_list, 1) : NULL); + } + else { + girara_error("no arguments"); + return false; + } + return true; } diff --git a/zathura.c b/zathura.c index dba3d87..de24885 100644 --- a/zathura.c +++ b/zathura.c @@ -257,6 +257,7 @@ document_info_open(gpointer data) } document_open(document_info->zathura, document_info->path, document_info->password); + free(document_info); return FALSE; }