Changeset 1067:9ce88d0b881d for src
- Timestamp:
- 12/21/22 10:17:25 (2 years ago)
- Branch:
- python3
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/config.py
r1045 r1067 260 260 self._updateURLUpdated = True 261 261 262 self._xplaneRemote = False 263 self._xplaneAddress = "" 264 262 265 self._messageTypeLevels = {} 263 266 … … 667 670 if updateURL!=self._updateURL: 668 671 self._updateURL = updateURL 672 self._modified = True 673 674 @property 675 def xplaneRemote(self): 676 """Indicate if X-Plane should be accessed remotely.""" 677 return self._xplaneRemote 678 679 @xplaneRemote.setter 680 def xplaneRemote(self, xplaneRemote): 681 """Set if X-Plane should be accessed remotely.""" 682 if xplaneRemote!=self._xplaneRemote: 683 self._xplaneRemote = xplaneRemote 684 self._modified = True 685 686 @property 687 def xplaneAddress(self): 688 """Get the address of the machine running X-Plane""" 689 return self._xplaneAddress 690 691 @xplaneAddress.setter 692 def xplaneAddress(self, xplaneAddress): 693 """Set the address of the machine running X-Plane.""" 694 if xplaneAddress!=self._xplaneAddress: 695 self._xplaneAddress = xplaneAddress 669 696 self._modified = True 670 697 … … 799 826 "defaultMSFS", os.name=="nt") 800 827 828 self._xplaneRemote = self._getBoolean(config, "general", 829 "xplaneRemote", False) 830 self._xplaneAddress = self._get(config, "general", 831 "xplaneAddress", "") 832 801 833 self._modified = False 802 834 … … 852 884 "yes" if self._defaultMSFS else "no") 853 885 886 config.set("general", "xplaneRemote", 887 "yes" if self._xplaneRemote else "no") 888 config.set("general", "xplaneAddress", self._xplaneAddress) 889 854 890 config.add_section(Config._messageTypesSection) 855 891 for messageType in const.messageTypes: … … 1002 1038 1003 1039 print(" defaultMSFS:", self._defaultMSFS) 1040 print(" xplaneRemote:", self._xplaneRemote) 1041 print(" xplaneAddress:", self._xplaneAddress) 1004 1042 1005 1043 print(" enableSounds:", self._enableSounds) -
src/mlx/gui/prefs.py
r1044 r1067 276 276 277 277 self._updateURL.set_text(config.updateURL) 278 279 self._xplaneRemote.set_active(config.xplaneRemote) 280 self._xplaneAddress.set_text(config.xplaneAddress) 278 281 279 282 self._settingFromConfig = False … … 321 324 config.updateURL = self._updateURL.get_text() 322 325 326 config.xplaneRemote = self._xplaneRemote.get_active() 327 config.xplaneAddress = self._xplaneAddress.get_text() 328 323 329 def _buildGeneral(self): 324 330 """Build the page for the general settings.""" … … 793 799 mainAlignment.add(mainBox) 794 800 801 frame = Gtk.Frame.new() 802 795 803 self._autoUpdate = Gtk.CheckButton(xstr("prefs_update_auto")) 796 mainBox.pack_start(self._autoUpdate, False, False, 4) 804 frame.set_label_widget(self._autoUpdate) 805 frame.set_label_align(0.025, 0.5) 806 mainBox.pack_start(frame, False, False, 4) 797 807 798 808 self._autoUpdate.set_use_underline(True) … … 802 812 803 813 updateURLBox = Gtk.HBox() 804 mainBox.pack_start(updateURLBox, False, False, 4)805 814 label = Gtk.Label(xstr("prefs_update_url")) 806 815 label.set_use_underline(True) … … 813 822 self._updateURL.connect("changed", self._updateURLChanged) 814 823 updateURLBox.pack_start(self._updateURL, True, True, 4) 824 825 updateURLBox.set_margin_top(6) 826 updateURLBox.set_margin_bottom(6) 827 updateURLBox.set_margin_left(4) 828 updateURLBox.set_margin_right(4) 829 frame.add(updateURLBox) 830 831 frame = Gtk.Frame.new() 832 self._xplaneRemote = Gtk.CheckButton(xstr("prefs_xplane_remote")) 833 frame.set_label_widget(self._xplaneRemote) 834 frame.set_label_align(0.025, 0.5) 835 mainBox.pack_start(frame, False, False, 4) 836 837 self._xplaneRemote.set_use_underline(True) 838 self._xplaneRemote.set_tooltip_text(xstr("prefs_xplane_remote_tooltip")) 839 self._xplaneRemote.connect("toggled", self._xplaneRemoteToggled) 840 841 xplaneAddressBox = Gtk.HBox() 842 label = Gtk.Label(xstr("prefs_xplane_address")) 843 label.set_use_underline(True) 844 xplaneAddressBox.pack_start(label, False, False, 4) 845 846 self._xplaneAddress = Gtk.Entry() 847 label.set_mnemonic_widget(self._xplaneAddress) 848 self._xplaneAddress.set_width_chars(40) 849 self._xplaneAddress.set_tooltip_text(xstr("prefs_xplane_address_tooltip")) 850 self._xplaneAddress.connect("changed", self._xplaneAddressChanged) 851 xplaneAddressBox.pack_start(self._xplaneAddress, True, True, 4) 852 853 xplaneAddressBox.set_margin_top(6) 854 xplaneAddressBox.set_margin_bottom(6) 855 xplaneAddressBox.set_margin_left(4) 856 xplaneAddressBox.set_margin_right(4) 857 frame.add(xplaneAddressBox) 815 858 816 859 return mainAlignment … … 824 867 except: 825 868 pass 869 870 if sensitive: 871 sensitive = not self._xplaneRemote.get_active() or \ 872 len(self._xplaneAddress.get_text())>0 826 873 827 874 okButton = self.get_widget_for_response(Gtk.ResponseType.ACCEPT) … … 845 892 self._setOKButtonSensitivity() 846 893 894 def _xplaneRemoteToggled(self, button): 895 """Called when the X-Plane remote access checkbox is toggled.""" 896 self._setOKButtonSensitivity() 897 898 def _xplaneAddressChanged(self, entry): 899 """Called when the X-Plane address is changed.""" 900 self._setOKButtonSensitivity() -
src/mlx/xplane.py
r1064 r1067 494 494 not due to no longer requested. 495 495 """ 496 config = self._connectionListener.config 497 if config.xplaneRemote: 498 address = "tcp:" + config.xplaneAddress 499 else: 500 address = "local" 501 502 print("xplane.Handler._connect: address:", address) 503 496 504 while self._connectionRequested: 497 505 if attempts>=self.NUM_CONNECTATTEMPTS: … … 507 515 try: 508 516 attempts += 1 509 self._xplane.connect( )517 self._xplane.connect(address = address) 510 518 511 519 (xplaneVersion, xplmVersion, xplraVersion) = \ … … 734 742 735 743 self._fuelCallback = None 744 745 @property 746 def config(self): 747 """Get the configuration.""" 748 return self._connectionListener.config 736 749 737 750 def connect(self, aircraft):
Note:
See TracChangeset
for help on using the changeset viewer.