Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
pwmt
zathura
Commits
8bf7587b
Commit
8bf7587b
authored
Oct 01, 2011
by
Moritz Lipp
Browse files
Show document information
parent
8b762ddc
Changes
5
Hide whitespace changes
Inline
Side-by-side
commands.c
View file @
8bf7587b
/* See LICENSE file for license and copyright information */
#include <string.h>
#include "commands.h"
#include "bookmarks.h"
#include "database.h"
#include "document.h"
#include "zathura.h"
#include "print.h"
#include "document.h"
#include "utils.h"
bool
cmd_bookmark_create
(
girara_session_t
*
UNUSED
(
session
),
girara_list_t
*
...
...
@@ -65,10 +69,61 @@ cmd_close(girara_session_t* session, girara_list_t* UNUSED(argument_list))
}
bool
cmd_info
(
girara_session_t
*
UNUSED
(
session
),
girara_list_t
*
UNUSED
(
argument_list
))
cmd_info
(
girara_session_t
*
session
,
girara_list_t
*
UNUSED
(
argument_list
))
{
return
true
;
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_notify
(
session
,
GIRARA_ERROR
,
"No document opened."
);
return
false
;
}
struct
meta_field
{
char
*
name
;
zathura_document_meta_t
field
;
};
struct
meta_field
meta_fields
[]
=
{
{
"Title"
,
ZATHURA_DOCUMENT_TITLE
},
{
"Author"
,
ZATHURA_DOCUMENT_AUTHOR
},
{
"Subject"
,
ZATHURA_DOCUMENT_SUBJECT
},
{
"Keywords"
,
ZATHURA_DOCUMENT_KEYWORDS
},
{
"Creator"
,
ZATHURA_DOCUMENT_CREATOR
},
{
"Producer"
,
ZATHURA_DOCUMENT_PRODUCER
},
{
"Creation date"
,
ZATHURA_DOCUMENT_CREATION_DATE
},
{
"Modiciation date"
,
ZATHURA_DOCUMENT_MODIFICATION_DATE
}
};
GString
*
string
=
g_string_new
(
NULL
);
if
(
string
==
NULL
)
{
return
true
;
}
for
(
unsigned
int
i
=
0
;
i
<
LENGTH
(
meta_fields
);
i
++
)
{
char
*
tmp
=
zathura_document_meta_get
(
zathura
->
document
,
meta_fields
[
i
].
field
);
if
(
tmp
!=
NULL
)
{
char
*
text
=
g_strdup_printf
(
"<b>%s:</b> %s
\n
"
,
meta_fields
[
i
].
name
,
tmp
);
if
(
text
==
NULL
)
{
g_free
(
tmp
);
return
true
;
}
g_string_append
(
string
,
text
);
g_free
(
text
);
g_free
(
tmp
);
}
}
if
(
strlen
(
string
->
str
)
>
0
)
{
g_string_erase
(
string
,
strlen
(
string
->
str
)
-
1
,
1
);
girara_notify
(
session
,
GIRARA_INFO
,
string
->
str
);
}
g_string_free
(
string
,
TRUE
);
return
false
;
}
bool
...
...
document.c
View file @
8bf7587b
...
...
@@ -20,8 +20,7 @@
#include "utils.h"
#include "zathura.h"
#include "render.h"
#define LENGTH(x) (sizeof(x)/sizeof((x)[0]))
#include "utils.h"
void
zathura_document_plugins_load
(
zathura_t
*
zathura
)
...
...
@@ -353,6 +352,21 @@ zathura_document_attachments_free(zathura_list_t* UNUSED(list))
return
false
;
}
char
*
zathura_document_meta_get
(
zathura_document_t
*
document
,
zathura_document_meta_t
meta
)
{
if
(
document
==
NULL
)
{
return
NULL
;
}
if
(
document
->
functions
.
document_meta_get
==
NULL
)
{
girara_error
(
"%s not implemented"
,
__FUNCTION__
);
return
NULL
;
}
return
document
->
functions
.
document_meta_get
(
document
,
meta
);
}
zathura_page_t
*
zathura_page_get
(
zathura_document_t
*
document
,
unsigned
int
page_id
)
{
...
...
document.h
View file @
8bf7587b
...
...
@@ -33,6 +33,18 @@ typedef struct zathura_type_plugin_mapping_s
zathura_document_plugin_t
*
plugin
;
}
zathura_type_plugin_mapping_t
;
typedef
enum
zathura_document_meta_e
{
ZATHURA_DOCUMENT_TITLE
,
ZATHURA_DOCUMENT_AUTHOR
,
ZATHURA_DOCUMENT_SUBJECT
,
ZATHURA_DOCUMENT_KEYWORDS
,
ZATHURA_DOCUMENT_CREATOR
,
ZATHURA_DOCUMENT_PRODUCER
,
ZATHURA_DOCUMENT_CREATION_DATE
,
ZATHURA_DOCUMENT_MODIFICATION_DATE
}
zathura_document_meta_t
;
/**
* Function prototype that is called to register a document plugin
*
...
...
@@ -195,6 +207,11 @@ struct zathura_document_s
*/
zathura_list_t
*
(
*
document_attachments_get
)(
zathura_document_t
*
document
);
/**
* Get document information
*/
char
*
(
*
document_meta_get
)(
zathura_document_t
*
document
,
zathura_document_meta_t
info
);
/**
* Gets the page object
*/
...
...
@@ -307,6 +324,15 @@ zathura_list_t* zathura_document_attachments_get(zathura_document_t* document);
*/
bool
zathura_document_attachments_free
(
zathura_list_t
*
list
);
/**
* Returns a string of the requested information
*
* @param document The zathura document
* @param meta The information field
* @return String or NULL if information could not be retreived
*/
char
*
zathura_document_meta_get
(
zathura_document_t
*
document
,
zathura_document_meta_t
meta
);
/**
* Get the page object
*
...
...
utils.h
View file @
8bf7587b
...
...
@@ -9,6 +9,8 @@
#include "document.h"
#define LENGTH(x) (sizeof(x)/sizeof((x)[0]))
typedef
struct
page_offset_s
{
int
x
;
...
...
zathura.c
View file @
8bf7587b
...
...
@@ -63,7 +63,7 @@ zathura_init(int argc, char* argv[])
/* plugins */
zathura
->
plugins
.
plugins
=
girara_list_new
();
girara_list_set_free_function
(
zathura
->
plugins
.
plugins
,
girara_list_set_free_function
(
zathura
->
plugins
.
plugins
,
(
girara_free_function_t
)
zathura_document_plugin_free
);
zathura
->
plugins
.
path
=
girara_list_new
();
girara_list_set_free_function
(
zathura
->
plugins
.
path
,
g_free
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment