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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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()
Note: See TracChangeset for help on using the changeset viewer.