Fixed build error by changing buildrequires from pkgconfig(turbo-jpeg) to libjpeg...
[platform/upstream/hplip.git] / printsettings.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 #
4 # (c) Copyright 2003-2009 Hewlett-Packard Development Company, L.P.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 #
20 # Author: Don Welch
21 #
22
23 __version__ = '1.0'
24 __title__ = 'Printer Settings Utility'
25 __mod__ = 'hp-printsettings'
26 __doc__ = "Printer settings (options) utility for HPLIP supported printers."
27
28 #Std Lib
29 import sys
30 import re
31 import getopt
32 import time
33 import operator
34 import os
35
36 # Local
37 from base.g import *
38 from base import device, utils, maint, tui, module
39 from prnt import cups
40
41
42 try:
43     mod = module.Module(__mod__, __title__, __version__, __doc__, None,
44                         (GUI_MODE,), (UI_TOOLKIT_QT4,))
45
46     mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS,
47              see_also_list=['hp-toolbox', 'hp-print'])
48
49     opts, device_uri, printer_name, mode, ui_toolkit, loc = \
50         mod.parseStdOpts('', ['fax'])
51
52     fax_mode = False
53     for o, a in opts:
54         if o == '--fax':
55             fax_mode = True
56
57     if fax_mode:
58         back_end_filter = ['hpfax']
59     else:
60         back_end_filter = ['hp', 'hpfax']
61
62     printer_name, device_uri = mod.getPrinterName(printer_name, device_uri, back_end_filter)
63
64     if ui_toolkit == 'qt3':
65         log.error("%s requires Qt4 support. Use hp-toolbox to adjust print settings. Exiting." % __mod__)
66         sys.exit(1)
67
68     if not utils.canEnterGUIMode4():
69         log.error("%s requires Qt4 GUI support. Exiting." % __mod__)
70         sys.exit(1)
71
72     try:
73         from PyQt4.QtGui import QApplication
74         from ui4.printsettingsdialog import PrintSettingsDialog
75     except ImportError:
76         log.error("Unable to load Qt4 support. Is it installed?")
77         sys.exit(1)
78
79     app = QApplication(sys.argv)
80
81     dialog = PrintSettingsDialog(None, printer_name, fax_mode)
82     dialog.show()
83     try:
84         log.debug("Starting GUI loop...")
85         app.exec_()
86     except KeyboardInterrupt:
87         log.error("User exit")
88         sys.exit(0)
89
90 except KeyboardInterrupt:
91     log.error("User exit")
92
93 log.info("")
94 log.info("Done.")
95