[GTK] Fix unicode warnings on Python 2

GTK3 on Python 2 returns bytes so decode before comparisons.
This commit is contained in:
Calum Lind 2018-11-05 16:47:58 +00:00
parent ab1b2bcf14
commit 9f9f564e62
3 changed files with 8 additions and 6 deletions

View File

@ -20,7 +20,7 @@ from gi.repository.GdkPixbuf import Pixbuf
from gi.repository.Pango import EllipsizeMode
import deluge.component as component
from deluge.common import TORRENT_STATE, resource_filename
from deluge.common import TORRENT_STATE, decode_bytes, resource_filename
from deluge.configmanager import ConfigManager
from deluge.ui.client import client
@ -224,7 +224,7 @@ class FilterTreeView(component.Component):
def render_cell_data(self, column, cell, model, row, data):
cat = model.get_value(row, 0)
label = model.get_value(row, 2)
label = decode_bytes(model.get_value(row, 2))
count = model.get_value(row, 3)
# Supress Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed

View File

@ -266,7 +266,8 @@ class ListView(object):
sort = None
if self.model_filter:
sort_id, order = self.model_filter.get_sort_column_id()
if self.get_column_name(sort_id) == column.get_title():
col_title = decode_bytes(column.get_title())
if self.get_column_name(sort_id) == col_title:
sort = sort_id
return ListViewColumnState(
@ -582,7 +583,7 @@ class ListView(object):
column_in_state = False
if self.state is not None:
for column_state in self.state:
if header == column_state.name:
if header == decode_bytes(column_state.name):
# We found a loaded state
column_in_state = True
if column_state.width > 0:

View File

@ -109,7 +109,8 @@ class Preferences(component.Component):
# Add and set separator after Plugins.
def set_separator(model, _iter, data=None):
if model.get_value(_iter, 1) == '_separator_':
entry = deluge.common.decode_bytes(model.get_value(_iter, 1))
if entry == '_separator_':
return True
self.treeview.set_row_separator_func(set_separator, None)
@ -277,7 +278,7 @@ class Preferences(component.Component):
self.iter_to_remove = None
def on_foreach_row(model, path, _iter, user_data):
row_name = model.get_value(_iter, 1)
row_name = deluge.common.decode_bytes(model.get_value(_iter, 1))
if row_name == user_data:
# This is the row we need to remove
self.page_num_to_remove = model.get_value(_iter, 0)