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