Exemplo n.º 1
0
 def cb_serverinfo_connect_button_clicked(self, *args) -> str:
     game = gtk_helpers.get_widget_value(
         self.gtk_widgets["serverinfo-gameid"])
     server = gtk_helpers.get_widget_value(
         self.gtk_widgets["serverinfo-host"])
     password = self.app.settings.settings_table["common"]["server-pass"]
     self.cb_server_connect(game, server, password)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    def cb_server_list_selection_changed(self, *args):
        """Updates text in Entry on TreeView selection change."""
        entry_field = self.gtk_widgets["server-connect-host"]
        game_selection = self.gtk_widgets["server-connect-game"]
        treeview = self.gtk_widgets["serverlist-view"]

        try:
            text = gtk_helpers.get_widget_value(treeview)[self.server_list_model_format.index("host")]
            game = gtk_helpers.get_widget_value(treeview)[self.server_list_model_format.index("game_id")]

            gtk_helpers.set_widget_value(entry_field, text)
            gtk_helpers.set_widget_value(game_selection, game, treeview_colnum=self.game_list_model_format.index("game_id"))
        except:
            pass
Exemplo n.º 5
0
    def cb_server_filters_changed(self, *args):
        filter_criteria = self.filter_criteria
        for criterium in filter_criteria:
            criterium["value"] = gtk_helpers.get_widget_value(
                self.gtk_widgets[criterium["widget"]])

        self.gtk_widgets["server-list-filter"].refilter()
Exemplo n.º 6
0
    def cb_server_connect_data_changed(self, *args):
        """Resets button sensitivity on server connect data change"""
        game = self.app.settings.settings_table["common"][
            "selected-game-connect"]
        try:
            server_list_table = self.core.game_table.get_servers_data(game)
        except (ValueError, KeyError):
            server_list_table = []
        host = self.app.settings.settings_table["common"]["server-host"]
        server_entry_index = helpers.search_dict_table(server_list_table,
                                                       "host", host)

        entry_field = self.gtk_widgets["server-connect-host"]
        info_button = self.gtk_widgets["action-info-button"]
        connect_button = self.gtk_widgets["action-connect-button"]

        if server_entry_index is None:
            info_button.set_property("sensitive", False)
            if gtk_helpers.get_widget_value(entry_field) == '':
                connect_button.set_property("sensitive", False)
            else:
                connect_button.set_property("sensitive", True)
        else:
            info_button.set_property("sensitive", True)
            connect_button.set_property("sensitive", True)
Exemplo n.º 7
0
 def update_game_settings_table(self, game, widget_option_mapping,
                                dynamic_settings_table, *args):
     for option in widget_option_mapping:
         value = gtk_helpers.get_widget_value(widget_option_mapping[option])
         if dynamic_settings_table[option][
                 "gtk_type"] == "Multiline Entry with Label":
             value = value.split("\n")
         self.core.game_table.set_game_setting(game, option, value)
Exemplo n.º 8
0
    def cb_game_combobox_changed(self, *args):
        """Actions on game combobox selection change."""
        combobox = self.gtk_widgets["game-combobox"]
        treeview = self.gtk_widgets["game-treeview"]
        game_id = gtk_helpers.get_widget_value(combobox)
        game_id_colnum = self.game_list_model_format.index("game_id")

        gtk_helpers.set_widget_value(treeview, game_id, treeview_colnum=game_id_colnum)
Exemplo n.º 9
0
    def cb_game_combobox_changed(self, *args):
        """Actions on game combobox selection change."""
        combobox = self.gtk_widgets["game-combobox"]
        treeview = self.gtk_widgets["game-treeview"]
        game_id = gtk_helpers.get_widget_value(combobox)
        game_id_colnum = self.game_list_model_format.index("game_id")

        gtk_helpers.set_widget_value(treeview,
                                     game_id,
                                     treeview_colnum=game_id_colnum)
Exemplo n.º 10
0
    def cb_server_list_selection_changed(self, *args):
        """Updates text in Entry on TreeView selection change."""
        entry_field = self.gtk_widgets["server-connect-host"]
        game_selection = self.gtk_widgets["server-connect-game"]
        treeview = self.gtk_widgets["serverlist-view"]

        try:
            text = gtk_helpers.get_widget_value(treeview)[
                self.server_list_model_format.index("host")]
            game = gtk_helpers.get_widget_value(treeview)[
                self.server_list_model_format.index("game_id")]

            gtk_helpers.set_widget_value(entry_field, text)
            gtk_helpers.set_widget_value(
                game_selection,
                game,
                treeview_colnum=self.game_list_model_format.index("game_id"))
        except:
            pass
Exemplo n.º 11
0
    def cb_game_treeview_togglebutton_clicked(self, *args):
        """Switches between TreeView and ComboBox game selection."""
        button = self.gtk_widgets["game-view-togglebutton"]
        combobox_revealer = self.gtk_widgets["game-combobox-revealer"]
        treeview_revealer = self.gtk_widgets["game-view-revealer"]

        if gtk_helpers.get_widget_value(button) is True:
            combobox_revealer.set_reveal_child(False)
            treeview_revealer.set_reveal_child(True)
        else:
            combobox_revealer.set_reveal_child(True)
            treeview_revealer.set_reveal_child(False)
Exemplo n.º 12
0
    def cb_game_treeview_togglebutton_clicked(self, *args):
        """Switches between TreeView and ComboBox game selection."""
        button = self.gtk_widgets["game-view-togglebutton"]
        combobox_revealer = self.gtk_widgets["game-combobox-revealer"]
        treeview_revealer = self.gtk_widgets["game-view-revealer"]

        if gtk_helpers.get_widget_value(button) is True:
            combobox_revealer.set_reveal_child(False)
            treeview_revealer.set_reveal_child(True)
        else:
            combobox_revealer.set_reveal_child(True)
            treeview_revealer.set_reveal_child(False)
Exemplo n.º 13
0
 def update_settings_table(self, *args):
     for group in self.widget_table:
         for option in self.widget_table[group]:
             # Define variables
             widget_name = self.widget_table[group][option]["gtk_widget_name"]
             widget = self.builder.get_object(widget_name)
             value = gtk_helpers.get_widget_value(widget)
             if isinstance(widget, Gtk.TreeView) and "gtk_widget_colnum" in self.widget_table[group][option].keys():
                 colnum = self.widget_table[group][option]["gtk_widget_colnum"]
                 try:
                     value = value[colnum]
                 except TypeError:
                     pass
             self.app.settings.settings_table[group][option] = str(value)
Exemplo n.º 14
0
 def update_settings_table(self, *args):
     for group in self.widget_table:
         for option in self.widget_table[group]:
             # Define variables
             widget_name = self.widget_table[group][option][
                 "gtk_widget_name"]
             widget = self.builder.get_object(widget_name)
             value = gtk_helpers.get_widget_value(widget)
             if isinstance(widget, Gtk.TreeView
                           ) and "gtk_widget_colnum" in self.widget_table[
                               group][option].keys():
                 colnum = self.widget_table[group][option][
                     "gtk_widget_colnum"]
                 try:
                     value = value[colnum]
                 except TypeError:
                     pass
             self.app.settings.settings_table[group][option] = str(value)
Exemplo n.º 15
0
    def cb_server_connect_data_changed(self, *args):
        """Resets button sensitivity on server connect data change"""
        game = self.app.settings.settings_table["common"]["selected-game-connect"]
        try:
            server_list_table = self.core.game_table.get_servers_data(game)
        except (ValueError, KeyError):
            server_list_table = []
        host = self.app.settings.settings_table["common"]["server-host"]
        server_entry_index = helpers.search_dict_table(server_list_table, "host", host)

        entry_field = self.gtk_widgets["server-connect-host"]
        info_button = self.gtk_widgets["action-info-button"]
        connect_button = self.gtk_widgets["action-connect-button"]

        if server_entry_index is None:
            info_button.set_property("sensitive", False)
            if gtk_helpers.get_widget_value(entry_field) == '':
                connect_button.set_property("sensitive", False)
            else:
                connect_button.set_property("sensitive", True)
        else:
            info_button.set_property("sensitive", True)
            connect_button.set_property("sensitive", True)
Exemplo n.º 16
0
    def cb_server_filters_changed(self, *args):
        filter_criteria = self.filter_criteria
        for criterium in filter_criteria:
            criterium["value"] = gtk_helpers.get_widget_value(self.gtk_widgets[criterium["widget"]])

        self.gtk_widgets["server-list-filter"].refilter()
Exemplo n.º 17
0
    def cb_filters_button_clicked(self, *args):
        button = self.gtk_widgets["filters-button"]
        revealer = self.gtk_widgets["filters-revealer"]
        show_filters = gtk_helpers.get_widget_value(button)

        revealer.set_reveal_child(show_filters)
Exemplo n.º 18
0
    def cb_filters_button_clicked(self, *args):
        button = self.gtk_widgets["filters-button"]
        revealer = self.gtk_widgets["filters-revealer"]
        show_filters = gtk_helpers.get_widget_value(button)

        revealer.set_reveal_child(show_filters)
Exemplo n.º 19
0
 def update_game_settings_table(self, game, widget_option_mapping, dynamic_settings_table, *args):
     for option in widget_option_mapping:
         value = gtk_helpers.get_widget_value(widget_option_mapping[option])
         if dynamic_settings_table[option]["gtk_type"] == "Multiline Entry with Label":
             value = value.split("\n")
         self.core.game_table.set_game_setting(game, option, value)
Exemplo n.º 20
0
 def cb_serverinfo_connect_button_clicked(self, *args) -> str:
     game = gtk_helpers.get_widget_value(self.gtk_widgets["serverinfo-gameid"])
     server = gtk_helpers.get_widget_value(self.gtk_widgets["serverinfo-host"])
     password = self.app.settings.settings_table["common"]["server-pass"]
     self.cb_server_connect(game, server, password)