Changeset 996:8035d80d5feb for src/mlx/gui/prefs.py
- Timestamp:
- 07/04/19 17:57:45 (5 years ago)
- Branch:
- python3
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/prefs.py
r995 r996 20 20 #------------------------------------------------------------------------------ 21 21 22 class Hotkey( gtk.HBox):22 class Hotkey(Gtk.HBox): 23 23 """A widget to handle a hotkey.""" 24 24 … … 43 43 super(Hotkey, self).__init__() 44 44 45 label = gtk.Label(labelText)45 label = Gtk.Label(labelText) 46 46 label.set_use_underline(True) 47 labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,47 labelAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5, 48 48 xscale = 0.0, yscale = 0.0) 49 49 labelAlignment.set_padding(padding_top = 0, padding_bottom = 0, … … 52 52 self.pack_start(labelAlignment, False, False, 0) 53 53 54 self._ctrl = gtk.CheckButton("Ctrl")54 self._ctrl = Gtk.CheckButton("Ctrl") 55 55 self._ctrl.set_tooltip_text(tooltips[1]) 56 56 self._ctrl.connect("toggled", self._ctrlToggled) 57 57 self.pack_start(self._ctrl, False, False, 4) 58 58 59 self._shift = gtk.CheckButton("Shift")59 self._shift = Gtk.CheckButton("Shift") 60 60 self._shift.set_tooltip_text(tooltips[2]) 61 61 self._shift.connect("toggled", self._shiftToggled) 62 62 self.pack_start(self._shift, False, False, 4) 63 63 64 self._hotkeyModel = gtk.ListStore(str)64 self._hotkeyModel = Gtk.ListStore(str) 65 65 for keyCode in list(range(ord("0"), ord("9")+1)) + list(range(ord("A"), ord("Z")+1)): 66 66 self._hotkeyModel.append([chr(keyCode)]) 67 67 68 self._hotkey = gtk.ComboBox(model = self._hotkeyModel)69 cell = gtk.CellRendererText()68 self._hotkey = Gtk.ComboBox(model = self._hotkeyModel) 69 cell = Gtk.CellRendererText() 70 70 self._hotkey.pack_start(cell, True) 71 71 self._hotkey.add_attribute(cell, 'text', 0) … … 166 166 #------------------------------------------------------------------------------ 167 167 168 class Preferences( gtk.Dialog):168 class Preferences(Gtk.Dialog): 169 169 """The preferences dialog.""" 170 170 def __init__(self, gui): … … 184 184 contentArea = self.get_content_area() 185 185 186 notebook = gtk.Notebook()186 notebook = Gtk.Notebook() 187 187 contentArea.pack_start(notebook, True, True, 4) 188 188 189 189 general = self._buildGeneral() 190 label = gtk.Label(xstr("prefs_tab_general"))190 label = Gtk.Label(xstr("prefs_tab_general")) 191 191 label.set_use_underline(True) 192 192 label.set_tooltip_text(xstr("prefs_tab_general_tooltip")) … … 194 194 195 195 messages = self._buildMessages() 196 label = gtk.Label(xstr("prefs_tab_messages"))196 label = Gtk.Label(xstr("prefs_tab_messages")) 197 197 label.set_use_underline(True) 198 198 label.set_tooltip_text(xstr("prefs_tab_message_tooltip")) … … 200 200 201 201 sounds = self._buildSounds() 202 label = gtk.Label(xstr("prefs_tab_sounds"))202 label = Gtk.Label(xstr("prefs_tab_sounds")) 203 203 label.set_use_underline(True) 204 204 label.set_tooltip_text(xstr("prefs_tab_sounds_tooltip")) … … 206 206 207 207 advanced = self._buildAdvanced() 208 label = gtk.Label(xstr("prefs_tab_advanced"))208 label = Gtk.Label(xstr("prefs_tab_advanced")) 209 209 label.set_use_underline(True) 210 210 label.set_tooltip_text(xstr("prefs_tab_advanced_tooltip")) … … 326 326 def _buildGeneral(self): 327 327 """Build the page for the general settings.""" 328 mainAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,328 mainAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 329 329 xscale = 1.0, yscale = 0.0) 330 330 mainAlignment.set_padding(padding_top = 0, padding_bottom = 8, 331 331 padding_left = 4, padding_right = 4) 332 mainBox = gtk.VBox()332 mainBox = Gtk.VBox() 333 333 mainAlignment.add(mainBox) 334 334 335 335 guiBox = self._createFrame(mainBox, xstr("prefs_frame_gui")) 336 336 337 languageBox = gtk.HBox()337 languageBox = Gtk.HBox() 338 338 guiBox.pack_start(languageBox, False, False, 4) 339 339 340 label = gtk.Label(xstr("prefs_language"))340 label = Gtk.Label(xstr("prefs_language")) 341 341 label.set_use_underline(True) 342 342 343 343 languageBox.pack_start(label, False, False, 4) 344 344 345 self._languageList = gtk.ListStore(str, str)345 self._languageList = Gtk.ListStore(str, str) 346 346 for language in const.languages: 347 347 self._languageList.append([xstr("prefs_lang_" + language), … … 349 349 350 350 self._languageComboBox = languageComboBox = \ 351 gtk.ComboBox(model = self._languageList)352 cell = gtk.CellRendererText()351 Gtk.ComboBox(model = self._languageList) 352 cell = Gtk.CellRendererText() 353 353 languageComboBox.pack_start(cell, True) 354 354 languageComboBox.add_attribute(cell, 'text', 0) … … 362 362 self._warnedRestartNeeded = False 363 363 364 self._hideMinimizedWindow = gtk.CheckButton(xstr("prefs_hideMinimizedWindow"))364 self._hideMinimizedWindow = Gtk.CheckButton(xstr("prefs_hideMinimizedWindow")) 365 365 self._hideMinimizedWindow.set_use_underline(True) 366 366 self._hideMinimizedWindow.set_tooltip_text(xstr("prefs_hideMinimizedWindow_tooltip")) 367 367 guiBox.pack_start(self._hideMinimizedWindow, False, False, 4) 368 368 369 self._quitOnClose = gtk.CheckButton(xstr("prefs_quitOnClose"))369 self._quitOnClose = Gtk.CheckButton(xstr("prefs_quitOnClose")) 370 370 self._quitOnClose.set_use_underline(True) 371 371 self._quitOnClose.set_tooltip_text(xstr("prefs_quitOnClose_tooltip")) … … 374 374 onlineBox = self._createFrame(mainBox, xstr("prefs_frame_online")) 375 375 376 self._onlineGateSystem = gtk.CheckButton(xstr("prefs_onlineGateSystem"))376 self._onlineGateSystem = Gtk.CheckButton(xstr("prefs_onlineGateSystem")) 377 377 self._onlineGateSystem.set_use_underline(True) 378 378 self._onlineGateSystem.set_tooltip_text(xstr("prefs_onlineGateSystem_tooltip")) 379 379 onlineBox.pack_start(self._onlineGateSystem, False, False, 4) 380 380 381 self._onlineACARS = gtk.CheckButton(xstr("prefs_onlineACARS"))381 self._onlineACARS = Gtk.CheckButton(xstr("prefs_onlineACARS")) 382 382 self._onlineACARS.set_use_underline(True) 383 383 self._onlineACARS.set_tooltip_text(xstr("prefs_onlineACARS_tooltip")) … … 386 386 simulatorBox = self._createFrame(mainBox, xstr("prefs_frame_simulator")) 387 387 388 self._flareTimeFromFS = gtk.CheckButton(xstr("prefs_flaretimeFromFS"))388 self._flareTimeFromFS = Gtk.CheckButton(xstr("prefs_flaretimeFromFS")) 389 389 self._flareTimeFromFS.set_use_underline(True) 390 390 self._flareTimeFromFS.set_tooltip_text(xstr("prefs_flaretimeFromFS_tooltip")) 391 391 simulatorBox.pack_start(self._flareTimeFromFS, False, False, 4) 392 392 393 self._syncFSTime = gtk.CheckButton(xstr("prefs_syncFSTime"))393 self._syncFSTime = Gtk.CheckButton(xstr("prefs_syncFSTime")) 394 394 self._syncFSTime.set_use_underline(True) 395 395 self._syncFSTime.set_tooltip_text(xstr("prefs_syncFSTime_tooltip")) 396 396 simulatorBox.pack_start(self._syncFSTime, False, False, 4) 397 397 398 self._usingFS2Crew = gtk.CheckButton(xstr("prefs_usingFS2Crew"))398 self._usingFS2Crew = Gtk.CheckButton(xstr("prefs_usingFS2Crew")) 399 399 self._usingFS2Crew.set_use_underline(True) 400 400 self._usingFS2Crew.set_tooltip_text(xstr("prefs_usingFS2Crew_tooltip")) … … 413 413 simulatorBox.pack_start(vsSmoothingBox, False, False, 4) 414 414 415 self._useSimBrief = gtk.CheckButton(xstr("prefs_useSimBrief"))415 self._useSimBrief = Gtk.CheckButton(xstr("prefs_useSimBrief")) 416 416 self._useSimBrief.set_use_underline(True) 417 417 self._useSimBrief.set_tooltip_text(xstr("prefs_useSimBrief_tooltip")) 418 418 mainBox.pack_start(self._useSimBrief, False, False, 0) 419 419 420 pirepBox = gtk.HBox()420 pirepBox = Gtk.HBox() 421 421 mainBox.pack_start(pirepBox, False, False, 8) 422 422 423 label = gtk.Label(xstr("prefs_pirepDirectory"))423 label = Gtk.Label(xstr("prefs_pirepDirectory")) 424 424 label.set_use_underline(True) 425 425 pirepBox.pack_start(label, False, False, 4) 426 426 427 self._pirepDirectory = gtk.Entry()427 self._pirepDirectory = Gtk.Entry() 428 428 self._pirepDirectory.set_tooltip_text(xstr("prefs_pirepDirectory_tooltip")) 429 429 self._pirepDirectory.connect("changed", self._pirepDirectoryChanged) … … 431 431 pirepBox.pack_start(self._pirepDirectory, True, True, 4) 432 432 433 self._pirepDirectoryButton = gtk.Button(xstr("button_browse"))433 self._pirepDirectoryButton = Gtk.Button(xstr("button_browse")) 434 434 self._pirepDirectoryButton.connect("clicked", 435 435 self._pirepDirectoryButtonClicked) 436 436 pirepBox.pack_start(self._pirepDirectoryButton, False, False, 4) 437 437 438 self._pirepAutoSave = gtk.CheckButton(xstr("prefs_pirepAutoSave"))438 self._pirepAutoSave = Gtk.CheckButton(xstr("prefs_pirepAutoSave")) 439 439 self._pirepAutoSave.set_use_underline(True) 440 440 self._pirepAutoSave.set_tooltip_text(xstr("prefs_pirepAutoSave_tooltip")) … … 447 447 448 448 Return the vbox.""" 449 frame = gtk.Frame(label = label)449 frame = Gtk.Frame(label = label) 450 450 mainBox.pack_start(frame, False, False, 4) 451 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,451 alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 452 452 xscale = 1.0, yscale = 0.0) 453 453 alignment.set_padding(padding_top = 4, padding_bottom = 0, 454 454 padding_left = 0, padding_right = 0) 455 455 frame.add(alignment) 456 vbox = gtk.VBox()456 vbox = Gtk.VBox() 457 457 alignment.add(vbox) 458 458 … … 462 462 maxSeconds = 10): 463 463 """Create a HBox that contains entry fields for smoothing some value.""" 464 smoothingBox = gtk.HBox()465 466 smoothingEnabled = gtk.CheckButton(checkBoxLabel)464 smoothingBox = Gtk.HBox() 465 466 smoothingEnabled = Gtk.CheckButton(checkBoxLabel) 467 467 smoothingEnabled.set_use_underline(True) 468 468 smoothingEnabled.set_tooltip_text(checkBoxTooltip) … … 470 470 smoothingBox.pack_start(smoothingEnabled, False, False, 0) 471 471 472 smoothingLength = gtk.SpinButton()472 smoothingLength = Gtk.SpinButton() 473 473 smoothingLength.set_numeric(True) 474 474 smoothingLength.set_range(2, maxSeconds) … … 479 479 smoothingBox.pack_start(smoothingLength, False, False, 0) 480 480 481 smoothingBox.pack_start( gtk.Label(xstr("prefs_smoothing_seconds")),481 smoothingBox.pack_start(Gtk.Label(xstr("prefs_smoothing_seconds")), 482 482 False, False, 4) 483 483 … … 511 511 """Called when the language has changed.""" 512 512 if not self._changingLanguage and not self._warnedRestartNeeded: 513 dialog = gtk.MessageDialog(parent = self,513 dialog = Gtk.MessageDialog(parent = self, 514 514 type = MESSAGETYPE_INFO, 515 515 message_format = xstr("prefs_restart")) … … 548 548 def _pirepDirectoryButtonClicked(self, button): 549 549 """Called when the PIREP directory button is clicked.""" 550 dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +550 dialog = Gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " + 551 551 xstr("prefs_pirepDirectory_browser_title"), 552 552 action = FILE_CHOOSER_ACTION_SELECT_FOLDER, 553 buttons = ( gtk.STOCK_CANCEL, RESPONSETYPE_CANCEL,554 gtk.STOCK_OK, RESPONSETYPE_OK),553 buttons = (Gtk.STOCK_CANCEL, RESPONSETYPE_CANCEL, 554 Gtk.STOCK_OK, RESPONSETYPE_OK), 555 555 parent = self) 556 556 dialog.set_modal(True) … … 578 578 """Build the page for the message settings.""" 579 579 580 mainAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,580 mainAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 581 581 xscale = 0.0, yscale = 0.0) 582 582 mainAlignment.set_padding(padding_top = 16, padding_bottom = 8, 583 583 padding_left = 4, padding_right = 4) 584 mainBox = gtk.VBox()584 mainBox = Gtk.VBox() 585 585 mainAlignment.add(mainBox) 586 586 587 table = gtk.Table(len(const.messageTypes) + 1, 3)587 table = Gtk.Table(len(const.messageTypes) + 1, 3) 588 588 table.set_row_spacings(8) 589 589 table.set_col_spacings(32) … … 591 591 mainBox.pack_start(table, False, False, 4) 592 592 593 label = gtk.Label(xstr("prefs_msgs_fs"))593 label = Gtk.Label(xstr("prefs_msgs_fs")) 594 594 label.set_justify(JUSTIFY_CENTER) 595 595 label.set_alignment(0.5, 1.0) 596 596 table.attach(label, 1, 2, 0, 1) 597 597 598 label = gtk.Label(xstr("prefs_msgs_sound"))598 label = Gtk.Label(xstr("prefs_msgs_sound")) 599 599 label.set_justify(JUSTIFY_CENTER) 600 600 label.set_alignment(0.5, 1.0) … … 606 606 for messageType in const.messageTypes: 607 607 messageTypeStr = const.messageType2string(messageType) 608 label = gtk.Label(xstr("prefs_msgs_type_" + messageTypeStr))608 label = Gtk.Label(xstr("prefs_msgs_type_" + messageTypeStr)) 609 609 label.set_justify(JUSTIFY_CENTER) 610 610 label.set_use_underline(True) … … 612 612 table.attach(label, 0, 1, row, row+1) 613 613 614 fsCheckButton = gtk.CheckButton()615 alignment = gtk.Alignment(xscale = 0.0, yscale = 0.0,614 fsCheckButton = Gtk.CheckButton() 615 alignment = Gtk.Alignment(xscale = 0.0, yscale = 0.0, 616 616 xalign = 0.5, yalign = 0.5) 617 617 alignment.add(fsCheckButton) … … 619 619 self._msgFSCheckButtons[messageType] = fsCheckButton 620 620 621 soundCheckButton = gtk.CheckButton()622 alignment = gtk.Alignment(xscale = 0.0, yscale = 0.0,621 soundCheckButton = Gtk.CheckButton() 622 alignment = Gtk.Alignment(xscale = 0.0, yscale = 0.0, 623 623 xalign = 0.5, yalign = 0.5) 624 624 alignment.add(soundCheckButton) … … 626 626 self._msgSoundCheckButtons[messageType] = soundCheckButton 627 627 628 mnemonicWidget = gtk.Label("")628 mnemonicWidget = Gtk.Label("") 629 629 table.attach(mnemonicWidget, 3, 4, row, row+1) 630 630 label.set_mnemonic_widget(mnemonicWidget) … … 655 655 def _buildSounds(self): 656 656 """Build the page for the sounds.""" 657 mainAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,657 mainAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 658 658 xscale = 1.0, yscale = 1.0) 659 659 mainAlignment.set_padding(padding_top = 8, padding_bottom = 8, 660 660 padding_left = 4, padding_right = 4) 661 661 662 mainBox = gtk.VBox()662 mainBox = Gtk.VBox() 663 663 mainAlignment.add(mainBox) 664 664 665 backgroundFrame = gtk.Frame(label = xstr("prefs_sounds_frame_bg"))665 backgroundFrame = Gtk.Frame(label = xstr("prefs_sounds_frame_bg")) 666 666 mainBox.pack_start(backgroundFrame, False, False, 4) 667 667 668 backgroundAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,668 backgroundAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 669 669 xscale = 1.0, yscale = 0.0) 670 670 backgroundAlignment.set_padding(padding_top = 4, padding_bottom = 4, … … 672 672 backgroundFrame.add(backgroundAlignment) 673 673 674 backgroundBox = gtk.VBox()674 backgroundBox = Gtk.VBox() 675 675 backgroundAlignment.add(backgroundBox) 676 676 677 self._enableSounds = gtk.CheckButton(xstr("prefs_sounds_enable"))677 self._enableSounds = Gtk.CheckButton(xstr("prefs_sounds_enable")) 678 678 self._enableSounds.set_use_underline(True) 679 679 self._enableSounds.set_tooltip_text(xstr("prefs_sounds_enable_tooltip")) 680 680 self._enableSounds.connect("toggled", self._enableSoundsToggled) 681 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,681 alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5, 682 682 xscale = 1.0, yscale = 0.0) 683 683 alignment.add(self._enableSounds) 684 684 backgroundBox.pack_start(alignment, False, False, 4) 685 685 686 self._pilotControlsSounds = gtk.CheckButton(xstr("prefs_sounds_pilotControls"))686 self._pilotControlsSounds = Gtk.CheckButton(xstr("prefs_sounds_pilotControls")) 687 687 self._pilotControlsSounds.set_use_underline(True) 688 688 self._pilotControlsSounds.set_tooltip_text(xstr("prefs_sounds_pilotControls_tooltip")) … … 697 697 backgroundBox.pack_start(self._pilotHotkey, False, False, 4) 698 698 699 self._enableApproachCallouts = gtk.CheckButton(xstr("prefs_sounds_approachCallouts"))699 self._enableApproachCallouts = Gtk.CheckButton(xstr("prefs_sounds_approachCallouts")) 700 700 self._enableApproachCallouts.set_use_underline(True) 701 701 self._enableApproachCallouts.set_tooltip_text(xstr("prefs_sounds_approachCallouts_tooltip")) 702 702 backgroundBox.pack_start(self._enableApproachCallouts, False, False, 4) 703 703 704 self._speedbrakeAtTD = gtk.CheckButton(xstr("prefs_sounds_speedbrakeAtTD"))704 self._speedbrakeAtTD = Gtk.CheckButton(xstr("prefs_sounds_speedbrakeAtTD")) 705 705 self._speedbrakeAtTD.set_use_underline(True) 706 706 self._speedbrakeAtTD.set_tooltip_text(xstr("prefs_sounds_speedbrakeAtTD_tooltip")) 707 707 backgroundBox.pack_start(self._speedbrakeAtTD, False, False, 4) 708 708 709 checklistFrame = gtk.Frame(label = xstr("prefs_sounds_frame_checklists"))709 checklistFrame = Gtk.Frame(label = xstr("prefs_sounds_frame_checklists")) 710 710 mainBox.pack_start(checklistFrame, False, False, 4) 711 711 712 checklistAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,712 checklistAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 713 713 xscale = 1.0, yscale = 0.0) 714 714 checklistAlignment.set_padding(padding_top = 4, padding_bottom = 4, … … 716 716 checklistFrame.add(checklistAlignment) 717 717 718 checklistBox = gtk.VBox()718 checklistBox = Gtk.VBox() 719 719 checklistAlignment.add(checklistBox) 720 720 721 self._enableChecklists = gtk.CheckButton(xstr("prefs_sounds_enableChecklists"))721 self._enableChecklists = Gtk.CheckButton(xstr("prefs_sounds_enableChecklists")) 722 722 self._enableChecklists.set_use_underline(True) 723 723 self._enableChecklists.set_tooltip_text(xstr("prefs_sounds_enableChecklists_tooltip")) … … 789 789 """Build the page for the advanced settings.""" 790 790 791 mainAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,791 mainAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0, 792 792 xscale = 1.0, yscale = 0.0) 793 793 mainAlignment.set_padding(padding_top = 16, padding_bottom = 8, 794 794 padding_left = 4, padding_right = 4) 795 mainBox = gtk.VBox()795 mainBox = Gtk.VBox() 796 796 mainAlignment.add(mainBox) 797 797 798 self._autoUpdate = gtk.CheckButton(xstr("prefs_update_auto"))798 self._autoUpdate = Gtk.CheckButton(xstr("prefs_update_auto")) 799 799 mainBox.pack_start(self._autoUpdate, False, False, 4) 800 800 … … 804 804 self._warnedAutoUpdate = False 805 805 806 updateURLBox = gtk.HBox()806 updateURLBox = Gtk.HBox() 807 807 mainBox.pack_start(updateURLBox, False, False, 4) 808 label = gtk.Label(xstr("prefs_update_url"))808 label = Gtk.Label(xstr("prefs_update_url")) 809 809 label.set_use_underline(True) 810 810 updateURLBox.pack_start(label, False, False, 4) 811 811 812 self._updateURL = gtk.Entry()812 self._updateURL = Gtk.Entry() 813 813 label.set_mnemonic_widget(self._updateURL) 814 814 self._updateURL.set_width_chars(40) … … 817 817 updateURLBox.pack_start(self._updateURL, True, True, 4) 818 818 819 self._useRPC = gtk.CheckButton(xstr("prefs_use_rpc"))819 self._useRPC = Gtk.CheckButton(xstr("prefs_use_rpc")) 820 820 mainBox.pack_start(self._useRPC, False, False, 16) 821 821 … … 841 841 if not self._settingFromConfig and not self._warnedAutoUpdate and \ 842 842 not self._autoUpdate.get_active(): 843 dialog = gtk.MessageDialog(parent = self,843 dialog = Gtk.MessageDialog(parent = self, 844 844 type = MESSAGETYPE_INFO, 845 845 message_format = xstr("prefs_update_auto_warning"))
Note:
See TracChangeset
for help on using the changeset viewer.