def __init__(self, extension_type, metadata, size_group): super(ManageSpicesRow, self).__init__() self.extension_type = extension_type self.metadata = metadata self.status_ids = {} self.writable = metadata['writable'] self.uuid = self.metadata['uuid'] self.name = translate(self.metadata['uuid'], self.metadata['name']) self.description = translate(self.metadata['uuid'], self.metadata['description']) try: self.max_instances = int(self.metadata['max-instances']) if self.max_instances < -1: self.max_instances = 1 except (KeyError, ValueError): self.max_instances = 1 try: self.role = self.metadata['role'] except (KeyError, ValueError): self.role = None try: last_edited = self.metadata['last-edited'] except (KeyError, ValueError): last_edited = -1 if 'multiversion' in self.metadata and self.metadata['multiversion']: self.metadata['path'] = find_extension_subdir( self.metadata['path']) # "hide-configuration": true in metadata trumps all # otherwise we check for "external-configuration-app" in metadata and settings-schema.json in settings self.has_config = False self.ext_config_app = None if not 'hide-configuration' in self.metadata or self.metadata[ 'hide-configuration'] != True: if 'external-configuration-app' in self.metadata: self.ext_config_app = os.path.join( self.metadata['path'], self.metadata['external-configuration-app']) if self.ext_config_app is not None: if os.path.exists(self.ext_config_app): self.has_config = True else: self.ext_config_app = None if self.ext_config_app is None and os.path.exists( '%s/settings-schema.json' % self.metadata['path']): self.has_config = True widget = SettingsWidget() self.add(widget) grid = Gtk.Grid() grid.set_column_spacing(15) widget.pack_start(grid, True, True, 0) icon = None if 'icon' in self.metadata: icon_name = self.metadata['icon'] if Gtk.IconTheme.get_default().has_icon(icon_name): icon = Gtk.Image.new_from_icon_name(icon_name, 3) if icon is None and os.path.exists( '%s/icon.png' % self.metadata['path']): try: pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( '%s/icon.png' % self.metadata['path'], 24, 24, True) icon = Gtk.Image.new_from_pixbuf(pixbuf) except: icon = None if icon is None: icon = Gtk.Image.new_from_icon_name('cs-%ss' % (extension_type), 3) grid.attach(icon, 0, 0, 1, 1) desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) desc_box.props.hexpand = True desc_box.props.halign = Gtk.Align.START name_label = Gtk.Label() name_markup = GLib.markup_escape_text(self.name) name_label.set_markup('<b>{}</b>'.format(name_markup)) name_label.props.xalign = 0.0 desc_box.add(name_label) description_label = SettingsLabel() description_markup = GLib.markup_escape_text( sanitize_html(self.description)) description_label.set_markup( '<small>{}</small>'.format(description_markup)) desc_box.add(description_label) grid.attach_next_to(desc_box, icon, Gtk.PositionType.RIGHT, 1, 1) self.status_box = Gtk.Box() self.status_box.set_spacing(4) grid.attach_next_to(self.status_box, desc_box, Gtk.PositionType.RIGHT, 1, 1) self.button_box = Gtk.Box() self.button_box.set_valign(Gtk.Align.CENTER) grid.attach_next_to(self.button_box, self.status_box, Gtk.PositionType.RIGHT, 1, 1) size_group.add_widget(self.button_box) if self.has_config: config_icon = Gtk.Image.new_from_icon_name('system-run-symbolic', 2) self.config_button = Gtk.Button(image=config_icon) self.config_button.set_tooltip_text(_('Configure')) self.button_box.pack_start(self.config_button, False, False, 0) self.config_button.connect('clicked', self.configure) self.set_can_config() if not self.writable: if self.extension_type == "applet": self.add_status( 'locked', 'changes-prevent-symbolic', _("This is a system applet. It cannot be removed.")) elif self.extension_type == "desklet": self.add_status( 'locked', 'changes-prevent-symbolic', _("This is a system desklet. It cannot be removed.")) elif self.extension_type == "extension": self.add_status( 'locked', 'changes-prevent-symbolic', _("This is a system extension. It cannot be removed.")) try: schema_filename = self.metadata['schema-file'] except (KeyError, ValueError): schema_filename = '' if self.writable: self.scan_extension_for_danger(self.metadata['path']) self.version_supported = False try: self.version_supported = curr_ver in self.metadata[ 'cinnamon-version'] or curr_ver.rsplit( '.', 1)[0] in self.metadata['cinnamon-version'] except (KeyError, ValueError): self.version_supported = True # Don't check version if not specified.
def __init__(self, uuid, data, spices, size_groups): super().__init__() self.uuid = uuid self.data = data self.spices = spices self.name = data['name'] self.description = data['description'] self.score = data['score'] self.timestamp = data['last_edited'] self.has_update = False self.status_ids = {} self.installed = self.spices.get_is_installed(uuid) widget = SettingsWidget() widget.set_spacing(15) self.add(widget) icon = spices.get_icon(uuid) widget.pack_start(icon, False, False, 0) desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) desc_box.set_hexpand(True) desc_box.set_halign(Gtk.Align.FILL) name_label = Gtk.Label() name_markup = GLib.markup_escape_text(self.name) name_label.set_markup('<b>{}</b>'.format(name_markup)) name_label.set_hexpand(True) name_label.set_halign(Gtk.Align.START) desc_box.pack_start(name_label, False, False, 0) description_label = SettingsLabel() description_markup = GLib.markup_escape_text( sanitize_html(self.description)) description_label.set_markup( '<small>{}</small>'.format(description_markup)) desc_box.pack_start(description_label, False, False, 0) widget.pack_start(desc_box, True, True, 0) score_box = Gtk.Box() score_image = Gtk.Image.new_from_icon_name('starred-symbolic', 2) score_box.pack_start(score_image, False, False, 0) score_label = Gtk.Label(self.score) score_box.pack_start(score_label, False, False, 5) widget.pack_start(score_box, False, False, 0) size_groups[0].add_widget(score_box) self.status_box = Gtk.Box() self.status_box.set_spacing(4) widget.pack_start(self.status_box, False, False, 0) size_groups[1].add_widget(self.status_box) self.button_box = Gtk.Box() self.button_box.set_valign(Gtk.Align.CENTER) self.button_box.set_baseline_position(Gtk.BaselinePosition.CENTER) widget.pack_start(self.button_box, False, False, 0) size_groups[2].add_widget(self.button_box) if not self.installed: download_button = Gtk.Button.new_from_icon_name( 'go-down-symbolic', 2) self.button_box.pack_start(download_button, False, False, 0) download_button.connect('clicked', self.download) download_button.set_tooltip_text(_("Install")) elif self.spices.get_has_update(uuid): self.has_update = True download_button = Gtk.Button.new_from_icon_name( 'view-refresh-symbolic', 2) self.button_box.pack_start(download_button, False, False, 0) download_button.connect('clicked', self.download) download_button.set_tooltip_text(_("Update")) if self.installed: self.add_status('installed', 'object-select-symbolic', _("Installed"))
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.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=_("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()
def __init__(self, uuid, data, spices, size_groups): super().__init__() self.uuid = uuid self.data = data self.spices = spices self.name = data['name'] self.description = data['description'] self.score = data['score'] self.timestamp = data['last_edited'] self.author = "" if 'author_user' in data: if data['author_user'].lower( ) != "none" and data['author_user'].lower() != "unknown": self.author = data['author_user'] if 'translations' in data.keys(): key = 'name_%s' % LANGUAGE_CODE if key in data['translations'].keys(): self.name = data['translations'][key] key = 'description_%s' % LANGUAGE_CODE if key in data['translations'].keys(): self.description = data['translations'][key] self.has_update = False self.status_ids = {} self.installed = self.spices.get_is_installed(uuid) widget = SettingsWidget() widget.set_spacing(15) self.add(widget) installed_box = Gtk.Box() installed_box.set_spacing(4) widget.pack_start(installed_box, False, False, 0) size_groups[0].add_widget(installed_box) installed_image = Gtk.Image.new_from_icon_name( 'object-select-symbolic', 2) installed_box.pack_end(installed_image, False, False, 0) installed_image.set_tooltip_text(_("Installed")) installed_image.set_no_show_all(True) if self.installed: installed_image.show() else: installed_image.hide() icon = spices.get_icon(uuid) widget.pack_start(icon, False, False, 0) desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) desc_box.set_hexpand(True) desc_box.set_halign(Gtk.Align.FILL) desc_box.set_spacing(1) name_label = Gtk.Label() name_markup = GLib.markup_escape_text(self.name) if self.author == "": name_label.set_markup('<b>{}</b>'.format(name_markup)) else: by_author = _("by %s") % self.author name_label.set_markup('<b>{}</b><small> {}</small>'.format( name_markup, by_author)) name_label.set_hexpand(True) name_label.set_halign(Gtk.Align.START) desc_box.pack_start(name_label, False, False, 0) uuid_label = Gtk.Label() uuid_markup = GLib.markup_escape_text(self.uuid) uuid_label.set_markup('<small><i>{}</i></small>'.format(uuid_markup)) uuid_label.props.xalign = 0.0 desc_box.add(uuid_label) description_label = SettingsLabel() description_markup = GLib.markup_escape_text( sanitize_html(self.description)) description_label.set_markup( '<small>{}</small>'.format(description_markup)) description_label.set_margin_top(2) desc_box.pack_start(description_label, False, False, 0) widget.pack_start(desc_box, True, True, 0) score_box = Gtk.Box() score_image = Gtk.Image.new_from_icon_name('starred-symbolic', 2) score_box.pack_start(score_image, False, False, 0) score_label = Gtk.Label(self.score) score_box.pack_start(score_label, False, False, 5) widget.pack_start(score_box, False, False, 0) size_groups[1].add_widget(score_box) self.status_box = Gtk.Box() self.status_box.set_spacing(4) widget.pack_start(self.status_box, False, False, 0) size_groups[2].add_widget(self.status_box) self.button_box = Gtk.Box() self.button_box.set_valign(Gtk.Align.CENTER) self.button_box.set_baseline_position(Gtk.BaselinePosition.CENTER) widget.pack_start(self.button_box, False, False, 0) size_groups[3].add_widget(self.button_box) if not self.installed: download_button = Gtk.Button.new_from_icon_name( 'go-down-symbolic', 2) self.button_box.pack_start(download_button, False, False, 0) download_button.connect('clicked', self.download) download_button.set_tooltip_text(_("Install")) elif self.spices.get_has_update(uuid): self.has_update = True download_button = Gtk.Button.new_from_icon_name( 'view-refresh-symbolic', 2) self.button_box.pack_start(download_button, False, False, 0) download_button.connect('clicked', self.download) download_button.set_tooltip_text(_("Update"))
def __init__(self, extension_type, metadata, size_groups): super(ManageSpicesRow, self).__init__() self.extension_type = extension_type self.metadata = metadata self.status_ids = {} self.writable = metadata['writable'] self.uuid = self.metadata['uuid'] self.name = translate(self.metadata['uuid'], self.metadata['name']) self.description = translate(self.metadata['uuid'], self.metadata['description']) self.author = "" if 'author' in metadata: if metadata['author'].lower( ) != "none" and metadata['author'].lower() != "unknown": self.author = metadata['author'] icon_path = os.path.join(self.metadata['path'], 'icon.png') try: self.max_instances = int(self.metadata['max-instances']) if self.max_instances < -1: self.max_instances = 1 except (KeyError, ValueError): self.max_instances = 1 try: self.role = self.metadata['role'] except (KeyError, ValueError): self.role = None try: last_edited = self.metadata['last-edited'] except (KeyError, ValueError): last_edited = -1 # Check for the right version subdir (if the spice is multi-versioned, it won't necessarily be in its root directory) self.metadata['path'] = find_extension_subdir(self.metadata['path']) # "hide-configuration": true in metadata trumps all # otherwise we check for "external-configuration-app" in metadata and settings-schema.json in settings self.has_config = False self.ext_config_app = None if not 'hide-configuration' in self.metadata or self.metadata[ 'hide-configuration'] != True: if 'external-configuration-app' in self.metadata: self.ext_config_app = os.path.join( self.metadata['path'], self.metadata['external-configuration-app']) if self.ext_config_app is not None: if os.path.exists(self.ext_config_app): self.has_config = True else: self.ext_config_app = None if self.ext_config_app is None and os.path.exists( '%s/settings-schema.json' % self.metadata['path']): self.has_config = True widget = SettingsWidget() self.add(widget) grid = Gtk.Grid() grid.set_column_spacing(15) widget.pack_start(grid, True, True, 0) enabled_box = Gtk.Box() enabled_box.set_spacing(4) size_groups[0].add_widget(enabled_box) self.enabled_image = Gtk.Image.new_from_icon_name( 'object-select-symbolic', 2) if self.extension_type == "applet": self.enabled_image.set_tooltip_text( _("This applet is currently enabled")) elif self.extension_type == "desklet": self.enabled_image.set_tooltip_text( _("This desklet is currently enabled")) elif self.extension_type == "extension": self.enabled_image.set_tooltip_text( _("This extension is currently enabled")) self.enabled_image.set_no_show_all(True) enabled_box.pack_end(self.enabled_image, False, False, 0) enabled_box.show() grid.attach(enabled_box, 0, 0, 1, 1) icon = None if 'icon' in self.metadata: icon_name = self.metadata['icon'] if Gtk.IconTheme.get_default().has_icon(icon_name): icon = Gtk.Image.new_from_icon_name(icon_name, 3) if os.path.exists(icon_path): try: pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( icon_path, 24, 24, True) icon = Gtk.Image.new_from_pixbuf(pixbuf) except: icon = None if icon is None: icon = Gtk.Image.new_from_icon_name('cs-%ss' % (extension_type), 3) grid.attach_next_to(icon, enabled_box, Gtk.PositionType.RIGHT, 1, 1) desc_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) desc_box.props.hexpand = True desc_box.props.halign = Gtk.Align.START desc_box.set_spacing(1) name_label = Gtk.Label() name_markup = GLib.markup_escape_text(self.name) if self.author == "": name_label.set_markup('<b>{}</b>'.format(name_markup)) else: by_author = _("by %s") % self.author name_label.set_markup('<b>{}</b><small> {}</small>'.format( name_markup, by_author)) name_label.props.xalign = 0.0 desc_box.add(name_label) uuid_label = Gtk.Label() uuid_markup = GLib.markup_escape_text(self.uuid) uuid_label.set_markup('<small><i>{}</i></small>'.format(uuid_markup)) uuid_label.props.xalign = 0.0 desc_box.add(uuid_label) description_label = SettingsLabel() description_markup = GLib.markup_escape_text( sanitize_html(self.description)) description_label.set_markup( '<small>{}</small>'.format(description_markup)) description_label.set_margin_top(2) desc_box.add(description_label) grid.attach_next_to(desc_box, icon, Gtk.PositionType.RIGHT, 1, 1) self.status_box = Gtk.Box() self.status_box.set_spacing(4) grid.attach_next_to(self.status_box, desc_box, Gtk.PositionType.RIGHT, 1, 1) size_groups[1].add_widget(self.status_box) self.button_box = Gtk.Box() self.button_box.set_valign(Gtk.Align.CENTER) grid.attach_next_to(self.button_box, self.status_box, Gtk.PositionType.RIGHT, 1, 1) size_groups[2].add_widget(self.button_box) if self.has_config: config_icon = Gtk.Image.new_from_icon_name('system-run-symbolic', 2) self.config_button = Gtk.Button(image=config_icon) self.config_button.set_tooltip_text(_('Configure')) self.button_box.pack_start(self.config_button, False, False, 0) self.config_button.connect('clicked', self.configure) self.set_can_config() if not self.writable: if self.extension_type == "applet": self.add_status( 'locked', 'changes-prevent-symbolic', _("This is a system applet. It cannot be removed.")) elif self.extension_type == "desklet": self.add_status( 'locked', 'changes-prevent-symbolic', _("This is a system desklet. It cannot be removed.")) elif self.extension_type == "extension": self.add_status( 'locked', 'changes-prevent-symbolic', _("This is a system extension. It cannot be removed.")) try: schema_filename = self.metadata['schema-file'] except (KeyError, ValueError): schema_filename = '' if self.writable: self.scan_extension_for_danger(self.metadata['path']) self.version_supported = self.is_compatible_with_cinnamon_version()
def __init__(self): Gtk.Window.__init__(self) self.connect("delete-event", lambda w, e: Gtk.main_quit()) self.set_size_request(800, -1) self.set_default_size(800, -1) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(box) page = SettingsPage() box.pack_start(page, False, False, 0) section = page.add_section(_("Mouse Damper")) widget = SettingsWidget() box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) widget.pack_start(box, False, False, 0) label = Gtk.Label( wrap=True, xalign=0.0, use_markup=True, label= _("<b>What this does</b>\n\n" "This program is intended to make mouse click actions a bit more forgiving for " "people suffering from essential tremor or other similar afflictions. Often when " "attempting to click items on the screen, due to the fact that many actions are only " "triggered on button-<i>release</i>, one can end up performing unintended actions if " "the mouse position moves from its original position between button-press and -release. " "This can range from accidentally invoking a drag operation to activating some adjacent " "element to the one you had originally intended. The toolkit libraries that " "graphical applications use (GTK, QT) have some preventatives for unintentional mouse " "movement, however they are of limited effectiveness, and do nothing to prevent mis-targeting " "on a button-release.\n\n" "The way these issues are addressed by this program is the pointer is frozen in place when " "a button is pressed. At this point, two things begin to be tracked - elapsed time and " "physical mouse movement. The freeze is removed when one of the following three events " "takes place:\n\n" "• The user proceeds to complete a double-click (a click, release, and second click within " "a certain duration).\n" "• The double-click timeout is exceeded.\n" "• The physical mouse movement from the freeze point exceeds a configurable threshold.\n\n" "While this is by no means a perfect solution, it at least allows the user to act on their " "intended target, without being affected by uncontrollable physical movement." )) box.pack_start(label, False, False, 0) section.add_row(widget) section = page.add_section(_("Movement threshold")) widget = SettingsWidget() box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) widget.pack_start(box, False, False, 0) label = Gtk.Label( wrap=True, xalign=0.0, use_markup=True, label=_( "<b>Distance at which the mouse will become unfrozen.</b>\n\n" "This is the straight-line distance from the initial click point " "- the value does not simply accumulate all movement")) box.pack_start(label, False, False, 0) section.add_row(widget) widget = KeyfileRange("", mini=50, maxi=1000, step=10, key="delta-threshold", show_value=True) section.add_row(widget) self.show_all()
def __init__(self, transfer_active): super(Preferences, self).__init__(modal=True, title=_("Warp Preferences")) size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL) page = SettingsPage() self.add(page) section = page.add_section(_("General")) widget = GSettingsEntry(_("Nickname"), PREFS_SCHEMA, BROADCAST_NAME_KEY, size_group=size_group) section.add_row(widget) if transfer_active: widget.set_sensitive(False) widget.set_tooltip_text("Nickname changes are not allowed while there are active transfers") widget = GSettingsSwitch(_("Start with main window open"), PREFS_SCHEMA, START_WITH_WINDOW_KEY) section.add_row(widget) 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) if transfer_active: widget.set_sensitive(False) widget.set_tooltip_text("Changes to the save location are not allowed while there are active transfers") widget = GSettingsSwitch(_("Abort transfer if files exist"), PREFS_SCHEMA, NO_OVERWRITE_KEY) section.add_row(widget) widget = GSettingsSwitch(_("Require approval before accepting files"), PREFS_SCHEMA, ASK_PERMISSION_KEY) section.add_row(widget) section = page.add_section(_("Network")) widget = GSettingsSpinButton(_("Port to use for traffic (program restart required)."), PREFS_SCHEMA, PORT_KEY, 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.show_all()