예제 #1
0
    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()
예제 #2
0
    def __init__(self,action='open',title='', path=os.path.expanduser('~'),ext='wld'):
        if action == 'open':
            act = Gtk.FileChooserAction.OPEN
            but = Gtk.STOCK_OPEN

        else:
            act = Gtk.FileChooserAction.SAVE
            but = Gtk.STOCK_SAVE

        Gtk.FileChooserDialog.__init__(self, title=title, action=act, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, but, Gtk.ResponseType.OK))

        try:
            startpath = utils.PROGRAMSDIR

        except:
            startpath = os.path.join(utils.get_rootdir())

        self.set_current_folder(startpath)
        wfilter = Gtk.FileFilter()
        wfilter.set_name(_("Worlds"))
        wfilter.add_pattern('*.wld')
        self.add_filter(wfilter)

        pfilter = Gtk.FileFilter()
        pfilter.set_name(_("Programs"))
        pfilter.add_pattern('*.gvr')
        self.add_filter(pfilter)

        if ext == 'wld':
            self.set_filter(wfilter)

        else:
            self.set_filter(pfilter)
예제 #3
0
    def on_gvr_lessons1_activate(self, widget, *args):
        """Display the GvR lessons in the default browser.
        This only works if the gvr lessons package version 0.2 is installed."""
        import webbrowser
        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) and utils.get_locale()[:2] != 'en':
            file = os.path.join(utils.get_rootdir(),'docs','lessons','en','html','index.html')
            self.logger.debug("Looking for the lessons in %s" % file)

        if os.path.exists(file):
            try:
                webbrowser.open(file, new=0)

            except webbrowser.Error,info:
                txt = str(info)+ '\n'+ "Be sure to set your env. variable 'BROWSER' to your preffered browser."
                self.show_warning(txt)
예제 #4
0
    global OnRefText
    # Quick hack to fix the loading of Summary.txt, should be done trying all
    # components of the locale, probably removing the -LANG suffix, as the
    # language is already on the locale dir and putting it in two places makes
    # things harder; is best to use the directory to choose the language or
    # put all the Summaries on the same dir.
    try:
        lang = olang.split('@')[0].split('.')[0].split('_')[0]
    except Exception,info:
        print info
        print "Can't load Summary for language '%s'" % lang
        print "Using default English file"
        lang = 'en'
    sumfile = "Summary-%s.txt" % lang
    if lang == 'en':
        path = os.path.join(get_rootdir(),'po',sumfile)
    else:
        path = os.path.join(get_rootdir(),'po',lang,sumfile)
    if DEBUG: print "trying to read",path
    try:
        lines = open(path,'r').read()
    except IOError,info:
        print info
        print "Can't load Summary for language '%s'" % lang
        print "Using default English file"
        OnRefText = BuiltinOnRefText
    else:
        OnRefText = lines

def set_WBsummary(olang):
    """Get the proper Worldbuilder summary file for the current locale"""
예제 #5
0
    global OnRefText
    # Quick hack to fix the loading of Summary.txt, should be done trying all
    # components of the locale, probably removing the -LANG suffix, as the
    # language is already on the locale dir and putting it in two places makes
    # things harder; is best to use the directory to choose the language or
    # put all the Summaries on the same dir.
    try:
        lang = olang.split('@')[0].split('.')[0].split('_')[0]
    except Exception, info:
        print info
        print "Can't load Summary for language '%s'" % lang
        print "Using default English file"
        lang = 'en'
    sumfile = "Summary-%s.txt" % lang
    if lang == 'en':
        path = os.path.join(get_rootdir(), 'po', sumfile)
    else:
        path = os.path.join(get_rootdir(), 'po', lang, sumfile)
    if DEBUG: print "trying to read", path
    try:
        lines = open(path, 'r').read()
    except IOError, info:
        print info
        print "Can't load Summary for language '%s'" % lang
        print "Using default English file"
        OnRefText = BuiltinOnRefText
    else:
        OnRefText = lines


def set_WBsummary(olang):