1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 import screenlets
39
40 import os
41 import gtk, gobject
42
43
44 import gettext
45 gettext.textdomain('screenlets')
46 gettext.bindtextdomain('screenlets', screenlets.INSTALL_PREFIX + '/share/locale')
47
49 return gettext.gettext(s)
50
51 from boolean_option import BoolOption
52 from string_option import StringOption
53 from number_option import IntOption, FloatOption
54 from list_option import ListOption
55 from account_option import AccountOption
56 from font_option import FontOption
57 from file_option import FileOption, DirectoryOption, ImageOption
58 from colour_option import ColorOption, ColorsOption
59 from time_option import TimeOption
60 from base import EditableOptions, OptionsDialog, create_option_from_node
61
62
63 if __name__ == "__main__":
64
65 import os
66
67
69
70 testlist = ['test1', 'test2', 3, 5, 'Noch ein Test']
71 pop3_account = ('Username', '')
72
73
74 pin_x = 100
75 pin_y = 6
76 text_x = 19
77 text_y = 35
78 font_name = 'Sans 12'
79 rgba_color = (0.0, 0.0, 1.0, 1.0)
80 text_prefix = '<b>'
81 text_suffix = '</b>'
82 note_text = ""
83 random_pin_pos = True
84 opt1 = 'testval 1'
85 opt2 = 'testval 2'
86 filename2 = ''
87 filename = ''
88 dirname = ''
89 font = 'Sans 12'
90 color = (0.1, 0.5, 0.9, 0.9)
91 name = 'a name'
92 name2 = 'another name'
93 combo_test = 'el2'
94 flt = 0.5
95 x = 10
96 y = 25
97 width = 30
98 height = 50
99 is_sticky = False
100 is_widget = False
101 time = (12, 32, 49)
102
104 EditableOptions.__init__(self)
105
106 self.add_options_group('General',
107 'The general options for this Object ...')
108 self.add_options_group('Window',
109 'The Window-related options for this Object ...')
110 self.add_options_group('Test', 'A Test-group ...')
111
112 self.add_option(ListOption('Test', 'testlist', default=self.testlist,
113 label='ListOption-Test', desc='Testing a ListOption-type ...'))
114 self.add_option(StringOption('Window', 'name', default='TESTNAME',
115 label='Testname', desc='The name/id of this Screenlet-instance ...'),
116 realtime=False)
117 self.add_option(AccountOption('Test', 'pop3_account',
118 default=self.pop3_account, label='Username/Password',
119 desc='Enter username/password here ...'))
120 self.add_option(StringOption('Window', 'name2', default='TESTNAME2',
121 label='String2', desc='Another string-test ...'))
122 self.add_option(StringOption('Test', 'combo_test', default="el1",
123 label='Combo', desc='A StringOption for a drop-down-list.',
124 choices=['el1', 'el2', 'element 3']))
125 self.add_option(FloatOption('General', 'flt', default=30.4,
126 label='A Float', desc='Testing a FLOAT-type ...',
127 min=0, max=gtk.gdk.screen_width(), increment=0.01, digits=4))
128 self.add_option(IntOption('General', 'x', default=30,
129 label='X-Position', desc='The X-position of this Screenlet ...',
130 min=0, max=gtk.gdk.screen_width()))
131 self.add_option(IntOption('General', 'y', default=30,
132 label='Y-Position', desc='The Y-position of this Screenlet ...',
133 min=0, max=gtk.gdk.screen_height()))
134 self.add_option(IntOption('Test', 'width', default=300,
135 label='Width', desc='The width of this Screenlet ...',
136 min=100, max=1000, increment=12))
137 self.add_option(IntOption('Test', 'height', default=150,
138 label='Height', desc='The height of this Screenlet ...',
139 min=100, max=1000))
140 self.add_option(BoolOption('General', 'is_sticky', default=True,
141 label='Stick to Desktop', desc='Show this Screenlet always ...'))
142 self.add_option(BoolOption('General', 'is_widget', default=False,
143 label='Treat as Widget', desc='Treat this Screenlet as a "Widget" ...'))
144 self.add_option(FontOption('Test', 'font', default='Sans 14',
145 label='Font', desc='The font for whatever ...'))
146 self.add_option(ColorOption('Test', 'color', default=(1, 0.35, 0.35, 0.7),
147 label='Color', desc='The color for whatever ...'))
148 self.add_option(ColorsOption('Test', 'rainbows', default=[(1, 0.35, 0.35, 0.7), (0.1, 0.8, 0.2, 0.2), (1, 0.35, 0.6, 0.7)],
149 label='Multi-Colours', desc='The colors for whatever ...'))
150 self.add_option(ColorsOption('Test', 'rainbow2', default=(1, 0.35, 0.35, 0.7),
151 label='Colours-Up', desc='The colors for whatever ...'))
152 self.add_option(FileOption('Test', 'filename', default=os.environ['HOME'],
153 label='Filename-Test', desc='Testing a FileOption-type ...',
154 patterns=[ ( 'Python Files', ['*.py', '*.pyc'] ) ]))
155 self.add_option(ImageOption('Test', 'filename2', default=os.environ['HOME'],
156 label='Image-Test', desc='Testing the ImageOption-type ...'))
157 self.add_option(DirectoryOption('Test', 'dirname', default=os.environ['HOME'],
158 label='Directory-Test', desc='Testing a FileOption-type ...'))
159 self.add_option(TimeOption('Test','time', default=self.time,
160 label='TimeOption-Test', desc='Testing a TimeOption-type ...'))
161
162 self.disable_option('width')
163 self.disable_option('height')
164
165
166
168 self.__dict__[name] = value
169 print name + "=" + str(value)
170
173
174
175
177
178 uses_theme = True
179 theme_name = 'test'
180
182 TestObject.__init__(self)
183 self.add_option(StringOption('Test', 'anothertest', default='ksjhsjgd',
184 label='Another Test', desc='An attribute in the subclass ...'))
185 self.add_option(StringOption('Test', 'theme_name', default=self.theme_name,
186 label='Theme', desc='The theme for this Screenelt ...',
187 choices=['test1', 'test2', 'mytheme', 'blue', 'test']))
188
189
190
191 to = TestChildObject()
192
193 se = OptionsDialog(500, 380)
194
195 img = gtk.Image()
196 img.set_from_file('../share/screenlets/Notes/icon.svg')
197 se.set_info('TestOptions',
198 'A test for an extended options-dialog with embedded about-info.' +
199 ' Can be used for the Screenlets to have all in one ...\nNOTE:' +
200 '<span color="red"> ONLY A TEST!</span>',
201 '(c) RYX 2007', version='v0.0.1', icon=img)
202 se.show_options_for_object(to)
203 resp = se.run()
204 if resp == gtk.RESPONSE_OK:
205 print "OK"
206 else:
207 print "Cancelled."
208 se.destroy()
209 print to.export_options_as_list()
210