Implemented cmd_print

This commit is contained in:
Moritz Lipp 2010-01-02 00:36:32 +01:00
parent 6d1d3901c6
commit 77d23a847f
2 changed files with 16 additions and 1 deletions

View file

@ -34,6 +34,7 @@ static const char DEFAULT_TEXT[] = "[No Name]";
/* printing */
#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 */
#define SHOW_SCROLLBARS 0

View file

@ -1345,6 +1345,20 @@ cmd_open(int argc, char** argv)
gboolean
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;
}
@ -1558,7 +1572,7 @@ cc_print(char* input)
while((current_char = fgetc(fp)) != EOF)
{
if(!current_line)
current_line = malloc(sizeof(char) * 512);
current_line = malloc(sizeof(char));
current_line = realloc(current_line, (count + 1) * sizeof(char));