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
7d18faa4
Commit
7d18faa4
authored
Mar 18, 2011
by
Moritz Lipp
Browse files
Replace GtkWidget with zathura_image_buffer_t
parent
58c2ee7d
Changes
9
Hide whitespace changes
Inline
Side-by-side
document.c
View file @
7d18faa4
...
...
@@ -124,7 +124,7 @@ zathura_document_plugins_free(void)
bool
zathura_document_plugin_register
(
zathura_document_plugin_t
*
new_plugin
,
void
*
handle
)
{
if
(
(
new_plugin
==
NULL
)
||
(
new_plugin
->
file_extension
==
NULL
)
||
(
new_plugin
->
open_function
==
NULL
)
if
(
(
new_plugin
==
NULL
)
||
(
new_plugin
->
file_extension
==
NULL
)
||
(
new_plugin
->
open_function
==
NULL
)
||
(
handle
==
NULL
)
)
{
fprintf
(
stderr
,
"plugin: could not register
\n
"
);
return
false
;
...
...
@@ -469,7 +469,7 @@ zathura_page_form_fields_free(zathura_list_t* list)
return
false
;
}
GtkWidge
t
*
zathura_image_buffer_
t
*
zathura_page_render
(
zathura_page_t
*
page
)
{
if
(
!
page
||
!
page
->
document
)
{
...
...
@@ -481,13 +481,13 @@ zathura_page_render(zathura_page_t* page)
return
NULL
;
}
GtkWidget
*
widget
=
page
->
document
->
functions
.
page_render
(
page
);
zathura_image_buffer_t
*
buffer
=
page
->
document
->
functions
.
page_render
(
page
);
if
(
widget
)
{
if
(
buffer
)
{
page
->
rendered
=
true
;
}
return
widget
;
return
buffer
;
}
zathura_index_element_t
*
...
...
@@ -523,3 +523,35 @@ zathura_index_element_free(zathura_index_element_t* index)
g_free
(
index
);
}
zathura_image_buffer_t
*
zathura_image_buffer_create
(
unsigned
int
width
,
unsigned
int
height
)
{
zathura_image_buffer_t
*
image_buffer
=
malloc
(
sizeof
(
zathura_image_buffer_t
));
if
(
image_buffer
==
NULL
)
{
return
NULL
;
}
image_buffer
->
data
=
calloc
(
width
*
height
*
3
,
sizeof
(
unsigned
char
));
if
(
image_buffer
->
data
==
NULL
)
{
free
(
image_buffer
);
return
NULL
;
}
image_buffer
->
width
=
width
;
image_buffer
->
height
=
height
;
return
image_buffer
;
}
void
zathura_image_buffer_free
(
zathura_image_buffer_t
*
image_buffer
)
{
if
(
image_buffer
==
NULL
)
{
return
;
}
free
(
image_buffer
->
data
);
}
document.h
View file @
7d18faa4
...
...
@@ -43,6 +43,32 @@ struct zathura_list_s
struct
zathura_list_s
*
next
;
/**> Next element in the list */
};
/**
* Image buffer
*/
typedef
struct
zathura_image_buffer_s
{
unsigned
char
*
data
;
/**> Image buffer data */
unsigned
int
height
;
/**> Height of the image */
unsigned
int
width
;
/**> Width of the image */
}
zathura_image_buffer_t
;
/**
* Creates an image buffer
*
* @param width Width of the image stored in the buffer
* @param height Height of the image stored in the buffer
* @return Image buffer or NULL if an error occured
*/
zathura_image_buffer_t
*
zathura_image_buffer_create
(
unsigned
int
width
,
unsigned
int
height
);
/**
* Frees the image buffer
*
* @param zathura_image_buffer_t
*/
void
zathura_image_buffer_free
(
zathura_image_buffer_t
*
);
/**
* Rectangle structure
*/
...
...
@@ -141,83 +167,51 @@ struct zathura_document_s
{
/**
* Frees the document
*
* @param document The document
*/
bool
(
*
document_free
)(
zathura_document_t
*
document
);
/**
* Generates the document index
*
* @param document The document
* @return NULL if an error occured or no index exists
*/
girara_tree_node_t
*
(
*
document_index_generate
)(
zathura_document_t
*
document
);
/**
* Save the document
*
* @param document The document
* @param path The new path
* @return true if no error occured
*/
bool
(
*
document_save_as
)(
zathura_document_t
*
document
,
const
char
*
path
);
/**
* Get list of attachments
*
* @param document The document
* @return NULL if an error occured, otherwise the attachment list
*/
zathura_list_t
*
(
*
document_attachments_get
)(
zathura_document_t
*
document
);
/**
* Gets the page object
*
* @param document The document
* @param page_id Number of the page
* @return The page object or NULL, if an error occured
*/
zathura_page_t
*
(
*
page_get
)(
zathura_document_t
*
document
,
unsigned
int
page_id
);
/**
* Search text
*
* @param page The page
* @param text Search item
* @return List of results
*/
zathura_list_t
*
(
*
page_search_text
)(
zathura_page_t
*
page
,
const
char
*
text
);
/**
* Get links on a page
*
* @param page
* @return List of links
*/
zathura_list_t
*
(
*
page_links_get
)(
zathura_page_t
*
page
);
/**
* Get form fields
*
* @param page
* @return List of form fields
*/
zathura_list_t
*
(
*
page_form_fields_get
)(
zathura_page_t
*
page
);
/**
* Renders the page
*
* @param page
* @return Rendered page
*/
GtkWidge
t
*
(
*
page_render
)(
zathura_page_t
*
page
);
zathura_image_buffer_
t
*
(
*
page_render
)(
zathura_page_t
*
page
);
/**
* Free page
*
* @param page
* @return true if no error occured, otherwise false
*/
bool
(
*
page_free
)(
zathura_page_t
*
page
);
}
functions
;
...
...
@@ -356,9 +350,9 @@ bool zathura_page_form_fields_free(zathura_list_t* list);
* Render page
*
* @param page The page object
* @return
Rendered page
* @return
Image buffer or NULL if an error occured
*/
GtkWidge
t
*
zathura_page_render
(
zathura_page_t
*
page
);
zathura_image_buffer_
t
*
zathura_page_render
(
zathura_page_t
*
page
);
/**
* Create new index element
...
...
ft/djvu/djvu.c
View file @
7d18faa4
...
...
@@ -215,7 +215,7 @@ djvu_page_form_fields_get(zathura_page_t* page)
return
NULL
;
}
GtkWidge
t
*
zathura_image_buffer_
t
*
djvu_page_render
(
zathura_page_t
*
page
)
{
if
(
!
Zathura
.
document
||
!
page
||
!
page
->
document
)
{
...
...
ft/djvu/djvu.h
View file @
7d18faa4
...
...
@@ -24,7 +24,7 @@ zathura_page_t* djvu_page_get(zathura_document_t* document, unsigned int page);
zathura_list_t
*
djvu_page_search_text
(
zathura_page_t
*
page
,
const
char
*
text
);
zathura_list_t
*
djvu_page_links_get
(
zathura_page_t
*
page
);
zathura_list_t
*
djvu_page_form_fields_get
(
zathura_page_t
*
page
);
GtkWidge
t
*
djvu_page_render
(
zathura_page_t
*
page
);
zathura_image_buffer_
t
*
djvu_page_render
(
zathura_page_t
*
page
);
bool
djvu_page_free
(
zathura_page_t
*
page
);
#endif // DJVU_H
ft/pdf-mupdf/pdf.c
View file @
7d18faa4
...
...
@@ -173,7 +173,7 @@ pdf_page_form_fields_get(zathura_page_t* page)
return
NULL
;
}
GtkWidge
t
*
zathura_image_buffer_
t
*
pdf_page_render
(
zathura_page_t
*
page
)
{
if
(
!
Zathura
.
document
||
!
page
||
!
page
->
data
||
!
page
->
document
)
{
...
...
ft/pdf-mupdf/pdf.h
View file @
7d18faa4
...
...
@@ -27,7 +27,7 @@ zathura_page_t* pdf_page_get(zathura_document_t* document, unsigned int page);
zathura_list_t
*
pdf_page_search_text
(
zathura_page_t
*
page
,
const
char
*
text
);
zathura_list_t
*
pdf_page_links_get
(
zathura_page_t
*
page
);
zathura_list_t
*
pdf_page_form_fields_get
(
zathura_page_t
*
page
);
GtkWidge
t
*
pdf_page_render
(
zathura_page_t
*
page
);
zathura_image_buffer_
t
*
pdf_page_render
(
zathura_page_t
*
page
);
bool
pdf_page_free
(
zathura_page_t
*
page
);
#endif // PDF_H
ft/pdf-poppler/pdf.c
View file @
7d18faa4
...
...
@@ -250,7 +250,7 @@ pdf_page_form_fields_get(zathura_page_t* page)
return
NULL
;
}
GtkWidge
t
*
zathura_image_buffer_
t
*
pdf_page_render
(
zathura_page_t
*
page
)
{
if
(
!
Zathura
.
document
||
!
page
||
!
page
->
data
||
!
page
->
document
)
{
...
...
ft/pdf-poppler/pdf.h
View file @
7d18faa4
...
...
@@ -22,7 +22,7 @@ zathura_page_t* pdf_page_get(zathura_document_t* document, unsigned int page);
zathura_list_t
*
pdf_page_search_text
(
zathura_page_t
*
page
,
const
char
*
text
);
zathura_list_t
*
pdf_page_links_get
(
zathura_page_t
*
page
);
zathura_list_t
*
pdf_page_form_fields_get
(
zathura_page_t
*
page
);
GtkWidge
t
*
pdf_page_render
(
zathura_page_t
*
page
);
zathura_image_buffer_
t
*
pdf_page_render
(
zathura_page_t
*
page
);
bool
pdf_page_free
(
zathura_page_t
*
page
);
#endif // PDF_H
render.c
View file @
7d18faa4
...
...
@@ -132,9 +132,9 @@ bool
render
(
zathura_page_t
*
page
)
{
g_static_mutex_lock
(
&
(
page
->
lock
));
GtkWidget
*
image
=
zathura_page_render
(
page
);
zathura_image_buffer_t
*
buffer
=
zathura_page_render
(
page
);
if
(
!
image
)
{
if
(
!
buffer
)
{
g_static_mutex_unlock
(
&
(
page
->
lock
));
printf
(
"error: rendering failed
\n
"
);
return
false
;
...
...
@@ -148,7 +148,7 @@ render(zathura_page_t* page)
if
(
!
widget
)
{
g_static_mutex_unlock
(
&
(
page
->
lock
));
printf
(
"error: page container does not exist
\n
"
);
g_object_un
re
f
(
image
);
// TODO: zathura_image_buffer_f
re
e
(image);
return
false
;
}
...
...
@@ -164,13 +164,13 @@ render(zathura_page_t* page)
gtk_container_remove
(
GTK_CONTAINER
(
Zathura
.
UI
.
page_view
),
widget
);
/* add new widget */
gtk_box_pack_start
(
GTK_BOX
(
Zathura
.
UI
.
page_view
),
image
,
TRUE
,
TRUE
,
0
);
// TODO:
gtk_box_pack_start(GTK_BOX(Zathura.UI.page_view), image, TRUE, TRUE, 0);
/* set old packaging values */
gtk_box_set_child_packing
(
GTK_BOX
(
Zathura
.
UI
.
page_view
),
image
,
expand
,
fill
,
padding
,
pack_type
);
// TODO:
gtk_box_set_child_packing(GTK_BOX(Zathura.UI.page_view), image, expand, fill, padding, pack_type);
/* reorder child */
gtk_box_reorder_child
(
GTK_BOX
(
Zathura
.
UI
.
page_view
),
image
,
page
->
number
);
// TODO:
gtk_box_reorder_child(GTK_BOX(Zathura.UI.page_view), image, page->number);
g_static_mutex_unlock
(
&
(
page
->
lock
));
return
true
;
...
...
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