Changeset 753:c4b335324b86 for src/mlx/gui
- Timestamp:
- 01/06/16 13:07:30 (9 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r739 r753 20 20 import tempfile 21 21 import threading 22 import re 22 23 23 24 #----------------------------------------------------------------------------- … … 327 328 table.attach(self._entranceExam, 1, 2, 3, 4, ypadding = 12) 328 329 330 self.addButton(xstr("button_login_register"), 331 clicked = self._registerClicked, 332 tooltip = xstr("button_login_register_tooltip")) 333 329 334 self.addButton(xstr("button_offline"), 330 335 clicked = self._offlineClicked, … … 385 390 self._loginButton.set_sensitive(pilotID!="" and 386 391 (password!="" or entranceExam)) 392 393 def _registerClicked(self, button): 394 """Called when the Register button was clicked.""" 395 self._wizard.jumpPage(3) 387 396 388 397 def _offlineClicked(self, button): … … 658 667 const.PLANE_AWAY) 659 668 else: 660 self._nextDistance = 2661 self._wizard.jumpPage( 2)669 self._nextDistance = 4 670 self._wizard.jumpPage(4) 662 671 663 672 def _fleetRetrieved(self, fleet): 664 673 """Called when the fleet has been retrieved.""" 665 674 if fleet is None: 666 self._nextDistance = 2667 self._wizard.jumpPage( 2)675 self._nextDistance = 4 676 self._wizard.jumpPage(4) 668 677 else: 669 678 plane = fleet[self._wizard._bookedFlight.tailNumber] 670 679 if plane is None: 671 self._nextDistance = 2672 self._wizard.jumpPage( 2)680 self._nextDistance = 4 681 self._wizard.jumpPage(4) 673 682 elif plane.gateNumber is not None and \ 674 683 not fleet.isGateConflicting(plane): 675 684 self._wizard._departureGate = plane.gateNumber 676 self._nextDistance = 2677 self._wizard.jumpPage( 2)685 self._nextDistance = 4 686 self._wizard.jumpPage(4) 678 687 else: 679 688 self._nextDistance = 1 … … 682 691 def _planeUpdated(self, success): 683 692 """Callback for the plane updating.""" 684 self._nextDistance = 2685 self._wizard.jumpPage( 2)693 self._nextDistance = 4 694 self._wizard.jumpPage(4) 686 695 687 696 def _getSaveDialog(self): … … 849 858 self._gateSelected() 850 859 else: 851 self._wizard. nextPage()860 self._wizard.jumpPage(3) 852 861 853 862 def _rowActivated(self, flightList, path, column): … … 871 880 """Callback for the plane updating call.""" 872 881 if success is None or success: 873 self._wizard. nextPage()882 self._wizard.jumpPage(3) 874 883 else: 875 884 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, … … 887 896 """Called when the fleet has been retrieved.""" 888 897 if fleet is None: 889 self._wizard. nextPage()898 self._wizard.jumpPage(3) 890 899 else: 891 900 self.activate() 901 902 #----------------------------------------------------------------------------- 903 904 class RegisterPage(Page): 905 """A page to enter the registration data.""" 906 907 # The minimal year of birth 908 _minYearOfBirth = 1900 909 910 # The maximal year of birth 911 _maxYearOfBirth = datetime.date.today().year 912 913 # The regular expression to check the e-mail address with 914 _emailAddressRE = re.compile("[^@]+@[^@]+\.[^@]+") 915 916 def __init__(self, wizard): 917 """Construct the registration page.""" 918 super(RegisterPage, self).__init__(wizard, xstr("register_title"), 919 xstr("register_help")) 920 921 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 922 xscale = 0.0, yscale = 0.0) 923 924 table = gtk.Table(11, 3) 925 table.set_row_spacings(4) 926 table.set_col_spacings(32) 927 alignment.add(table) 928 self.setMainWidget(alignment) 929 930 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 931 xscale = 0.0, yscale = 0.0) 932 label = gtk.Label(xstr("register_name")) 933 label.set_use_underline(True) 934 labelAlignment.add(label) 935 table.attach(labelAlignment, 0, 1, 0, 1) 936 937 self._name = gtk.Entry() 938 self._name.connect("changed", self._updateButtons) 939 self._name.set_tooltip_text(xstr("register_name_tooltip")) 940 self._name.set_width_chars(30) 941 table.attach(self._name, 1, 2, 0, 1) 942 label.set_mnemonic_widget(self._name) 943 944 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 945 xscale = 0.0, yscale = 0.0) 946 label = gtk.Label(xstr("register_year_of_birth")) 947 label.set_use_underline(True) 948 labelAlignment.add(label) 949 table.attach(labelAlignment, 0, 1, 1, 2) 950 951 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 952 xscale = 0.0, yscale = 0.0) 953 954 self._yearOfBirth = gtk.SpinButton() 955 self._yearOfBirth.set_increments(step = 1, page = 10) 956 self._yearOfBirth.set_range(min = RegisterPage._minYearOfBirth, 957 max = RegisterPage._maxYearOfBirth) 958 self._yearOfBirth.set_numeric(True) 959 self._yearOfBirth.set_tooltip_text(xstr("register_year_of_birth_tooltip")) 960 self._yearOfBirth.set_width_chars(5) 961 self._yearOfBirth.connect("changed", self._updateButtons) 962 self._yearOfBirth.connect("value-changed", self._updateButtons) 963 alignment.add(self._yearOfBirth) 964 table.attach(alignment, 1, 2, 1, 2) 965 label.set_mnemonic_widget(self._yearOfBirth) 966 967 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 968 xscale = 0.0, yscale = 0.0) 969 label = gtk.Label(xstr("register_email")) 970 label.set_use_underline(True) 971 labelAlignment.add(label) 972 table.attach(labelAlignment, 0, 1, 2, 3) 973 974 self._emailAddress = gtk.Entry() 975 self._emailAddress.connect("changed", self._updateButtons) 976 self._emailAddress.set_tooltip_text(xstr("register_email_tooltip")) 977 table.attach(self._emailAddress, 1, 2, 2, 3) 978 label.set_mnemonic_widget(self._emailAddress) 979 980 self._emailAddressPublic = gtk.CheckButton(xstr("register_email_public")) 981 self._emailAddressPublic.set_use_underline(True) 982 self._emailAddressPublic.set_tooltip_text(xstr("register_email_public_tooltip")) 983 table.attach(self._emailAddressPublic, 2, 3, 2, 3) 984 985 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 986 xscale = 0.0, yscale = 0.0) 987 label = gtk.Label(xstr("register_vatsim_id")) 988 label.set_use_underline(True) 989 labelAlignment.add(label) 990 table.attach(labelAlignment, 0, 1, 3, 4) 991 992 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 993 xscale = 0.0, yscale = 0.0) 994 self._vatsimID = IntegerEntry() 995 self._vatsimID.connect("changed", self._updateButtons) 996 self._vatsimID.set_tooltip_text(xstr("register_vatsim_id_tooltip")) 997 self._vatsimID.set_width_chars(7) 998 alignment.add(self._vatsimID) 999 table.attach(alignment, 1, 2, 3, 4) 1000 label.set_mnemonic_widget(self._vatsimID) 1001 1002 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 1003 xscale = 0.0, yscale = 0.0) 1004 label = gtk.Label(xstr("register_ivao_id")) 1005 label.set_use_underline(True) 1006 labelAlignment.add(label) 1007 table.attach(labelAlignment, 0, 1, 4, 5) 1008 1009 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 1010 xscale = 0.0, yscale = 0.0) 1011 self._ivaoID = IntegerEntry() 1012 self._ivaoID.connect("changed", self._updateButtons) 1013 self._ivaoID.set_tooltip_text(xstr("register_ivao_id_tooltip")) 1014 self._ivaoID.set_width_chars(7) 1015 alignment.add(self._ivaoID) 1016 table.attach(alignment, 1, 2, 4, 5) 1017 label.set_mnemonic_widget(self._ivaoID) 1018 1019 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 1020 xscale = 0.0, yscale = 0.0) 1021 label = gtk.Label(xstr("register_phone_num")) 1022 label.set_use_underline(True) 1023 label.set_use_markup(True) 1024 labelAlignment.add(label) 1025 table.attach(labelAlignment, 0, 1, 5, 6) 1026 1027 self._phoneNumber = gtk.Entry() 1028 self._phoneNumber.set_tooltip_text(xstr("register_phone_num_tooltip")) 1029 table.attach(self._phoneNumber, 1, 2, 5, 6) 1030 label.set_mnemonic_widget(self._phoneNumber) 1031 1032 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 1033 xscale = 0.0, yscale = 0.0) 1034 label = gtk.Label(xstr("register_nationality")) 1035 label.set_use_underline(True) 1036 label.set_use_markup(True) 1037 labelAlignment.add(label) 1038 table.attach(labelAlignment, 0, 1, 6, 7) 1039 1040 1041 self._nationality = gtk.Entry() 1042 self._nationality.set_tooltip_text(xstr("register_nationality_tooltip")) 1043 table.attach(self._nationality, 1, 2, 6, 7) 1044 label.set_mnemonic_widget(self._nationality) 1045 1046 placeholder = gtk.Label() 1047 placeholder.set_text(xstr("register_password_mismatch")) 1048 placeholder.set_use_markup(True) 1049 placeholder.set_child_visible(False) 1050 placeholder.hide() 1051 table.attach(placeholder, 2, 3, 6, 7) 1052 1053 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 1054 xscale = 0.0, yscale = 0.0) 1055 label = gtk.Label(xstr("register_password")) 1056 label.set_use_underline(True) 1057 labelAlignment.add(label) 1058 table.attach(labelAlignment, 0, 1, 8, 9) 1059 1060 self._password = gtk.Entry() 1061 self._password.set_visibility(False) 1062 self._password.connect("changed", self._updateButtons) 1063 self._password.set_tooltip_text(xstr("register_password_tooltip")) 1064 table.attach(self._password, 1, 2, 8, 9) 1065 label.set_mnemonic_widget(self._password) 1066 1067 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, 1068 xscale = 0.0, yscale = 0.0) 1069 self._passwordStatus = gtk.Label() 1070 alignment.add(self._passwordStatus) 1071 table.attach(alignment, 2, 3, 8, 9) 1072 1073 labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, 1074 xscale = 0.0, yscale = 0.0) 1075 label = gtk.Label(xstr("register_password2")) 1076 label.set_use_underline(True) 1077 labelAlignment.add(label) 1078 table.attach(labelAlignment, 0, 1, 9, 10) 1079 1080 self._password2 = gtk.Entry() 1081 self._password2.set_visibility(False) 1082 self._password2.connect("changed", self._updateButtons) 1083 self._password2.set_tooltip_text(xstr("register_password2_tooltip")) 1084 table.attach(self._password2, 1, 2, 9, 10) 1085 label.set_mnemonic_widget(self._password2) 1086 1087 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5, 1088 xscale = 0.0, yscale = 0.0) 1089 self._password2Status = gtk.Label() 1090 alignment.add(self._password2Status) 1091 table.attach(alignment, 2, 3, 9, 10) 1092 1093 self._rememberButton = gtk.CheckButton(xstr("remember_password")) 1094 self._rememberButton.set_use_underline(True) 1095 self._rememberButton.set_tooltip_text(xstr("login_remember_tooltip")) 1096 table.attach(self._rememberButton, 1, 2, 10, 11) 1097 1098 cancelButton = \ 1099 self.addButton(xstr("button_cancel")) 1100 cancelButton.connect("clicked", self._cancelClicked) 1101 1102 self._registerButton = \ 1103 self.addButton(xstr("button_register"), default = True, 1104 tooltip = xstr("button_register_tooltip")) 1105 self._registerButton.connect("clicked", self._registerClicked) 1106 1107 self._updateButtons() 1108 1109 def activate(self): 1110 """Setup the route from the booked flight.""" 1111 self._yearOfBirth.set_value(0) 1112 self._yearOfBirth.set_text("") 1113 self._updateButtons() 1114 1115 def _updateButtons(self, widget = None): 1116 """Update the sensitive state of the buttons""" 1117 name = self._name.get_text() 1118 nameLength = len(name) 1119 nameSpacePosition = name.find(" ") 1120 1121 yearOfBirthText = self._yearOfBirth.get_text() 1122 yearOfBirth = int(yearOfBirthText) if yearOfBirthText else 0 1123 1124 emailAddressText = self._emailAddress.get_text() 1125 emailAddressMatch = RegisterPage._emailAddressRE.match(emailAddressText) 1126 1127 vatsimID = self._vatsimID.get_int() 1128 ivaoID = self._ivaoID.get_int() 1129 1130 password = self._password.get_text() 1131 password2 = self._password2.get_text() 1132 if not password: 1133 self._passwordStatus.set_text("") 1134 elif len(password)<5: 1135 self._passwordStatus.set_text(xstr("register_password_too_short")) 1136 else: 1137 self._passwordStatus.set_text(xstr("register_password_ok")) 1138 self._passwordStatus.set_use_markup(True) 1139 1140 if len(password)<5 or not password2: 1141 self._password2Status.set_text("") 1142 elif password!=password2: 1143 self._password2Status.set_text(xstr("register_password_mismatch")) 1144 else: 1145 self._password2Status.set_text(xstr("register_password_ok")) 1146 self._password2Status.set_use_markup(True) 1147 1148 sensitive = \ 1149 nameLength >= 5 and nameSpacePosition != -1 and \ 1150 nameSpacePosition<(nameLength-2) and \ 1151 yearOfBirth>=RegisterPage._minYearOfBirth and \ 1152 yearOfBirth<=RegisterPage._maxYearOfBirth and \ 1153 emailAddressMatch is not None and \ 1154 (vatsimID>=800000 or ivaoID>=100000) and \ 1155 len(password)>=5 and password==password2 1156 1157 self._registerButton.set_sensitive(sensitive) 1158 1159 def _cancelClicked(self, button): 1160 """Called when the Cancel button is clicked.""" 1161 self.goBack() 1162 1163 def _registerClicked(self, button): 1164 """Called when the Register button is clicked.""" 1165 1166 #----------------------------------------------------------------------------- 1167 1168 class StudentPage(Page): 1169 """A page displayed to students after logging in.""" 1170 def __init__(self, wizard): 1171 """Construct the student page.""" 1172 super(StudentPage, self).__init__(wizard, xstr("student_title"), 1173 xstr("student_help")) 892 1174 893 1175 #----------------------------------------------------------------------------- … … 4256 4538 self._pages.append(FlightSelectionPage(self)) 4257 4539 self._pages.append(GateSelectionPage(self)) 4540 self._pages.append(RegisterPage(self)) 4541 self._pages.append(StudentPage(self)) 4258 4542 self._pages.append(ConnectPage(self)) 4259 4543 self._payloadPage = PayloadPage(self)
Note:
See TracChangeset
for help on using the changeset viewer.