comparison browser_side/dialog.py @ 399:6e38d317bc16

browser_side: RoomChooser small improvements: - hide "Already joined" row if no room has been joined - select by default the first joined room (if any)
author souliane <souliane@mailoo.org>
date Tue, 11 Mar 2014 12:55:31 +0100
parents 2b5503392fbd
children d52f529a6d42
comparison
equal deleted inserted replaced
398:462fc3359ee3 399:6e38d317bc16
48 48
49 def __init__(self, host, default_room=DEFAULT_MUC): 49 def __init__(self, host, default_room=DEFAULT_MUC):
50 Grid.__init__(self, 2, 2, Width='100%') 50 Grid.__init__(self, 2, 2, Width='100%')
51 self.host = host 51 self.host = host
52 52
53 self.exist_radio = RadioButton("room", "Already joined:")
54 self.rooms_list = ListBox(Width='95%')
55 self.setRooms()
56
57 self.new_radio = RadioButton("room", "Discussion room:") 53 self.new_radio = RadioButton("room", "Discussion room:")
58 self.new_radio.setChecked(True) 54 self.new_radio.setChecked(True)
59 self.box = TextBox(Width='95%') 55 self.box = TextBox(Width='95%')
60 self.box.setText(self.GENERATE_MUC if default_room == "" else default_room) 56 self.box.setText(self.GENERATE_MUC if default_room == "" else default_room)
57 self.exist_radio = RadioButton("room", "Already joined:")
58 self.rooms_list = ListBox(Width='95%')
61 59
62 self.add(self.new_radio, 0, 0) 60 self.add(self.new_radio, 0, 0)
63 self.add(self.box, 0, 1) 61 self.add(self.box, 0, 1)
64 self.add(self.exist_radio, 1, 0) 62 self.add(self.exist_radio, 1, 0)
65 self.add(self.rooms_list, 1, 1) 63 self.add(self.rooms_list, 1, 1)
66 64
65 self.box.addFocusListener(self)
67 self.rooms_list.addFocusListener(self) 66 self.rooms_list.addFocusListener(self)
68 self.box.addFocusListener(self) 67
68 self.exist_radio.setVisible(False)
69 self.rooms_list.setVisible(False)
70 self.setRooms()
69 71
70 def onFocus(self, sender): 72 def onFocus(self, sender):
71 if sender == self.rooms_list: 73 if sender == self.rooms_list:
72 self.exist_radio.setChecked(True) 74 self.exist_radio.setChecked(True)
73 elif sender == self.box: 75 elif sender == self.box:
78 def onLostFocus(self, sender): 80 def onLostFocus(self, sender):
79 if sender == self.box: 81 if sender == self.box:
80 if self.box.getText() == "": 82 if self.box.getText() == "":
81 self.box.setText(self.GENERATE_MUC) 83 self.box.setText(self.GENERATE_MUC)
82 84
83 def setRooms(self, room_data): 85 def setRooms(self):
84 for room in self.host.room_list: 86 for room in self.host.room_list:
85 self.rooms_list.addItem(room.bare) 87 self.rooms_list.addItem(room.bare)
88 if len(self.host.room_list) > 0:
89 self.exist_radio.setVisible(True)
90 self.rooms_list.setVisible(True)
91 self.exist_radio.setChecked(True)
86 92
87 def getRoom(self): 93 def getRoom(self):
88 if self.exist_radio.getChecked(): 94 if self.exist_radio.getChecked():
89 values = self.rooms_list.getSelectedValues() 95 values = self.rooms_list.getSelectedValues()
90 return "" if values == [] else values[0] 96 return "" if values == [] else values[0]
172 178
173 self.room_panel = RoomChooser(host, "" if visible == (False, True) else DEFAULT_MUC) 179 self.room_panel = RoomChooser(host, "" if visible == (False, True) else DEFAULT_MUC)
174 self.contact_panel = ContactsChooser(host, nb_contact, ok_button) 180 self.contact_panel = ContactsChooser(host, nb_contact, ok_button)
175 181
176 self.stack_panel = ToggleStackPanel(Width="100%") 182 self.stack_panel = ToggleStackPanel(Width="100%")
177 self.stack_panel.add(self.room_panel, title_room, visible=visible[0]) 183 self.stack_panel.add(self.room_panel, visible=visible[0])
178 self.stack_panel.add(self.contact_panel, title_invite, visible=visible[1]) 184 self.stack_panel.add(self.contact_panel, visible=visible[1])
179 self.stack_panel.addStackChangeListener(self) 185 self.stack_panel.addStackChangeListener(self)
186 self.onStackChanged(self.stack_panel, 0, visible[0])
187 self.onStackChanged(self.stack_panel, 1, visible[1])
188
180 main_panel = VerticalPanel() 189 main_panel = VerticalPanel()
181 main_panel.setStyleName("room-contact-chooser") 190 main_panel.setStyleName("room-contact-chooser")
182 main_panel.add(self.stack_panel) 191 main_panel.add(self.stack_panel)
183 main_panel.add(button_panel) 192 main_panel.add(button_panel)
184 193