Tizen 2.1 base
[platform/upstream/hplip.git] / ui / coverpageform.py
1 # -*- coding: utf-8 -*-
2 #
3 # (c) Copyright 2003-2008 Hewlett-Packard Development Company, L.P.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # Author: Don Welch
20 #
21
22 # Std Lib
23
24 # Local
25 from base.g import *
26 from ui_utils import load_pixmap
27 from fax import coverpages
28 from ui_utils import load_pixmap
29
30 # Qt
31 from qt import *
32 from coverpageform_base import CoverpageForm_base
33
34
35
36 class CoverpageForm(CoverpageForm_base):
37     def __init__(self, cover_page_name='', preserve_formatting=False, parent=None, name=None, modal=0, fl=0):
38         CoverpageForm_base.__init__(self, parent, name, modal, fl)
39
40         self.preserve_formatting = preserve_formatting
41         self.preserveFormattingCheckBox.setChecked(preserve_formatting)
42         self.prevCoverpageButton.setPixmap(load_pixmap('prev', '16x16'))
43         self.nextCoverpageButton.setPixmap(load_pixmap('next', '16x16'))
44         self.coverpage_list = coverpages.COVERPAGES.keys()
45
46         if cover_page_name:
47             self.coverpage_index = self.coverpage_list.index(cover_page_name)
48         else:    
49             self.coverpage_index = 0
50
51         self.setCoverpage()
52
53
54     def setCoverpage(self, inc=0):
55         self.coverpage_index += inc
56
57         if self.coverpage_index > len(self.coverpage_list) - 1:
58             self.coverpage_index = 0
59
60         elif self.coverpage_index < 0:
61             self.coverpage_index = len(self.coverpage_list) - 1
62
63         self.coverpage_name = self.coverpage_list[self.coverpage_index]
64         self.data = coverpages.COVERPAGES[self.coverpage_name]
65
66         self.coverpagePixmap.setPixmap(load_pixmap(self.data[1], 'other'))
67
68         
69     def prevCoverpageButton_clicked(self):
70         self.setCoverpage(-1)
71
72         
73     def nextCoverpageButton_clicked(self):
74         self.setCoverpage(1)
75
76         
77     def preserveFormattingCheckBox_toggled(self,a0):
78         self.preserve_formatting = bool(a0)
79
80         
81     def __tr(self,s,c = None):
82         return qApp.translate("CoverpageForm_base",s,c)