Example #1
0
class T2Activity(activity.Activity):
    def xois_clicked(self, widget, data=None):
        self.webview.load_uri('http://teach-teacher.ep.io/slides/1')

    def guide_clicked(self, widget, data=None):
        self.webview.load_uri('http://teach-teacher.ep.io/slides/17')

    def diary_clicked(self, widget, data=None):
        self.webview.load_uri('http://laptop.org/')

    def society_clicked(self, widget, data=None):
        self.webview.load_uri('http://147.47.120.20/~olpc_community/')

    def __init__(self, handle):
        print "running activity init", handle
        activity.Activity.__init__(self, handle)
        print "activity running"

        self.set_title('Teach Teacher')

        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
	toolbar = gtk.Toolbar()	

        self.xois = ToolButton('computer-xo')
        self.xois.set_tooltip("T's XO")
        self.xois.connect('clicked', self.xois_clicked)
        toolbar.insert(self.xois, -1)
        self.xois.show()

        self.guide = ToolButton('go-next')
        self.guide.set_tooltip("T's Guide")
        self.guide.connect('clicked', self.guide_clicked)
        toolbar.insert(self.guide, -1)
        self.guide.show()

        self.diary = ToolButton('activity-journal')
        self.diary.set_tooltip("T's Diary")
        self.diary.connect('clicked', self.diary_clicked)
        toolbar.insert(self.diary, -1)
        self.diary.show()

        self.society = ToolButton('zoom-neighborhood')
        self.society.set_tooltip("T's Society")
        self.society.connect('clicked', self.society_clicked)
        toolbar.insert(self.society, -1)
        self.society.show()

	toolbar.show()
	toolbox.add_toolbar("Menu", toolbar)
        toolbox.show()
        
        self.webview = WebView()
	self.set_canvas(self.webview)
        self.webview.show()
	self.webview.load_uri('http://teach-teacher.ep.io/')	


    
        print "AT END OF THE CLASS"
Example #2
0
class Navegador():
    ''' Es un Navegador web from hulahop.webview import WebView '''
    def __init__(self):
        self.navegador = None

    def get_Navegador(self):
        # Establece la dirección por defecto, y devuelve el navegador para ser incrustado en un contenedor gtk
        self.navegador = WebView()
        self.navegador.load_uri(DIRECTORIO_DATOS + "web.htm")
        return self.navegador

    def set_web_por_defecto(self):
        # crea una web para el archivo swf
        htm = """
		<html>
		<head>
		<title>Embedded SWF Player</title>
		</head>
		<body onLoad="resizeTo(1200, 900);">
		<embed src = %s width="1170" height="845"
		   hidden=false autostart=true loop=1>
		</body>
		</html>
		""" % JUEGO

        # Abrir la web creada
        web = open(DIRECTORIO_DATOS + "web.htm", "w")
        web.write(htm)
        web.close()

        try:
            # solo sucede la 1º vez que ejecutas la actividad ya que solo el propietario puede modificar los permisos
            os.chmod(DIRECTORIO_DATOS + "web.htm", 0666)
        except:
            pass
Example #3
0
class GeckoDownloader(object):
    def __init__(self, callback):
        self.callback = callback
        self.w = gtk.Window()
        self.w.show()
        self.w.hide()

    def _callback(self,listener):
        html = self.v.dom_window.document.documentElement.innerHTML
        self.callback(html)
        gtk.main_quit()

    def download(self, url):
        self.v = WebView()
        self.w.add(self.v)
        self.v.show()
        self.v.load_uri(url)

        listener = ProgressListener()
        wrapped_listener = xpcom.server.WrapObject(listener, interfaces.nsIWebProgressListener)
        self.v.web_progress.addProgressListener(wrapped_listener, interfaces.nsIWebProgress.NOTIFY_STATE_ALL)

        listener.connect('finished', self._callback)

        gtk.main()
Example #4
0
class T2Activity(activity.Activity):
    def xois_clicked(self, widget, data=None):
        self.webview.load_uri('http://teach-teacher.ep.io/slides/1')

    def guide_clicked(self, widget, data=None):
        self.webview.load_uri('http://teach-teacher.ep.io/slides/17')

    def back_clicked(self, widget, data=None):
        if self.webview.get_web_navigation().canGoBack:
            self.webview.get_web_navigation().goBack()

    def home_clicked(self, widget, data=None):
        self.webview.load_uri('http://147.47.120.20/~tsquare/menu.php')

    def __init__(self, handle):
        print "running activity init", handle
        activity.Activity.__init__(self, handle)
        print "activity running"

        self.set_title('Teach Teacher')

        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbar = gtk.Toolbar()

        self.goBack = ToolButton('go-left')
        self.goBack.set_tooltip("Go Back")
        self.goBack.connect('clicked', self.back_clicked)
        toolbar.insert(self.goBack, -1)
        self.goBack.show()

        self.home = ToolButton('go-home')
        self.home.set_tooltip("Home")
        self.home.connect('clicked', self.home_clicked)
        toolbar.insert(self.home, -1)
        self.home.show()

        self.xois = ToolButton('computer-xo')
        self.xois.set_tooltip("T's XO")
        self.xois.connect('clicked', self.xois_clicked)
        # toolbar.insert(self.xois, -1)
        # self.xois.show()

        self.guide = ToolButton('go-next')
        self.guide.set_tooltip("T's Guide")
        self.guide.connect('clicked', self.guide_clicked)
        # toolbar.insert(self.guide, -1)
        # self.guide.show()

        toolbar.show()
        toolbox.add_toolbar("Menu", toolbar)
        toolbox.show()

        self.webview = WebView()
        self.set_canvas(self.webview)
        self.webview.show()
        self.webview.load_uri('http://147.47.120.20/~tsquare/menu.php')

        print "AT END OF THE CLASS"
Example #5
0
 def __init__(self):
     gtk.VBox.__init__(self)
     #vbox = gtk.VBox(False, 8)
     wv = WebView()
     print 'show', WORKFILE, path(WORKFILE).exists()
     wv.load_uri(WORKFILE)
     wv.show()
     self.pack_start(wv, True, True, 0)
     #self.add(wv)
     self.show_all()
Example #6
0
 def __init__(self):
     gtk.VBox.__init__(self)
     #vbox = gtk.VBox(False, 8)
     wv = WebView()
     print 'show', WORKFILE, path(WORKFILE).exists()
     wv.load_uri(WORKFILE)
     wv.show()
     self.pack_start(wv, True, True, 0)
     #self.add(wv)
     self.show_all()
Example #7
0
class HelpActivity(activity.Activity):
    def __init__(self, handle):
        activity.Activity.__init__(self, handle)

        self.props.max_participants = 1

        self._web_view = WebView()

        toolbox = activity.ActivityToolbox(self)
        self.set_toolbox(toolbox)
        toolbox.show()

        toolbar = Toolbar(self._web_view)
        toolbox.add_toolbar(_('Navigation'), toolbar)
        toolbar.show()

        self.set_canvas(self._web_view)
        self._web_view.show()

        toolbox.set_current_toolbar(1)

        self._web_view.load_uri(HOME)
Example #8
0
class ContentWindow(gtk.HBox):
    
    def __init__(self, toolbar=None):
        gtk.HBox.__init__(self, False)
        
        self._create_treeview()
        sw = gtk.ScrolledWindow()
        sw.add(self.treeview)
        self.pack_start(sw, False)
        self.treeview.set_size_request(300, -1)
        
        self.web_view = None
        self.last_uri = HOME_PAGE
        
        self.connect("expose-event", self._exposed)
        self.show_all()

        self.library_type = "advanced"
        
        # Could be loaded on expose, but the set_url function won't work
        self._load_treeview()
    
    def switch(self, toolbutton, library_type):
        self.library_type = library_type
        self._load_treeview()
    
    def _create_browser(self):
        if hulahop_ok:
            self.web_view = WebView()
            self.pack_start(self.web_view, True, True)
            self.progress_listener = ProgressListener()
            self.progress_listener.setup(self.web_view)
            self.progress_listener.connect('location-changed', self._location_changed_cb)
            
            self.web_view.load_uri(self.last_uri)
            self.web_view.show()
        else:
            self.web_view = gtk.Button()
            self.web_view.load_uri = self.web_view.set_label
            self.web_view.load_uri(self.last_uri)
            self.add(self.web_view)
            self.web_view.show()
    
    def _create_treeview(self):
        # Provided by Poteland:
        # create a TreeStore with one string column to use as the model
        self.treestore = gtk.TreeStore(str, str)
        
        # create the TreeView using treestore
        self.treeview = gtk.TreeView(self.treestore)
        
        # create the TreeViewColumn to display the data
        tvcolumn = gtk.TreeViewColumn("")
        cell = gtk.CellRendererText()
        tvcolumn.pack_start(cell, True)
        self.treeview.append_column(tvcolumn)
        
        # set the cell "text" attribute to column 0 - retrieve text
        tvcolumn.add_attribute(cell, 'text', 0)
        
        # make it searchable
        self.treeview.set_search_column(0)
        
        self.treeview_loaded = False
        self.treeview.connect("cursor-changed", self.cursor_changed_cb)
        
    def _exposed(self, widget, event):
        if not self.treeview_loaded:
            self.path_iter = {}
            self.treeview_loaded = True
            self._load_treeview()
            
        if not self.web_view:
            # First exposes the widget and then (when idle) creates the browser, so the screen shows up faster
            self.web_view = True # temporary so the conditions doesn't meet
            gobject.idle_add(self._create_browser)
            
    def ditch(self):
        """ Called when we need to ditch the browsing window and hide the whole window """
        if self.web_view:
            self.remove(self.web_view)
            self.web_view = None
            self.progress_listener = None
    
    def _load_treeview(self):
        self.treeview_loaded = True
        self.path_iter = {}
        self.treestore.clear()
        self._load_treeview_recursive(ROOT_PATH, None)
    
    def _load_treeview_recursive(self, directory, parent_iter):
        dirList = listdir(directory)
        for node in sorted(dirList):
            load = self.check_type(node)
            if load:
                nodepath = os.path.join(directory, node)
                if isfile(nodepath):
                    if node.endswith(".html") and not node in ignore_list:
                        display_name = self.get_display_name(node)
                        _iter = self.treestore.append(parent_iter, (display_name, nodepath.encode("utf-8")))
                        self.path_iter[nodepath] = _iter
                else:
                    if not node in ignore_list:
                        display_name = self.get_display_name(node)
                        path = self.check_default_file(nodepath)
                        _iter = self.treestore.append(parent_iter, (display_name, path.encode("utf-8")))
                        self.path_iter[path] = _iter
                        self._load_treeview_recursive(nodepath, _iter)
    
    def check_type(self, node):
        if self.library_type == "advanced" and "-simple" in node:
            return False
        elif self.library_type == "basic" and "-avanzado" in node:
            return False
        else:
            return True
    
    def check_default_file(self, nodepath):
        aux = os.path.join(nodepath, "default-avanzado.html")
        if exists(aux):
            return aux
            
        aux = os.path.join(nodepath, "default-simple.html")
        if exists(aux):
            return aux
            
        aux = os.path.join(nodepath, "default.html")
        if exists(aux):
            return aux
        
        return nodepath

    def get_display_name(self, file_name):
        display_name = file_name.replace(".html", "")
        display_name = display_name.replace("-avanzado", "")
        display_name = display_name.replace("-simple", "")
        display_name = display_name.split("-", 1)[-1]
        return display_name
    
    def cursor_changed_cb(self, treeview):
        tree_path, column = self.treeview.get_cursor()
        
        it = self.treestore.get_iter(tree_path)
        path = self.treestore.get_value(it, 1)
        
        if path.endswith(".html") and self.web_view:
            uri = u"file://" + unicode(path, "utf-8")
            if not self.last_uri.startswith(uri):           # avoids reloading a page when the cursor is changed by the program
                self.last_uri = uri
                self.web_view.load_uri(self.last_uri)

    def _location_changed_cb(self, progress_listener, uri):
        if uri:
            path = utilities.unquote(uri.path.encode("utf-8"))
            uri = u"file://" + path
            if self.last_uri <> uri:
                self.last_uri = uri
                onlypath = path.split("#")[0]
                self.position_in_filename(onlypath)
        
    def position_in_filename(self, filepath):
        if filepath in self.path_iter:
            _iter = self.path_iter[filepath]
            if self.treeview.get_selection().get_selected()[1] <> _iter:   # avoids falling in a loop with location_changed
                treepath = self.treestore.get_path(_iter)
                self.treeview.expand_to_path(treepath)
                self.treeview.set_cursor(treepath)
        
    def set_url(self, link, anchor=None):
        # First fix the link in advanced or simple:
        if self.library_type == "basic":
            link = link.replace("-avanzado", "-simple")
        
        # Then add the base path and position in the tree
        link = os.path.join(ROOT_PATH, link)
        self.position_in_filename(link)
        
        # Last add the protocol and the anchor
        if anchor:
            self.last_uri = u"file://" + link + u"#" + unicode(anchor)
        else:
            self.last_uri = u"file://" + link
        
        if self.web_view:
            self.web_view.load_uri( self.last_uri )
        
    def get_toolbar(self):
        toolbar = gtk.Toolbar()
        
        radio_adv = RadioToolButton()
        radio_adv.set_active(True)
        radio_adv.set_label("Avanzada")
        radio_adv.set_tooltip("Mostrar biblioteca avanzada")
        radio_adv.connect("clicked", self.switch, "advanced")
        toolbar.insert(radio_adv, -1)
        radio_adv.show()
        
        radio_bas = RadioToolButton(group=radio_adv)
        radio_bas.set_label("Simple")
        radio_bas.set_tooltip("Mostrar biblioteca sencilla")
        radio_bas.connect("clicked", self.switch, "basic")
        toolbar.insert(radio_bas, -1)
        
        toolbar.show_all()
        
        return toolbar
Example #9
0
class Renderer(object):
    def __init__(self, activity, deck):
        """Constructs a new SlideRenderer that will render slides from deck"""
        self.__logger = logging.getLogger('Renderer')
        self.__logger.setLevel('error')
        self.__deck = deck
        self.__activity = activity
        self.__wv = WebView()
        self.__wv.show()
        self.__htmlflag = True

    def getSlideDimensionsFromFirstLayer(self, n=None):
        """Returns the [width, height] of the first slide layer"""
        if n is None:
            n = self.__deck.getIndex()
        layers = self.__deck.getSlideLayers(n)
        
        # return some default reasonable value if this is an empty slide
        if len(layers) == 0:
            return [640.0, 480.0]
        
        ftype = utils.getFileType(layers[0])
        
        # This may be optimizable to avoid having to open the first layer to get its size,
        # or at least keeping it around to re-use it when the slide is first rendered
        if ftype == "svg":
            f = open(layers[0], 'rb')
            svg_data = f.read()
            f.close()
            handle = rsvg.Handle(data=svg_data)
            a, b, w, h = handle.get_dimension_data()
            return [w,h]
        elif ftype == "png":
            surface = cairo.ImageSurface.create_from_png(layers[0])
            return [float(surface.get_width()), float(surface.get_height())]
        elif ftype == "jpg":
            pbuf = gtk.gdk.pixbuf_new_from_file(layers[0])
            return [float(pbuf.get_width()), float(pbuf.get_height())]
        else:
            return [640.0, 480.0]
    
    def getSlideDimensions(self, n=None):
        """Returns the slide dimensions, using the value in the XML file first, if it exists, and then the size of the first layer"""
        if n is None:
            n = self.__deck.getIndex()
        dims = self.__deck.getSlideDimensionsFromXML(n)
        if dims == False:
            return self.getSlideDimensionsFromFirstLayer(n)
        else:
            w, h = dims
            return [w, h]
    
    def renderSlideToSurface(self, surface, n=None):
        if n is None:
            n = self.__deck.getIndex()
            
        timerstart = time.time()
            
        self.__logger.debug("rendering slide " + str(n))
        ctx = gtk.gdk.CairoContext(cairo.Context(surface))
        #ctx = cairo.Context(surface)
        
        self.__logger.debug("Got context at " + str(time.time() - timerstart))
        
        # Get the slide dimensions and set up a Cairo transformation matrix
        srcw, srch = self.getSlideDimensions(n)
        if srcw > 640:
            srcw = 640
        if srch > 480:
            srch = 480
        targw = float(surface.get_width())
        targh = float(surface.get_height())
        x_scale = targw/srcw
        y_scale = targh/srch
        print 'rendering slide', str(n), "w=", targw, srcw, x_scale, "h=", targh, srch, y_scale
        
        self.__logger.debug("Surface is " + str(targw) +  "x" + str(targh)) 
        
        scale = x_scale
        if y_scale < x_scale:
            scale = y_scale
        
        if scale < .98 or scale > 1.02:
            ctx.transform(cairo.Matrix(scale, 0, 0, scale, 0, 0))
        
        self.__logger.debug("Got transformation matrix at " + str(time.time() - timerstart))
        
        # Paint the slide background
        ctx.set_source_rgb(1.0, 1.0, 1.0)
        ctx.rectangle(0, 0, srcw, srch)
        ctx.fill()
        
        self.__logger.debug("Filled background at " + str(time.time() - timerstart))
        
        # Paint the layers
        layers = self.__deck.getSlideLayers(n)
        self.__logger.debug("Got layers at " + str(time.time() - timerstart))
        for layer in layers:
            type = utils.getFileType(layer)
            print 'Drawing layer ', type, layer
            self.__logger.debug("Drawing layer " + str(layer) +" " + str(scale) + " at "  + str(time.time() - timerstart))
            print 'drawing layer', type, str(layer)
            if type == "svg":
                f = open(layer, "rb")
                svg_data = f.read()
                f.close()
                handle = rsvg.Handle(data=svg_data)
                handle.render_cairo(ctx)
            elif type == "png":
                png_surface = cairo.ImageSurface.create_from_png(layer)
                self.__logger.debug("Got PNG surface at "+ str(time.time() - timerstart))
                ctx.set_source_surface(png_surface, 0, 0)
                ctx.rectangle(0, 0, png_surface.get_width(), png_surface.get_height())
                ctx.fill()
            elif type == "jpg":
                jpg_pixbuf = gtk.gdk.pixbuf_new_from_file(layer)
                self.__logger.debug("Got JPG pixbuf at "+ str(time.time() - timerstart))
                ctx.set_source_pixbuf(jpg_pixbuf, 0, 0)
                ctx.rectangle(0, 0, jpg_pixbuf.get_width(), jpg_pixbuf.get_height())
                ctx.fill()
            elif type == "html":
                #use hulahop to display
                print 'html slide', self.__htmlflag, layer
                scrn4 = self.__activity.set_screen(3)
                if self.__htmlflag:
                    scrn4.add(self.__wv)
                    self.__htmlflag = False
                self.__wv.load_uri('file://' + layer)
                self.__wv.show()
            self.__logger.debug("Finished drawing layer at "+ str(time.time() - timerstart))
Example #10
0
import hulahop
hulahop.startup(os.path.expanduser('~/.test-hulahop'))
from hulahop.webview import WebView

from xpcom import components


def _quit(window):
    hulahop.shutdown()
    gtk.main_quit()


cls = components.classes["@mozilla.org/preferences-service;1"]
prefService = cls.getService(components.interfaces.nsIPrefService)
branch = prefService.getBranch('')
branch.setBoolPref('security.warn_submit_insecure', False)
branch.setBoolPref('security.warn_submit_insecure.show_once', False)

window = gtk.Window()
window.connect("destroy", _quit)

web_view = WebView()
web_view.load_uri('http://www.google.com')
window.add(web_view)
web_view.show()

window.show()

gtk.main()
Example #11
0
class XOCom:
    # Constructor gives full XPCom access by default
    # This should be improved for future apps that may not need/want full access
    cometPort = 8889
    ajaxPort = 8890

    def __init__(self, control_sending_text,uri=None):
        self.cond = Condition()
        #h = hash(Instance.instanceId)
        self.__class__.cometPort = 10
        self.__class__.ajaxPort = 11
        self.cometLogic = ServerLogic(self)
        #self.ajaxServer = ServerThread(self.__class__.ajaxPort, self.cometLogic)
        #self.ajaxServer.start()
        #self.cometServer = ServerThread(self.__class__.cometPort, self.cometLogic)
        #self.cometServer.start()
        if uri:
            self.uri = uri
        else:
            self.uri = 'file://' + get_bundle_path() + '/web/index.html?ajax='+str(self.__class__.ajaxPort)+'&comet='+str(self.__class__.cometPort);
        self.control_sending_text=control_sending_text
        self.give_full_xpcom_access()
        self.set_observer()
        ##self.send_to_browser_localize(['initlocalize'])  ## to initialize the localized strings in socialcalc
	
    # Give the browser permission to use XPCom interfaces
    # This is necessary for XPCom communication to work
    # Note: Not all of these preferences may be required - requires further
    #       investigation
    def give_full_xpcom_access(self):
        pref_class = components.classes["@mozilla.org/preferences-service;1"]
        prefs = pref_class.getService(components.interfaces.nsIPrefService)
        prefs.getBranch('signed.applets.').setBoolPref('codebase_principal_support',
                True);
        prefs.getBranch('capability.principal.').setCharPref(
                        'socialcalc.granted', 'UniversalXPConnect')
        prefs.getBranch('capability.principal.').setCharPref(
                        'socialcalc.id', self.uri)

    # Wrapper method to create a new webview embedded browser component
    # Uses hulahop's WebView.  Assumes that you'll want to serve
    # web/index.html relative to your activity directory.
    def create_webview(self):
        self.web_view = WebView()
        ##self.uri = 'file://' + get_bundle_path() + '/web/index.html';
        self.web_view.load_uri(self.uri)
        self.web_view.show()
        return self.web_view
    
    def set_observer(self):
        #try:
            print 'enter: set_observer'
            observerService = components.classes["@mozilla.org/observer-service;1"]
            ob_serv = observerService.getService(components.interfaces.nsIObserverService);
            observer=Observer(self.control_sending_text)
            ob_serv.addObserver(observer,"xo-message2",False);
            print 'exit: set_observer'
        #except:
            #print 'error is there, remove try and except thing'
        
        
    # Use XPCom to execute a javascript callback registered with XO.js
    # The command will execute a javascript method registered with the same name,
    # and return any value received from the javascript
    def send_to_browser(self, command, parameter=None):
        if((command == "read") and (parameter is not None)):
            self.web_view.load_uri("javascript:XO.observer.setSheet('"+parameter.replace('\\n','DECNEWLINE').replace('\n','NEWLINE').replace("\\","B_SLASH").replace("'","\\'")+"');void(0);")
            return

        # Set up an array for parameters and return values for the XPCom call
        array = components.classes["@mozilla.org/array;1"].createInstance(
                components.interfaces.nsIMutableArray)
     
        # Optionally pass data to the javascript
        if parameter: 
            str = components.classes["@mozilla.org/supports-string;1"].createInstance(
                        components.interfaces.nsISupportsString)
            str.data = parameter
            array.appendElement(str, False)

        # Use XPCom to send an event to a javascript observer (web/xo.js)
        observerService = components.classes["@mozilla.org/observer-service;1"]
        ob_serv = observerService.getService(components.interfaces.nsIObserverService)
        ob_serv.notifyObservers(array, "xo-message", command)
        #ob_serv.addObserver(self.control_sending_text,"xo-message2",False)

        # check if the browser returned anything
        if array.length:
            iter = array.enumerate()
            result = iter.getNext()
            result = result.QueryInterface(components.interfaces.nsISupportsString)
            return result.toString()
        return None
    
    def send_to_browser_shared(self,command):
        if command[0]=='execute':
            array = components.classes["@mozilla.org/array;1"].createInstance(components.interfaces.nsIMutableArray)
            str = components.classes["@mozilla.org/supports-string;1"].createInstance(components.interfaces.nsISupportsString)
            str.data = command[1]
            array.appendElement(str, False)
            str2 = components.classes["@mozilla.org/supports-string;1"].createInstance(components.interfaces.nsISupportsString)
            str2.data = command[2]
            array.appendElement(str2, False)
            
            observerService = components.classes["@mozilla.org/observer-service;1"]
            ob_serv = observerService.getService(components.interfaces.nsIObserverService);
            if not array.length: 
                print 'no need of sending anywhere , array is empty'
            ob_serv.notifyObservers(array, "xo-message", 'execute');

    def send_to_browser_localize(self,command):
        #self.ajaxServer.closing = 1
        print 'sending to javascript part to localize\n'
        #array = components.classes["@mozilla.org/array;1"].createInstance(components.interfaces.nsIMutableArray)
        localstr = "javascript:XO.lang=["
        for i,j in localized_strings.iteritems():
            localstr = localstr+"'"+i.replace("'","\\'")+"','"+j.replace("'","\\'")+"',"
            #str1 = components.classes["@mozilla.org/supports-string;1"].createInstance(components.interfaces.nsISupportsString)
            #str1.data=i
            #array.appendElement(str1, False)
            #str2 = components.classes["@mozilla.org/supports-string;1"].createInstance(components.interfaces.nsISupportsString)
            #str2.data=j
            #array.appendElement(str2, False)
        localstr = localstr+"'xv'];XO.observe();void(0);"
        self.web_view.load_uri(localstr)
        return

        observerService = components.classes["@mozilla.org/observer-service;1"]
        ob_serv = observerService.getService(components.interfaces.nsIObserverService);
        if not array.length: 
           print 'no need of sending anywhere , array is empty'
        ob_serv.notifyObservers(array, "xo-message3", 'initlocalize');

        if array.length:
            iter = array.enumerate()
            result = iter.getNext()
            result = result.QueryInterface(components.interfaces.nsISupportsString)
            print result.toString()
Example #12
0

def entry_activate_cb(entry):
    web_view.load_uri(entry.get_text())


window = gtk.Window()
window.set_default_size(600, 400)
window.connect("destroy", quit)

vbox = gtk.VBox()

entry = gtk.Entry()
entry.connect('activate', entry_activate_cb)
vbox.pack_start(entry, False)
entry.show()

web_view = WebView()
web_view.load_uri('http://www.gnome.org')
vbox.pack_start(web_view)
web_view.show()

window.add(vbox)
vbox.show()

window.show()

entry.grab_focus()

gtk.main()
Example #13
0
 def create_webview(self):
     web_view = WebView()
     web_view.load_uri(self.uri)
     web_view.show()
     return web_view
Example #14
0
    hulahop.shutdown()
    gtk.main_quit()

def entry_activate_cb(entry):
    web_view.load_uri(entry.get_text())

window = gtk.Window()
window.set_default_size(600, 400)
window.connect("destroy", quit)

vbox = gtk.VBox()

entry = gtk.Entry()
entry.connect('activate', entry_activate_cb)
vbox.pack_start(entry, False)
entry.show()

web_view = WebView()
web_view.load_uri('http://www.gnome.org')
vbox.pack_start(web_view)
web_view.show()

window.add(vbox)
vbox.show()

window.show()

entry.grab_focus()

gtk.main()
 def create_webview(self):
     web_view = WebView()
     web_view.load_uri(self.uri)
     web_view.show()
     return web_view
Example #16
0
import gtk

import hulahop
hulahop.startup(os.path.expanduser('~/.test-hulahop'))
from hulahop.webview import WebView

from xpcom import components
    
def _quit(window):
    hulahop.shutdown()
    gtk.main_quit()

cls = components.classes["@mozilla.org/preferences-service;1"]
prefService = cls.getService(components.interfaces.nsIPrefService)
branch = prefService.getBranch('')
branch.setBoolPref('security.warn_submit_insecure', False)
branch.setBoolPref('security.warn_submit_insecure.show_once', False)

window = gtk.Window()
window.connect("destroy", _quit)

web_view = WebView()
web_view.load_uri('http://www.google.com')
window.add(web_view)
web_view.show()

window.show()

gtk.main()
Example #17
0
class HtmlPage(object):
    """
    inv: self._widget_list is not None
    inv: self._widget_list is not None
    """

    def __init__(self, controller, uri, parent_widget, widget_list):
        """
        pre: parent_widget is not None
        pre: widget_list is not None
        """
        self._controller = controller
        self._widget_list = widget_list
        self._parent_widget = parent_widget
        self._htmlview = None
        self._uri = '' if uri is None else uri 
        try:
            # The XOCom object helps us communicate with the browser
            # This uses web/index.html as the default page to load
#!!            from XOCom import XOCom
#!!            self.xocom = XOCom(self.control_sending_text) #REMEMBER THAT I HAVE STILL TO SEND THE ARGUMENT IN THE XOCOM CLASS
#!!            self._htmlview = self.xocom.create_webview()
            self._htmlview = WebView()
        except:
            ka_debug.err('failed creating hulahop [%s] [%s]' % \
                   (sys.exc_info()[0], sys.exc_info()[1]))
            traceback.print_exc(file=sys.__stderr__)

    def autoconnect_events(self):
        """Auto connect introduction view."""
        self._widget_list.get_widget('kandidNotebook') \
                          .connect('switch-page', self.on_notebook_switch_page)
        
    def localize(self):
        """A dummy"""
        pass

    def activate_gui(self):
        """Insert HTML view."""
        if self._htmlview is not None:
            intro_scrolled = self._widget_list.get_widget(self._parent_widget)
            intro_scrolled.add_with_viewport(self._htmlview)

    def set_uri(self, uri):
        """ """
        self._uri = '' if uri is None else uri 

    def on_notebook_switch_page(self, *args):
        """Test if introduction page will be displayed.
        Lazy evaluation to fill the page with text.
        pre: len(args) >= 3
        """
        visible = args[2] == self._controller.find_page_number(self.__class__.__name__)
#        ka_debug.info('on_notebook_switch_page %s %s' % (visible, args[2]))
        if visible and len(self._uri) > 0: 
            if ka_debug.locale_testrun:
                # Only for testing on my computer
                result = webbrowser.open(self._uri)
                ka_debug.info('webbrowser.open: [%s] %s' % 
                                                 (self._uri, str(result)))
            if self._htmlview is not None:
                self._htmlview.load_uri(self._uri)