[GTK3] Fix import and attribute warnings

Fixes:
- warning import GConf
- Gtk is not defined
- 'ResponseType' has no attribute 'Yes'
- selection.data should be selection.get_data
This commit is contained in:
hugosenari 2018-08-20 06:18:49 -03:00 committed by Calum Lind
parent 2f879c33f3
commit dfed17ac0d
7 changed files with 12 additions and 9 deletions

View File

@ -802,7 +802,7 @@ class AddTorrentDialog(component.Component):
dialog.show_all()
response = dialog.run()
infohash = entry.get_text().strip()
if response == Gtk.RESPONSE_OK and deluge.common.is_infohash(infohash):
if response == Gtk.ResponseType.OK and deluge.common.is_infohash(infohash):
# Create a list of trackers from the textview buffer
tview_buf = textview.get_buffer()
trackers_text = tview_buf.get_text(*tview_buf.get_bounds())

View File

@ -247,8 +247,11 @@ def associate_magnet_links(overwrite=False):
elif not osx_check():
# gconf method is only available in a GNOME environment
try:
import gi
gi.require_version('GConf', '2.0')
from gi.repository import GConf
except ImportError:
except ValueError:
log.debug(
'gconf not available, so will not attempt to register magnet uri handler'
)

View File

@ -322,7 +322,7 @@ class ConnectionManager(component.Component):
dialog = AuthenticationDialog(reason.value.message, reason.value.username)
def dialog_finished(response_id):
if response_id == Gtk.RESPONSE_OK:
if response_id == Gtk.ResponseType.OK:
self._connect(host_id, dialog.get_username(), dialog.get_password())
return dialog.run().addCallback(dialog_finished)

View File

@ -29,7 +29,7 @@ def last_tier_trackers_from_liststore(trackers_liststore):
"""Create a list of tracker from existing liststore and find last tier number.
Args:
tracker_liststore (Gtk.ListStore): A gtk.ListStore with [tier (int), tracker (str)] rows.
tracker_liststore (Gtk.ListStore): A Gtk.ListStore with [tier (int), tracker (str)] rows.
Returns:
tuple(int, list): A tuple containing last tier number and list of trackers.

View File

@ -821,9 +821,9 @@ class FilesTab(Tab):
self, treeview, context, x, y, selection, info, etime
):
try:
selected = pickle.loads(selection.data)
selected = pickle.loads(selection.get_data())
except pickle.UnpicklingError:
log.debug('Invalid selection data: %s', selection.data)
log.debug('Invalid selection data: %s', selection.get_data())
return
log.debug('selection.data: %s', selected)
drop_info = treeview.get_dest_row_at_pos(x, y)

View File

@ -354,7 +354,7 @@ class GtkUI(object):
def on_dialog_response(response):
"""User response to switching mode dialog."""
if response == ResponseType.Yes:
if response == ResponseType.YES:
# Turning off standalone
self.config['standalone'] = False
self._start_thinclient()

View File

@ -17,7 +17,7 @@ gi.require_version('PangoCairo', '1.0') # NOQA: E402
# isort:imports-thirdparty
from gi.repository import PangoCairo, cairo
from gi.repository.Gtk import DrawingArea, ProgressBar
from gi.repository.Gtk import DrawingArea, ProgressBar, StateFlags
from gi.repository.Pango import SCALE, Weight
# isort:imports-firstparty
@ -36,7 +36,7 @@ class PiecesBar(DrawingArea):
# Get progress bar styles, in order to keep font consistency
pb = ProgressBar()
pb_style = pb.get_style_context()
self.text_font = pb_style.get_property('font', Gtk.StateFlags.NORMAL)
self.text_font = pb_style.get_property('font', StateFlags.NORMAL)
self.text_font.set_weight(Weight.BOLD)
# Done with the ProgressBar styles, don't keep refs of it
del pb, pb_style