~vorlon/ubuntu/saucy/gourmet/trunk

« back to all changes in this revision

Viewing changes to src/lib/exporters/lprprinter.py

  • Committer: Bazaar Package Importer
  • Author(s): Jamie Strandboge
  • Date: 2009-12-29 09:12:49 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20091229091249-n45z95fou0yr2t1t
Tags: 0.15.2-0ubuntu1
* New upstream release (LP: #431806, Closes: #530841). Also fixes the
  following bugs:
  - LP: #315836
  - LP: #295982
  - LP: #316445 (the GUI has been changed so this no longer applies)
* Drop forcing of python2.5
* debian/control: Recommends python-gnome2-extras for printing
* drop debian/patches/05-add_manpage.patch, which is now included upstream
* Fix some lintian warnings:
  - add debian/README.source
  - debian/control: bump Standards-Version to 3.8.3
  - debian/compat: bump to 5
* debian/control: Depends on python-poppler (needed for printing)
* debian/patches/01_fix_raise_str.patch: don't raise str exception
  in src/lib/plugin_gui.py
* debian/patches/02_fix_nutrition_index_out_of_range.patch: don't
  add entries beyond the width of the field in databaseGrabber.py
* debian/patches/03_dont_remove_nonexistent_plugin.patch: don't
  remove an inactive plugin in plugin_loader.py and don't deactivate
  a plugin from a non-existent database

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
from gourmet.gtk_extras import dialog_extras as de
2
 
import exporter
3
 
import os
4
 
from gettext import gettext as _
5
 
 
6
 
class RecRenderer:
7
 
    def __init__ (self, rd, recs, mult=1, dialog_title=_("Print Recipes"),
8
 
                  dialog_parent=None, change_units=True):        
9
 
        command = self.get_command(label='Enter print command',
10
 
                                   sublabel='Please enter the command you would like to use to print.',
11
 
                                   default_value='lpr')
12
 
        # TO TEST LOUSY COMMAND-ENTERING CODE, UNCOMMENT THE FOLLOWING
13
 
        #command = 'asdf'
14
 
        while os.system('which %s'%command.split()[0]) != 0:
15
 
            label = _("Enter print command")
16
 
            sublabel = _("Unable to find command \"%s\".")%command
17
 
            sublabel += _('Please enter the command you would like to use to print.')
18
 
            command=self.get_command(label=_('Enter print command'),
19
 
                                     sublabel=label)
20
 
        lpr = os.popen(command,'w')
21
 
        de.show_message(
22
 
            label=_('Printing via %s')%command,
23
 
            sublabel=_('If you install python-gnome, you will be able to print with a much more attractive interface.'))
24
 
        for r in recs:
25
 
            exporter.exporter_mult(rd, r, out=lpr,mult=mult,change_units=change_units)
26
 
        lpr.close()
27
 
 
28
 
    def get_command (self, label="",sublabel="",default_value=None):
29
 
        cmd = de.getEntry(label=label,
30
 
                          sublabel=sublabel,
31
 
                          entryLabel=_('Command:'),
32
 
                          default_value=default_value)
33
 
        if not cmd: raise "User cancelled!"
34
 
        else: return cmd
35
 
    
36
 
 
37
 
class SimpleWriter:
38
 
    def __init__ (self, file=None, dialog_parent=None, show_dialog=True):
39
 
        if file:
40
 
            self.out = open(file,'w')
41
 
        else:
42
 
            self.out = os.popen('lpr','w')
43
 
        if show_dialog:
44
 
            de.show_message(
45
 
                label='Printing via LPR',
46
 
                sublabel='If you install python-gnome, you will be able to print with a much more attractive interface.')
47
 
 
48
 
    def write_header (self, text):
49
 
        self.out.write("%s\n---\n"%text)
50
 
        
51
 
    def write_subheader (self, text):
52
 
        self.out.write("\n\n%s\n---\n"%text)
53
 
 
54
 
    def write_paragraph (self, text):
55
 
        self.out.write("%s\n"%text)
56
 
 
57
 
    def close (self):
58
 
        self.out.close()
59
 
    
60