def fill_server_list_model(self, server_table): """Fill the server view""" view_table = helpers.deepcopy(server_table) model = self.gtk_widgets["server-list-model"] model_append = model.append model_format = self.server_list_model_format game_icons = self.game_icons flag_icons = self.flag_icons # Clears the model # UGLY HACK! # Workaround for chaotic TreeViewSelection on ListModel erase host_selection = gtk_helpers.get_widget_value( self.gtk_widgets["server-connect-host"]) game_selection = gtk_helpers.get_widget_value( self.gtk_widgets["server-connect-game"]) model.clear() gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-host"], host_selection) gtk_helpers.set_widget_value( self.gtk_widgets["server-connect-game"], game_selection, treeview_colnum=self.game_list_model_format.index("game_id")) # Goodies for GUI for entry in view_table: game_id = entry.get("game_id") country = entry.get("country") # Game icon entry["game_icon"] = game_icons.get(game_id) # Lock icon if entry["password"] is True: entry["password_icon"] = "network-wireless-encrypted-symbolic" else: entry["password_icon"] = None if entry["secure"] is True: entry["secure_icon"] = "security-high-symbolic" else: entry["secure_icon"] = None # Country flags entry["country_icon"] = flag_icons.get(country) # Filtering stuff entry["full"] = entry["player_count"] >= entry["player_limit"] entry["empty"] = entry["player_count"] == 0 view_table = helpers.sort_dict_table(view_table, "ping") server_list = helpers.dict_to_list(view_table, model_format) for entry in server_list: model_append(entry)
def fill_server_list_model(self, server_table): """Fill the server view""" view_table = helpers.deepcopy(server_table) model = self.gtk_widgets["server-list-model"] model_append = model.append model_format = self.server_list_model_format game_icons = self.game_icons flag_icons = self.flag_icons # Clears the model # UGLY HACK! # Workaround for chaotic TreeViewSelection on ListModel erase host_selection = gtk_helpers.get_widget_value(self.gtk_widgets["server-connect-host"]) game_selection = gtk_helpers.get_widget_value(self.gtk_widgets["server-connect-game"]) model.clear() gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-host"], host_selection) gtk_helpers.set_widget_value(self.gtk_widgets["server-connect-game"], game_selection, treeview_colnum=self.game_list_model_format.index("game_id")) # Goodies for GUI for entry in view_table: game_id = entry.get("game_id") country = entry.get("country") # Game icon entry["game_icon"] = game_icons.get(game_id) # Lock icon if entry["password"] is True: entry["password_icon"] = "network-wireless-encrypted-symbolic" else: entry["password_icon"] = None if entry["secure"] is True: entry["secure_icon"] = "security-high-symbolic" else: entry["secure_icon"] = None # Country flags entry["country_icon"] = flag_icons.get(country) # Filtering stuff entry["full"] = entry["player_count"] >= entry["player_limit"] entry["empty"] = entry["player_count"] == 0 view_table = helpers.sort_dict_table(view_table, "ping") server_list = helpers.dict_to_list(view_table, model_format) for entry in server_list: model_append(entry)
def fill_game_store(self): """ Loads game list into a list store """ game_table = self.core.game_table.copy game_icons = self.game_icons game_model = self.gtk_widgets["game-list-model"] game_store_table = [] for entry in game_table: game_store_table.append({}) game_store_table[-1]["game_id"] = entry game_store_table[-1]["name"] = game_table[entry]["info"]["name"] game_store_table[-1]["status_icon"] = None game_store_table[-1]["game_icon"] = game_icons[entry] game_store_table = helpers.sort_dict_table(game_store_table, "name") game_store_list = helpers.dict_to_list(game_store_table, self.game_list_model_format) for list_entry in game_store_list: game_model.append(list_entry)