2010-11-10 20:31:15 +01:00
|
|
|
/* See LICENSE file for license and copyright information */
|
|
|
|
|
|
|
|
#include "commands.h"
|
2011-03-12 11:32:24 +01:00
|
|
|
#include "zathura.h"
|
2011-04-29 00:28:19 +02:00
|
|
|
#include "print.h"
|
2010-11-10 20:31:15 +01:00
|
|
|
|
|
|
|
bool
|
2011-04-19 10:38:59 +02:00
|
|
|
cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list)
|
2010-11-10 20:31:15 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-04-19 10:38:59 +02:00
|
|
|
cmd_bookmark_delete(girara_session_t* session, girara_list_t* argument_list)
|
2010-11-10 20:31:15 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-04-19 10:38:59 +02:00
|
|
|
cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list)
|
2010-11-10 20:31:15 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-04-19 10:38:59 +02:00
|
|
|
cmd_close(girara_session_t* session, girara_list_t* argument_list)
|
2010-11-10 20:31:15 +01:00
|
|
|
{
|
2011-04-18 18:29:50 +02:00
|
|
|
g_return_val_if_fail(session != NULL, false);
|
|
|
|
g_return_val_if_fail(session->global.data != NULL, false);
|
|
|
|
zathura_t* zathura = session->global.data;
|
2011-08-30 23:40:13 +02:00
|
|
|
if (zathura->document == NULL) {
|
|
|
|
// nothing needs to be done
|
|
|
|
return true;
|
|
|
|
}
|
2011-04-18 18:29:50 +02:00
|
|
|
|
|
|
|
document_close(zathura);
|
2011-03-12 11:32:24 +01:00
|
|
|
|
2010-11-10 20:31:15 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-04-19 10:38:59 +02:00
|
|
|
cmd_info(girara_session_t* session, girara_list_t* argument_list)
|
2010-11-10 20:31:15 +01:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-01 13:15:27 +02:00
|
|
|
bool
|
|
|
|
cmd_help(girara_session_t* session, girara_list_t* argument_list)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-05-25 00:24:43 +02:00
|
|
|
bool
|
|
|
|
cmd_open(girara_session_t* session, girara_list_t* argument_list)
|
|
|
|
{
|
2011-08-31 00:08:33 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-05-25 00:24:43 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-10 20:31:15 +01:00
|
|
|
bool
|
2011-04-19 10:38:59 +02:00
|
|
|
cmd_print(girara_session_t* session, girara_list_t* argument_list)
|
2010-11-10 20:31:15 +01:00
|
|
|
{
|
2011-04-29 00:28:19 +02:00
|
|
|
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 == NULL) {
|
|
|
|
girara_error("no document as been opened");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-08-31 12:42:22 +02:00
|
|
|
print((zathura_t*) session->global.data);
|
2011-04-29 00:28:19 +02:00
|
|
|
|
2010-11-10 20:31:15 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-04-19 10:38:59 +02:00
|
|
|
cmd_save(girara_session_t* session, girara_list_t* argument_list)
|
2010-11-10 20:31:15 +01:00
|
|
|
{
|
2011-09-01 11:51:49 +02:00
|
|
|
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 == NULL) {
|
|
|
|
girara_error("no document as been opened");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (girara_list_size(argument_list) == 1) {
|
|
|
|
document_save(zathura, girara_list_nth(argument_list, 0), false);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
girara_error("invalid arguments");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
cmd_savef(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 == NULL) {
|
|
|
|
girara_error("no document as been opened");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (girara_list_size(argument_list) == 1) {
|
|
|
|
document_save(zathura, girara_list_nth(argument_list, 0), true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
girara_error("invalid arguments");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-11-10 20:31:15 +01:00
|
|
|
return true;
|
|
|
|
}
|