changeset 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 462fc3359ee3
children 487dd238ab88
files browser_side/dialog.py
diffstat 1 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/dialog.py	Tue Mar 11 12:31:29 2014 +0100
+++ b/browser_side/dialog.py	Tue Mar 11 12:55:31 2014 +0100
@@ -50,22 +50,24 @@
         Grid.__init__(self, 2, 2, Width='100%')
         self.host = host
 
-        self.exist_radio = RadioButton("room", "Already joined:")
-        self.rooms_list = ListBox(Width='95%')
-        self.setRooms()
-
         self.new_radio = RadioButton("room", "Discussion room:")
         self.new_radio.setChecked(True)
         self.box = TextBox(Width='95%')
         self.box.setText(self.GENERATE_MUC if default_room == "" else default_room)
+        self.exist_radio = RadioButton("room", "Already joined:")
+        self.rooms_list = ListBox(Width='95%')
 
         self.add(self.new_radio, 0, 0)
         self.add(self.box, 0, 1)
         self.add(self.exist_radio, 1, 0)
         self.add(self.rooms_list, 1, 1)
 
+        self.box.addFocusListener(self)
         self.rooms_list.addFocusListener(self)
-        self.box.addFocusListener(self)
+
+        self.exist_radio.setVisible(False)
+        self.rooms_list.setVisible(False)
+        self.setRooms()
 
     def onFocus(self, sender):
         if sender == self.rooms_list:
@@ -80,9 +82,13 @@
             if self.box.getText() == "":
                 self.box.setText(self.GENERATE_MUC)
 
-    def setRooms(self, room_data):
+    def setRooms(self):
         for room in self.host.room_list:
             self.rooms_list.addItem(room.bare)
+        if len(self.host.room_list) > 0:
+            self.exist_radio.setVisible(True)
+            self.rooms_list.setVisible(True)
+            self.exist_radio.setChecked(True)
 
     def getRoom(self):
         if self.exist_radio.getChecked():
@@ -174,9 +180,12 @@
         self.contact_panel = ContactsChooser(host, nb_contact, ok_button)
 
         self.stack_panel = ToggleStackPanel(Width="100%")
-        self.stack_panel.add(self.room_panel, title_room, visible=visible[0])
-        self.stack_panel.add(self.contact_panel, title_invite, visible=visible[1])
+        self.stack_panel.add(self.room_panel, visible=visible[0])
+        self.stack_panel.add(self.contact_panel, visible=visible[1])
         self.stack_panel.addStackChangeListener(self)
+        self.onStackChanged(self.stack_panel, 0, visible[0])
+        self.onStackChanged(self.stack_panel, 1, visible[1])
+
         main_panel = VerticalPanel()
         main_panel.setStyleName("room-contact-chooser")
         main_panel.add(self.stack_panel)