def on_module_selected(self): if not self.loaded: print("Loading Privacy module") page = SettingsPage() self.sidePage.add_widget(page) switch = GSettingsSwitch("", PRIVACY_SCHEMA, GTK_RECENT_ENABLE_KEY) switch.label.set_markup("<b>%s</b>" % _("Remember recently accessed files")) switch.fill_row() page.add(switch) settings = page.add_reveal_section(_("Recent files"), PRIVACY_SCHEMA, GTK_RECENT_ENABLE_KEY) self.indefinite_switch = Switch(_("Never forget old files")) self.indefinite_switch.content_widget.connect("notify::active", self.on_indefinite_toggled) settings.add_row(self.indefinite_switch) widget = SettingsWidget() label = SettingsLabel(_("Number of days to remember old files")) widget.pack_start(label, False, False, 0) self.spinner = Gtk.SpinButton.new_with_range(1.0, 365.0, 1.0) self.spinner.set_digits(0) self.spinner.set_increments(1, 10) widget.pack_end(self.spinner, False, False, 0) self.revealer = SettingsRevealer() vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) vbox.add(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)) list_box = Gtk.ListBox() row = Gtk.ListBoxRow() row.add(widget) list_box.add(row) vbox.add(list_box) self.revealer.add(vbox) settings.box.add(self.revealer) start_age = self.settings.get_int(GTK_RECENT_MAX_AGE) if start_age == -1: self.indefinite_switch.content_widget.set_active(True) self.revealer.set_reveal_child(False) self.spinner.set_value(30) else: self.indefinite_switch.content_widget.set_active(False) self.revealer.set_reveal_child(True) if start_age == 0: # Shouldn't happen, unless someone manually sets the value self.settings.set_int(GTK_RECENT_MAX_AGE, 30) self.bind_spinner() self._init_nm_client() if self.nm_client is not None and self.nm_client.connectivity_check_get_available(): section = page.add_section(_("Internet connectivity")) connectivity_switch = Switch(_("Check connectivity")) connectivity_switch.content_widget.set_active(self.nm_client.connectivity_check_get_enabled()) connectivity_switch.content_widget.connect("notify::active", self.on_connectivity_toggled) section.add_row(connectivity_switch) section.add_note(_("Check that network connections can reach the Internet. This makes it possible to detect captive portals, but also generates periodic network traffic."))
def __init__(self, transient_for): self.builder = Gtk.Builder.new_from_file( os.path.join(config.pkgdatadir, "prefs-window.ui")) self.window = self.builder.get_object("prefs_window") self.content_box = self.builder.get_object("content_box") self.page_switcher = self.builder.get_object("page_switcher") self.window.set_title(title=_("Warpinator Preferences")) self.window.set_icon_name("preferences-system") self.window.set_transient_for(transient_for) size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL) page_stack = SettingsStack() self.content_box.pack_start(page_stack, True, True, 0) self.page_switcher.set_stack(page_stack) # Settings page = SettingsPage() page_stack.add_titled(page, "general", _("General")) section = page.add_section(_("Desktop")) widget = GSettingsSwitch(_("Show an icon in the notification area"), PREFS_SCHEMA, TRAY_ICON_KEY) section.add_row(widget) widget = GSettingsSwitch(_("Start with main window open"), PREFS_SCHEMA, START_WITH_WINDOW_KEY) section.add_reveal_row(widget, PREFS_SCHEMA, TRAY_ICON_KEY) widget = GSettingsSwitch(_("Start automatically"), PREFS_SCHEMA, AUTOSTART_KEY) section.add_row(widget) section = page.add_section(_("File Transfers")) widget = GSettingsSwitch( _("Use compression when possible."), PREFS_SCHEMA, USE_COMPRESSION_KEY, tooltip= _("Warning: This may have a negative impact on performance on some faster networks." )) section.add_row(widget) widget = GSettingsFileChooser(_("Location for received files"), PREFS_SCHEMA, FOLDER_NAME_KEY, size_group=size_group, dir_select=True) section.add_row(widget) widget = GSettingsSwitch(_("Require approval before accepting files"), PREFS_SCHEMA, ASK_PERMISSION_KEY) section.add_row(widget) widget = GSettingsSwitch( _("Require approval when files would be overwritten"), PREFS_SCHEMA, NO_OVERWRITE_KEY) section.add_row(widget) widget = GSettingsSwitch( _("Display a notification when someone sends (or tries to send) you files" ), PREFS_SCHEMA, SHOW_NOTIFICATIONS_KEY) section.add_row(widget) page = SettingsPage() page_stack.add_titled(page, "network", _("Connection")) section = page.add_section(_("Identification")) entry_size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.VERTICAL) button_size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.BOTH) widget = GroupCodeEntry( _("Group Code"), tooltip= _("You cannot communicate with computers that do not use the same code." ), entry_size_group=entry_size_group, button_size_group=button_size_group) section.add_row(widget) section = page.add_section(_("Network")) options = [] options.append(("auto", _("Automatic"))) current_selection_exists = get_preferred_iface() == "auto" or False devices = networkmonitor.get_network_monitor().get_devices() for dev in devices: iface = dev.get_iface() if iface == get_preferred_iface(): current_selection_exists = True desc = dev.get_product() if (desc != None and desc != ""): orig_label = "%s - %s" % (iface, desc) if len(orig_label) > 50: label = orig_label[:47] + "..." else: label = orig_label options.append((iface, label)) else: options.append((iface, iface)) if not current_selection_exists: # translation: combobox item shown when a previosuly set interface can no longer be found - 'wlan0 - not found' options.append((get_preferred_iface(), _("%s - not found") % get_preferred_iface())) self.iface_combo = ComboBox(_("Network interface to use"), options, valtype=str) self.iface_combo.content_widget.set_active_iter( self.iface_combo.option_map[get_preferred_iface()]) self.iface_combo.label.set_line_wrap(False) section.add_row(self.iface_combo) self.main_port = PortSpinButton(_("Incoming port for transfers"), mini=1024, maxi=49151, step=1, page=10, size_group=size_group, entry_size_group=entry_size_group, button_size_group=button_size_group) section.add_row(self.main_port) self.auth_port = PortSpinButton(_("Incoming port for registration"), mini=1024, maxi=49151, step=1, page=10, size_group=size_group, entry_size_group=entry_size_group, button_size_group=button_size_group) section.add_row(self.auth_port) self.main_port.content_widget.set_value(get_port()) self.auth_port.content_widget.set_value(get_auth_port()) self.settings = Gio.Settings(schema_id=PREFS_SCHEMA) self.main_port.content_widget.connect("value-changed", self.net_values_changed) self.auth_port.content_widget.connect("value-changed", self.net_values_changed) self.iface_combo_id = self.iface_combo.content_widget.connect( "changed", self.net_values_changed) self.port_button = Button(_("Apply network changes"), self.apply_net_settings) self.port_button.content_widget.set_sensitive(False) self.port_button.content_widget.get_style_context().add_class( "suggested-action") section.add_row(self.port_button) widget = SettingsWidget() if config.include_firewall_mod and GLib.find_program_in_path("ufw"): button = Gtk.Button(label=_("Update firewall rules"), valign=Gtk.Align.CENTER) button.connect("clicked", self.open_port) widget.pack_end(button, False, False, 0) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) widget.pack_start(box, True, True, 0) # Pulling in a label with attributes was simpler than trying to add attributes # to a label here - the PangoAttribute python binding for font weight is missing. box.pack_start(self.builder.get_object("port_help_heading"), False, False, 0) label = Gtk.Label(wrap=True, xalign=0.0, label=_("""\ Any port numbers will work for the application, but using the same ports for all computers \ can make it simpler to add firewall exceptions if necessary.""")) box.pack_start(label, False, False, 0) section.add_row(widget) self.window.show_all()
def __init__(self, transient_for): self.builder = Gtk.Builder.new_from_file( os.path.join(config.pkgdatadir, "prefs-window.ui")) self.window = self.builder.get_object("prefs_window") self.content_box = self.builder.get_object("content_box") self.window.set_title(title=_("Warpinator Preferences")) self.window.set_icon_name("preferences-system") self.window.set_transient_for(transient_for) size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL) page = SettingsPage() self.content_box.pack_start(page, True, True, 0) section = page.add_section(_("Desktop")) self.settings_widget = GSettingsSwitch( _("Show an icon in the notification area"), PREFS_SCHEMA, TRAY_ICON_KEY) section.add_row(self.settings_widget) widget = GSettingsSwitch(_("Start with main window open"), PREFS_SCHEMA, START_WITH_WINDOW_KEY) section.add_reveal_row(widget, PREFS_SCHEMA, TRAY_ICON_KEY) widget = GSettingsSwitch(_("Start automatically"), PREFS_SCHEMA, AUTOSTART_KEY) section.add_row(widget) section = page.add_section(_("File Transfers")) widget = GSettingsFileChooser(_("Location for received files"), PREFS_SCHEMA, FOLDER_NAME_KEY, size_group=size_group, dir_select=True) section.add_row(widget) # widget = GSettingsSwitch(_("Preserve original file permissions"), # PREFS_SCHEMA, KEEP_PERMISSIONS_KEY) # section.add_row(widget) widget = GSettingsSwitch(_("Require approval before accepting files"), PREFS_SCHEMA, ASK_PERMISSION_KEY) section.add_row(widget) widget = GSettingsSwitch( _("Require approval when files would be overwritten"), PREFS_SCHEMA, NO_OVERWRITE_KEY) section.add_row(widget) widget = GSettingsSwitch( _("Display a notification when someone sends (or tries to send) you files" ), PREFS_SCHEMA, SHOW_NOTIFICATIONS_KEY) section.add_row(widget) section = page.add_section(_("Network")) entry_size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.VERTICAL) button_size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.BOTH) widget = GroupCodeEntry( _("Group Code"), tooltip= _("You cannot communicate with computers that do not use the same code." ), entry_size_group=entry_size_group, button_size_group=button_size_group) section.add_row(widget) widget = PortSpinButton(_("Incoming port for transfers"), mini=1024, maxi=49151, step=1, page=10, size_group=size_group, entry_size_group=entry_size_group, button_size_group=button_size_group) section.add_row(widget) widget = SettingsWidget() if config.include_firewall_mod and GLib.find_program_in_path("ufw"): button = Gtk.Button(label=_("Update firewall rules"), valign=Gtk.Align.CENTER) button.connect("clicked", self.open_port) widget.pack_end(button, False, False, 0) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) widget.pack_start(box, True, True, 0) # Pulling in a label with attributes was simpler than trying to add attributes # to a label here - the PangoAttribute python binding for font weight is missing. box.pack_start(self.builder.get_object("port_help_heading"), False, False, 0) label = Gtk.Label(wrap=True, xalign=0.0, label=_("""\ Any port number will work for the application, but using the same port for all computers \ can make it simpler to add firewall exceptions if necessary.""")) box.pack_start(label, False, False, 0) section.add_row(widget) self.window.show_all()
def __init__(self, transient_for): self.builder = Gtk.Builder.new_from_file( os.path.join(config.pkgdatadir, "prefs-window.ui")) self.window = self.builder.get_object("prefs_window") self.content_box = self.builder.get_object("content_box") self.window.set_title(title=_("Warp Preferences")) self.window.set_icon_name("preferences-system") self.window.set_transient_for(transient_for) size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL) page = SettingsPage() self.content_box.pack_start(page, True, True, 0) section = page.add_section(_("Desktop")) self.settings_widget = GSettingsSwitch( _("Show a Warpinator icon in the notification area"), PREFS_SCHEMA, TRAY_ICON_KEY) section.add_row(self.settings_widget) widget = GSettingsSwitch(_("Start with main window open"), PREFS_SCHEMA, START_WITH_WINDOW_KEY) section.add_reveal_row(widget, PREFS_SCHEMA, TRAY_ICON_KEY) # widget = GSettingsSwitch(_("Pin the window by default"), # PREFS_SCHEMA, START_PINNED_KEY) # section.add_row(widget) widget = GSettingsSwitch(_("Start automatically"), PREFS_SCHEMA, AUTOSTART_KEY) section.add_row(widget) section = page.add_section(_("File Transfers")) widget = GSettingsFileChooser(_("Location for received files"), PREFS_SCHEMA, FOLDER_NAME_KEY, size_group=size_group, dir_select=True) section.add_row(widget) widget = GSettingsSwitch(_("Require approval before accepting files"), PREFS_SCHEMA, ASK_PERMISSION_KEY) section.add_row(widget) widget = GSettingsSwitch( _("Require approval when files would be overwritten"), PREFS_SCHEMA, NO_OVERWRITE_KEY) section.add_row(widget) widget = GSettingsSwitch( _("Display a notification when someone sends (or tries to send) you files" ), PREFS_SCHEMA, SHOW_NOTIFICATIONS_KEY) section.add_row(widget) section = page.add_section(_("Network")) widget = PortSpinButton(_("Incoming port for transfers"), mini=1024, maxi=49151, step=1, page=10, size_group=size_group) section.add_row(widget) widget = SettingsWidget() label = Gtk.Label(use_markup=True, label=_("""\ <b>Note on port numbers</b>: Any port number will work for the application, but using the same port for all computers can make it simpler to add firewall exceptions if necessary.""")) widget.add(label) section.add_row(widget) self.window.show_all()