Example #1
0
def createHtmlObj(mainWidget,widget=None):
    try:
        a= WebView()
        a.connect('navigation-requested', _on_navigation_requested,a)
        return a
    except:
        return gtkhtml2.View()
Example #2
0
 def create_webview(self):
     self.web_view = WebView()
     self.web_view.connect("navigation-requested", self.on_navigation_requested)
     ##self.uri = 'file://' + get_bundle_path() + '/web/index.html';
     self.web_view.load_uri(self.uri)
     self.web_view.show()
     return self.web_view
Example #3
0
    def create_browser(debug=False, cache_model=None, process_model=None):
        """Creates a WebView instance, properly configured.

        Arguments:
            debug -- boolean to indicate if it should output debug and add
                context menu and inspector.
        """
        gi.require_version('WebKit', '3.0')
        from gi.repository.WebKit import WebView, WebSettings, set_cache_model

        if debug:
            WebKitMethods.print_version()

        if cache_model is not None:
            # http://lazka.github.io/pgi-docs/WebKit-3.0/functions.html#WebKit.set_cache_model
            set_cache_model(cache_model)

        # Setting for WebKit via git http://lazka.github.io/pgi-docs/#WebKit-3.0/classes/WebSettings.html
        settings = WebSettings()
        settings.set_property('enable-accelerated-compositing', True)
        settings.set_property('enable-file-access-from-file-uris', True)

        settings.set_property('enable-default-context-menu', not debug)

        webview = WebView()
        webview.set_settings(settings)
        return webview
Example #4
0
    def __init__(self, handle):
        print "running activity init", handle
        activity.Activity.__init__(self, handle)
        print "activity running"

        self.set_title('Teach Teacher')

        toolbarbox = ToolbarBox()
        self.set_toolbar_box(toolbarbox)

        toolbar = Gtk.Toolbar()

        button = ActivityToolbarButton(self)
        toolbarbox.toolbar.insert(button, -1)

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

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

        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()

        toolbarbox.toolbar.insert(ToolbarButton(page=toolbar, icon_name='toolbar-edit'), -1)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbarbox.toolbar.insert(separator, -1)

        stop_button = StopButton(self)
        toolbarbox.toolbar.insert(stop_button, -1)

        scroll = Gtk.ScrolledWindow()
        self.set_canvas(scroll)

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

        toolbar.show_all()
        toolbarbox.show_all()
        toolbarbox.toolbar.show_all()
        self.show_all()

        print "AT END OF THE CLASS"
Example #5
0
    def __init__(self, handle):
        print "running activity init", handle
        activity.Activity.__init__(self, handle)
        print "activity running"

        self.set_title('Teach Teacher')

        toolbarbox = ToolbarBox()
        self.set_toolbar_box(toolbarbox)

        toolbar = Gtk.Toolbar()

        button = ActivityToolbarButton(self)
        toolbarbox.toolbar.insert(button, -1)

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

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

        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()

        toolbarbox.toolbar.insert(ToolbarButton(page=toolbar, icon_name='toolbar-edit'), -1)

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbarbox.toolbar.insert(separator, -1)

        stop_button = StopButton(self)
        toolbarbox.toolbar.insert(stop_button, -1)

        scroll = Gtk.ScrolledWindow()
        self.set_canvas(scroll)

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

        toolbar.show_all()
        toolbarbox.show_all()
        toolbarbox.toolbar.show_all()
        self.show_all()

        print "AT END OF THE CLASS"
 def draw(self):
     # from promogest.dao.StoricoDocumento import StoricoDocumento
     # docs = StoricoDocumento().select(padre=self.ana.dao.id)
     # print "Documento padre", docs
     # docs = StoricoDocumento().select(figli=self.ana.dao.id)
     # print "documenti figli", docs
     self.web_view = WebView()
     self.placeholder_scrolledwindow.add(self.web_view)
     self.web_view.show()
     self.clear()
    def __init__(self, handle, parent=None, **kwargs):
        gvr_gtk_glade.window_main.__init__(self)

        self._parent = parent
        self._parent.set_canvas(self)
        self.logger = logging.getLogger("gvr.gvr_gtk.WindowXO")

        # Get and set the sugar toolbar
        toolbarbox = ToolbarBox()
        self._parent.set_toolbar_box(toolbarbox)
        toolbarbox.show_all()

        toolbar = toolbarbox.toolbar

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar.insert(separator, -1)

        stop_button = StopButton(self._parent)
        toolbar.insert(stop_button, -1)

        toolbar.show_all()

        # remove seperator and 'quit' menu items as we have the sugar toolbox
        self.imagemenuitem49.destroy()

        # Embed webview as the lessons display
        self.WV = WebView()

        file = os.path.join(utils.get_rootdir(), 'docs', 'lessons', utils.get_locale()[:2], 'html', 'index.html')
        self.logger.debug("Looking for the lessons in %s" % file)
        if not os.path.exists(file):
            self.logger.debug("%s not found, loading default English lessons" % file)
            file = os.path.join(utils.get_rootdir(), 'docs', 'lessons', 'en', 'html', 'index.html')

        self.WV.open('file:///%s' % file)

        scroll = Gtk.ScrolledWindow()
        scroll.add(self.WV)

        vbox = Gtk.VBox(False, 4)
        vbox.pack_start(Widgets.WebToolbar(self.WV), False, False, 2)
        vbox.pack_start(scroll, True, True, 2)
        vbox.show_all()
        self.eventboxlessons.add(vbox)

        self.new()
        self.show_all()
Example #8
0
    def create_browser(debug=False, cache_model=None, process_model=None):
        """Creates a WebView instance, properly configured.

        Arguments:
            debug -- boolean to indicate if it should output debug and add
                context menu and inspector.
        """
        gi.require_version('WebKit2', '4.0')
        from gi.repository.WebKit2 import WebView, Settings

        if debug:
            WebKit2Methods.print_version()

        settings = Settings()
        settings.set_allow_file_access_from_file_urls(True)
        if debug:
            settings.set_enable_developer_extras(True)
            settings.set_enable_write_console_messages_to_stdout(True)
        webview = WebView()

        if cache_model is not None:
            # http://lazka.github.io/pgi-docs/WebKit2-4.0/classes/WebContext.html#WebKit2.WebContext.set_cache_model
            context = webview.get_context()
            context.set_cache_model(cache_model)

        if process_model is not None:
            # http://lazka.github.io/pgi-docs/WebKit2-4.0/classes/WebContext.html#WebKit2.WebContext.set_process_model
            context = webview.get_context()
            context.set_process_model(process_model)

        if not debug:
            # https://people.gnome.org/~gcampagna/docs/WebKit2-3.0/WebKit2.WebView-context-menu.html
            def menu_contextual(webview, context_menu, event, hit_test_result):
                context_menu.remove_all()

            webview.connect('context-menu', menu_contextual)

        webview.set_settings(settings)
        return webview
Example #9
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
    handler = None
    return_value = None

    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):
        pass
        '''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.web_view.connect("navigation-requested",
                              self.on_navigation_requested)
        ##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 on_navigation_requested(self, view, frame, req, data=None):
        uri = req.get_uri()
        try:
            scheme, data = uri.split(':#', 1)
        except:
            return False
        if scheme == 'xo-message2':
            if handler is not None:
                data = json.loads(data)
                self.handler(data, 'xo-message2', data[1])
            return True
        elif scheme == 'return-value':
            self.return_value = json.loads(data)
            return True
        else:
            return False

    def set_observer(self):
        #try:
        print 'enter: set_observer'
        self.handler = self.control_sending_text
        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=''):
        if ((command == "read") and (parameter != '')):
            self.web_view.execute_script(
                "XO.observer.setSheet('" + parameter.replace(
                    '\\n', 'DECNEWLINE').replace('\n', 'NEWLINE').replace(
                        "\\", "B_SLASH").replace("'", "\\'") + "');")
            return

        self.web_view.execute_script("XO.observer.observe(['" + parameter +
                                     "'], 'xo-message', '" + command + "');")
        self.handler = self.control_sending_text

        # check if the browser returned anything
        while self.return_value == None:
            while Gtk.events_pending():
                Gtk.main_iteration()
        if self.return_value != '':
            value = self.return_value
            self.return_value = None
            return value
        return None

    def send_to_browser_shared(self, command):
        if command[0] == 'execute':
            self.web_view.execute_script('XO.observe(' + str(command[1:3]) +
                                         ', "xo-message", "execute");')

    def send_to_browser_localize(self, command):
        print 'sending to javascript part to localize\n'
        localstr = "XO.lang=["
        for i, j in localized_strings.iteritems():
            localstr = localstr + "'" + i.replace(
                "'", "\\'") + "','" + j.replace("'", "\\'") + "',"
        localstr = localstr + "'xv'];XO.observe();"
        self.web_view.execute_script(localstr)
        return
Example #10
0
def createHtmlObj(mainWidget,widget=None):
    a= WebView()
    a.connect('navigation-requested', _on_navigation_requested,a)
    return a
class WindowXO(gvr_gtk_glade.window_main):

    def __init__(self, handle, parent=None, **kwargs):
        gvr_gtk_glade.window_main.__init__(self)

        self._parent = parent
        self._parent.set_canvas(self)
        self.logger = logging.getLogger("gvr.gvr_gtk.WindowXO")

        # Get and set the sugar toolbar
        toolbarbox = ToolbarBox()
        self._parent.set_toolbar_box(toolbarbox)
        toolbarbox.show_all()

        toolbar = toolbarbox.toolbar

        separator = Gtk.SeparatorToolItem()
        separator.props.draw = False
        separator.set_expand(True)
        toolbar.insert(separator, -1)

        stop_button = StopButton(self._parent)
        toolbar.insert(stop_button, -1)

        toolbar.show_all()

        # remove seperator and 'quit' menu items as we have the sugar toolbox
        self.imagemenuitem49.destroy()

        # Embed webview as the lessons display
        self.WV = WebView()

        file = os.path.join(utils.get_rootdir(), 'docs', 'lessons', utils.get_locale()[:2], 'html', 'index.html')
        self.logger.debug("Looking for the lessons in %s" % file)
        if not os.path.exists(file):
            self.logger.debug("%s not found, loading default English lessons" % file)
            file = os.path.join(utils.get_rootdir(), 'docs', 'lessons', 'en', 'html', 'index.html')

        self.WV.open('file:///%s' % file)

        scroll = Gtk.ScrolledWindow()
        scroll.add(self.WV)

        vbox = Gtk.VBox(False, 4)
        vbox.pack_start(Widgets.WebToolbar(self.WV), False, False, 2)
        vbox.pack_start(scroll, True, True, 2)
        vbox.show_all()
        self.eventboxlessons.add(vbox)

        self.new()
        self.show_all()

    def new(self):
        self.connect_signals()
        self.statusbar = Widgets.StatusBar(self.statusbar7)
        self._setup_canvas()
        # these calls will add the editors to the GUI
        self.new_world_editor()
        self.new_program_editor()
        self._set_sensitive_button('all',True)
        self.timerinterval = 150

    def connect_signals(self):
        self.menuitem48.connect("activate", self.on_open_worldbuilder1_activate)
        self.imagemenuitem49.connect("activate", self.on_quit1_activate)
        self.imagemenuitem50.connect("activate", self.on_set_speed1_activate)
        ##self.imagemenuitem51.connect("activate", self.on_set_language1_activate)
        self.imagemenuitem52.connect("activate", self.on_gvr_lessons1_activate)
        self.imagemenuitem54.connect("activate", self.on_gvr_worldbuilder1_activate)
        self.imagemenuitem55.connect("activate", self.on_about1_activate)
        self.button_reload.connect("clicked", self.on_button_reload)
        self.button_step.connect("clicked", self.on_button_step)
        self.button_execute.connect("clicked", self.on_button_execute)
        self.button_abort.connect("clicked", self.on_button_abort)
        self.statusbar7.connect("text-pushed", self.on_statusbar1_text_pushed)
        self.statusbar7.connect("text-popped", self.on_statusbar1_text_popped)

    def new_world_editor(self):
        self.world_editor = WorldTextEditorWin(parent=self)

    def new_program_editor(self):
        self.program_editor = CodeTextEditorWin(parent=self)

    def _setup_canvas(self):
        # setup the canvas
        self._canvas = Widgets.Canvas()
        self.align = Gtk.Alignment()
        self.viewport = Gtk.Viewport()
        self.scrolledwindow8.add(self.viewport)
        self.viewport.add(self._canvas)
        self.scrolledwindow8.show_all()
        self._set_sensitive_button('all',False)
        self.WB_ACTIVATED = False

    def _set_sensitive_button(self,button,value):
        """used to 'grey out' buttons.
        When the @button is 'all', all the buttons are handled.
        We also clear the statusbar if the buttons are disabled."""
        if button == 'all':
            for b in (self.button_abort, self.button_execute, self.button_reload, self.button_step):
                b.set_sensitive(value)

        else:
            but = {'abort': self.button_abort,
                'reload': self.button_reload,
                'execute': self.button_execute,
                'step': self.button_step}[button]

            but.set_sensitive(value)

        if button == 'all' or button in ('reload', 'step') and value == False:
            self.statusbar.clear()

    def _worldeditor_observer_callback(self):
        self.world_editor = None

    def _programeditor_observer_callback(self):
        self.program_editor = None
        
    ## These are the callbacks mandatory for the controller
    def start(self,args):
        """This will start the GUI."""
        self.logger.debug("start called with args: %s,%s" % args)
        # there are only args when gvr is started by gvrng.py (non-XO systems)
        if args[0] and args[1]:
            wfile, pfile = args[0], args[1]
            self.world_editor.on_new1_activate(file=wfile)
            self.program_editor.on_new1_activate(file=pfile)

    def get_timer(self):
        """The controller will call this and expect to get a timer object.
         The timer must provide the following methods:
         start, stop, set_func and set_interval
         see the timer docstrings for more info"""
        return Widgets.Timer()
    
    def get_timer_interval(self):
        return self.timerinterval
    
    def stop(self,*args):
        """Stops the gui, when running in non-XO"""
        Gtk.main_quit()
    
    def set_controller(self,contr):
        self.logger.debug("controller set in %s" % self)
        self.controller = contr
    
    def worldwin_gettext(self):
        if self.world_editor:
            wcode = self.world_editor.get_all_text()
            if wcode:
                return wcode

        self.show_warning(_("You don't have a world file loaded."))
    
    def codewin_gettext(self):
        if self.program_editor:
            wcode = self.program_editor.get_all_text()
            if wcode:
                return wcode

        self.show_warning(_("You don't have a program file loaded."))
    
    def highlight_line_code_editor(self,line):
        """ Controller calls this with the current line of code that's
        been executed after the execute button is pressed."""
        try:
            self.program_editor.editor.set_highlight(line)
        except Exception,info:
            print info
class StoricoDocumentoPage(GladeWidget):
    """ Widget di configurazione del codice installazione e dei parametri
    di configurazione """
    def __init__(self, mainnn):
        GladeWidget.__init__(self, root='storico_vbox',
                             path='storico_notebook.glade')
        self.ana = mainnn
        self.dao_temp = None
        self.draw()

    def draw(self):
        # from promogest.dao.StoricoDocumento import StoricoDocumento
        # docs = StoricoDocumento().select(padre=self.ana.dao.id)
        # print "Documento padre", docs
        # docs = StoricoDocumento().select(figli=self.ana.dao.id)
        # print "documenti figli", docs
        self.web_view = WebView()
        self.placeholder_scrolledwindow.add(self.web_view)
        self.web_view.show()
        self.clear()

    def on_mostra_storico_button_clicked(self, widget):
        if self.ana.dao.id:

            my_page_data = {
                'file': 'storico_documenti.html',
                'padre': get_padre(self.ana.dao.id),
                'figli': get_figli(self.ana.dao.id),
                'dao': self.ana.dao
            }

            html = renderTemplate(pageData=my_page_data)
            self.web_view.load_html_string(html, "file:///"+sys.path[0]+os.sep)
        else:
            messageWarning("E' necessario salvare il documento prima di mostrarne lo storico.")

    def on_aggiungi_figlio_button_clicked(self, widget):
        def returnDao(anagWindow):
            if anag.dao:
                self.dao_temp = anag.dao
                # agganciare il documento selezionato al documento padre
                add_relazione(self.ana.dao.id, self.dao_temp.id)
            else:
                self.dao_temp = None

        from promogest.ui.anagDocumenti.AnagraficaDocumentiFilter import RicercaDocumenti
        anag = RicercaDocumenti()
        anagWindow = anag.getTopLevel()
        returnWindow = self.getTopLevel().get_toplevel()
        anagWindow.set_transient_for(returnWindow)
        anagWindow.show_all()
        anagWindow.connect("hide",returnDao)

    def on_aggiungi_padre_button_clicked(self, widget):
        def returnDao(anagWindow):
            if anag.dao:
                self.dao_temp = anag.dao
                add_relazione(self.dao_temp.id, self.ana.dao.id)
            else:
                self.dao_temp = None

        from promogest.ui.anagDocumenti.AnagraficaDocumentiFilter import RicercaDocumenti
        anag = RicercaDocumenti()
        anagWindow = anag.getTopLevel()
        returnWindow = self.getTopLevel().get_toplevel()
        anagWindow.set_transient_for(returnWindow)
        anagWindow.show_all()
        anagWindow.connect("hide",returnDao)

    def clear(self):
        html = "<html><body></body></html>"
        self.web_view.load_html_string(html, "file:///"+sys.path[0]+os.sep)
Example #13
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
    handler = None
    return_value = None

    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):
        pass
        '''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.web_view.connect("navigation-requested", self.on_navigation_requested)
        ##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 on_navigation_requested(self, view, frame, req, data=None):
        uri = req.get_uri()
        try:
            scheme, data = uri.split(':#', 1)
        except:
            return False
        if scheme == 'xo-message2':
            if handler is not None:
                data = json.loads(data)
                self.handler(data, 'xo-message2', data[1])
            return True
        elif scheme == 'return-value':
            self.return_value = json.loads(data)
            return True
        else:
            return False

    def set_observer(self):
        #try:
            print 'enter: set_observer'
            self.handler = self.control_sending_text;
            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=''):
        if((command == "read") and (parameter != '')):
            self.web_view.execute_script("XO.observer.setSheet('"+parameter.replace('\\n','DECNEWLINE').replace('\n','NEWLINE').replace("\\","B_SLASH").replace("'","\\'")+"');")
            return

        self.web_view.execute_script("XO.observer.observe(['"+parameter+"'], 'xo-message', '"+command+"');");
        self.handler = self.control_sending_text;

        # check if the browser returned anything
        while self.return_value == None:
            while Gtk.events_pending():
                Gtk.main_iteration()
        if self.return_value != '':
            value = self.return_value
            self.return_value = None
            return value
        return None
    
    def send_to_browser_shared(self,command):
        if command[0]=='execute':
            self.web_view.execute_script('XO.observe(' + str(command[1:3]) + ', "xo-message", "execute");');

    def send_to_browser_localize(self,command):
        print 'sending to javascript part to localize\n'
        localstr = "XO.lang=["
        for i,j in localized_strings.iteritems():
            localstr = localstr+"'"+i.replace("'","\\'")+"','"+j.replace("'","\\'")+"',"
        localstr = localstr+"'xv'];XO.observe();"
        self.web_view.execute_script(localstr)
        return