예제 #1
0
    def changePasswordDialog(self, button=None):
        '''
        Show dialog to change password

        @param button: Widget that was clicked to activate this handler.
        '''

        s = _("Change Password")
        changepasswordDialog = gtk.Dialog(title="%s" % s,
                                          flags=gtk.DIALOG_MODAL)
        changepasswordDialog.vbox.set_border_width(5)

        header = gtk.Label()
        header.set_markup("<b><big>%s:</big></b>" % s)
        changepasswordDialog.vbox.pack_start(header)

        s = _("Old Password")
        oldpassword = gtkutil.EntryWithLabel(label="%s: " % s,
                                             visibility=False)
        changepasswordDialog.vbox.pack_start(oldpassword)

        s = _("Password")
        password1 = gtkutil.EntryWithLabel(label="%s: " % s, visibility=False)
        changepasswordDialog.vbox.pack_start(password1)

        s = _("Confirm Password")
        password2 = gtkutil.EntryWithLabel(label="%s: " % s, visibility=False)
        changepasswordDialog.vbox.pack_start(password2)

        okbutton = gtk.Button(_("Change"))
        cancelbutton = gtk.Button(_("Cancel"))

        changepasswordDialog.action_area.pack_start(okbutton)
        changepasswordDialog.action_area.pack_start(cancelbutton)

        okbutton.connect("clicked", self.changePassword, oldpassword,
                         password1, password2, changepasswordDialog)
        cancelbutton.connect("clicked",
                             lambda b: changepasswordDialog.destroy())

        changepasswordDialog.show_all()
예제 #2
0
    def showHostDialog(self, view):
        '''
        Show host information dialog

        @param view: 
        '''
        title = _("Host Information")
        dialog = gtk.Dialog(title=title, flags=gtk.DIALOG_MODAL)
        dialog.vbox.set_border_width(5)

        header = gtk.Label()
        header.set_markup("<b><big>%s:</big></b>" % title)
        dialog.vbox.pack_start(header)

        s = _("Host")
        host = gtkutil.EntryWithLabel(label="%s: " % s, visibility=True)
        dialog.vbox.pack_start(host)

        s = _("Game port")
        gport = gtkutil.EntryWithLabel(label="%s: " % s, visibility=True)
        dialog.vbox.pack_start(gport)

        s = _("Web port")
        wport = gtkutil.EntryWithLabel(label="%s: " % s, visibility=True)
        dialog.vbox.pack_start(wport)

        s = _("Location")
        location = gtkutil.EntryWithLabel(label="%s: " % s, visibility=True)
        dialog.vbox.pack_start(location)

        okbutton = gtk.Button(_("Ok"))
        cancelbutton = gtk.Button(_("Cancel"))

        dialog.action_area.pack_start(okbutton)
        dialog.action_area.pack_start(cancelbutton)

        okbutton.connect("clicked", self.setHost, host, gport, wport, location,
                         dialog, view)
        cancelbutton.connect("clicked", lambda b: dialog.destroy())

        dialog.show_all()
예제 #3
0
    def showCreateUserDialog_cb(self, button = None):
        '''
        Show dialog to create new user

        @param button: Widget that was clicked to activate this handler.
        '''

        s = _("Register New User")
        dialog = gtk.Dialog(title=s, flags=gtk.DIALOG_MODAL)
        dialog.vbox.set_border_width( 5 )

        header = gtk.Label()
        header.set_markup("<b><big>%s:</big></b>" % s)
        dialog.vbox.pack_start(header)

        s = _("Username")
        username = gtkutil.EntryWithLabel( label="%s:" % s)
        dialog.vbox.pack_start( username )

        s = _("Password")
        password1 = gtkutil.EntryWithLabel(label="%s: " %s, visibility=False)
        dialog.vbox.pack_start( password1 )

        s = _("Confirm Password")
        password2 = gtkutil.EntryWithLabel(label="%s: " %s, visibility=False)
        dialog.vbox.pack_start( password2 )

        okbutton = gtk.Button(_("Create"))
        cancelbutton = gtk.Button(_("Cancel"))

        dialog.action_area.pack_start(okbutton)
        dialog.action_area.pack_start(cancelbutton)

        okbutton.connect("clicked", self.createNewUser_cb, username, password1, password2, dialog)
        cancelbutton.connect("clicked", lambda b: dialog.destroy() )

        dialog.show_all()
예제 #4
0
    def createGameWindow(self, button=None):
        '''
        Show the dialog to create a new game

        @param button: Widget that was clicked to activate this handler.
        '''

        s = _("Create New Game")
        self.gamedialog = gtk.Dialog(title="%s" % s, flags=gtk.DIALOG_MODAL)
        self.gamedialog.vbox.set_spacing(10)
        self.gamedialog.vbox.set_border_width(5)
        self.gamedialog.vbox.set_homogeneous(False)
        main = gtk.VBox(False, 5)

        header = gtk.Label()
        header.set_markup("<b><big>%s:</big></b>" % s)
        main.pack_start(header)

        s = _("Game Name")
        self.createGameEntry = gtkutil.EntryWithLabel(
            label="%s: " % s, maxLength=constants.MAX_NAME_LENGTH)
        main.pack_start(self.createGameEntry)

        s = _("Options")
        main.pack_start(gtk.Label("%s:" % s))

        centerOption = gtk.CheckButton(_("Center square is double word score"))
        centerOption.set_active(True)
        rankedOption = gtk.CheckButton(_("Official Game"))
        rankedOption.set_active(True)
        showCountOption = gtk.CheckButton(_("Show letter distribution"))
        showCountOption.set_active(True)
        finalLetterOption = gtk.CheckButton(_("Final letter redistribution"))
        finalLetterOption.set_active(True)
        longWordBonus = gtk.CheckButton(_("Long word bonus"))
        longWordBonus.set_active(False)
        noRepeatOption = gtk.CheckButton(_("Disallow words already on board"))
        noRepeatOption.set_active(False)

        timeBox = gtk.HBox(False, 2)
        limitBox = gtk.HBox(False, 2)
        moveTimeBox = gtk.HBox(False, 2)
        limitOption = gtk.CheckButton(_('Optional Overtime Limit'))
        untimedOption = gtk.RadioButton(None, _('Untimed'))
        timedOption = gtk.RadioButton(untimedOption, _('Timed Game'))
        moveTimeOption = gtk.RadioButton(untimedOption, _('Timed Moves'))

        a = gtk.Adjustment(value=25,
                           lower=1,
                           upper=100,
                           step_incr=1,
                           page_incr=1,
                           page_size=1)
        timeControl = gtk.SpinButton(a, climb_rate=1, digits=0)
        timeBox.pack_start(timedOption, False, False, 0)
        timeBox.pack_start(timeControl, False, False, 5)
        timedOption.set_active(False)
        timedOption.connect(
            "toggled",
            lambda w, a, b: [x.set_sensitive(w.get_active()) for x in (a, b)],
            timeControl, limitBox)
        timedOption.connect("toggled",
                            lambda w, a: a.set_active(w.get_active()),
                            limitOption)
        timeControl.set_sensitive(False)

        a = gtk.Adjustment(value=1,
                           lower=1,
                           upper=100,
                           step_incr=1,
                           page_incr=1,
                           page_size=1)
        limitControl = gtk.SpinButton(a, climb_rate=1, digits=0)
        limitBox.pack_start(limitOption, False, False, 20)
        limitBox.pack_start(limitControl, False, False, 5)
        limitOption.connect("toggled",
                            lambda w, a: a.set_sensitive(w.get_active()),
                            limitControl)
        limitBox.set_sensitive(False)

        self.tips.set_tip(
            rankedOption,
            _('If this game is Official, the outcome will be marked in your statistics'
              ))
        self.tips.set_tip(
            limitOption,
            _('If you set the optional overtime limit, a player will be allowed to go over the normal game time, but the player will be penalized 10 points for every overtime minute'
              ))
        self.tips.set_tip(
            timedOption,
            _('Select this option if you wish to limit the overall time each player has for the entire game'
              ))
        self.tips.set_tip(
            moveTimeOption,
            _('Select this option if you wish to limit the time a player has for each move'
              ))
        self.tips.set_tip(
            showCountOption,
            _('Select this option if you wish to show a count of the letters remaining in the bag during the game'
              ))
        self.tips.set_tip(
            finalLetterOption,
            _('Select this option if you wish for player who put the final tile to get points from the remaining players letters'
              ))
        self.tips.set_tip(
            longWordBonus,
            _('Select this option if you wish to reward long words with more points'
              ))
        self.tips.set_tip(
            noRepeatOption,
            _('Select this option if you wish to disallow repeating words'))

        a = gtk.Adjustment(value=3,
                           lower=0,
                           upper=100,
                           step_incr=1,
                           page_incr=1,
                           page_size=1)
        moveTimeControl = gtk.SpinButton(a, climb_rate=.1, digits=1)
        moveTimeBox.pack_start(moveTimeOption, False, False, 0)
        moveTimeBox.pack_start(moveTimeControl, False, False, 5)
        moveTimeOption.connect("toggled",
                               lambda w, a: a.set_sensitive(w.get_active()),
                               moveTimeControl)
        moveTimeControl.set_sensitive(False)

        box = gtk.VBox(False, 5)
        box.pack_start(untimedOption, False, False, 0)
        box.pack_start(timeBox, False, False, 0)
        box.pack_start(limitBox, False, False, 0)
        box.pack_start(moveTimeBox, False, False, 0)

        exp = gtk.Expander(_('Timing Options'))
        exp.add(box)
        exp.set_spacing(10)

        main.pack_start(centerOption, False, False, 3)
        main.pack_start(rankedOption, False, False, 3)
        main.pack_start(showCountOption, False, False, 3)
        main.pack_start(finalLetterOption, False, False, 3)
        main.pack_start(longWordBonus, False, False, 3)
        main.pack_start(noRepeatOption, False, False, 3)

        box = gtk.HBox(False, 3)
        box.pack_start(gtk.Label(_('Rules:')), False, False, 3)

        model = gtk.ListStore(str, str)

        l = manager.LocaleManager()
        locales = l.getAvailableLocales()
        for locale in locales:
            model.append([_(l.getLocaleDescription(locale)), locale])
        model.append([_('Swedish'), 'sv'])
        cell = gtk.CellRendererText()
        combo = gtk.ComboBox(model)
        combo.pack_start(cell)
        combo.add_attribute(cell, 'text', 0)

        cur = None
        for locale in locales:
            if l.locale == locale:
                cur = locale

        if cur is not None:
            i = model.get_iter_first()
            while i:
                if model.get_value(i, 1) == cur:
                    combo.set_active_iter(i)
                    break
                i = model.iter_next(i)
        else:
            combo.set_active(0)

        box.pack_start(combo, False, False, 0)
        main.pack_start(box, False, False, 3)

        okbutton = gtk.Button(_("Create"))
        cancelbutton = gtk.Button(_("Cancel"))

        self.gamedialog.vbox.pack_start(main, False, False, 0)
        self.gamedialog.vbox.pack_start(exp, False, False, 0)

        self.gamedialog.action_area.pack_start(okbutton)
        self.gamedialog.action_area.pack_start(cancelbutton)

        okbutton.connect("clicked", self.createGame, centerOption,
                         rankedOption, showCountOption, finalLetterOption,
                         longWordBonus, noRepeatOption, combo, timedOption,
                         timeControl, limitOption, limitControl,
                         moveTimeOption, moveTimeControl)
        cancelbutton.connect("clicked", lambda b: self.gamedialog.destroy())

        self.gamedialog.show_all()
        self.gamedialog.run()