changeset 181:c0b78a3af06d

browser side: web widget first draft
author Goffi <goffi@goffi.org>
date Sun, 24 Feb 2013 18:15:38 +0100
parents ea6ae7c4b3f0
children ec37ec737411
files browser_side/menu.py browser_side/panels.py
diffstat 2 files changed, 39 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/menu.py	Sun Feb 24 15:58:19 2013 +0100
+++ b/browser_side/menu.py	Sun Feb 24 18:15:38 2013 +0100
@@ -38,6 +38,7 @@
 from jid import JID
 from tools import html_sanitize
 from xmlui import XMLUI
+import panels
 import dialog
 import re
 
@@ -127,6 +128,7 @@
         _item_tpl = "<img src='media/icons/menu/%s_menu_red.png' />%s"
 
         menu_general = MenuBar(vertical=True)
+        menu_general.addItem("Web widget", MenuCmd(self, "onWebWidget"))
         menu_general.addItem("Disconnect", MenuCmd(self, "onDisconnect"))
 
         menu_contacts = MenuBar(vertical=True)
@@ -169,6 +171,11 @@
         self.add(menubar)
 
     #General menu
+    def onWebWidget(self):
+        web_panel = panels.WebPanel(self.host, "http://www.goffi.org")
+        self.host.addTab(web_panel, "Web widget")
+
+
     def onDisconnect(self):
         def confirm_cb(answer):
             if answer:
--- a/browser_side/panels.py	Sun Feb 24 15:58:19 2013 +0100
+++ b/browser_side/panels.py	Sun Feb 24 18:15:38 2013 +0100
@@ -28,8 +28,9 @@
 from pyjamas.ui.TabPanel import TabPanel
 from pyjamas.ui.HTMLPanel import HTMLPanel
 from pyjamas.ui.FlexTable import FlexTable
-from pyjamas.ui.Grid import Grid
+from pyjamas.ui.Frame import Frame
 from pyjamas.ui.TextArea import TextArea
+from pyjamas.ui.TextBox import TextBox
 from pyjamas.ui.Label import Label
 from pyjamas.ui.Button import Button
 from pyjamas.ui.HTML import HTML
@@ -663,7 +664,7 @@
         HTML.__init__(self, "<div class='occupant'>%s</div>" % html_sanitize(nick))
 
     def __str__(self):
-        return nick
+        return self.nick
 
 class OccupantsList(AbsolutePanel):
     """Panel user to show occupants of a room"""
@@ -818,6 +819,35 @@
         elif game_type=="RadioCol":
             return self.radiocol_panel 
 
+class WebPanel(LiberviaWidget):
+    """ (mini)browser like widget """
+    
+    def __init__(self, host, url=None):
+        """
+        @param host: SatWebFrontend instance
+        """
+        LiberviaWidget.__init__(self, host)
+        self._vpanel = VerticalPanel()
+        self._vpanel.setSize('100%', '20')
+        self._url = TextBox()
+        self._url.setText(url or "")
+        self._url.setWidth('100%')
+        hpanel = HorizontalPanel()
+        hpanel.add(self._url)
+        btn = Button("Go", self.onUrlClick)
+        hpanel.setCellWidth(self._url, "100%")
+        #self.setCellWidth(btn, "10%")
+        hpanel.add(self._url)
+        hpanel.add(btn)
+        self._vpanel.add(hpanel)
+        self._frame = Frame(url or "")
+        self._frame.setSize('100%', '100%')
+        self._vpanel.add(self._frame)
+        self.setWidget(self._vpanel)
+
+    def onUrlClick(self, sender):
+        self._frame.setUrl(self._url.getText())
+
 class WidgetsPanel(ScrollPanelWrapper):
     
     def __init__(self, host):