def init_layout(self): perspective_widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) perspective_manager.set_perspective_widget("fics", perspective_widget) self.infobar = InfoBarNotebook("fics_lounge_infobar") self.infobar.hide() perspective_widget.pack_start(self.infobar, False, False, 0) self.dock = PyDockTop("fics", self) align = Gtk.Alignment() align.show() align.add(self.dock) self.dock.show() perspective_widget.pack_start(align, True, True, 0) self.notebooks = {"ficshome": new_notebook()} self.main_notebook = self.notebooks["ficshome"] for panel in self.sidePanels: self.notebooks[panel_name(panel.__name__)] = new_notebook(panel_name(panel.__name__)) self.docks["ficshome"] = (Gtk.Label(label="ficshome"), self.notebooks["ficshome"], None) for panel in self.sidePanels: self.docks[panel_name(panel.__name__)][1] = self.notebooks[panel_name(panel.__name__)] self.load_from_xml() # Default layout of side panels first_time_layout = False if not os.path.isfile(self.dockLocation): first_time_layout = True leaf = self.dock.dock(self.docks["ficshome"][1], CENTER, self.docks["ficshome"][0], "ficshome") leaf.setDockable(False) console_leaf = leaf.dock(self.docks["ConsolePanel"][1], SOUTH, self.docks["ConsolePanel"][0], "ConsolePanel") console_leaf.dock(self.docks["NewsPanel"][1], CENTER, self.docks["NewsPanel"][0], "NewsPanel") seek_leaf = leaf.dock(self.docks["SeekListPanel"][1], WEST, self.docks["SeekListPanel"][0], "SeekListPanel") seek_leaf.dock(self.docks["SeekGraphPanel"][1], CENTER, self.docks["SeekGraphPanel"][0], "SeekGraphPanel") seek_leaf.dock(self.docks["PlayerListPanel"][1], CENTER, self.docks["PlayerListPanel"][0], "PlayerListPanel") seek_leaf.dock(self.docks["GameListPanel"][1], CENTER, self.docks["GameListPanel"][0], "GameListPanel") seek_leaf.dock(self.docks["ArchiveListPanel"][1], CENTER, self.docks["ArchiveListPanel"][0], "ArchiveListPanel") leaf = leaf.dock(self.docks["ChatPanel"][1], SOUTH, self.docks["ChatPanel"][0], "ChatPanel") # leaf.dock(self.docks["LecturesPanel"][1], CENTER, self.docks["LecturesPanel"][0], "LecturesPanel") def unrealize(dock): dock.saveToXML(self.dockLocation) dock._del() self.dock.connect("unrealize", unrealize) self.dock.show_all() perspective_widget.show_all() perspective_manager.set_perspective_menuitems("fics", self.menuitems, default=first_time_layout) log.debug("FICS.__init__: finished")
def init_layout(self): perspective_widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) perspective_manager.set_perspective_widget("fics", perspective_widget) perspective_manager.set_perspective_menuitems("fics", self.menuitems) self.infobar = InfoBarNotebook("fics_lounge_infobar") self.infobar.hide() perspective_widget.pack_start(self.infobar, False, False, 0) self.dock = PyDockTop("fics", self) align = Gtk.Alignment() align.show() align.add(self.dock) self.dock.show() perspective_widget.pack_start(align, True, True, 0) self.notebooks = {"ficshome": new_notebook()} self.main_notebook = self.notebooks["ficshome"] for panel in self.sidePanels: self.notebooks[panel_name(panel.__name__)] = new_notebook(panel_name(panel.__name__)) self.docks["ficshome"] = (Gtk.Label(label="ficshome"), self.notebooks["ficshome"], None) for panel in self.sidePanels: self.docks[panel_name(panel.__name__)][1] = self.notebooks[panel_name(panel.__name__)] self.load_from_xml() # Default layout of side panels if not os.path.isfile(self.dockLocation): leaf = self.dock.dock(self.docks["ficshome"][1], CENTER, self.docks["ficshome"][0], "ficshome") leaf.setDockable(False) console_leaf = leaf.dock(self.docks["ConsolePanel"][1], SOUTH, self.docks["ConsolePanel"][0], "ConsolePanel") console_leaf.dock(self.docks["NewsPanel"][1], CENTER, self.docks["NewsPanel"][0], "NewsPanel") seek_leaf = leaf.dock(self.docks["SeekListPanel"][1], WEST, self.docks["SeekListPanel"][0], "SeekListPanel") seek_leaf.dock(self.docks["SeekGraphPanel"][1], CENTER, self.docks["SeekGraphPanel"][0], "SeekGraphPanel") seek_leaf.dock(self.docks["PlayerListPanel"][1], CENTER, self.docks["PlayerListPanel"][0], "PlayerListPanel") seek_leaf.dock(self.docks["GameListPanel"][1], CENTER, self.docks["GameListPanel"][0], "GameListPanel") seek_leaf.dock(self.docks["ArchiveListPanel"][1], CENTER, self.docks["ArchiveListPanel"][0], "ArchiveListPanel") leaf = leaf.dock(self.docks["ChatPanel"][1], SOUTH, self.docks["ChatPanel"][0], "ChatPanel") # leaf.dock(self.docks["LecturesPanel"][1], CENTER, self.docks["LecturesPanel"][0], "LecturesPanel") def unrealize(dock): dock.saveToXML(self.dockLocation) dock._del() self.dock.connect("unrealize", unrealize) self.dock.show_all() perspective_widget.show_all() log.debug("FICS.__init__: finished")
def attachGameWidget(self, gmwidg): log.debug("attachGameWidget: %s" % gmwidg) if self.first_run: self.init_layout() self.first_run = False perspective_manager.activate_perspective("games") gmwidg.panels = [ panel.Sidepanel().load(gmwidg) for panel in self.sidePanels ] self.key2gmwidg[gmwidg.notebookKey] = gmwidg headbook = self.getheadbook() headbook.append_page(gmwidg.notebookKey, gmwidg.tabcontent) gmwidg.notebookKey.show_all() if hasattr(headbook, "set_tab_reorderable"): headbook.set_tab_reorderable(gmwidg.notebookKey, True) def callback(notebook, gpointer, page_num, gmwidg): if notebook.get_nth_page(page_num) == gmwidg.notebookKey: gmwidg.infront() if gmwidg.gamemodel.players and gmwidg.gamemodel.isObservationGame( ): gmwidg.light_on_off(False) text = gmwidg.game_info_label.get_text() gmwidg.game_info_label.set_markup( '<span color="black" weight="bold">%s</span>' % text) self.key2cid[gmwidg.notebookKey] = headbook.connect_after( "switch-page", callback, gmwidg) gmwidg.infront() align = gamewidget.createAlignment(0, 0, 0, 0) align.show() align.add(gmwidg.infobar) self.notebooks["messageArea"].append_page(align, None) self.notebooks["board"].append_page(gmwidg.boardvbox, None) gmwidg.boardvbox.show_all() for panel, instance in zip(self.sidePanels, gmwidg.panels): self.notebooks[panel_name(panel.__name__)].append_page( instance, None) instance.show_all() self.notebooks["buttons"].append_page(gmwidg.stat_hbox, None) gmwidg.stat_hbox.show_all() if headbook.get_n_pages() == 1: self.show_tabs(not conf.get("hideTabs")) else: # We should always show tabs if more than one exists self.show_tabs(True) headbook.set_current_page(-1) widgets = gamewidget.getWidgets() if headbook.get_n_pages( ) == 1 and not widgets["show_sidepanels"].get_active(): self.zoomToBoard(True)
def attachGameWidget(self, gmwidg): log.debug("attachGameWidget: %s" % gmwidg) if self.first_run: self.init_layout() self.first_run = False perspective_manager.activate_perspective("games") gmwidg.panels = [panel.Sidepanel().load(gmwidg) for panel in self.sidePanels] self.key2gmwidg[gmwidg.notebookKey] = gmwidg headbook = self.getheadbook() headbook.append_page(gmwidg.notebookKey, gmwidg.tabcontent) gmwidg.notebookKey.show_all() if hasattr(headbook, "set_tab_reorderable"): headbook.set_tab_reorderable(gmwidg.notebookKey, True) def callback(notebook, gpointer, page_num, gmwidg): if notebook.get_nth_page(page_num) == gmwidg.notebookKey: gmwidg.infront() if gmwidg.gamemodel.players and gmwidg.gamemodel.isObservationGame(): gmwidg.light_on_off(False) text = gmwidg.game_info_label.get_text() gmwidg.game_info_label.set_markup( '<span color="black" weight="bold">%s</span>' % text) self.key2cid[gmwidg.notebookKey] = headbook.connect_after("switch-page", callback, gmwidg) gmwidg.infront() align = gamewidget.createAlignment(0, 0, 0, 0) align.show() align.add(gmwidg.infobar) self.notebooks["messageArea"].append_page(align, None) self.notebooks["board"].append_page(gmwidg.boardvbox, None) gmwidg.boardvbox.show_all() for panel, instance in zip(self.sidePanels, gmwidg.panels): self.notebooks[panel_name(panel.__name__)].append_page(instance, None) instance.show_all() self.notebooks["buttons"].append_page(gmwidg.stat_hbox, None) gmwidg.stat_hbox.show_all() if headbook.get_n_pages() == 1: self.show_tabs(not conf.get("hideTabs")) else: # We should always show tabs if more than one exists self.show_tabs(True) headbook.set_current_page(-1) widgets = gamewidget.getWidgets() if headbook.get_n_pages() == 1 and not widgets["show_sidepanels"].get_active(): self.zoomToBoard(True)
def init_layout(self): perspective_widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) perspective_manager.set_perspective_widget("games", perspective_widget) self.notebooks = {"board": new_notebook("board"), "buttons": new_notebook("buttons"), "messageArea": new_notebook("messageArea")} self.main_notebook = self.notebooks["board"] for panel in self.sidePanels: self.notebooks[panel_name(panel.__name__)] = new_notebook(panel_name(panel.__name__)) # Initing headbook align = gamewidget.createAlignment(4, 4, 0, 4) align.set_property("yscale", 0) headbook = Gtk.Notebook() headbook.set_name("headbook") headbook.set_scrollable(True) align.add(headbook) perspective_widget.pack_start(align, False, True, 0) self.show_tabs(not conf.get("hideTabs")) # Initing center centerVBox = Gtk.VBox() # The dock self.dock = PyDockTop("main", self) self.dockAlign = gamewidget.createAlignment(4, 4, 0, 4) self.dockAlign.add(self.dock) centerVBox.pack_start(self.dockAlign, True, True, 0) self.dockAlign.show() self.dock.show() self.docks["board"] = (Gtk.Label(label="Board"), self.notebooks["board"], None) for panel in self.sidePanels: self.docks[panel_name(panel.__name__)][1] = self.notebooks[panel_name(panel.__name__)] self.load_from_xml() # Default layout of side panels if not os.path.isfile(self.dockLocation): leaf = self.dock.dock(self.docks["board"][1], CENTER, Gtk.Label(label=self.docks["board"][0]), "board") self.docks["board"][1].show_all() leaf.setDockable(False) # S epanel = leaf.dock(self.docks["bookPanel"][1], SOUTH, self.docks["bookPanel"][0], "bookPanel") epanel.default_item_height = 45 epanel = epanel.dock(self.docks["engineOutputPanel"][1], CENTER, self.docks["engineOutputPanel"][0], "engineOutputPanel") # NE leaf = leaf.dock(self.docks["annotationPanel"][1], EAST, self.docks["annotationPanel"][0], "annotationPanel") leaf = leaf.dock(self.docks["historyPanel"][1], CENTER, self.docks["historyPanel"][0], "historyPanel") leaf = leaf.dock(self.docks["scorePanel"][1], CENTER, self.docks["scorePanel"][0], "scorePanel") # SE leaf = leaf.dock(self.docks["chatPanel"][1], SOUTH, self.docks["chatPanel"][0], "chatPanel") leaf = leaf.dock(self.docks["commentPanel"][1], CENTER, self.docks["commentPanel"][0], "commentPanel") def unrealize(dock, notebooks): # unhide the panel before saving so its configuration is saved correctly self.notebooks["board"].get_parent().get_parent().zoomDown() dock.saveToXML(self.dockLocation) dock._del() self.dock.connect("unrealize", unrealize, self.notebooks) hbox = Gtk.HBox() # Buttons self.notebooks["buttons"].set_border_width(4) hbox.pack_start(self.notebooks["buttons"], False, True, 0) # The message area # TODO: If you try to fix this first read issue #958 and 1018 align = gamewidget.createAlignment(0, 0, 0, 0) # sw = Gtk.ScrolledWindow() # port = Gtk.Viewport() # port.add(self.notebooks["messageArea"]) # sw.add(port) # align.add(sw) align.add(self.notebooks["messageArea"]) hbox.pack_start(align, True, True, 0) def ma_switch_page(notebook, gpointer, page_num): notebook.props.visible = notebook.get_nth_page(page_num).\ get_child().props.visible self.notebooks["messageArea"].connect("switch-page", ma_switch_page) centerVBox.pack_start(hbox, False, True, 0) perspective_widget.pack_start(centerVBox, True, True, 0) centerVBox.show_all() perspective_widget.show_all() perspective_manager.set_perspective_menuitems("games", self.menuitems) conf.notify_add("hideTabs", self.tabsCallback) # Connecting headbook to other notebooks def hb_switch_page(notebook, gpointer, page_num): for notebook in self.notebooks.values(): notebook.set_current_page(page_num) gmwidg = self.key2gmwidg[self.getheadbook().get_nth_page(page_num)] if isinstance(gmwidg.gamemodel, ICGameModel): primary = "primary " + str(gmwidg.gamemodel.ficsgame.gameno) gmwidg.gamemodel.connection.client.run_command(primary) headbook.connect("switch-page", hb_switch_page) if hasattr(headbook, "set_tab_reorderable"): def page_reordered(widget, child, new_num, headbook): old_num = self.notebooks["board"].page_num(self.key2gmwidg[child].boardvbox) if old_num == -1: log.error('Games and labels are out of sync!') else: for notebook in self.notebooks.values(): notebook.reorder_child( notebook.get_nth_page(old_num), new_num) headbook.connect("page-reordered", page_reordered, headbook)
def open_lounge(self, connection, helperconn, host): if self.first_run: self.init_layout() self.connection = connection self.helperconn = helperconn self.host = host self.finger_sent = False self.messages = [] self.players = [] self.game_cids = {} self.widgets = uistuff.GladeWidgets("fics_lounge.glade") self.widgets["fics_lounge"].hide() fics_home = self.widgets["fics_home"] self.widgets["fics_lounge_content_hbox"].remove(fics_home) self.archive_list = self.widgets["archiveListContent"] self.widgets["fics_panels_notebook"].remove(self.archive_list) self.games_list = self.widgets["gamesListContent"] self.widgets["fics_panels_notebook"].remove(self.games_list) self.news_list = self.widgets["news"] self.widgets["fics_home"].remove(self.news_list) self.players_list = self.widgets["playersListContent"] self.widgets["fics_panels_notebook"].remove(self.players_list) self.seek_graph = self.widgets["seekGraphContent"] self.widgets["fics_panels_notebook"].remove(self.seek_graph) self.seek_list = self.widgets["seekListContent"] self.widgets["fics_panels_notebook"].remove(self.seek_list) self.seek_challenge = SeekChallengeSection(self) def on_autoLogout(alm): self.emit("autoLogout") self.close() self.connection.alm.connect("logOut", on_autoLogout) self.connection.connect("disconnected", lambda connection: self.close()) self.connection.connect("error", self.on_connection_error) if self.connection.isRegistred(): numtimes = conf.get("numberOfTimesLoggedInAsRegisteredUser") + 1 conf.set("numberOfTimesLoggedInAsRegisteredUser", numtimes) self.connection.em.connect( "onCommandNotFound", lambda em, cmd: log.error( "Fics answered '%s': Command not found" % cmd)) self.connection.bm.connect("playGameCreated", self.onPlayGameCreated) self.connection.bm.connect("obsGameCreated", self.onObserveGameCreated) self.connection.bm.connect("exGameCreated", self.onObserveGameCreated) self.connection.fm.connect("fingeringFinished", self.onFinger) # the rest of these relay server messages to the lounge infobar self.connection.bm.connect("tooManySeeks", self.tooManySeeks) self.connection.bm.connect("nonoWhileExamine", self.nonoWhileExamine) self.connection.bm.connect("matchDeclined", self.matchDeclined) self.connection.bm.connect("player_on_censor", self.player_on_censor) self.connection.bm.connect("player_on_noplay", self.player_on_noplay) self.connection.bm.connect("req_not_fit_formula", self.req_not_fit_formula) self.connection.glm.connect("seek-updated", self.on_seek_updated) self.connection.glm.connect("our-seeks-removed", self.our_seeks_removed) self.connection.cm.connect("arrivalNotification", self.onArrivalNotification) self.connection.cm.connect("departedNotification", self.onDepartedNotification) def get_top_games(): if perspective_manager.current_perspective == self: self.connection.client.run_command("games *19") return True if self.connection.ICC: self.event_id = GLib.timeout_add_seconds(5, get_top_games) for user in self.connection.notify_users: user = self.connection.players.get(user) self.user_from_notify_list_is_present(user) self.userinfo = UserInfoSection(self.widgets, self.connection, self.host, self) if not self.first_run: self.notebooks["ficshome"].remove_page(-1) self.notebooks["ficshome"].append_page(fics_home) self.panels = [ panel.Sidepanel().load(self.widgets, self.connection, self) for panel in self.sidePanels ] for panel, instance in zip(self.sidePanels, self.panels): if not self.first_run: self.notebooks[panel_name(panel.__name__)].remove_page(-1) self.notebooks[panel_name(panel.__name__)].append_page(instance) instance.show() tool_buttons = [ self.logoff_button, ] self.quick_seek_buttons = [] if self.connection.ICC: self.quick_seek_buttons = [ self.minute_1_button, self.minute_3_button, self.minute_5_button, self.minute_15_button, self.minute_25_button, self.chess960_button ] tool_buttons += self.quick_seek_buttons perspective_manager.set_perspective_toolbuttons("fics", tool_buttons) if self.first_run: self.first_run = False # After all panel is set up we can push initial messages out self.connection.com.onConsoleMessage("", self.connection.ini_messages)
def init_layout(self): perspective_widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) perspective_manager.set_perspective_widget("database", perspective_widget) self.notebooks = {"gamelist": new_notebook()} self.main_notebook = self.notebooks["gamelist"] for panel in self.sidePanels: self.notebooks[panel_name(panel.__name__)] = new_notebook( panel_name(panel.__name__)) self.spinner = Gtk.Spinner() self.spinner.set_size_request(50, 50) self.progressbar0 = Gtk.ProgressBar(show_text=True) self.progressbar = Gtk.ProgressBar(show_text=True) self.progress_dialog = Gtk.Dialog( "", mainwindow(), 0, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) self.progress_dialog.set_deletable(False) self.progress_dialog.get_content_area().pack_start( self.spinner, True, True, 0) self.progress_dialog.get_content_area().pack_start( self.progressbar0, True, True, 0) self.progress_dialog.get_content_area().pack_start( self.progressbar, True, True, 0) self.progress_dialog.get_content_area().show_all() # Initing headbook align = createAlignment(4, 4, 0, 4) align.set_property("yscale", 0) self.headbook = Gtk.Notebook() self.headbook.set_name("headbook") self.headbook.set_scrollable(True) align.add(self.headbook) perspective_widget.pack_start(align, False, True, 0) self.headbook.connect_after("switch-page", self.on_switch_page) # The dock self.dock = PyDockTop("database", self) align = Gtk.Alignment() align.show() align.add(self.dock) self.dock.show() perspective_widget.pack_start(align, True, True, 0) self.docks["gamelist"] = (Gtk.Label(label="gamelist"), self.notebooks["gamelist"], None) for panel in self.sidePanels: self.docks[panel_name( panel.__name__)][1] = self.notebooks[panel_name( panel.__name__)] self.load_from_xml() # Default layout of side panels first_time_layout = False if not os.path.isfile(self.dockLocation): first_time_layout = True leaf = self.dock.dock(self.docks["gamelist"][1], CENTER, self.docks["gamelist"][0], "gamelist") leaf.setDockable(False) leaf = leaf.dock(self.docks["OpeningTreePanel"][1], EAST, self.docks["OpeningTreePanel"][0], "OpeningTreePanel") leaf = leaf.dock(self.docks["FilterPanel"][1], CENTER, self.docks["FilterPanel"][0], "FilterPanel") leaf.dock(self.docks["PreviewPanel"][1], SOUTH, self.docks["PreviewPanel"][0], "PreviewPanel") def unrealize(dock): dock.saveToXML(self.dockLocation) dock._del() self.dock.connect("unrealize", unrealize) self.dock.show_all() perspective_widget.show_all() perspective_manager.set_perspective_menuitems( "database", self.menuitems, default=first_time_layout) perspective_manager.set_perspective_toolbuttons( "database", [self.import_button, self.save_as_button])
def init_layout(self): perspective_manager.set_perspective_toolbuttons( "learn", (self.exit_button, )) perspective_widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) perspective_manager.set_perspective_widget("learn", perspective_widget) perspective_manager.set_perspective_menuitems("learn", self.menuitems) self.notebooks = {"home": new_notebook()} self.main_notebook = self.notebooks["home"] for panel in self.sidePanels: self.notebooks[panel_name(panel.__name__)] = new_notebook( panel_name(panel.__name__)) self.dock = PyDockTop("learn", self) align = Gtk.Alignment() align.show() align.add(self.dock) self.dock.show() perspective_widget.pack_start(align, True, True, 0) self.notebooks = {"learnhome": new_notebook()} self.main_notebook = self.notebooks["learnhome"] for panel in self.sidePanels: self.notebooks[panel_name(panel.__name__)] = new_notebook( panel_name(panel.__name__)) self.docks["learnhome"] = (Gtk.Label(label="learnhome"), self.notebooks["learnhome"], None) for panel in self.sidePanels: self.docks[panel_name( panel.__name__)][1] = self.notebooks[panel_name( panel.__name__)] self.load_from_xml() # Default layout of side panels if not os.path.isfile(self.dockLocation): leaf0 = self.dock.dock(self.docks["learnhome"][1], CENTER, self.docks["learnhome"][0], "learnhome") leaf0.setDockable(False) leaf = leaf0.dock(self.docks["PuzzlesPanel"][1], WEST, self.docks["PuzzlesPanel"][0], "PuzzlesPanel") leaf.dock(self.docks["LessonsPanel"][1], SOUTH, self.docks["LessonsPanel"][0], "LessonsPanel") leaf = leaf0.dock(self.docks["LecturesPanel"][1], SOUTH, self.docks["LecturesPanel"][0], "LecturesPanel") leaf.dock(self.docks["EndgamesPanel"][1], SOUTH, self.docks["EndgamesPanel"][0], "EndgamesPanel") def unrealize(dock): dock.saveToXML(self.dockLocation) dock._del() self.dock.connect("unrealize", unrealize) self.dock.show_all() perspective_widget.show_all() log.debug("Learn.__init__: finished")
def activate(self): if self.first_run: self.init_layout() self.first_run = False learn_home = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) box = Gtk.Box() self.tv = Gtk.TreeView() color = Gdk.RGBA() color.parse("lightblue") for i, col in enumerate( (_("lichess"), _("wtharvey"), _("yacpdb"), _("lessons"))): renderer = Gtk.CellRendererProgress() renderer.set_orientation(Gtk.Orientation.VERTICAL) renderer.props.height = 100 renderer.props.inverted = True renderer.props.cell_background_rgba = color column = Gtk.TreeViewColumn(col, renderer, text=i * 2, value=i * 2 + 1) self.tv.append_column(column) self.store = Gtk.ListStore(str, int, str, int, str, int, str, int) self.update_progress(None, None, None) self.tv.set_model(self.store) self.tv.get_selection().set_mode(Gtk.SelectionMode.NONE) puzzles_solving_progress.connect("progress_updated", self.update_progress) lessons_solving_progress.connect("progress_updated", self.update_progress) box.pack_start(self.tv, False, False, 6) label = Gtk.Label(xpad=6, xalign=0) label.set_markup("<b>%s</b>" % _("Progress")) learn_home.pack_start(label, False, False, 6) learn_home.pack_start(box, False, False, 0) reset = Gtk.Button(_("Reset my progress")) learn_home.pack_start(reset, False, False, 6) def on_reset_clicked(button): dialog = Gtk.MessageDialog( mainwindow(), 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL, _("You will lose all your progress data!")) response = dialog.run() if response == Gtk.ResponseType.OK: for filename, progress in lessons_solving_progress.items(): lessons_solving_progress[filename] = [0] * len(progress) for filename, progress in puzzles_solving_progress.items(): puzzles_solving_progress[filename] = [0] * len(progress) self.update_progress(None, None, None) dialog.destroy() reset.connect("clicked", on_reset_clicked) learn_home.show_all() if not self.first_run: self.notebooks["learnhome"].remove_page(-1) self.notebooks["learnhome"].append_page(learn_home) self.panels = [ panel.Sidepanel().load(self) for panel in self.sidePanels ] for panel, instance in zip(self.sidePanels, self.panels): if not self.first_run: self.notebooks[panel_name(panel.__name__)].remove_page(-1) self.notebooks[panel_name(panel.__name__)].append_page(instance) instance.show() perspective_manager.activate_perspective("learn")
def init_layout(self): perspective_widget = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) perspective_manager.set_perspective_widget("database", perspective_widget) self.notebooks = {"gamelist": new_notebook()} self.main_notebook = self.notebooks["gamelist"] for panel in self.sidePanels: self.notebooks[panel_name(panel.__name__)] = new_notebook(panel_name(panel.__name__)) self.spinner = Gtk.Spinner() self.spinner.set_size_request(50, 50) self.progressbar0 = Gtk.ProgressBar(show_text=True) self.progressbar = Gtk.ProgressBar(show_text=True) self.progress_dialog = Gtk.Dialog("", mainwindow(), 0, ( Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) self.progress_dialog.set_deletable(False) self.progress_dialog.get_content_area().pack_start(self.spinner, True, True, 0) self.progress_dialog.get_content_area().pack_start(self.progressbar0, True, True, 0) self.progress_dialog.get_content_area().pack_start(self.progressbar, True, True, 0) self.progress_dialog.get_content_area().show_all() # Initing headbook align = createAlignment(4, 4, 0, 4) align.set_property("yscale", 0) self.headbook = Gtk.Notebook() self.headbook.set_name("headbook") self.headbook.set_scrollable(True) align.add(self.headbook) perspective_widget.pack_start(align, False, True, 0) self.headbook.connect_after("switch-page", self.on_switch_page) # The dock self.dock = PyDockTop("database", self) align = Gtk.Alignment() align.show() align.add(self.dock) self.dock.show() perspective_widget.pack_start(align, True, True, 0) self.docks["gamelist"] = (Gtk.Label(label="gamelist"), self.notebooks["gamelist"], None) for panel in self.sidePanels: self.docks[panel_name(panel.__name__)][1] = self.notebooks[panel_name(panel.__name__)] self.load_from_xml() # Default layout of side panels if not os.path.isfile(self.dockLocation): leaf = self.dock.dock(self.docks["gamelist"][1], CENTER, self.docks["gamelist"][0], "gamelist") leaf.setDockable(False) leaf = leaf.dock(self.docks["OpeningTreePanel"][1], EAST, self.docks["OpeningTreePanel"][0], "OpeningTreePanel") leaf = leaf.dock(self.docks["FilterPanel"][1], CENTER, self.docks["FilterPanel"][0], "FilterPanel") leaf.dock(self.docks["PreviewPanel"][1], SOUTH, self.docks["PreviewPanel"][0], "PreviewPanel") def unrealize(dock): dock.saveToXML(self.dockLocation) dock._del() self.dock.connect("unrealize", unrealize) self.dock.show_all() perspective_widget.show_all() perspective_manager.set_perspective_menuitems("database", self.menuitems) perspective_manager.set_perspective_toolbuttons("database", [ self.import_button, self.save_as_button])
def open_lounge(self, connection, helperconn, host): if self.first_run: self.init_layout() self.connection = connection self.helperconn = helperconn self.host = host self.finger_sent = False self.messages = [] self.players = [] self.game_cids = {} self.widgets = uistuff.GladeWidgets("fics_lounge.glade") self.widgets["fics_lounge"].hide() fics_home = self.widgets["fics_home"] self.widgets["fics_lounge_content_hbox"].remove(fics_home) self.archive_list = self.widgets["archiveListContent"] self.widgets["fics_panels_notebook"].remove(self.archive_list) self.games_list = self.widgets["gamesListContent"] self.widgets["fics_panels_notebook"].remove(self.games_list) self.news_list = self.widgets["news"] self.widgets["fics_home"].remove(self.news_list) self.players_list = self.widgets["playersListContent"] self.widgets["fics_panels_notebook"].remove(self.players_list) self.seek_graph = self.widgets["seekGraphContent"] self.widgets["fics_panels_notebook"].remove(self.seek_graph) self.seek_list = self.widgets["seekListContent"] self.widgets["fics_panels_notebook"].remove(self.seek_list) self.seek_challenge = SeekChallengeSection(self) def on_autoLogout(alm): self.emit("autoLogout") self.close() self.connection.alm.connect("logOut", on_autoLogout) self.connection.connect("disconnected", lambda connection: self.close()) self.connection.connect("error", self.on_connection_error) if self.connection.isRegistred(): numtimes = conf.get("numberOfTimesLoggedInAsRegisteredUser") + 1 conf.set("numberOfTimesLoggedInAsRegisteredUser", numtimes) self.connection.em.connect("onCommandNotFound", lambda em, cmd: log.error( "Fics answered '%s': Command not found" % cmd)) self.connection.bm.connect("playGameCreated", self.onPlayGameCreated) self.connection.bm.connect("obsGameCreated", self.onObserveGameCreated) self.connection.bm.connect("exGameCreated", self.onObserveGameCreated) self.connection.fm.connect("fingeringFinished", self.onFinger) # the rest of these relay server messages to the lounge infobar self.connection.bm.connect("tooManySeeks", self.tooManySeeks) self.connection.bm.connect("nonoWhileExamine", self.nonoWhileExamine) self.connection.bm.connect("matchDeclined", self.matchDeclined) self.connection.bm.connect("player_on_censor", self.player_on_censor) self.connection.bm.connect("player_on_noplay", self.player_on_noplay) self.connection.bm.connect("req_not_fit_formula", self.req_not_fit_formula) self.connection.glm.connect("seek-updated", self.on_seek_updated) self.connection.glm.connect("our-seeks-removed", self.our_seeks_removed) self.connection.cm.connect("arrivalNotification", self.onArrivalNotification) self.connection.cm.connect("departedNotification", self.onDepartedNotification) def get_top_games(): if perspective_manager.current_perspective == self: self.connection.client.run_command("games *19") return True if self.connection.ICC: self.event_id = GLib.timeout_add_seconds(5, get_top_games) for user in self.connection.notify_users: user = self.connection.players.get(user) self.user_from_notify_list_is_present(user) self.userinfo = UserInfoSection(self.widgets, self.connection, self.host, self) if not self.first_run: self.notebooks["ficshome"].remove_page(-1) self.notebooks["ficshome"].append_page(fics_home) self.panels = [panel.Sidepanel().load(self.widgets, self.connection, self) for panel in self.sidePanels] for panel, instance in zip(self.sidePanels, self.panels): if not self.first_run: self.notebooks[panel_name(panel.__name__)].remove_page(-1) self.notebooks[panel_name(panel.__name__)].append_page(instance) instance.show() tool_buttons = [self.logoff_button, ] self.quick_seek_buttons = [] if self.connection.ICC: self.quick_seek_buttons = [self.minute_1_button, self.minute_3_button, self.minute_5_button, self.minute_15_button, self.minute_25_button, self.chess960_button] tool_buttons += self.quick_seek_buttons perspective_manager.set_perspective_toolbuttons("fics", tool_buttons) if self.first_run: self.first_run = False # After all panel is set up we can push initial messages out self.connection.com.onConsoleMessage("", self.connection.ini_messages)