1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 """connection widgets and dialogs"""
19
20 import os
21 import gettext
22
23 import gobject
24 import gtk
25 from kiwi.ui.objectlist import Column
26 from pango import ELLIPSIZE_MIDDLE, ELLIPSIZE_END
27
28 from flumotion.admin.connections import getRecentConnections, \
29 hasRecentConnections
30 from flumotion.common.pygobject import gsignal, gproperty
31 from flumotion.ui.glade import GladeWidget, GladeWindow
32
33 __version__ = "$Rev$"
34 _ = gettext.gettext
35
36
39
40
42 gladeFile = 'connections.glade'
43
44 gsignal('have-connection', bool)
45 gsignal('connection-activated', object)
46 gsignal('connections-cleared')
47
49 GladeWidget.__init__(self)
50
51 self.connections.set_columns(
52 [Column("host", title=_("Hostname"), searchable=True,
53 ellipsize=ELLIPSIZE_MIDDLE, expand=True, width=100),
54 Column("manager", title=_("Manager"), searchable=True,
55 ellipsize=ELLIPSIZE_END, expand=True, width=50),
56 Column("timestamp", title=_("Last used"),
57 sorted=True,
58 order=gtk.SORT_DESCENDING,
59 format_func=format_timestamp),
60 ])
61 self.connections.add_list(getRecentConnections())
62 self.connections.get_treeview().set_search_equal_func(
63 self._searchEqual)
64 self.connections.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
65 self.connections.set_property('selection-mode', gtk.SELECTION_SINGLE)
66 self.connections.set_size_request(-1, 160)
67
68 self._updateButtons()
69
76
84
89
93
94
95
100
103
104 - def update(self, connection):
106
107
108
114
118
121
124
125 gobject.type_register(Connections)
126
127
129 gladeFile = 'connection-dialog.glade'
130
131 gsignal('have-connection', object)
132
135
138
139 - def on_ok(self, button):
140 self.emit('have-connection',
141 self.widgets['connections'].get_selected())
142
145
147 self.button_ok.set_sensitive(False)
148
149 gobject.type_register(ConnectionsDialog)
150
151
153 gladeFile = 'open-connection.glade'
154
155 gproperty(bool, 'can-activate', 'If the state of the widget is complete',
156 False)
157
164
168
170 old_can_act = self.get_property('can-activate')
171 can_act = self.host_entry.get_text() and self.port_entry.get_text()
172
173 if old_can_act != can_act:
174 self.set_property('can-activate', can_act)
175
177 if button.get_active():
178 self.port_entry.set_text('7531')
179 else:
180 self.port_entry.set_text('8642')
181
183 self.host_entry.set_text(state['host'])
184 self.port_entry.set_text(str(state['port']))
185 self.ssl_check.set_active(not state['use_insecure'])
186
188 return {'host': self.host_entry.get_text(),
189 'port': int(self.port_entry.get_text()),
190 'use_insecure': not self.ssl_check.get_active()}
191 gobject.type_register(OpenConnection)
192
193
195 gladeFile = 'authenticate.glade'
196
197 gproperty(bool, 'can-activate', 'If the state of the widget is complete',
198 False)
199
200
201 auth_method_combo = None
202 user_entry = None
203 passwd_entry = None
204
211
213 toplevel = self.get_toplevel()
214 toplevel.wizard.next()
215
218
220 can_act = self.user_entry.get_text() and self.passwd_entry.get_text()
221 self.set_property('can-activate', can_act)
222
230
234 gobject.type_register(Authenticate)
235