summaryrefslogtreecommitdiffstats
path: root/deluge/ui/gtk3/path_combo_chooser.py
diff options
context:
space:
mode:
Diffstat (limited to 'deluge/ui/gtk3/path_combo_chooser.py')
-rwxr-xr-xdeluge/ui/gtk3/path_combo_chooser.py39
1 files changed, 15 insertions, 24 deletions
diff --git a/deluge/ui/gtk3/path_combo_chooser.py b/deluge/ui/gtk3/path_combo_chooser.py
index 72e98e497..74d9055b7 100755
--- a/deluge/ui/gtk3/path_combo_chooser.py
+++ b/deluge/ui/gtk3/path_combo_chooser.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
#
# Copyright (C) 2013 Bro <bro.development@gmail.com>
#
@@ -8,15 +7,13 @@
# See LICENSE for more details.
#
-from __future__ import division, print_function, unicode_literals
-
import os
import warnings
from gi.repository import Gdk, GObject, Gtk
from gi.repository.GObject import SignalFlags
-from deluge.common import PY2, resource_filename
+from deluge.common import resource_filename
from deluge.path_chooser_common import get_completion_paths
# Filter the pygobject signal warning:
@@ -64,7 +61,7 @@ def path_without_trailing_path_sep(path):
return path
-class ValueList(object):
+class ValueList:
paths_without_trailing_path_sep = False
@@ -176,7 +173,7 @@ class ValueList(object):
"""
for i, row in enumerate(self.tree_store):
if row[0] == value:
- self.treeview.set_cursor((i))
+ self.treeview.set_cursor(i)
return
# The value was not found
if select_first:
@@ -374,7 +371,7 @@ class StoredValuesList(ValueList):
"""
# This is left click
if event.button != 3:
- super(StoredValuesList, self).on_treeview_mouse_button_press_event(
+ super().on_treeview_mouse_button_press_event(
treeview, event, double_click=True
)
return False
@@ -412,9 +409,7 @@ class StoredValuesList(ValueList):
PathChooserPopup.popup(self)
def on_stored_values_treeview_key_press_event(self, widget, event):
- super(StoredValuesList, self).on_value_list_treeview_key_press_event(
- widget, event
- )
+ super().on_value_list_treeview_key_press_event(widget, event)
# Prevent the default event handler to move the cursor in the list
if key_is_up_or_down(event.keyval):
return True
@@ -479,9 +474,9 @@ class CompletionList(ValueList):
] = self.on_completion_treeview_motion_notify_event
# Add super class signal handler
- self.signal_handlers['on_completion_treeview_mouse_button_press_event'] = super(
- CompletionList, self
- ).on_treeview_mouse_button_press_event
+ self.signal_handlers[
+ 'on_completion_treeview_mouse_button_press_event'
+ ] = super().on_treeview_mouse_button_press_event
def reduce_values(self, prefix):
"""
@@ -499,9 +494,7 @@ class CompletionList(ValueList):
self.add_values(matching_values, clear=True)
def on_completion_treeview_key_press_event(self, widget, event):
- ret = super(CompletionList, self).on_value_list_treeview_key_press_event(
- widget, event
- )
+ ret = super().on_value_list_treeview_key_press_event(widget, event)
if ret:
return ret
keyval = event.keyval
@@ -529,7 +522,7 @@ class CompletionList(ValueList):
self.handle_list_scroll(path=path[0], _next=None)
-class PathChooserPopup(object):
+class PathChooserPopup:
"""This creates the popop window for the ComboEntry."""
def __init__(self, min_visible_rows, max_visible_rows, popup_alignment_widget):
@@ -983,7 +976,7 @@ class PathCompletionPopup(CompletionList, PathChooserPopup):
return True
-class PathAutoCompleter(object):
+class PathAutoCompleter:
def __init__(self, builder, path_entry, max_visible_rows):
self.completion_popup = PathCompletionPopup(
builder, path_entry, max_visible_rows
@@ -1106,9 +1099,7 @@ class PathAutoCompleter(object):
class PathChooserComboBox(Gtk.Box, StoredValuesPopup, GObject.GObject):
__gsignals__ = {
- signal
- if not PY2
- else signal.encode(): (SignalFlags.RUN_FIRST, GObject.TYPE_NONE, (object,))
+ signal: (SignalFlags.RUN_FIRST, GObject.TYPE_NONE, (object,))
for signal in [
'text-changed',
'accelerator-set',
@@ -1414,7 +1405,7 @@ class PathChooserComboBox(Gtk.Box, StoredValuesPopup, GObject.GObject):
self.set_text(self.get_text())
def _on_entry_combobox_hbox_realize(self, widget):
- """ Must do this when the widget is realized """
+ """Must do this when the widget is realized"""
self.set_filechooser_button_visible(self.filechooser_visible)
self.set_path_entry_visible(self.path_entry_visible)
@@ -1466,7 +1457,7 @@ class PathChooserComboBox(Gtk.Box, StoredValuesPopup, GObject.GObject):
)
return True
elif is_ascii_value(keyval, 's'):
- super(PathChooserComboBox, self).add_current_value_to_saved_list()
+ super().add_current_value_to_saved_list()
return True
elif is_ascii_value(keyval, 'd'):
# Set the default value in the text entry
@@ -1696,7 +1687,7 @@ if __name__ == '__main__':
box1 = Gtk.Box.new(Gtk.Orientation.VERTICAL, spacing=0)
def get_resource2(filename):
- return '%s/glade/%s' % (os.path.abspath(os.path.dirname(sys.argv[0])), filename)
+ return f'{os.path.abspath(os.path.dirname(sys.argv[0]))}/glade/{filename}'
# Override get_resource which fetches from deluge install
# get_resource = get_resource2