Ejemplo n.º 1
0
def test_save_load_global_window_size():
    x1 = Dice.roll()[0]
    y1 = Dice.roll()[0]
    prefs.save_global_window_size(window_name, x1, y1)
    x2, y2 = prefs.load_global_window_size(window_name)
    assert x2 == x1
    assert y2 == y1
Ejemplo n.º 2
0
def test_save_load_global_window_size():
    x1 = Dice.roll()[0]
    y1 = Dice.roll()[0]
    prefs.save_global_window_size(window_name, x1, y1)
    x2, y2 = prefs.load_global_window_size(window_name)
    assert x2 == x1
    assert y2 == y1
Ejemplo n.º 3
0
    def __init__(self, playername, password, server_name, server_port,
                 connect_now, log_path):
        gtk.Window.__init__(self)

        self.playernames = set()
        self.server_names = set()
        self.server_ports = set()

        self.set_title("Slugathon - Connect")
        self.set_default_size(400, -1)

        vbox1 = gtk.VBox()
        self.add(vbox1)

        hbox1 = gtk.HBox(homogeneous=True)
        vbox1.pack_start(hbox1, expand=False)
        label1 = gtk.Label("Player name")
        hbox1.pack_start(label1, expand=False)
        self.playername_comboboxentry = gtk.ComboBoxEntry()
        hbox1.pack_start(self.playername_comboboxentry, expand=False)

        hbox2 = gtk.HBox(homogeneous=True)
        vbox1.pack_start(hbox2, expand=False)
        label2 = gtk.Label("Password")
        hbox2.pack_start(label2, expand=False)
        self.password_entry = gtk.Entry()
        self.password_entry.set_visibility(False)
        hbox2.pack_start(self.password_entry, expand=False)

        hbox3 = gtk.HBox(homogeneous=True)
        vbox1.pack_start(hbox3, expand=False)
        label3 = gtk.Label("Server name")
        hbox3.pack_start(label3, expand=False)
        self.server_name_comboboxentry = gtk.ComboBoxEntry()
        hbox3.pack_start(self.server_name_comboboxentry, expand=False)

        hbox4 = gtk.HBox(homogeneous=True)
        vbox1.pack_start(hbox4, expand=False)
        label4 = gtk.Label("Server port")
        hbox4.pack_start(label4, expand=False)
        self.server_port_comboboxentry = gtk.ComboBoxEntry()
        hbox4.pack_start(self.server_port_comboboxentry, expand=False)

        connect_button = gtk.Button("Connect to server")
        connect_button.connect("button-press-event",
                               self.cb_connect_button_clicked)
        vbox1.pack_start(connect_button, expand=False)

        hseparator1 = gtk.HSeparator()
        vbox1.pack_start(hseparator1, expand=False)

        start_server_button = gtk.Button("Start local server")
        start_server_button.connect("button-press-event",
                                    self.cb_start_server_button_clicked)
        vbox1.pack_start(start_server_button, expand=False)

        hseparator2 = gtk.HSeparator()
        vbox1.pack_start(hseparator2, expand=False)

        self.status_textview = gtk.TextView()
        vbox1.pack_start(self.status_textview, expand=False)

        self._init_playernames(playername)
        self._init_password(password)
        self._init_server_names_and_ports(server_name, server_port)

        self.connect("destroy", guiutils.exit)
        self.connect("configure-event", self.cb_configure_event)
        self.set_icon(icon.pixbuf)

        tup = prefs.load_global_window_position(self.__class__.__name__)
        if tup:
            x, y = tup
            self.move(x, y)
        tup = prefs.load_global_window_size(self.__class__.__name__)
        if tup:
            width, height = tup
            self.resize(width, height)

        self.show_all()

        self._setup_logging(log_path)

        if connect_now:
            reactor.callWhenRunning(self.cb_connect_button_clicked)