mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-02-05 09:34:56 +01:00
Implemented cmd_print
This commit is contained in:
parent
6d1d3901c6
commit
77d23a847f
2 changed files with 16 additions and 1 deletions
|
@ -34,6 +34,7 @@ static const char DEFAULT_TEXT[] = "[No Name]";
|
||||||
|
|
||||||
/* printing */
|
/* printing */
|
||||||
#define LIST_PRINTER_COMMAND "lpstat -v | sed -n '/^.*device for \\(.*\\): .*$/s//\\1/p'"
|
#define LIST_PRINTER_COMMAND "lpstat -v | sed -n '/^.*device for \\(.*\\): .*$/s//\\1/p'"
|
||||||
|
#define PRINT_COMMAND "lp -d '%s' -p %s %s" /* printer / pages / file */
|
||||||
|
|
||||||
/* additional settings */
|
/* additional settings */
|
||||||
#define SHOW_SCROLLBARS 0
|
#define SHOW_SCROLLBARS 0
|
||||||
|
|
16
zathura.c
16
zathura.c
|
@ -1345,6 +1345,20 @@ cmd_open(int argc, char** argv)
|
||||||
gboolean
|
gboolean
|
||||||
cmd_print(int argc, char** argv)
|
cmd_print(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
if(!Zathura.PDF.document)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
if(argc == 0)
|
||||||
|
{
|
||||||
|
notify(WARNING, "No printer specified");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* printer = argv[0];
|
||||||
|
char* sites = (argc == 2) ? argv[1] : g_strdup_printf("%i", Zathura.PDF.number_of_pages);
|
||||||
|
char* print_command = g_strdup_printf(PRINT_COMMAND, printer, sites, Zathura.PDF.file);
|
||||||
|
system(print_command);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1558,7 +1572,7 @@ cc_print(char* input)
|
||||||
while((current_char = fgetc(fp)) != EOF)
|
while((current_char = fgetc(fp)) != EOF)
|
||||||
{
|
{
|
||||||
if(!current_line)
|
if(!current_line)
|
||||||
current_line = malloc(sizeof(char) * 512);
|
current_line = malloc(sizeof(char));
|
||||||
|
|
||||||
current_line = realloc(current_line, (count + 1) * sizeof(char));
|
current_line = realloc(current_line, (count + 1) * sizeof(char));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue