diff browser_side/panels.py @ 50:72c51a4839cc

MUC group joining
author Goffi <goffi@goffi.org>
date Thu, 26 May 2011 20:13:41 +0200
parents f1d2eb9b2523
children 9f19e16187ff
line wrap: on
line diff
--- a/browser_side/panels.py	Thu May 26 19:15:44 2011 +0200
+++ b/browser_side/panels.py	Thu May 26 20:13:41 2011 +0200
@@ -29,10 +29,13 @@
 from pyjamas.ui.TabPanel import TabPanel
 from pyjamas.ui.HTMLPanel import HTMLPanel
 from pyjamas.ui.Grid import Grid
+from pyjamas.ui.DialogBox import DialogBox
 from pyjamas.ui.AutoComplete import AutoCompleteTextBox
 from pyjamas.ui.MenuBar import MenuBar
 from pyjamas.ui.MenuItem import MenuItem
 from pyjamas.ui.Label import Label
+from pyjamas.ui.TextBox import TextBox
+from pyjamas.ui.Button import Button
 from pyjamas.ui.HTML import HTML
 from pyjamas.ui.Frame import Frame
 from pyjamas.ui.DropWidget import DropWidget
@@ -72,12 +75,16 @@
         menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract"))
         menu_general.addItem("About", MenuCmd(self, "onAbout"))
 
+        menu_group = MenuBar(vertical=True)
+        menu_group.addItem("join room", MenuCmd(self, "onJoinRoom"))
+
         menu_games = MenuBar(vertical=True)
         menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame"))
         menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame"))
 
         menubar = MenuBar(vertical=False)
         menubar.addItem(MenuItem("General", menu_general))
+        menubar.addItem(MenuItem("Groups", menu_group))
         menubar.addItem(MenuItem("Games", True, menu_games))
         self.add(menubar)
 
@@ -101,6 +108,40 @@
         _dialog = dialog.InfoDialog("About", _about)
         _dialog.show()
     
+    #Group menu
+    def onJoinRoom(self):
+        _dialog = None
+        _edit = None
+
+        def onOK(sender):
+            if not _edit.getText():
+                Window.alert('You must enter a room jid in the form libervia@conference.libervia.org')
+            if self.host.whoami:
+                nick = self.host.whoami.node
+                self.host.bridge.call('joinMUC', None, _edit.getText(), nick)
+            _dialog.hide()
+
+        def onCancel(sender):
+            _dialog.hide()
+
+        _main_panel = VerticalPanel()
+        _label = Label("Discussion room:")
+        _edit = TextBox()
+        _edit.setText('libervia@conference.tazar.int')
+        hpanel = HorizontalPanel()
+        hpanel.add(_label)
+        hpanel.add(_edit)
+        _main_panel.add(hpanel)
+        button_panel = HorizontalPanel()
+        button_panel.add(Button("Join", onOK))
+        button_panel.add(Button("Cancel", onCancel))
+        _main_panel.add(button_panel)
+        _dialog = DialogBox(centered=True)
+        _dialog.setHTML('<b>Group discussions</b>')
+        _dialog.setWidget(_main_panel)
+        _dialog.show()
+        
+
     #Game menu
 
     def onTarotGame(self):