Changeset 1067:9ce88d0b881d


Ignore:
Timestamp:
12/21/22 10:17:25 (16 months ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

Support for connecting to X-Plane remotely

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r1034 r1067  
    18571857
    18581858msgid "prefs_update_auto"
    1859 msgstr "Update the program auto_matically"
     1859msgstr "Update the program automaticall_y"
    18601860
    18611861msgid "prefs_update_auto_tooltip"
     
    18781878"The URL from which to download the updates. Change this only if you "
    18791879"know what you are doing!"
     1880
     1881msgid "prefs_xplane_remote"
     1882msgstr "Connect to X-Plane _remotely"
     1883
     1884msgid "prefs_xplane_remote_tooltip"
     1885msgstr ""
     1886"If selected and you are usinb X-Plane, the logger will connect to X-Plane "
     1887"running on another machine, whose IP address or domain name should be "
     1888"entered below."
     1889
     1890msgid "prefs_xplane_address"
     1891msgstr "_Address or name:"
     1892
     1893msgid "prefs_xplane_address_tooltip"
     1894msgstr ""
     1895"Enter the IP address or the domain name of the machine, "
     1896"where X-Plane runs."
    18801897
    18811898msgid "prefs_use_rpc"
  • locale/hu/mlx.po

    r1034 r1067  
    18901890"Az URL, ahol a frissítéseket keresi a program. Csak akkor változtasd meg, "
    18911891"ha biztos vagy a dolgodban!"
     1892
     1893msgid "prefs_xplane_remote"
     1894msgstr "X-Plane _távoli elérése"
     1895
     1896msgid "prefs_xplane_remote_tooltip"
     1897msgstr ""
     1898"Ha ez ki van választva, és X-Plane-t használsz, a logger a lent megadott "
     1899"névvel vagy IP címmel rendelkező másik gépen futó X-Plane-hez fog "
     1900"kapcsolódni."
     1901
     1902msgid "prefs_xplane_address"
     1903msgstr "_Cím vagy név:"
     1904
     1905msgid "prefs_xplane_address_tooltip"
     1906msgstr ""
     1907"Add meg az X-Plane-t futtató gép IP címét vagy nevét."
    18921908
    18931909msgid "prefs_use_rpc"
  • src/mlx/config.py

    r1045 r1067  
    260260        self._updateURLUpdated = True
    261261
     262        self._xplaneRemote = False
     263        self._xplaneAddress = ""
     264
    262265        self._messageTypeLevels = {}
    263266
     
    667670        if updateURL!=self._updateURL:
    668671            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
    669696            self._modified = True
    670697
     
    799826                                             "defaultMSFS", os.name=="nt")
    800827
     828        self._xplaneRemote = self._getBoolean(config, "general",
     829                                              "xplaneRemote", False)
     830        self._xplaneAddress = self._get(config, "general",
     831                                        "xplaneAddress", "")
     832
    801833        self._modified = False
    802834
     
    852884                   "yes" if self._defaultMSFS else "no")
    853885
     886        config.set("general", "xplaneRemote",
     887                   "yes" if self._xplaneRemote else "no")
     888        config.set("general", "xplaneAddress", self._xplaneAddress)
     889
    854890        config.add_section(Config._messageTypesSection)
    855891        for messageType in const.messageTypes:
     
    10021038
    10031039        print("  defaultMSFS:", self._defaultMSFS)
     1040        print("  xplaneRemote:", self._xplaneRemote)
     1041        print("  xplaneAddress:", self._xplaneAddress)
    10041042
    10051043        print("  enableSounds:", self._enableSounds)
  • src/mlx/gui/prefs.py

    r1044 r1067  
    276276
    277277        self._updateURL.set_text(config.updateURL)
     278
     279        self._xplaneRemote.set_active(config.xplaneRemote)
     280        self._xplaneAddress.set_text(config.xplaneAddress)
    278281
    279282        self._settingFromConfig = False
     
    321324        config.updateURL = self._updateURL.get_text()
    322325
     326        config.xplaneRemote = self._xplaneRemote.get_active()
     327        config.xplaneAddress = self._xplaneAddress.get_text()
     328
    323329    def _buildGeneral(self):
    324330        """Build the page for the general settings."""
     
    793799        mainAlignment.add(mainBox)
    794800
     801        frame = Gtk.Frame.new()
     802
    795803        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)
    797807
    798808        self._autoUpdate.set_use_underline(True)
     
    802812
    803813        updateURLBox = Gtk.HBox()
    804         mainBox.pack_start(updateURLBox, False, False, 4)
    805814        label = Gtk.Label(xstr("prefs_update_url"))
    806815        label.set_use_underline(True)
     
    813822        self._updateURL.connect("changed", self._updateURLChanged)
    814823        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)
    815858
    816859        return mainAlignment
     
    824867        except:
    825868            pass
     869
     870        if sensitive:
     871            sensitive = not self._xplaneRemote.get_active() or \
     872                len(self._xplaneAddress.get_text())>0
    826873
    827874        okButton = self.get_widget_for_response(Gtk.ResponseType.ACCEPT)
     
    845892        self._setOKButtonSensitivity()
    846893
     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  
    494494        not due to no longer requested.
    495495        """
     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
    496504        while self._connectionRequested:
    497505            if attempts>=self.NUM_CONNECTATTEMPTS:
     
    507515            try:
    508516                attempts += 1
    509                 self._xplane.connect()
     517                self._xplane.connect(address = address)
    510518
    511519                (xplaneVersion, xplmVersion, xplraVersion) = \
     
    734742
    735743        self._fuelCallback = None
     744
     745    @property
     746    def config(self):
     747        """Get the configuration."""
     748        return self._connectionListener.config
    736749
    737750    def connect(self, aircraft):
Note: See TracChangeset for help on using the changeset viewer.