mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 08:45:59 +01:00
Handle URIs in :open
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
d895ad32a1
commit
73699b12ea
2 changed files with 34 additions and 15 deletions
|
@ -238,9 +238,9 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
|
||||||
document_close(zathura, false);
|
document_close(zathura, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
document_open(zathura, girara_list_nth(argument_list, 0),
|
document_open_idle(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, NULL, NULL);
|
||||||
} else {
|
} else {
|
||||||
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
|
girara_notify(session, GIRARA_ERROR, _("No arguments given."));
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -46,11 +46,11 @@
|
||||||
|
|
||||||
typedef struct zathura_document_info_s {
|
typedef struct zathura_document_info_s {
|
||||||
zathura_t* zathura;
|
zathura_t* zathura;
|
||||||
const char* path;
|
char* path;
|
||||||
const char* password;
|
char* password;
|
||||||
int page_number;
|
int page_number;
|
||||||
const char* mode;
|
char* mode;
|
||||||
const char* synctex;
|
char* synctex;
|
||||||
} zathura_document_info_t;
|
} zathura_document_info_t;
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,6 +63,20 @@ static void zathura_jumplist_save(zathura_t* zathura);
|
||||||
static gboolean zathura_signal_sigterm(gpointer data);
|
static gboolean zathura_signal_sigterm(gpointer data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_document_info(zathura_document_info_t* document_info)
|
||||||
|
{
|
||||||
|
if (document_info == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(document_info->path);
|
||||||
|
g_free(document_info->password);
|
||||||
|
g_free(document_info->mode);
|
||||||
|
g_free(document_info->synctex);
|
||||||
|
g_free(document_info);
|
||||||
|
}
|
||||||
|
|
||||||
/* function implementation */
|
/* function implementation */
|
||||||
zathura_t*
|
zathura_t*
|
||||||
zathura_create(void)
|
zathura_create(void)
|
||||||
|
@ -610,7 +624,7 @@ document_info_open(gpointer data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(document_info);
|
free_document_info(document_info);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,9 +1057,8 @@ 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, const char* mode, const char* synctex)
|
int page_number, const char* mode, const char* synctex)
|
||||||
{
|
{
|
||||||
if (zathura == NULL || path == NULL) {
|
g_return_if_fail(zathura != NULL);
|
||||||
return;
|
g_return_if_fail(path != NULL);
|
||||||
}
|
|
||||||
|
|
||||||
zathura_document_info_t* document_info = g_try_malloc0(sizeof(zathura_document_info_t));
|
zathura_document_info_t* document_info = g_try_malloc0(sizeof(zathura_document_info_t));
|
||||||
if (document_info == NULL) {
|
if (document_info == NULL) {
|
||||||
|
@ -1053,11 +1066,17 @@ document_open_idle(zathura_t* zathura, const char* path, const char* password,
|
||||||
}
|
}
|
||||||
|
|
||||||
document_info->zathura = zathura;
|
document_info->zathura = zathura;
|
||||||
document_info->path = path;
|
document_info->path = g_strdup(path);
|
||||||
document_info->password = password;
|
if (password != NULL) {
|
||||||
|
document_info->password = g_strdup(password);
|
||||||
|
}
|
||||||
document_info->page_number = page_number;
|
document_info->page_number = page_number;
|
||||||
document_info->mode = mode;
|
if (mode != NULL) {
|
||||||
document_info->synctex = synctex;
|
document_info->mode = g_strdup(mode);
|
||||||
|
}
|
||||||
|
if (synctex != NULL) {
|
||||||
|
document_info->synctex = g_strdup(synctex);
|
||||||
|
}
|
||||||
|
|
||||||
gdk_threads_add_idle(document_info_open, document_info);
|
gdk_threads_add_idle(document_info_open, document_info);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue