comparison 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
comparison
equal deleted inserted replaced
49:f1d2eb9b2523 50:72c51a4839cc
27 from pyjamas.ui.HorizontalPanel import HorizontalPanel 27 from pyjamas.ui.HorizontalPanel import HorizontalPanel
28 from pyjamas.ui.ScrollPanel import ScrollPanel 28 from pyjamas.ui.ScrollPanel import ScrollPanel
29 from pyjamas.ui.TabPanel import TabPanel 29 from pyjamas.ui.TabPanel import TabPanel
30 from pyjamas.ui.HTMLPanel import HTMLPanel 30 from pyjamas.ui.HTMLPanel import HTMLPanel
31 from pyjamas.ui.Grid import Grid 31 from pyjamas.ui.Grid import Grid
32 from pyjamas.ui.DialogBox import DialogBox
32 from pyjamas.ui.AutoComplete import AutoCompleteTextBox 33 from pyjamas.ui.AutoComplete import AutoCompleteTextBox
33 from pyjamas.ui.MenuBar import MenuBar 34 from pyjamas.ui.MenuBar import MenuBar
34 from pyjamas.ui.MenuItem import MenuItem 35 from pyjamas.ui.MenuItem import MenuItem
35 from pyjamas.ui.Label import Label 36 from pyjamas.ui.Label import Label
37 from pyjamas.ui.TextBox import TextBox
38 from pyjamas.ui.Button import Button
36 from pyjamas.ui.HTML import HTML 39 from pyjamas.ui.HTML import HTML
37 from pyjamas.ui.Frame import Frame 40 from pyjamas.ui.Frame import Frame
38 from pyjamas.ui.DropWidget import DropWidget 41 from pyjamas.ui.DropWidget import DropWidget
39 from pyjamas.ui.ClickListener import ClickHandler 42 from pyjamas.ui.ClickListener import ClickHandler
40 from pyjamas.ui.KeyboardListener import KEY_ENTER 43 from pyjamas.ui.KeyboardListener import KEY_ENTER
70 73
71 menu_general = MenuBar(vertical=True) 74 menu_general = MenuBar(vertical=True)
72 menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract")) 75 menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract"))
73 menu_general.addItem("About", MenuCmd(self, "onAbout")) 76 menu_general.addItem("About", MenuCmd(self, "onAbout"))
74 77
78 menu_group = MenuBar(vertical=True)
79 menu_group.addItem("join room", MenuCmd(self, "onJoinRoom"))
80
75 menu_games = MenuBar(vertical=True) 81 menu_games = MenuBar(vertical=True)
76 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame")) 82 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame"))
77 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame")) 83 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame"))
78 84
79 menubar = MenuBar(vertical=False) 85 menubar = MenuBar(vertical=False)
80 menubar.addItem(MenuItem("General", menu_general)) 86 menubar.addItem(MenuItem("General", menu_general))
87 menubar.addItem(MenuItem("Groups", menu_group))
81 menubar.addItem(MenuItem("Games", True, menu_games)) 88 menubar.addItem(MenuItem("Games", True, menu_games))
82 self.add(menubar) 89 self.add(menubar)
83 90
84 #General menu 91 #General menu
85 def onSocialContract(self): 92 def onSocialContract(self):
99 Any help Welcome :) 106 Any help Welcome :)
100 """) 107 """)
101 _dialog = dialog.InfoDialog("About", _about) 108 _dialog = dialog.InfoDialog("About", _about)
102 _dialog.show() 109 _dialog.show()
103 110
111 #Group menu
112 def onJoinRoom(self):
113 _dialog = None
114 _edit = None
115
116 def onOK(sender):
117 if not _edit.getText():
118 Window.alert('You must enter a room jid in the form libervia@conference.libervia.org')
119 if self.host.whoami:
120 nick = self.host.whoami.node
121 self.host.bridge.call('joinMUC', None, _edit.getText(), nick)
122 _dialog.hide()
123
124 def onCancel(sender):
125 _dialog.hide()
126
127 _main_panel = VerticalPanel()
128 _label = Label("Discussion room:")
129 _edit = TextBox()
130 _edit.setText('libervia@conference.tazar.int')
131 hpanel = HorizontalPanel()
132 hpanel.add(_label)
133 hpanel.add(_edit)
134 _main_panel.add(hpanel)
135 button_panel = HorizontalPanel()
136 button_panel.add(Button("Join", onOK))
137 button_panel.add(Button("Cancel", onCancel))
138 _main_panel.add(button_panel)
139 _dialog = DialogBox(centered=True)
140 _dialog.setHTML('<b>Group discussions</b>')
141 _dialog.setWidget(_main_panel)
142 _dialog.show()
143
144
104 #Game menu 145 #Game menu
105 146
106 def onTarotGame(self): 147 def onTarotGame(self):
107 #Window.alert("Tarot selected") 148 #Window.alert("Tarot selected")
108 #self.host.tab_panel.add(EmptyPanel(self.host), "Tarot") 149 #self.host.tab_panel.add(EmptyPanel(self.host), "Tarot")