comparison browser_side/panels.py @ 48:153de5d461a4

added Social Contract \o. (in French only so far) - new infoDialog, to show widget, it's used here to show an external webpage - some CSS tuning
author Goffi <goffi@goffi.org>
date Thu, 26 May 2011 18:44:31 +0200
parents a7ff1e6f1229
children f1d2eb9b2523
comparison
equal deleted inserted replaced
47:7cabe3c1a5f2 48:153de5d461a4
32 from pyjamas.ui.AutoComplete import AutoCompleteTextBox 32 from pyjamas.ui.AutoComplete import AutoCompleteTextBox
33 from pyjamas.ui.MenuBar import MenuBar 33 from pyjamas.ui.MenuBar import MenuBar
34 from pyjamas.ui.MenuItem import MenuItem 34 from pyjamas.ui.MenuItem import MenuItem
35 from pyjamas.ui.Label import Label 35 from pyjamas.ui.Label import Label
36 from pyjamas.ui.HTML import HTML 36 from pyjamas.ui.HTML import HTML
37 from pyjamas.ui.Frame import Frame
37 from pyjamas.ui.DropWidget import DropWidget 38 from pyjamas.ui.DropWidget import DropWidget
38 from pyjamas.ui.ClickListener import ClickHandler 39 from pyjamas.ui.ClickListener import ClickHandler
39 from pyjamas.ui import HasAlignment
40 from pyjamas.ui.KeyboardListener import KEY_ENTER 40 from pyjamas.ui.KeyboardListener import KEY_ENTER
41 from pyjamas.Timer import Timer 41 from pyjamas.Timer import Timer
42 from pyjamas import Window 42 from pyjamas import Window
43 from pyjamas import DOM 43 from pyjamas import DOM
44 from __pyjamas__ import JS, doc 44 from __pyjamas__ import JS, doc
48 from card_game import CardPanel 48 from card_game import CardPanel
49 from jid import JID 49 from jid import JID
50 from tools import html_sanitize 50 from tools import html_sanitize
51 from datetime import datetime 51 from datetime import datetime
52 from time import time 52 from time import time
53 from dialog import ContactsChooser, PopupPanelWrapper 53 import dialog
54 54
55 class MenuCmd: 55 class MenuCmd:
56 56
57 def __init__(self, object, handler): 57 def __init__(self, object, handler):
58 self._object = object 58 self._object = object
67 def __init__(self, host): 67 def __init__(self, host):
68 self.host = host 68 self.host = host
69 SimplePanel.__init__(self) 69 SimplePanel.__init__(self)
70 70
71 menu_general = MenuBar(vertical=True) 71 menu_general = MenuBar(vertical=True)
72 menu_general.addItem("Properties", MenuCmd(self, "onProperties")) 72 menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract"))
73 menu_general.addItem("About", MenuCmd(self, "onAbout"))
73 74
74 menu_games = MenuBar(vertical=True) 75 menu_games = MenuBar(vertical=True)
75 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame")) 76 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame"))
76 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame")) 77 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame"))
77 78
78 menubar = MenuBar(vertical=False) 79 menubar = MenuBar(vertical=False)
79 menubar.addItem(MenuItem("General", menu_general)) 80 menubar.addItem(MenuItem("General", menu_general))
80 menubar.addItem(MenuItem("Games", True, menu_games)) 81 menubar.addItem(MenuItem("Games", True, menu_games))
81 self.add(menubar) 82 self.add(menubar)
82 83
83 def onProperties(self): 84 #General menu
84 Window.alert("Properties selected") 85 def onSocialContract(self):
86 _frame = Frame('contrat_social.html')
87 _frame.setStyleName('infoFrame')
88 _dialog = dialog.InfoDialog("Contrat Social", _frame)
89 _dialog.setSize('80%', '80%')
90 _dialog.show()
91
92 def onAbout(self):
93 dialog.SimpleDialog("About", "Libervia, a Salut à Toi project").show()
94
95 #Game menu
85 96
86 def onTarotGame(self): 97 def onTarotGame(self):
87 #Window.alert("Tarot selected") 98 #Window.alert("Tarot selected")
88 #self.host.tab_panel.add(EmptyPanel(self.host), "Tarot") 99 #self.host.tab_panel.add(EmptyPanel(self.host), "Tarot")
89 def onPlayersSelected(other_players): 100 def onPlayersSelected(other_players):
90 self.host.bridge.call('launchTarotGame', None, other_players) 101 self.host.bridge.call('launchTarotGame', None, other_players)
91 ContactsChooser(self.host, onPlayersSelected, 3, text="Please select 3 other players").getContacts() 102 dialog.ContactsChooser(self.host, onPlayersSelected, 3, text="Please select 3 other players").getContacts()
92 103
93 def onXiangqiGame(self): 104 def onXiangqiGame(self):
94 Window.alert("Xiangqi selected") 105 Window.alert("A Xiangqi is planed, but not available yet")
95 106
96 class DropCell(DropWidget): 107 class DropCell(DropWidget):
97 """Cell in the middle grid which replace itself with the dropped widget on DnD""" 108 """Cell in the middle grid which replace itself with the dropped widget on DnD"""
98 109
99 def __init__(self): 110 def __init__(self):
243 else: 254 else:
244 print "WARNING: undetermined target for this message" 255 print "WARNING: undetermined target for this message"
245 return 256 return
246 contents = HTML(msg) 257 contents = HTML(msg)
247 258
248 self._popup = PopupPanelWrapper(autoHide=False, modal=False) 259 self._popup = dialog.PopupPanelWrapper(autoHide=False, modal=False)
249 self._popup.target_data = target_data 260 self._popup.target_data = target_data
250 self._popup.add(contents) 261 self._popup.add(contents)
251 self._popup.setStyleName("warningPopup") 262 self._popup.setStyleName("warningPopup")
252 if style: 263 if style:
253 self._popup.addStyleName(style) 264 self._popup.addStyleName(style)