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
ebd6605a
Commit
ebd6605a
authored
Apr 29, 2011
by
Moritz Lipp
Browse files
Began to implement the printing dialog
parent
2504604e
Changes
5
Hide whitespace changes
Inline
Side-by-side
commands.c
View file @
ebd6605a
...
...
@@ -2,6 +2,7 @@
#include "commands.h"
#include "zathura.h"
#include "print.h"
bool
cmd_bookmark_create
(
girara_session_t
*
session
,
girara_list_t
*
argument_list
)
...
...
@@ -43,6 +44,17 @@ cmd_info(girara_session_t* session, girara_list_t* argument_list)
bool
cmd_print
(
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
;
}
print
((
zathura_t
*
)
session
->
global
.
data
);;
return
true
;
}
...
...
print.c
0 → 100644
View file @
ebd6605a
#include "print.h"
#include "document.h"
void
print
(
zathura_t
*
zathura
)
{
g_return_if_fail
(
zathura
!=
NULL
);
g_return_if_fail
(
zathura
->
document
!=
NULL
);
GtkPrintOperation
*
print_operation
=
gtk_print_operation_new
();
/* print operation settings */
if
(
zathura
->
print
.
settings
!=
NULL
)
{
gtk_print_operation_set_print_settings
(
print_operation
,
zathura
->
print
.
settings
);
}
if
(
zathura
->
print
.
page_setup
!=
NULL
)
{
gtk_print_operation_set_default_page_setup
(
print_operation
,
zathura
->
print
.
page_setup
);
}
gtk_print_operation_set_show_progress
(
print_operation
,
TRUE
);
gtk_print_operation_set_n_pages
(
print_operation
,
zathura
->
document
->
number_of_pages
);
gtk_print_operation_set_current_page
(
print_operation
,
zathura
->
document
->
current_page_number
);
/* print operation signals */
g_signal_connect
(
print_operation
,
"draw-page"
,
G_CALLBACK
(
cb_print_draw_page
),
zathura
);
/* print */
GtkPrintOperationResult
result
=
gtk_print_operation_run
(
print_operation
,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG
,
NULL
,
NULL
);
if
(
result
==
GTK_PRINT_OPERATION_RESULT_APPLY
)
{
/* save previous settings */
zathura
->
print
.
settings
=
gtk_print_operation_get_print_settings
(
print_operation
);
zathura
->
print
.
page_setup
=
gtk_print_operation_get_default_page_setup
(
print_operation
);
}
else
if
(
result
==
GTK_PRINT_OPERATION_RESULT_ERROR
)
{
girara_error
(
"Error occured while printing progress"
);
}
g_object_unref
(
print_operation
);
}
void
cb_print_draw_page
(
GtkPrintOperation
*
print_operation
,
GtkPrintContext
*
context
,
gint
page_number
,
zathura_t
*
zathura
)
{
cairo_t
*
cairo
=
gtk_print_context_get_cairo_context
(
context
);
/*zathura_page_t* page = zathura->document->pages[page_number];*/
/*g_static_mutex_lock(&(page->lock));*/
/*zathura_image_buffer_t* image_buffer = zathura_page_render(page);*/
/*g_static_mutex_unlock(&(page->lock));*/
/*for (unsigned int y = 0; y < image_buffer->height; y++) {*/
/*unsigned char* src = image_buffer->data + y * image_buffer->rowstride;*/
/*for (unsigned int x = 0; x < image_buffer->width; x++) {*/
/*cairo_set_source_rgb(cairo, src[0], src[1], src[2]);*/
/*cairo_rectangle(cairo, x, y, 1, 1);*/
/*cairo_fill(cairo);*/
/*}*/
/*}*/
}
print.h
0 → 100644
View file @
ebd6605a
/* See LICENSE file for license and copyright information */
#ifndef PRINT_H
#define PRINT_H
#include "zathura.h"
/**
* Opens a print dialog to print the current file
*
* @param zathura
*/
void
print
(
zathura_t
*
zathura
);
/**
* Callback that is executed for every page that should be printed
*
* @param print_operation Print operation object
* @param context Print context
* @param page_number Current page number
* @param zathura Zathura object
*/
void
cb_print_draw_page
(
GtkPrintOperation
*
print_operation
,
GtkPrintContext
*
context
,
gint
page_number
,
zathura_t
*
zathura
);
#endif // PRINT_H
zathura.c
View file @
ebd6605a
...
...
@@ -31,6 +31,9 @@ zathura_init(int argc, char* argv[])
return
NULL
;
}
/* general */
zathura
->
document
=
NULL
;
/* plugins */
zathura
->
plugins
.
plugins
=
girara_list_new
();
zathura
->
plugins
.
path
=
girara_list_new
();
...
...
@@ -101,6 +104,10 @@ zathura_init(int argc, char* argv[])
zathura
->
ui
.
page_view
=
NULL
;
zathura
->
ui
.
index
=
NULL
;
/* Print settings */
zathura
->
print
.
settings
=
NULL
;
zathura
->
print
.
page_setup
=
NULL
;
/* load plugins */
zathura_document_plugins_load
(
zathura
);
...
...
@@ -206,6 +213,10 @@ zathura_free(zathura_t* zathura)
document_close
(
zathura
);
/* free print settings */
g_object_unref
(
zathura
->
print
.
settings
);
g_object_unref
(
zathura
->
print
.
page_setup
);
/* free registered plugins */
zathura_document_plugins_free
(
zathura
);
girara_list_free
(
zathura
->
plugins
.
plugins
);
...
...
zathura.h
View file @
ebd6605a
...
...
@@ -65,6 +65,12 @@ typedef struct zathura_s
gchar
*
data_dir
;
}
config
;
struct
{
GtkPrintSettings
*
settings
;
GtkPageSetup
*
page_setup
;
}
print
;
struct
{
unsigned
int
page_padding
;
...
...
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