Exemplo n.º 1
0
 def __init__ (self):
     self.widgets = uistuff.GladeWidgets("fics_logon.glade")
     uistuff.keepWindowSize("fics_logon", self.widgets["fics_logon"],
                            defaultPosition=uistuff.POSITION_GOLDEN)
     
     self.widgets["fics_logon"].connect('key-press-event',
             lambda w, e: e.keyval == gtk.keysyms.Escape and w.hide())
     
     
     def on_logOnAsGuest_toggled (check):
         self.widgets["nameLabel"].set_sensitive(not check.get_active())
         self.widgets["nameEntry"].set_sensitive(not check.get_active())
         self.widgets["passwordLabel"].set_sensitive(not check.get_active())
         self.widgets["passEntry"].set_sensitive(not check.get_active())
     self.widgets["logOnAsGuest"].connect("toggled", on_logOnAsGuest_toggled)
     uistuff.keep(self.widgets["logOnAsGuest"], "logOnAsGuest")
     uistuff.keep(self.widgets["nameEntry"], "usernameEntry")
     uistuff.keep(self.widgets["passEntry"], "passwordEntry")
     uistuff.makeYellow(self.widgets["messagePanel"])
     
     self.widgets["cancelButton"].connect("clicked", self.onCancel, True)
     self.widgets["stopButton"].connect("clicked", self.onCancel, False)
     self.widgets["fics_logon"].connect("delete-event", self.onClose)
     
     self.widgets["createNewButton"].connect("clicked", self.onCreateNew)
     self.widgets["connectButton"].connect("clicked", self.onConnectClicked)
     
     self.connection = None
     self.lounge = None
Exemplo n.º 2
0
    def __init__(self):
        self.widgets = uistuff.GladeWidgets("fics_logon.glade")
        uistuff.keepWindowSize("fics_logon",
                               self.widgets["fics_logon"],
                               defaultPosition=uistuff.POSITION_GOLDEN)

        self.widgets["fics_logon"].connect(
            'key-press-event',
            lambda w, e: e.keyval == gtk.keysyms.Escape and w.hide())

        def on_logOnAsGuest_toggled(check):
            self.widgets["nameLabel"].set_sensitive(not check.get_active())
            self.widgets["nameEntry"].set_sensitive(not check.get_active())
            self.widgets["passwordLabel"].set_sensitive(not check.get_active())
            self.widgets["passEntry"].set_sensitive(not check.get_active())

        self.widgets["logOnAsGuest"].connect("toggled",
                                             on_logOnAsGuest_toggled)
        uistuff.keep(self.widgets["logOnAsGuest"], "logOnAsGuest")
        uistuff.keep(self.widgets["nameEntry"], "usernameEntry")
        uistuff.keep(self.widgets["passEntry"], "passwordEntry")
        uistuff.makeYellow(self.widgets["messagePanel"])

        self.widgets["cancelButton"].connect("clicked", self.onCancel, True)
        self.widgets["stopButton"].connect("clicked", self.onCancel, False)
        self.widgets["fics_logon"].connect("delete-event", self.onClose)

        self.widgets["createNewButton"].connect("clicked", self.onCreateNew)
        self.widgets["connectButton"].connect("clicked", self.onConnectClicked)

        self.connection = None
        self.lounge = None
Exemplo n.º 3
0
    def _createPage(cls, parrentIter, tag):
        name = tag[-1]
        iter = cls.treeview.get_model().append(parrentIter, (name, ))
        cls.tagToIter[tag] = iter

        widgets = uistuff.GladeWidgets("findbar.glade")
        frame = widgets["frame"]
        frame.unparent()
        frame.show_all()

        uistuff.keepDown(widgets["scrolledwindow"])
        textview = widgets["textview"]
        tb = textview.get_buffer()
        tb.create_tag(str(LOG_DEBUG), family='Monospace')
        tb.create_tag(str(LOG_LOG),
                      family='Monospace',
                      weight=pango.WEIGHT_BOLD)
        tb.create_tag(str(LOG_WARNING), family='Monospace', foreground="red")
        tb.create_tag(str(LOG_ERROR),
                      family='Monospace',
                      weight=pango.WEIGHT_BOLD,
                      foreground="red")

        findbar = widgets["findbar"]
        findbar.hide()
        # Make searchEntry and "out of label" share height with the buttons
        widgets["prevButton"].connect(
            "size-allocate",
            lambda w, alloc: widgets["searchEntry"].set_size_request(
                -1, alloc.height) or widgets["outofLabel"].set_size_request(
                    -1, alloc.height - 2))

        # Make "out of label" more visually distinct
        uistuff.makeYellow(widgets["outofLabel"])
        widgets["outofLabel"].hide()

        widgets["closeButton"].connect("clicked",
                                       lambda w: widgets["findbar"].hide())

        # Connect showing/hiding of the findbar
        cls.window.connect("key-press-event", cls.onTextviewKeypress, widgets)
        widgets["findbar"].connect("key-press-event", cls.onFindbarKeypress)

        widgets["searchEntry"].connect("changed", cls.onSearchChanged, widgets)

        widgets["prevButton"].connect("clicked",
                                      lambda w: cls.searchJump(-1, widgets))
        widgets["nextButton"].connect("clicked",
                                      lambda w: cls.searchJump(1, widgets))

        cls.pages.append_page(frame)
        page = {"child": frame, "textview": textview}
        cls.tagToPage[tag] = page
        cls.pathToPage[cls.treeview.get_model().get_path(iter)] = page

        cls.treeview.expand_all()
Exemplo n.º 4
0
 def _createPage (cls, parrentIter, tag):
     name = tag[-1]
     if isinstance(name, int):
         name=str(name)
     iter = cls.treeview.get_model().append(parrentIter, (name,))
     cls.tagToIter[tag] = iter
     
     widgets = uistuff.GladeWidgets("findbar.glade")
     frame = widgets["frame"]
     frame.unparent()
     frame.show_all()
     
     uistuff.keepDown(widgets["scrolledwindow"])
     textview = widgets["textview"]
     tb = textview.get_buffer()
     tb.create_tag(str(logging.DEBUG), family='Monospace')
     tb.create_tag(str(logging.INFO), family='Monospace', weight=Pango.Weight.BOLD)
     tb.create_tag(str(logging.WARNING), family='Monospace', foreground="red")
     tb.create_tag(str(logging.ERROR), family='Monospace', weight=Pango.Weight.BOLD, foreground="red")
     
     
     findbar = widgets["findbar"]
     findbar.hide()
     # Make searchEntry and "out of label" share height with the buttons
     widgets["prevButton"].connect("size-allocate", lambda w, alloc:
             widgets["searchEntry"].set_size_request(-1, alloc.height) or
             widgets["outofLabel"].set_size_request(-1, alloc.height-2))
     
     # Make "out of label" more visually distinct
     uistuff.makeYellow(widgets["outofLabel"])
     widgets["outofLabel"].hide()
     
     widgets["closeButton"].connect("clicked", lambda w:
                                    widgets["findbar"].hide())
     
     # Connect showing/hiding of the findbar
     cls.window.connect("key-press-event", cls.onTextviewKeypress, widgets)
     widgets["findbar"].connect("key-press-event", cls.onFindbarKeypress)
     
     widgets["searchEntry"].connect("changed", cls.onSearchChanged, widgets)
     
     widgets["prevButton"].connect("clicked", lambda w: cls.searchJump(-1, widgets))
     widgets["nextButton"].connect("clicked", lambda w: cls.searchJump(1, widgets))
     
     
     
     
     cls.pages.append_page(frame, None)
     page = {"child": frame, "textview":textview}
     cls.tagToPage[tag] = page
     cls.pathToPage[cls.treeview.get_model().get_path(iter).to_string()] = page
     
     cls.treeview.expand_all()
Exemplo n.º 5
0
    def initBoardAndClock(self, gamemodel):
        boardvbox = gtk.VBox()
        boardvbox.set_spacing(2)

        messageSock = createAlignment(0, 0, 0, 0)
        makeYellow(messageSock)

        if gamemodel.timemodel:
            ccalign = createAlignment(0, 0, 0, 0)
            cclock = ChessClock()
            cclock.setModel(gamemodel.timemodel)
            ccalign.add(cclock)
            ccalign.set_size_request(-1, 32)
            boardvbox.pack_start(ccalign, expand=False)

        actionMenuDic = {}
        for item in ACTION_MENU_ITEMS:
            actionMenuDic[item] = widgets[item]

        board = BoardControl(gamemodel, actionMenuDic)
        boardvbox.pack_start(board)
        return boardvbox, board, messageSock
Exemplo n.º 6
0
    def initBoardAndClock(self, gamemodel):
        boardvbox = gtk.VBox()
        boardvbox.set_spacing(2)

        messageSock = createAlignment(0, 0, 0, 0)
        makeYellow(messageSock)

        if gamemodel.timemodel:
            ccalign = createAlignment(0, 0, 0, 0)
            cclock = ChessClock()
            cclock.setModel(gamemodel.timemodel)
            ccalign.add(cclock)
            ccalign.set_size_request(-1, 32)
            boardvbox.pack_start(ccalign, expand=False)

        actionMenuDic = {}
        for item in ACTION_MENU_ITEMS:
            actionMenuDic[item] = widgets[item]

        board = BoardControl(gamemodel, actionMenuDic)
        boardvbox.pack_start(board)
        return boardvbox, board, messageSock
 def __init__ (self, widgets):
     
     # Put engines in trees and combos
     
     engines = discoverer.getEngines()
     allstore = gtk.ListStore(gtk.gdk.Pixbuf, str)
     for engine in engines.values():
         c = discoverer.getCountry(engine)
         if c:
             flag = addDataPrefix("flags/%s.png" % c)
         if not c or not os.path.isfile(flag):
             flag = addDataPrefix("flags/unknown.png")
         flag_icon = gtk.gdk.pixbuf_new_from_file(flag)
         allstore.append((flag_icon, discoverer.getName(engine)))
     
     tv = widgets["engines_treeview"]
     tv.set_model(allstore)
     tv.append_column(gtk.TreeViewColumn(
             _("Flag"), gtk.CellRendererPixbuf(), pixbuf=0))
     tv.append_column(gtk.TreeViewColumn(
             _("Name"), gtk.CellRendererText(), text=1))
     
     analyzers = list(discoverer.getAnalyzers())
     ana_data = []
     invana_data = []
     for engine in analyzers:
         name = discoverer.getName(engine)
         c = discoverer.getCountry(engine)
         if c:
             flag = addDataPrefix("flags/%s.png" % c)
         if not c or not os.path.isfile(flag):
             flag = addDataPrefix("flags/unknown.png")
         flag_icon = gtk.gdk.pixbuf_new_from_file(flag)
         ana_data.append((flag_icon, name))
         invana_data.append((flag_icon, name))
     
     uistuff.createCombo(widgets["ana_combobox"], ana_data)
     uistuff.createCombo(widgets["inv_ana_combobox"], invana_data)
     
     # Save, load and make analyze combos active
     
     conf.set("ana_combobox", conf.get("ana_combobox", 0))
     conf.set("inv_ana_combobox", conf.get("inv_ana_combobox", 0))
     
     def on_analyzer_check_toggled (check):
         widgets["analyzers_vbox"].set_sensitive(check.get_active())
         widgets["hint_mode"].set_active(check.get_active())
         from pychess.Main import gameDic
         if gameDic:
             widgets["hint_mode"].set_sensitive(check.get_active())
     widgets["analyzer_check"].connect("toggled", on_analyzer_check_toggled)
     uistuff.keep(widgets["analyzer_check"], "analyzer_check")
     
     def on_invanalyzer_check_toggled (check):
         widgets["inv_analyzers_vbox"].set_sensitive(check.get_active())
         widgets["spy_mode"].set_active(check.get_active())
         from pychess.Main import gameDic
         if gameDic:
             widgets["spy_mode"].set_sensitive(check.get_active())
     widgets["inv_analyzer_check"].connect("toggled", on_invanalyzer_check_toggled)
     uistuff.keep(widgets["inv_analyzer_check"], "inv_analyzer_check")
     
     # Put options in trees in add/edit dialog
     
     #=======================================================================
     # tv = widgets["optionview"]
     # tv.append_column(gtk.TreeViewColumn(
     #    "Option", gtk.CellRendererText(), text=0))
     # tv.append_column(gtk.TreeViewColumn(
     #    "Value", gtk.CellRendererText(), text=1))
     # 
     # def edit (button):
     #    
     #    iter = widgets["engines_treeview"].get_selection().get_selected()[1]
     #    if iter: row = allstore.get_path(iter)[0]
     #    else: return
     #    
     #    engine = discoverer.getEngineN(row)
     #    optionstags = engine.getElementsByTagName("options")
     #    if not optionstags:
     #        widgets["engine_options_expander"].hide()
     #    else:
     #        widgets["engine_options_expander"].show()
     #        widgets["engine_options_expander"].set_expanded(False)
     #        
     #        optionsstore = gtk.ListStore(str, str)
     #        tv = widgets["optionview"]
     #        tv.set_model(optionsstore)
     #        
     #        for option in optionstags[0].childNodes:
     #            if option.nodeType != option.ELEMENT_NODE: continue
     #            optionsstore.append( [option.getAttribute("name"),
     #                                  option.getAttribute("default")] )
     #        
     #    widgets["engine_path_chooser"].set_title(_("Locate Engine"))
     #    widgets["engine_path_chooser"].set_uri("file:///usr/bin/gnuchess")
     #    
     #    dialog = widgets["addconfig_engine"]
     #    answer = dialog.run()
     #    dialog.hide()
     # widgets["edit_engine_button"].connect("clicked", edit)
     #=======================================================================
     #widgets["remove_engine_button"].connect("clicked", remove)
     #widgets["add_engine_button"].connect("clicked", add)
     
     # Give widgets to kepper
     
     for combo in ("ana_combobox", "inv_ana_combobox"):
         
         def get_value (combobox):
             engine = list(discoverer.getAnalyzers())[combobox.get_active()]
             if engine.find('md5') != None:
                 return engine.find('md5').text.strip()
         
         def set_value (combobox, value):
             engine = discoverer.getEngineByMd5(value)
             if not engine:
                 combobox.set_active(0)
             else:
                 try:
                     index = list(discoverer.getAnalyzers()).index(engine)
                 except ValueError:
                     index = 0
                 combobox.set_active(index)
         
         uistuff.keep (widgets[combo], combo, get_value, set_value)
     
     # Init info box
     
     uistuff.makeYellow(widgets["analyzer_pref_infobox"])
     widgets["analyzer_pref_infobox"].hide()
     def updatePrefInfobox (widget, *args):
         widgets["analyzer_pref_infobox"].show()
     widgets["ana_combobox"].connect("changed", updatePrefInfobox)
     widgets["analyzer_check"].connect("toggled", updatePrefInfobox)
     widgets["inv_ana_combobox"].connect("changed", updatePrefInfobox)
     widgets["inv_analyzer_check"].connect("toggled", updatePrefInfobox)
     widgets["preferences"].connect("hide", lambda *a: widgets["analyzer_pref_infobox"].hide())
    def __init__(self, widgets):

        # Put engines in trees and combos

        engines = discoverer.getEngines()
        allstore = gtk.ListStore(gtk.gdk.Pixbuf, str)
        for engine in engines.values():
            c = discoverer.getCountry(engine)
            if c:
                flag = addDataPrefix("flags/%s.png" % c)
            if not c or not os.path.isfile(flag):
                flag = addDataPrefix("flags/unknown.png")
            flag_icon = gtk.gdk.pixbuf_new_from_file(flag)
            allstore.append((flag_icon, discoverer.getName(engine)))

        tv = widgets["engines_treeview"]
        tv.set_model(allstore)
        tv.append_column(
            gtk.TreeViewColumn(_("Flag"), gtk.CellRendererPixbuf(), pixbuf=0))
        tv.append_column(
            gtk.TreeViewColumn(_("Name"), gtk.CellRendererText(), text=1))

        analyzers = list(discoverer.getAnalyzers())
        ana_data = []
        invana_data = []
        for engine in analyzers:
            name = discoverer.getName(engine)
            c = discoverer.getCountry(engine)
            if c:
                flag = addDataPrefix("flags/%s.png" % c)
            if not c or not os.path.isfile(flag):
                flag = addDataPrefix("flags/unknown.png")
            flag_icon = gtk.gdk.pixbuf_new_from_file(flag)
            ana_data.append((flag_icon, name))
            invana_data.append((flag_icon, name))

        uistuff.createCombo(widgets["ana_combobox"], ana_data)
        uistuff.createCombo(widgets["inv_ana_combobox"], invana_data)

        # Save, load and make analyze combos active

        conf.set("ana_combobox", conf.get("ana_combobox", 0))
        conf.set("inv_ana_combobox", conf.get("inv_ana_combobox", 0))

        def on_analyzer_check_toggled(check):
            widgets["analyzers_vbox"].set_sensitive(check.get_active())
            widgets["hint_mode"].set_active(check.get_active())
            from pychess.Main import gameDic
            if gameDic:
                widgets["hint_mode"].set_sensitive(check.get_active())

        widgets["analyzer_check"].connect("toggled", on_analyzer_check_toggled)
        uistuff.keep(widgets["analyzer_check"], "analyzer_check")

        def on_invanalyzer_check_toggled(check):
            widgets["inv_analyzers_vbox"].set_sensitive(check.get_active())
            widgets["spy_mode"].set_active(check.get_active())
            from pychess.Main import gameDic
            if gameDic:
                widgets["spy_mode"].set_sensitive(check.get_active())

        widgets["inv_analyzer_check"].connect("toggled",
                                              on_invanalyzer_check_toggled)
        uistuff.keep(widgets["inv_analyzer_check"], "inv_analyzer_check")

        # Put options in trees in add/edit dialog

        #=======================================================================
        # tv = widgets["optionview"]
        # tv.append_column(gtk.TreeViewColumn(
        #    "Option", gtk.CellRendererText(), text=0))
        # tv.append_column(gtk.TreeViewColumn(
        #    "Value", gtk.CellRendererText(), text=1))
        #
        # def edit (button):
        #
        #    iter = widgets["engines_treeview"].get_selection().get_selected()[1]
        #    if iter: row = allstore.get_path(iter)[0]
        #    else: return
        #
        #    engine = discoverer.getEngineN(row)
        #    optionstags = engine.getElementsByTagName("options")
        #    if not optionstags:
        #        widgets["engine_options_expander"].hide()
        #    else:
        #        widgets["engine_options_expander"].show()
        #        widgets["engine_options_expander"].set_expanded(False)
        #
        #        optionsstore = gtk.ListStore(str, str)
        #        tv = widgets["optionview"]
        #        tv.set_model(optionsstore)
        #
        #        for option in optionstags[0].childNodes:
        #            if option.nodeType != option.ELEMENT_NODE: continue
        #            optionsstore.append( [option.getAttribute("name"),
        #                                  option.getAttribute("default")] )
        #
        #    widgets["engine_path_chooser"].set_title(_("Locate Engine"))
        #    widgets["engine_path_chooser"].set_uri("file:///usr/bin/gnuchess")
        #
        #    dialog = widgets["addconfig_engine"]
        #    answer = dialog.run()
        #    dialog.hide()
        # widgets["edit_engine_button"].connect("clicked", edit)
        #=======================================================================
        #widgets["remove_engine_button"].connect("clicked", remove)
        #widgets["add_engine_button"].connect("clicked", add)

        # Give widgets to kepper

        for combo in ("ana_combobox", "inv_ana_combobox"):

            def get_value(combobox):
                engine = list(discoverer.getAnalyzers())[combobox.get_active()]
                if engine.find('md5') != None:
                    return engine.find('md5').text.strip()

            def set_value(combobox, value):
                engine = discoverer.getEngineByMd5(value)
                if not engine:
                    combobox.set_active(0)
                else:
                    try:
                        index = list(discoverer.getAnalyzers()).index(engine)
                    except ValueError:
                        index = 0
                    combobox.set_active(index)

            uistuff.keep(widgets[combo], combo, get_value, set_value)

        # Init info box

        uistuff.makeYellow(widgets["analyzer_pref_infobox"])
        widgets["analyzer_pref_infobox"].hide()

        def updatePrefInfobox(widget, *args):
            widgets["analyzer_pref_infobox"].show()

        widgets["ana_combobox"].connect("changed", updatePrefInfobox)
        widgets["analyzer_check"].connect("toggled", updatePrefInfobox)
        widgets["inv_ana_combobox"].connect("changed", updatePrefInfobox)
        widgets["inv_analyzer_check"].connect("toggled", updatePrefInfobox)
        widgets["preferences"].connect(
            "hide", lambda *a: widgets["analyzer_pref_infobox"].hide())