Use Enum or IntEnum instead of range() constants.
This commit is contained in:
parent
b6b1a7a074
commit
2fbadc91e9
17 changed files with 580 additions and 570 deletions
|
@ -23,6 +23,8 @@
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
##
|
##
|
||||||
|
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
@ -30,11 +32,10 @@ from gi.repository import Pango
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
|
||||||
(
|
class Column(IntEnum):
|
||||||
C_PREFNAME,
|
PREFERENCE_NAME = 0
|
||||||
C_VALUE,
|
VALUE = 1
|
||||||
C_TYPE
|
TYPE = 2
|
||||||
) = range(3)
|
|
||||||
|
|
||||||
def rate_limit(rate):
|
def rate_limit(rate):
|
||||||
"""
|
"""
|
||||||
|
@ -135,8 +136,8 @@ class AdvancedConfigurationWindow(object):
|
||||||
Check if it's boolen or holds password stuff and if yes make the
|
Check if it's boolen or holds password stuff and if yes make the
|
||||||
cellrenderertext not editable, else - it's editable
|
cellrenderertext not editable, else - it's editable
|
||||||
"""
|
"""
|
||||||
optname = model[iter_][C_PREFNAME]
|
optname = model[iter_][Column.PREFERENCE_NAME]
|
||||||
opttype = model[iter_][C_TYPE]
|
opttype = model[iter_][Column.TYPE]
|
||||||
if opttype == self.types['boolean'] or optname == 'password':
|
if opttype == self.types['boolean'] or optname == 'password':
|
||||||
cell.set_property('editable', False)
|
cell.set_property('editable', False)
|
||||||
else:
|
else:
|
||||||
|
@ -263,8 +264,8 @@ class AdvancedConfigurationWindow(object):
|
||||||
elif len(opt_path) == 3:
|
elif len(opt_path) == 3:
|
||||||
default = gajim.config.get_default_per(opt_path[2], opt_path[0])
|
default = gajim.config.get_default_per(opt_path[2], opt_path[0])
|
||||||
|
|
||||||
if model[iter_][C_TYPE] == self.types['boolean']:
|
if model[iter_][Column.TYPE] == self.types['boolean']:
|
||||||
if self.right_true_dict[default] == model[iter_][C_VALUE]:
|
if self.right_true_dict[default] == model[iter_][Column.VALUE]:
|
||||||
return
|
return
|
||||||
modelpath = self.modelfilter.convert_path_to_child_path(path)
|
modelpath = self.modelfilter.convert_path_to_child_path(path)
|
||||||
modelrow = self.model[modelpath]
|
modelrow = self.model[modelpath]
|
||||||
|
@ -275,15 +276,15 @@ class AdvancedConfigurationWindow(object):
|
||||||
keyrow = self.model[modelpath[:2]]
|
keyrow = self.model[modelpath[:2]]
|
||||||
key = keyrow[0]
|
key = keyrow[0]
|
||||||
self.remember_option(option + '\n' + key + '\n' + optname,
|
self.remember_option(option + '\n' + key + '\n' + optname,
|
||||||
modelrow[C_VALUE], default)
|
modelrow[Column.VALUE], default)
|
||||||
gajim.config.set_per(optname, key, option, default)
|
gajim.config.set_per(optname, key, option, default)
|
||||||
else:
|
else:
|
||||||
self.remember_option(option, modelrow[C_VALUE], default)
|
self.remember_option(option, modelrow[Column.VALUE], default)
|
||||||
gajim.config.set(option, default)
|
gajim.config.set(option, default)
|
||||||
modelrow[C_VALUE] = self.right_true_dict[default]
|
modelrow[Column.VALUE] = self.right_true_dict[default]
|
||||||
self.check_for_restart()
|
self.check_for_restart()
|
||||||
else:
|
else:
|
||||||
if str(default) == model[iter_][C_VALUE]:
|
if str(default) == model[iter_][Column.VALUE]:
|
||||||
return
|
return
|
||||||
self.on_config_edited(None, path.to_string(), str(default))
|
self.on_config_edited(None, path.to_string(), str(default))
|
||||||
|
|
||||||
|
@ -317,14 +318,14 @@ class AdvancedConfigurationWindow(object):
|
||||||
def visible_func(self, model, treeiter, data):
|
def visible_func(self, model, treeiter, data):
|
||||||
search_string = self.entry.get_text().lower()
|
search_string = self.entry.get_text().lower()
|
||||||
for it in tree_model_pre_order(model, treeiter):
|
for it in tree_model_pre_order(model, treeiter):
|
||||||
if model[it][C_TYPE] != '':
|
if model[it][Column.TYPE] != '':
|
||||||
opt_path = self.get_option_path(model, it)
|
opt_path = self.get_option_path(model, it)
|
||||||
if len(opt_path) == 3:
|
if len(opt_path) == 3:
|
||||||
desc = gajim.config.get_desc_per(opt_path[2], opt_path[1],
|
desc = gajim.config.get_desc_per(opt_path[2], opt_path[1],
|
||||||
opt_path[0])
|
opt_path[0])
|
||||||
elif len(opt_path) == 1:
|
elif len(opt_path) == 1:
|
||||||
desc = gajim.config.get_desc(opt_path[0])
|
desc = gajim.config.get_desc(opt_path[0])
|
||||||
if search_string in model[it][C_PREFNAME] or (desc and \
|
if search_string in model[it][Column.PREFERENCE_NAME] or (desc and \
|
||||||
search_string in desc.lower()):
|
search_string in desc.lower()):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -46,7 +46,7 @@ from common import ged
|
||||||
from common import i18n
|
from common import i18n
|
||||||
from common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
|
from common.stanza_session import EncryptedStanzaSession, ArchivingStanzaSession
|
||||||
from common.contacts import GC_Contact
|
from common.contacts import GC_Contact
|
||||||
from common.logger import constants
|
from common.logger import KindConstant
|
||||||
from nbxmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
|
from nbxmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC
|
||||||
from nbxmpp.protocol import NS_RECEIPTS, NS_ESESSION
|
from nbxmpp.protocol import NS_RECEIPTS, NS_ESESSION
|
||||||
from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO
|
from nbxmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO
|
||||||
|
@ -1679,15 +1679,15 @@ class ChatControl(ChatControlBase):
|
||||||
additional_data = row[4]
|
additional_data = row[4]
|
||||||
if not msg: # message is empty, we don't print it
|
if not msg: # message is empty, we don't print it
|
||||||
continue
|
continue
|
||||||
if row[1] in (constants.KIND_CHAT_MSG_SENT,
|
if row[1] in (KindConstant.CHAT_MSG_SENT,
|
||||||
constants.KIND_SINGLE_MSG_SENT):
|
KindConstant.SINGLE_MSG_SENT):
|
||||||
kind = 'outgoing'
|
kind = 'outgoing'
|
||||||
name = self.get_our_nick()
|
name = self.get_our_nick()
|
||||||
elif row[1] in (constants.KIND_SINGLE_MSG_RECV,
|
elif row[1] in (KindConstant.SINGLE_MSG_RECV,
|
||||||
constants.KIND_CHAT_MSG_RECV):
|
KindConstant.CHAT_MSG_RECV):
|
||||||
kind = 'incoming'
|
kind = 'incoming'
|
||||||
name = self.contact.get_shown_name()
|
name = self.contact.get_shown_name()
|
||||||
elif row[1] == constants.KIND_ERROR:
|
elif row[1] == KindConstant.ERROR:
|
||||||
kind = 'status'
|
kind = 'status'
|
||||||
name = self.contact.get_shown_name()
|
name = self.contact.get_shown_name()
|
||||||
|
|
||||||
|
|
|
@ -35,15 +35,15 @@
|
||||||
import re
|
import re
|
||||||
from common import defs
|
from common import defs
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
(
|
class Option(IntEnum):
|
||||||
OPT_TYPE,
|
TYPE = 0
|
||||||
OPT_VAL,
|
VAL = 1
|
||||||
OPT_DESC,
|
DESC = 2
|
||||||
# If OPT_RESTART is True - we need restart to use our changed option
|
# If Option.RESTART is True - we need restart to use our changed option
|
||||||
# OPT_DESC also should be there
|
# Option.DESC also should be there
|
||||||
OPT_RESTART,
|
RESTART = 3
|
||||||
) = range(4)
|
|
||||||
|
|
||||||
opt_int = [ 'integer', 0 ]
|
opt_int = [ 'integer', 0 ]
|
||||||
opt_str = [ 'string', 0 ]
|
opt_str = [ 'string', 0 ]
|
||||||
|
@ -633,7 +633,7 @@ class Config:
|
||||||
def set(self, optname, value):
|
def set(self, optname, value):
|
||||||
if optname not in self.__options[1]:
|
if optname not in self.__options[1]:
|
||||||
return
|
return
|
||||||
value = self.is_valid(self.__options[0][optname][OPT_TYPE], value)
|
value = self.is_valid(self.__options[0][optname][Option.TYPE], value)
|
||||||
if value is None:
|
if value is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -650,24 +650,24 @@ class Config:
|
||||||
def get_default(self, optname):
|
def get_default(self, optname):
|
||||||
if optname not in self.__options[0]:
|
if optname not in self.__options[0]:
|
||||||
return None
|
return None
|
||||||
return self.__options[0][optname][OPT_VAL]
|
return self.__options[0][optname][Option.VAL]
|
||||||
|
|
||||||
def get_type(self, optname):
|
def get_type(self, optname):
|
||||||
if optname not in self.__options[0]:
|
if optname not in self.__options[0]:
|
||||||
return None
|
return None
|
||||||
return self.__options[0][optname][OPT_TYPE][0]
|
return self.__options[0][optname][Option.TYPE][0]
|
||||||
|
|
||||||
def get_desc(self, optname):
|
def get_desc(self, optname):
|
||||||
if optname not in self.__options[0]:
|
if optname not in self.__options[0]:
|
||||||
return None
|
return None
|
||||||
if len(self.__options[0][optname]) > OPT_DESC:
|
if len(self.__options[0][optname]) > Option.DESC:
|
||||||
return self.__options[0][optname][OPT_DESC]
|
return self.__options[0][optname][Option.DESC]
|
||||||
|
|
||||||
def get_restart(self, optname):
|
def get_restart(self, optname):
|
||||||
if optname not in self.__options[0]:
|
if optname not in self.__options[0]:
|
||||||
return None
|
return None
|
||||||
if len(self.__options[0][optname]) > OPT_RESTART:
|
if len(self.__options[0][optname]) > Option.RESTART:
|
||||||
return self.__options[0][optname][OPT_RESTART]
|
return self.__options[0][optname][Option.RESTART]
|
||||||
|
|
||||||
def add_per(self, typename, name): # per_group_of_option
|
def add_per(self, typename, name): # per_group_of_option
|
||||||
if typename not in self.__options_per_key:
|
if typename not in self.__options_per_key:
|
||||||
|
@ -679,7 +679,7 @@ class Config:
|
||||||
return 'you already have added %s before' % name
|
return 'you already have added %s before' % name
|
||||||
opt[1][name] = {}
|
opt[1][name] = {}
|
||||||
for o in opt[0]:
|
for o in opt[0]:
|
||||||
opt[1][name][o] = opt[0][o][OPT_VAL]
|
opt[1][name][o] = opt[0][o][Option.VAL]
|
||||||
self._timeout_save()
|
self._timeout_save()
|
||||||
|
|
||||||
def del_per(self, typename, name, subname = None): # per_group_of_option
|
def del_per(self, typename, name, subname = None): # per_group_of_option
|
||||||
|
@ -705,7 +705,7 @@ class Config:
|
||||||
obj = dict_[key]
|
obj = dict_[key]
|
||||||
if subname not in obj:
|
if subname not in obj:
|
||||||
return
|
return
|
||||||
typ = self.__options_per_key[optname][0][subname][OPT_TYPE]
|
typ = self.__options_per_key[optname][0][subname][Option.TYPE]
|
||||||
value = self.is_valid(typ, value)
|
value = self.is_valid(typ, value)
|
||||||
if value is None:
|
if value is None:
|
||||||
return
|
return
|
||||||
|
@ -735,7 +735,7 @@ class Config:
|
||||||
dict_ = self.__options_per_key[optname][0]
|
dict_ = self.__options_per_key[optname][0]
|
||||||
if subname not in dict_:
|
if subname not in dict_:
|
||||||
return None
|
return None
|
||||||
return dict_[subname][OPT_VAL]
|
return dict_[subname][Option.VAL]
|
||||||
|
|
||||||
def get_type_per(self, optname, subname):
|
def get_type_per(self, optname, subname):
|
||||||
if optname not in self.__options_per_key:
|
if optname not in self.__options_per_key:
|
||||||
|
@ -743,7 +743,7 @@ class Config:
|
||||||
dict_ = self.__options_per_key[optname][0]
|
dict_ = self.__options_per_key[optname][0]
|
||||||
if subname not in dict_:
|
if subname not in dict_:
|
||||||
return None
|
return None
|
||||||
return dict_[subname][OPT_TYPE][0]
|
return dict_[subname][Option.TYPE][0]
|
||||||
|
|
||||||
def get_desc_per(self, optname, key=None, subname=None):
|
def get_desc_per(self, optname, key=None, subname=None):
|
||||||
if optname not in self.__options_per_key:
|
if optname not in self.__options_per_key:
|
||||||
|
@ -758,8 +758,8 @@ class Config:
|
||||||
return None
|
return None
|
||||||
if subname not in obj:
|
if subname not in obj:
|
||||||
return None
|
return None
|
||||||
if len(obj[subname]) > OPT_DESC:
|
if len(obj[subname]) > Option.DESC:
|
||||||
return obj[subname][OPT_DESC]
|
return obj[subname][Option.DESC]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_restart_per(self, optname, key=None, subname=None):
|
def get_restart_per(self, optname, key=None, subname=None):
|
||||||
|
@ -775,8 +775,8 @@ class Config:
|
||||||
return False
|
return False
|
||||||
if subname not in obj:
|
if subname not in obj:
|
||||||
return False
|
return False
|
||||||
if len(obj[subname]) > OPT_RESTART:
|
if len(obj[subname]) > Option.RESTART:
|
||||||
return obj[subname][OPT_RESTART]
|
return obj[subname][Option.RESTART]
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def should_log(self, account, jid):
|
def should_log(self, account, jid):
|
||||||
|
@ -794,7 +794,7 @@ class Config:
|
||||||
|
|
||||||
def _init_options(self):
|
def _init_options(self):
|
||||||
for opt in self.__options[0]:
|
for opt in self.__options[0]:
|
||||||
self.__options[1][opt] = self.__options[0][opt][OPT_VAL]
|
self.__options[1][opt] = self.__options[0][opt][Option.VAL]
|
||||||
|
|
||||||
def _really_save(self):
|
def _really_save(self):
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
|
|
@ -26,12 +26,12 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from common import defs
|
from common import defs
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
(
|
class Type(Enum):
|
||||||
TYPE_CONFIG,
|
CONFIG = 0
|
||||||
TYPE_CACHE,
|
CACHE = 1
|
||||||
TYPE_DATA
|
DATA = 2
|
||||||
) = range(3)
|
|
||||||
|
|
||||||
# Note on path and filename encodings:
|
# Note on path and filename encodings:
|
||||||
#
|
#
|
||||||
|
@ -65,7 +65,7 @@ def get(key):
|
||||||
|
|
||||||
class ConfigPaths:
|
class ConfigPaths:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
# {'name': (type, path), } type can be TYPE_CONFIG, TYPE_CACHE, TYPE_DATA
|
# {'name': (type, path), } type can be Type.CONFIG, Type.CACHE, Type.DATA
|
||||||
# or None
|
# or None
|
||||||
self.paths = {}
|
self.paths = {}
|
||||||
|
|
||||||
|
@ -109,11 +109,11 @@ class ConfigPaths:
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
type_, path = self.paths[key]
|
type_, path = self.paths[key]
|
||||||
if type_ == TYPE_CONFIG:
|
if type_ == Type.CONFIG:
|
||||||
return os.path.join(self.config_root, path)
|
return os.path.join(self.config_root, path)
|
||||||
elif type_ == TYPE_CACHE:
|
elif type_ == Type.CACHE:
|
||||||
return os.path.join(self.cache_root, path)
|
return os.path.join(self.cache_root, path)
|
||||||
elif type_ == TYPE_DATA:
|
elif type_ == Type.DATA:
|
||||||
return os.path.join(self.data_root, path)
|
return os.path.join(self.data_root, path)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
@ -145,26 +145,26 @@ class ConfigPaths:
|
||||||
'RNG_SEED': 'rng_seed'}
|
'RNG_SEED': 'rng_seed'}
|
||||||
for name in d:
|
for name in d:
|
||||||
d[name] += profile
|
d[name] += profile
|
||||||
self.add(name, TYPE_DATA, windowsify(d[name]))
|
self.add(name, Type.DATA, windowsify(d[name]))
|
||||||
if len(profile):
|
if len(profile):
|
||||||
self.add('MY_DATA', TYPE_DATA, 'data.dir')
|
self.add('MY_DATA', Type.DATA, 'data.dir')
|
||||||
else:
|
else:
|
||||||
self.add('MY_DATA', TYPE_DATA, '')
|
self.add('MY_DATA', Type.DATA, '')
|
||||||
|
|
||||||
d = {'CACHE_DB': 'cache.db', 'VCARD': 'vcards',
|
d = {'CACHE_DB': 'cache.db', 'VCARD': 'vcards',
|
||||||
'AVATAR': 'avatars'}
|
'AVATAR': 'avatars'}
|
||||||
for name in d:
|
for name in d:
|
||||||
d[name] += profile
|
d[name] += profile
|
||||||
self.add(name, TYPE_CACHE, windowsify(d[name]))
|
self.add(name, Type.CACHE, windowsify(d[name]))
|
||||||
if len(profile):
|
if len(profile):
|
||||||
self.add('MY_CACHE', TYPE_CACHE, 'cache.dir')
|
self.add('MY_CACHE', Type.CACHE, 'cache.dir')
|
||||||
else:
|
else:
|
||||||
self.add('MY_CACHE', TYPE_CACHE, '')
|
self.add('MY_CACHE', Type.CACHE, '')
|
||||||
|
|
||||||
if len(profile):
|
if len(profile):
|
||||||
self.add('MY_CONFIG', TYPE_CONFIG, 'config.dir')
|
self.add('MY_CONFIG', Type.CONFIG, 'config.dir')
|
||||||
else:
|
else:
|
||||||
self.add('MY_CONFIG', TYPE_CONFIG, '')
|
self.add('MY_CONFIG', Type.CONFIG, '')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.add('TMP', None, tempfile.gettempdir())
|
self.add('TMP', None, tempfile.gettempdir())
|
||||||
|
@ -187,10 +187,10 @@ class ConfigPaths:
|
||||||
certsdir += u'.' + profile
|
certsdir += u'.' + profile
|
||||||
localcertsdir += u'.' + profile
|
localcertsdir += u'.' + profile
|
||||||
|
|
||||||
self.add('SECRETS_FILE', TYPE_DATA, secretsfile)
|
self.add('SECRETS_FILE', Type.DATA, secretsfile)
|
||||||
self.add('MY_PEER_CERTS', TYPE_DATA, certsdir)
|
self.add('MY_PEER_CERTS', Type.DATA, certsdir)
|
||||||
self.add('CONFIG_FILE', TYPE_CONFIG, conffile)
|
self.add('CONFIG_FILE', Type.CONFIG, conffile)
|
||||||
self.add('PLUGINS_CONFIG_DIR', TYPE_CONFIG, pluginsconfdir)
|
self.add('PLUGINS_CONFIG_DIR', Type.CONFIG, pluginsconfdir)
|
||||||
self.add('MY_CERT', TYPE_CONFIG, localcertsdir)
|
self.add('MY_CERT', Type.CONFIG, localcertsdir)
|
||||||
|
|
||||||
gajimpaths = ConfigPaths()
|
gajimpaths = ConfigPaths()
|
||||||
|
|
|
@ -35,6 +35,7 @@ import nbxmpp
|
||||||
from common import dataforms
|
from common import dataforms
|
||||||
from common import exceptions
|
from common import exceptions
|
||||||
from common.zeroconf import zeroconf
|
from common.zeroconf import zeroconf
|
||||||
|
from common.zeroconf.zeroconf import Constant
|
||||||
from common.logger import LOG_DB_PATH
|
from common.logger import LOG_DB_PATH
|
||||||
from common.pep import SUPPORTED_PERSONAL_USER_EVENTS
|
from common.pep import SUPPORTED_PERSONAL_USER_EVENTS
|
||||||
from nbxmpp.protocol import NS_CHATSTATES
|
from nbxmpp.protocol import NS_CHATSTATES
|
||||||
|
@ -1328,7 +1329,7 @@ class ZeroconfMessageReceivedEvent(MessageReceivedEvent):
|
||||||
if self.fjid is None:
|
if self.fjid is None:
|
||||||
for key in self.conn.connection.zeroconf.contacts:
|
for key in self.conn.connection.zeroconf.contacts:
|
||||||
if self.ip == self.conn.connection.zeroconf.contacts[key][
|
if self.ip == self.conn.connection.zeroconf.contacts[key][
|
||||||
zeroconf.C_ADDRESS]:
|
Constant.ADDRESS]:
|
||||||
self.fjid = key
|
self.fjid = key
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import nbxmpp
|
||||||
import socket
|
import socket
|
||||||
from common import gajim
|
from common import gajim
|
||||||
import logging
|
import logging
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
log = logging.getLogger('gajim.c.jingle_transport')
|
log = logging.getLogger('gajim.c.jingle_transport')
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ def get_jingle_transport(node):
|
||||||
return transports[namespace](node)
|
return transports[namespace](node)
|
||||||
|
|
||||||
|
|
||||||
class TransportType(object):
|
class TransportType(IntEnum):
|
||||||
"""
|
"""
|
||||||
Possible types of a JingleTransport
|
Possible types of a JingleTransport
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -36,6 +36,7 @@ import json
|
||||||
from gzip import GzipFile
|
from gzip import GzipFile
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
from common import exceptions
|
from common import exceptions
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
@ -50,59 +51,50 @@ CACHE_DB_PATH = gajim.gajimpaths['CACHE_DB']
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger('gajim.c.logger')
|
log = logging.getLogger('gajim.c.logger')
|
||||||
|
|
||||||
class Constants:
|
class JIDConstant(IntEnum):
|
||||||
def __init__(self):
|
NORMAL_TYPE = 0
|
||||||
(
|
ROOM_TYPE = 1
|
||||||
self.JID_NORMAL_TYPE,
|
|
||||||
self.JID_ROOM_TYPE
|
|
||||||
) = range(2)
|
|
||||||
|
|
||||||
(
|
class KindConstant(IntEnum):
|
||||||
self.KIND_STATUS,
|
STATUS = 0
|
||||||
self.KIND_GCSTATUS,
|
GCSTATUS = 1
|
||||||
self.KIND_GC_MSG,
|
GC_MSG = 2
|
||||||
self.KIND_SINGLE_MSG_RECV,
|
SINGLE_MSG_RECV = 3
|
||||||
self.KIND_CHAT_MSG_RECV,
|
CHAT_MSG_RECV = 4
|
||||||
self.KIND_SINGLE_MSG_SENT,
|
SINGLE_MSG_SENT = 5
|
||||||
self.KIND_CHAT_MSG_SENT,
|
CHAT_MSG_SENT = 6
|
||||||
self.KIND_ERROR
|
ERROR = 7
|
||||||
) = range(8)
|
|
||||||
|
|
||||||
(
|
class ShowConstant(IntEnum):
|
||||||
self.SHOW_ONLINE,
|
ONLINE = 0
|
||||||
self.SHOW_CHAT,
|
CHAT = 1
|
||||||
self.SHOW_AWAY,
|
AWAY = 2
|
||||||
self.SHOW_XA,
|
XA = 3
|
||||||
self.SHOW_DND,
|
DND = 4
|
||||||
self.SHOW_OFFLINE
|
OFFLINE = 5
|
||||||
) = range(6)
|
|
||||||
|
|
||||||
(
|
class TypeConstant(IntEnum):
|
||||||
self.TYPE_AIM,
|
AIM = 0
|
||||||
self.TYPE_GG,
|
GG = 1
|
||||||
self.TYPE_HTTP_WS,
|
HTTP_WS = 2
|
||||||
self.TYPE_ICQ,
|
ICQ = 3
|
||||||
self.TYPE_MSN,
|
MSN = 4
|
||||||
self.TYPE_QQ,
|
QQ = 5
|
||||||
self.TYPE_SMS,
|
SMS = 6
|
||||||
self.TYPE_SMTP,
|
SMTP = 7
|
||||||
self.TYPE_TLEN,
|
TLEN = 8
|
||||||
self.TYPE_YAHOO,
|
YAHOO = 9
|
||||||
self.TYPE_NEWMAIL,
|
NEWMAIL = 10
|
||||||
self.TYPE_RSS,
|
RSS = 11
|
||||||
self.TYPE_WEATHER,
|
WEATHER = 12
|
||||||
self.TYPE_MRIM,
|
MRIM = 13
|
||||||
self.TYPE_NO_TRANSPORT,
|
NO_TRANSPORT = 14
|
||||||
) = range(15)
|
|
||||||
|
|
||||||
(
|
class SubscriptionConstant(IntEnum):
|
||||||
self.SUBSCRIPTION_NONE,
|
NONE = 0
|
||||||
self.SUBSCRIPTION_TO,
|
TO = 1
|
||||||
self.SUBSCRIPTION_FROM,
|
FROM = 2
|
||||||
self.SUBSCRIPTION_BOTH,
|
BOTH = 3
|
||||||
) = range(4)
|
|
||||||
|
|
||||||
constants = Constants()
|
|
||||||
|
|
||||||
class Logger:
|
class Logger:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -231,7 +223,7 @@ class Logger:
|
||||||
if row is None:
|
if row is None:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
if row[0] == constants.JID_ROOM_TYPE:
|
if row[0] == JIDConstant.ROOM_TYPE:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -255,9 +247,9 @@ class Logger:
|
||||||
return row[0]
|
return row[0]
|
||||||
# oh! a new jid :), we add it now
|
# oh! a new jid :), we add it now
|
||||||
if typestr == 'ROOM':
|
if typestr == 'ROOM':
|
||||||
typ = constants.JID_ROOM_TYPE
|
typ = JIDConstant.ROOM_TYPE
|
||||||
else:
|
else:
|
||||||
typ = constants.JID_NORMAL_TYPE
|
typ = JIDConstant.NORMAL_TYPE
|
||||||
try:
|
try:
|
||||||
self.cur.execute('INSERT INTO jids (jid, type) VALUES (?, ?)', (jid,
|
self.cur.execute('INSERT INTO jids (jid, type) VALUES (?, ?)', (jid,
|
||||||
typ))
|
typ))
|
||||||
|
@ -277,34 +269,34 @@ class Logger:
|
||||||
Convert from string style to constant ints for db
|
Convert from string style to constant ints for db
|
||||||
"""
|
"""
|
||||||
if kind == 'status':
|
if kind == 'status':
|
||||||
kind_col = constants.KIND_STATUS
|
kind_col = KindConstant.STATUS
|
||||||
elif kind == 'gcstatus':
|
elif kind == 'gcstatus':
|
||||||
kind_col = constants.KIND_GCSTATUS
|
kind_col = KindConstant.GCSTATUS
|
||||||
elif kind == 'gc_msg':
|
elif kind == 'gc_msg':
|
||||||
kind_col = constants.KIND_GC_MSG
|
kind_col = KindConstant.GC_MSG
|
||||||
elif kind == 'single_msg_recv':
|
elif kind == 'single_msg_recv':
|
||||||
kind_col = constants.KIND_SINGLE_MSG_RECV
|
kind_col = KindConstant.SINGLE_MSG_RECV
|
||||||
elif kind == 'single_msg_sent':
|
elif kind == 'single_msg_sent':
|
||||||
kind_col = constants.KIND_SINGLE_MSG_SENT
|
kind_col = KindConstant.SINGLE_MSG_SENT
|
||||||
elif kind == 'chat_msg_recv':
|
elif kind == 'chat_msg_recv':
|
||||||
kind_col = constants.KIND_CHAT_MSG_RECV
|
kind_col = KindConstant.CHAT_MSG_RECV
|
||||||
elif kind == 'chat_msg_sent':
|
elif kind == 'chat_msg_sent':
|
||||||
kind_col = constants.KIND_CHAT_MSG_SENT
|
kind_col = KindConstant.CHAT_MSG_SENT
|
||||||
elif kind == 'error':
|
elif kind == 'error':
|
||||||
kind_col = constants.KIND_ERROR
|
kind_col = KindConstant.ERROR
|
||||||
|
|
||||||
if show == 'online':
|
if show == 'online':
|
||||||
show_col = constants.SHOW_ONLINE
|
show_col = ShowConstant.ONLINE
|
||||||
elif show == 'chat':
|
elif show == 'chat':
|
||||||
show_col = constants.SHOW_CHAT
|
show_col = ShowConstant.CHAT
|
||||||
elif show == 'away':
|
elif show == 'away':
|
||||||
show_col = constants.SHOW_AWAY
|
show_col = ShowConstant.AWAY
|
||||||
elif show == 'xa':
|
elif show == 'xa':
|
||||||
show_col = constants.SHOW_XA
|
show_col = ShowConstant.XA
|
||||||
elif show == 'dnd':
|
elif show == 'dnd':
|
||||||
show_col = constants.SHOW_DND
|
show_col = ShowConstant.DND
|
||||||
elif show == 'offline':
|
elif show == 'offline':
|
||||||
show_col = constants.SHOW_OFFLINE
|
show_col = ShowConstant.OFFLINE
|
||||||
elif show is None:
|
elif show is None:
|
||||||
show_col = None
|
show_col = None
|
||||||
else: # invisible in GC when someone goes invisible
|
else: # invisible in GC when someone goes invisible
|
||||||
|
@ -318,70 +310,70 @@ class Logger:
|
||||||
Convert from string style to constant ints for db
|
Convert from string style to constant ints for db
|
||||||
"""
|
"""
|
||||||
if type_ == 'aim':
|
if type_ == 'aim':
|
||||||
return constants.TYPE_AIM
|
return TypeConstant.AIM
|
||||||
if type_ == 'gadu-gadu':
|
if type_ == 'gadu-gadu':
|
||||||
return constants.TYPE_GG
|
return TypeConstant.GG
|
||||||
if type_ == 'http-ws':
|
if type_ == 'http-ws':
|
||||||
return constants.TYPE_HTTP_WS
|
return TypeConstant.HTTP_WS
|
||||||
if type_ == 'icq':
|
if type_ == 'icq':
|
||||||
return constants.TYPE_ICQ
|
return TypeConstant.ICQ
|
||||||
if type_ == 'msn':
|
if type_ == 'msn':
|
||||||
return constants.TYPE_MSN
|
return TypeConstant.MSN
|
||||||
if type_ == 'qq':
|
if type_ == 'qq':
|
||||||
return constants.TYPE_QQ
|
return TypeConstant.QQ
|
||||||
if type_ == 'sms':
|
if type_ == 'sms':
|
||||||
return constants.TYPE_SMS
|
return TypeConstant.SMS
|
||||||
if type_ == 'smtp':
|
if type_ == 'smtp':
|
||||||
return constants.TYPE_SMTP
|
return TypeConstant.SMTP
|
||||||
if type_ in ('tlen', 'x-tlen'):
|
if type_ in ('tlen', 'x-tlen'):
|
||||||
return constants.TYPE_TLEN
|
return TypeConstant.TLEN
|
||||||
if type_ == 'yahoo':
|
if type_ == 'yahoo':
|
||||||
return constants.TYPE_YAHOO
|
return TypeConstant.YAHOO
|
||||||
if type_ == 'newmail':
|
if type_ == 'newmail':
|
||||||
return constants.TYPE_NEWMAIL
|
return TypeConstant.NEWMAIL
|
||||||
if type_ == 'rss':
|
if type_ == 'rss':
|
||||||
return constants.TYPE_RSS
|
return TypeConstant.RSS
|
||||||
if type_ == 'weather':
|
if type_ == 'weather':
|
||||||
return constants.TYPE_WEATHER
|
return TypeConstant.WEATHER
|
||||||
if type_ == 'mrim':
|
if type_ == 'mrim':
|
||||||
return constants.TYPE_MRIM
|
return TypeConstant.MRIM
|
||||||
if type_ == 'jabber':
|
if type_ == 'jabber':
|
||||||
return constants.TYPE_NO_TRANSPORT
|
return TypeConstant.NO_TRANSPORT
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def convert_api_values_to_human_transport_type(self, type_id):
|
def convert_api_values_to_human_transport_type(self, type_id):
|
||||||
"""
|
"""
|
||||||
Convert from constant ints for db to string style
|
Convert from constant ints for db to string style
|
||||||
"""
|
"""
|
||||||
if type_id == constants.TYPE_AIM:
|
if type_id == TypeConstant.AIM:
|
||||||
return 'aim'
|
return 'aim'
|
||||||
if type_id == constants.TYPE_GG:
|
if type_id == TypeConstant.GG:
|
||||||
return 'gadu-gadu'
|
return 'gadu-gadu'
|
||||||
if type_id == constants.TYPE_HTTP_WS:
|
if type_id == TypeConstant.HTTP_WS:
|
||||||
return 'http-ws'
|
return 'http-ws'
|
||||||
if type_id == constants.TYPE_ICQ:
|
if type_id == TypeConstant.ICQ:
|
||||||
return 'icq'
|
return 'icq'
|
||||||
if type_id == constants.TYPE_MSN:
|
if type_id == TypeConstant.MSN:
|
||||||
return 'msn'
|
return 'msn'
|
||||||
if type_id == constants.TYPE_QQ:
|
if type_id == TypeConstant.QQ:
|
||||||
return 'qq'
|
return 'qq'
|
||||||
if type_id == constants.TYPE_SMS:
|
if type_id == TypeConstant.SMS:
|
||||||
return 'sms'
|
return 'sms'
|
||||||
if type_id == constants.TYPE_SMTP:
|
if type_id == TypeConstant.SMTP:
|
||||||
return 'smtp'
|
return 'smtp'
|
||||||
if type_id == constants.TYPE_TLEN:
|
if type_id == TypeConstant.TLEN:
|
||||||
return 'tlen'
|
return 'tlen'
|
||||||
if type_id == constants.TYPE_YAHOO:
|
if type_id == TypeConstant.YAHOO:
|
||||||
return 'yahoo'
|
return 'yahoo'
|
||||||
if type_id == constants.TYPE_NEWMAIL:
|
if type_id == TypeConstant.NEWMAIL:
|
||||||
return 'newmail'
|
return 'newmail'
|
||||||
if type_id == constants.TYPE_RSS:
|
if type_id == TypeConstant.RSS:
|
||||||
return 'rss'
|
return 'rss'
|
||||||
if type_id == constants.TYPE_WEATHER:
|
if type_id == TypeConstant.WEATHER:
|
||||||
return 'weather'
|
return 'weather'
|
||||||
if type_id == constants.TYPE_MRIM:
|
if type_id == TypeConstant.MRIM:
|
||||||
return 'mrim'
|
return 'mrim'
|
||||||
if type_id == constants.TYPE_NO_TRANSPORT:
|
if type_id == TypeConstant.NO_TRANSPORT:
|
||||||
return 'jabber'
|
return 'jabber'
|
||||||
|
|
||||||
def convert_human_subscription_values_to_db_api_values(self, sub):
|
def convert_human_subscription_values_to_db_api_values(self, sub):
|
||||||
|
@ -389,25 +381,25 @@ class Logger:
|
||||||
Convert from string style to constant ints for db
|
Convert from string style to constant ints for db
|
||||||
"""
|
"""
|
||||||
if sub == 'none':
|
if sub == 'none':
|
||||||
return constants.SUBSCRIPTION_NONE
|
return SubscriptionConstant.NONE
|
||||||
if sub == 'to':
|
if sub == 'to':
|
||||||
return constants.SUBSCRIPTION_TO
|
return SubscriptionConstant.TO
|
||||||
if sub == 'from':
|
if sub == 'from':
|
||||||
return constants.SUBSCRIPTION_FROM
|
return SubscriptionConstant.FROM
|
||||||
if sub == 'both':
|
if sub == 'both':
|
||||||
return constants.SUBSCRIPTION_BOTH
|
return SubscriptionConstant.BOTH
|
||||||
|
|
||||||
def convert_db_api_values_to_human_subscription_values(self, sub):
|
def convert_db_api_values_to_human_subscription_values(self, sub):
|
||||||
"""
|
"""
|
||||||
Convert from constant ints for db to string style
|
Convert from constant ints for db to string style
|
||||||
"""
|
"""
|
||||||
if sub == constants.SUBSCRIPTION_NONE:
|
if sub == SubscriptionConstant.NONE:
|
||||||
return 'none'
|
return 'none'
|
||||||
if sub == constants.SUBSCRIPTION_TO:
|
if sub == SubscriptionConstant.TO:
|
||||||
return 'to'
|
return 'to'
|
||||||
if sub == constants.SUBSCRIPTION_FROM:
|
if sub == SubscriptionConstant.FROM:
|
||||||
return 'from'
|
return 'from'
|
||||||
if sub == constants.SUBSCRIPTION_BOTH:
|
if sub == SubscriptionConstant.BOTH:
|
||||||
return 'both'
|
return 'both'
|
||||||
|
|
||||||
def commit_to_db(self, values, write_unread=False):
|
def commit_to_db(self, values, write_unread=False):
|
||||||
|
@ -539,12 +531,12 @@ class Logger:
|
||||||
except exceptions.PysqliteOperationalError as e:
|
except exceptions.PysqliteOperationalError as e:
|
||||||
raise exceptions.PysqliteOperationalError(str(e))
|
raise exceptions.PysqliteOperationalError(str(e))
|
||||||
if show is None: # show is None (xmpp), but we say that 'online'
|
if show is None: # show is None (xmpp), but we say that 'online'
|
||||||
show_col = constants.SHOW_ONLINE
|
show_col = ShowConstant.ONLINE
|
||||||
|
|
||||||
elif kind == 'gcstatus':
|
elif kind == 'gcstatus':
|
||||||
# status in ROOM (for pm status see status)
|
# status in ROOM (for pm status see status)
|
||||||
if show is None: # show is None (xmpp), but we say that 'online'
|
if show is None: # show is None (xmpp), but we say that 'online'
|
||||||
show_col = constants.SHOW_ONLINE
|
show_col = ShowConstant.ONLINE
|
||||||
jid, nick = jid.split('/', 1)
|
jid, nick = jid.split('/', 1)
|
||||||
try:
|
try:
|
||||||
# re-get jid_id for the new jid
|
# re-get jid_id for the new jid
|
||||||
|
@ -608,9 +600,9 @@ class Logger:
|
||||||
SELECT time, kind, message, subject, additional_data FROM logs
|
SELECT time, kind, message, subject, additional_data FROM logs
|
||||||
WHERE (%s) AND kind IN (%d, %d, %d, %d, %d) AND time > %d
|
WHERE (%s) AND kind IN (%d, %d, %d, %d, %d) AND time > %d
|
||||||
ORDER BY time DESC LIMIT %d OFFSET %d
|
ORDER BY time DESC LIMIT %d OFFSET %d
|
||||||
''' % (where_sql, constants.KIND_SINGLE_MSG_RECV,
|
''' % (where_sql, KindConstant.SINGLE_MSG_RECV,
|
||||||
constants.KIND_CHAT_MSG_RECV, constants.KIND_SINGLE_MSG_SENT,
|
KindConstant.CHAT_MSG_RECV, KindConstant.SINGLE_MSG_SENT,
|
||||||
constants.KIND_CHAT_MSG_SENT, constants.KIND_ERROR, timed_out,
|
KindConstant.CHAT_MSG_SENT, KindConstant.ERROR, timed_out,
|
||||||
restore_how_many_rows, pending_how_many), jid_tuple)
|
restore_how_many_rows, pending_how_many), jid_tuple)
|
||||||
|
|
||||||
results = self.cur.fetchall()
|
results = self.cur.fetchall()
|
||||||
|
@ -736,7 +728,7 @@ class Logger:
|
||||||
AND kind NOT IN (%d, %d)
|
AND kind NOT IN (%d, %d)
|
||||||
ORDER BY time
|
ORDER BY time
|
||||||
''' % (where_sql, start_of_month, last_second_of_month,
|
''' % (where_sql, start_of_month, last_second_of_month,
|
||||||
constants.KIND_STATUS, constants.KIND_GCSTATUS), jid_tuple)
|
KindConstant.STATUS, KindConstant.GCSTATUS), jid_tuple)
|
||||||
result = self.cur.fetchall()
|
result = self.cur.fetchall()
|
||||||
|
|
||||||
# convert timestamps to day of month
|
# convert timestamps to day of month
|
||||||
|
@ -765,7 +757,7 @@ class Logger:
|
||||||
SELECT MAX(time) FROM logs
|
SELECT MAX(time) FROM logs
|
||||||
WHERE (%s)
|
WHERE (%s)
|
||||||
AND kind NOT IN (%d, %d)
|
AND kind NOT IN (%d, %d)
|
||||||
''' % (where_sql, constants.KIND_STATUS, constants.KIND_GCSTATUS),
|
''' % (where_sql, KindConstant.STATUS, KindConstant.GCSTATUS),
|
||||||
jid_tuple)
|
jid_tuple)
|
||||||
|
|
||||||
results = self.cur.fetchone()
|
results = self.cur.fetchone()
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
|
|
||||||
from common.zeroconf import zeroconf
|
from common.zeroconf import zeroconf
|
||||||
|
from common.zeroconf.zeroconf import Constant, ConstantRI
|
||||||
|
|
||||||
class Roster:
|
class Roster:
|
||||||
def __init__(self, zeroconf):
|
def __init__(self, zeroconf):
|
||||||
|
@ -29,7 +30,7 @@ class Roster:
|
||||||
|
|
||||||
def update_roster(self):
|
def update_roster(self):
|
||||||
for val in self.zeroconf.contacts.values():
|
for val in self.zeroconf.contacts.values():
|
||||||
self.setItem(val[zeroconf.C_NAME])
|
self.setItem(val[Constant.NAME])
|
||||||
|
|
||||||
def getRoster(self):
|
def getRoster(self):
|
||||||
if self._data is None:
|
if self._data is None:
|
||||||
|
@ -58,13 +59,13 @@ class Roster:
|
||||||
|
|
||||||
addresses = []
|
addresses = []
|
||||||
i = 0
|
i = 0
|
||||||
for ri in contact[zeroconf.C_RESOLVED_INFO]:
|
for ri in contact[Constant.RESOLVED_INFO]:
|
||||||
addresses += [{}]
|
addresses += [{}]
|
||||||
addresses[i]['host'] = ri[zeroconf.C_RI_HOST]
|
addresses[i]['host'] = ri[ConstantRI.HOST]
|
||||||
addresses[i]['address'] = ri[zeroconf.C_RI_ADDRESS]
|
addresses[i]['address'] = ri[ConstantRI.ADDRESS]
|
||||||
addresses[i]['port'] = ri[zeroconf.C_RI_PORT]
|
addresses[i]['port'] = ri[ConstantRI.PORT]
|
||||||
i += 1
|
i += 1
|
||||||
txt = contact[zeroconf.C_TXT]
|
txt = contact[Constant.TXT]
|
||||||
|
|
||||||
self._data[jid]={}
|
self._data[jid]={}
|
||||||
self._data[jid]['ask'] = 'none'
|
self._data[jid]['ask'] = 'none'
|
||||||
|
|
|
@ -17,8 +17,22 @@
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
##
|
##
|
||||||
|
|
||||||
C_NAME, C_DOMAIN, C_RESOLVED_INFO, C_BARE_NAME, C_TXT = range(5)
|
from enum import IntEnum
|
||||||
C_RI_INTERFACE, C_RI_PROTOCOL, C_RI_HOST, C_RI_APROTOCOL, C_RI_ADDRESS, C_RI_PORT = range(6)
|
|
||||||
|
class Constant(IntEnum):
|
||||||
|
NAME = 0
|
||||||
|
DOMAIN = 1
|
||||||
|
RESOLVED_INFO = 2
|
||||||
|
BARE_NAME = 3
|
||||||
|
TXT = 4
|
||||||
|
|
||||||
|
class ConstantRI(IntEnum):
|
||||||
|
INTERFACE = 0
|
||||||
|
PROTOCOL = 1
|
||||||
|
HOST = 2
|
||||||
|
APROTOCOL = 3
|
||||||
|
ADDRESS = 4
|
||||||
|
PORT = 5
|
||||||
|
|
||||||
def test_avahi():
|
def test_avahi():
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -25,8 +25,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
from common.zeroconf.zeroconf import C_BARE_NAME, C_RESOLVED_INFO, \
|
from common.zeroconf.zeroconf import Constant, ConstantRI
|
||||||
C_RI_INTERFACE, C_RI_PROTOCOL, C_DOMAIN, C_TXT
|
|
||||||
|
|
||||||
class Zeroconf:
|
class Zeroconf:
|
||||||
def __init__(self, new_serviceCB, remove_serviceCB, name_conflictCB,
|
def __init__(self, new_serviceCB, remove_serviceCB, name_conflictCB,
|
||||||
|
@ -95,15 +94,15 @@ class Zeroconf:
|
||||||
if name != self.name:
|
if name != self.name:
|
||||||
for key in self.contacts.keys():
|
for key in self.contacts.keys():
|
||||||
val = self.contacts[key]
|
val = self.contacts[key]
|
||||||
if val[C_BARE_NAME] == name:
|
if val[Constant.BARE_NAME] == name:
|
||||||
# try to reduce instead of delete first
|
# try to reduce instead of delete first
|
||||||
resolved_info = val[C_RESOLVED_INFO]
|
resolved_info = val[Constant.RESOLVED_INFO]
|
||||||
if len(resolved_info) > 1:
|
if len(resolved_info) > 1:
|
||||||
for i in range(len(resolved_info)):
|
for i in range(len(resolved_info)):
|
||||||
if resolved_info[i][C_RI_INTERFACE] == interface and resolved_info[i][C_RI_PROTOCOL] == protocol:
|
if resolved_info[i][ConstantRI.INTERFACE] == interface and resolved_info[i][ConstantRI.PROTOCOL] == protocol:
|
||||||
del self.contacts[key][C_RESOLVED_INFO][i]
|
del self.contacts[key][Constant.RESOLVED_INFO][i]
|
||||||
# if still something left, don't remove
|
# if still something left, don't remove
|
||||||
if len(self.contacts[key][C_RESOLVED_INFO]) > 1: return
|
if len(self.contacts[key][Constant.RESOLVED_INFO]) > 1: return
|
||||||
del self.contacts[key]
|
del self.contacts[key]
|
||||||
self.remove_serviceCB(key)
|
self.remove_serviceCB(key)
|
||||||
return
|
return
|
||||||
|
@ -201,7 +200,7 @@ class Zeroconf:
|
||||||
name = name + '@' + name
|
name = name + '@' + name
|
||||||
# update TXT data only, as intended according to resolve_all comment
|
# update TXT data only, as intended according to resolve_all comment
|
||||||
old_contact = self.contacts[name]
|
old_contact = self.contacts[name]
|
||||||
self.contacts[name] = old_contact[0:C_TXT] + (txt,) + old_contact[C_TXT+1:]
|
self.contacts[name] = old_contact[0:Constant.TXT] + (txt,) + old_contact[Constant.TXT+1:]
|
||||||
|
|
||||||
def service_added_callback(self):
|
def service_added_callback(self):
|
||||||
log.debug('Service successfully added')
|
log.debug('Service successfully added')
|
||||||
|
@ -450,9 +449,9 @@ class Zeroconf:
|
||||||
for val in self.contacts.values():
|
for val in self.contacts.values():
|
||||||
# get txt data from last recorded resolved info
|
# get txt data from last recorded resolved info
|
||||||
# TODO: Better try to get it from last IPv6 mDNS, then last IPv4?
|
# TODO: Better try to get it from last IPv6 mDNS, then last IPv4?
|
||||||
ri = val[C_RESOLVED_INFO][0]
|
ri = val[Constant.RESOLVED_INFO][0]
|
||||||
self.server.ResolveService(int(ri[C_RI_INTERFACE]), int(ri[C_RI_PROTOCOL]),
|
self.server.ResolveService(int(ri[ConstantRI.INTERFACE]), int(ri[ConstantRI.PROTOCOL]),
|
||||||
val[C_BARE_NAME], self.stype, val[C_DOMAIN],
|
val[Constant.BARE_NAME], self.stype, val[Constant.DOMAIN],
|
||||||
self.avahi.PROTO_UNSPEC, dbus.UInt32(0),
|
self.avahi.PROTO_UNSPEC, dbus.UInt32(0),
|
||||||
reply_handler=self.service_resolved_all_callback,
|
reply_handler=self.service_resolved_all_callback,
|
||||||
error_handler=self.error_callback)
|
error_handler=self.error_callback)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
from common import gajim
|
from common import gajim
|
||||||
import select
|
import select
|
||||||
import re
|
import re
|
||||||
from common.zeroconf.zeroconf import C_BARE_NAME, C_DOMAIN, C_TXT
|
from common.zeroconf.zeroconf import Constant
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pybonjour
|
import pybonjour
|
||||||
|
@ -86,7 +86,7 @@ class Zeroconf:
|
||||||
return
|
return
|
||||||
if name != self.name:
|
if name != self.name:
|
||||||
for key in self.contacts.keys():
|
for key in self.contacts.keys():
|
||||||
if self.contacts[key][C_BARE_NAME] == name:
|
if self.contacts[key][Constant.BARE_NAME] == name:
|
||||||
del self.contacts[key]
|
del self.contacts[key]
|
||||||
self.remove_serviceCB(key)
|
self.remove_serviceCB(key)
|
||||||
return
|
return
|
||||||
|
@ -171,7 +171,7 @@ class Zeroconf:
|
||||||
if name != self.name:
|
if name != self.name:
|
||||||
# update TXT data only, as intended according to resolve_all comment
|
# update TXT data only, as intended according to resolve_all comment
|
||||||
old_contact = self.contacts[name]
|
old_contact = self.contacts[name]
|
||||||
self.contacts[name] = old_contact[0:C_TXT] + (self.txt,) + old_contact[C_TXT+1:]
|
self.contacts[name] = old_contact[0:Constant.TXT] + (self.txt,) + old_contact[Constant.TXT+1:]
|
||||||
|
|
||||||
|
|
||||||
def service_added_callback(self, sdRef, flags, errorCode, name, regtype, domain):
|
def service_added_callback(self, sdRef, flags, errorCode, name, regtype, domain):
|
||||||
|
@ -303,8 +303,8 @@ class Zeroconf:
|
||||||
|
|
||||||
for val in self.contacts.values():
|
for val in self.contacts.values():
|
||||||
resolve_sdRef = pybonjour.DNSServiceResolve(0,
|
resolve_sdRef = pybonjour.DNSServiceResolve(0,
|
||||||
pybonjour.kDNSServiceInterfaceIndexAny, val[C_BARE_NAME],
|
pybonjour.kDNSServiceInterfaceIndexAny, val[Constant.BARE_NAME],
|
||||||
self.stype + '.', val[C_DOMAIN] + '.',
|
self.stype + '.', val[Constant.DOMAIN] + '.',
|
||||||
self.service_resolved_all_callback)
|
self.service_resolved_all_callback)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -29,6 +29,8 @@ from gi.repository import Pango
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
import tooltips
|
import tooltips
|
||||||
import dialogs
|
import dialogs
|
||||||
|
@ -42,14 +44,15 @@ from nbxmpp.protocol import NS_JINGLE_FILE_TRANSFER
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger('gajim.filetransfer_window')
|
log = logging.getLogger('gajim.filetransfer_window')
|
||||||
|
|
||||||
C_IMAGE = 0
|
class Column(IntEnum):
|
||||||
C_LABELS = 1
|
IMAGE = 0
|
||||||
C_FILE = 2
|
LABELS = 1
|
||||||
C_TIME = 3
|
FILE = 2
|
||||||
C_PROGRESS = 4
|
TIME = 3
|
||||||
C_PERCENT = 5
|
PROGRESS = 4
|
||||||
C_PULSE = 6
|
PERCENT = 5
|
||||||
C_SID = 7
|
PULSE = 6
|
||||||
|
SID = 7
|
||||||
|
|
||||||
|
|
||||||
class FileTransfersWindow:
|
class FileTransfersWindow:
|
||||||
|
@ -85,11 +88,11 @@ class FileTransfersWindow:
|
||||||
col = Gtk.TreeViewColumn(_('File'))
|
col = Gtk.TreeViewColumn(_('File'))
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col.pack_start(renderer, False)
|
col.pack_start(renderer, False)
|
||||||
col.add_attribute(renderer, 'markup', C_LABELS)
|
col.add_attribute(renderer, 'markup', Column.LABELS)
|
||||||
renderer.set_property('yalign', 0.)
|
renderer.set_property('yalign', 0.)
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col.pack_start(renderer, True)
|
col.pack_start(renderer, True)
|
||||||
col.add_attribute(renderer, 'markup', C_FILE)
|
col.add_attribute(renderer, 'markup', Column.FILE)
|
||||||
renderer.set_property('xalign', 0.)
|
renderer.set_property('xalign', 0.)
|
||||||
renderer.set_property('yalign', 0.)
|
renderer.set_property('yalign', 0.)
|
||||||
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
|
renderer.set_property('ellipsize', Pango.EllipsizeMode.END)
|
||||||
|
@ -100,7 +103,7 @@ class FileTransfersWindow:
|
||||||
col = Gtk.TreeViewColumn(_('Time'))
|
col = Gtk.TreeViewColumn(_('Time'))
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col.pack_start(renderer, False)
|
col.pack_start(renderer, False)
|
||||||
col.add_attribute(renderer, 'markup', C_TIME)
|
col.add_attribute(renderer, 'markup', Column.TIME)
|
||||||
renderer.set_property('yalign', 0.5)
|
renderer.set_property('yalign', 0.5)
|
||||||
renderer.set_property('xalign', 0.5)
|
renderer.set_property('xalign', 0.5)
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
|
@ -114,9 +117,9 @@ class FileTransfersWindow:
|
||||||
renderer.set_property('yalign', 0.5)
|
renderer.set_property('yalign', 0.5)
|
||||||
renderer.set_property('xalign', 0.5)
|
renderer.set_property('xalign', 0.5)
|
||||||
col.pack_start(renderer, False)
|
col.pack_start(renderer, False)
|
||||||
col.add_attribute(renderer, 'text', C_PROGRESS)
|
col.add_attribute(renderer, 'text', Column.PROGRESS)
|
||||||
col.add_attribute(renderer, 'value', C_PERCENT)
|
col.add_attribute(renderer, 'value', Column.PERCENT)
|
||||||
col.add_attribute(renderer, 'pulse', C_PULSE)
|
col.add_attribute(renderer, 'pulse', Column.PULSE)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
col.set_expand(False)
|
col.set_expand(False)
|
||||||
self.tree.append_column(col)
|
self.tree.append_column(col)
|
||||||
|
@ -480,7 +483,7 @@ class FileTransfersWindow:
|
||||||
iter_ = self.get_iter_by_sid(file_props.type_, file_props.sid)
|
iter_ = self.get_iter_by_sid(file_props.type_, file_props.sid)
|
||||||
if iter_ is None:
|
if iter_ is None:
|
||||||
return
|
return
|
||||||
self.model[iter_][C_SID]
|
self.model[iter_][Column.SID]
|
||||||
if status == 'stop':
|
if status == 'stop':
|
||||||
file_props.stopped = True
|
file_props.stopped = True
|
||||||
elif status == 'ok':
|
elif status == 'ok':
|
||||||
|
@ -490,21 +493,21 @@ class FileTransfersWindow:
|
||||||
full_size = file_props.size
|
full_size = file_props.size
|
||||||
text += helpers.convert_bytes(received_size) + '/' + \
|
text += helpers.convert_bytes(received_size) + '/' + \
|
||||||
helpers.convert_bytes(full_size)
|
helpers.convert_bytes(full_size)
|
||||||
self.model.set(iter_, C_PROGRESS, text)
|
self.model.set(iter_, Column.PROGRESS, text)
|
||||||
self.model.set(iter_, C_PULSE, GLib.MAXINT32)
|
self.model.set(iter_, Column.PULSE, GLib.MAXINT32)
|
||||||
elif status == 'computing':
|
elif status == 'computing':
|
||||||
self.model.set(iter_, C_PULSE, 1)
|
self.model.set(iter_, Column.PULSE, 1)
|
||||||
text = _('Checking file…') + '\n'
|
text = _('Checking file…') + '\n'
|
||||||
received_size = int(file_props.received_len)
|
received_size = int(file_props.received_len)
|
||||||
full_size = file_props.size
|
full_size = file_props.size
|
||||||
text += helpers.convert_bytes(received_size) + '/' + \
|
text += helpers.convert_bytes(received_size) + '/' + \
|
||||||
helpers.convert_bytes(full_size)
|
helpers.convert_bytes(full_size)
|
||||||
self.model.set(iter_, C_PROGRESS, text)
|
self.model.set(iter_, Column.PROGRESS, text)
|
||||||
def pulse():
|
def pulse():
|
||||||
p = self.model.get(iter_, C_PULSE)[0]
|
p = self.model.get(iter_, Column.PULSE)[0]
|
||||||
if p == GLib.MAXINT32:
|
if p == GLib.MAXINT32:
|
||||||
return False
|
return False
|
||||||
self.model.set(iter_, C_PULSE, p + 1)
|
self.model.set(iter_, Column.PULSE, p + 1)
|
||||||
return True
|
return True
|
||||||
GLib.timeout_add(100, pulse)
|
GLib.timeout_add(100, pulse)
|
||||||
elif status == 'hash_error':
|
elif status == 'hash_error':
|
||||||
|
@ -513,9 +516,9 @@ class FileTransfersWindow:
|
||||||
full_size = file_props.size
|
full_size = file_props.size
|
||||||
text += helpers.convert_bytes(received_size) + '/' + \
|
text += helpers.convert_bytes(received_size) + '/' + \
|
||||||
helpers.convert_bytes(full_size)
|
helpers.convert_bytes(full_size)
|
||||||
self.model.set(iter_, C_PROGRESS, text)
|
self.model.set(iter_, Column.PROGRESS, text)
|
||||||
self.model.set(iter_, C_PULSE, GLib.MAXINT32)
|
self.model.set(iter_, Column.PULSE, GLib.MAXINT32)
|
||||||
self.model.set(iter_, C_IMAGE, self.get_icon(status))
|
self.model.set(iter_, Column.IMAGE, self.get_icon(status))
|
||||||
path = self.model.get_path(iter_)
|
path = self.model.get_path(iter_)
|
||||||
self.select_func(path)
|
self.select_func(path)
|
||||||
|
|
||||||
|
@ -609,7 +612,7 @@ class FileTransfersWindow:
|
||||||
iter_ = self.get_iter_by_sid(typ, sid)
|
iter_ = self.get_iter_by_sid(typ, sid)
|
||||||
if iter_ is not None:
|
if iter_ is not None:
|
||||||
just_began = False
|
just_began = False
|
||||||
if self.model[iter_][C_PERCENT] == 0 and int(percent > 0):
|
if self.model[iter_][Column.PERCENT] == 0 and int(percent > 0):
|
||||||
just_began = True
|
just_began = True
|
||||||
text = self._format_percent(percent)
|
text = self._format_percent(percent)
|
||||||
if transfered_size == 0:
|
if transfered_size == 0:
|
||||||
|
@ -631,8 +634,8 @@ class FileTransfersWindow:
|
||||||
eta, speed = self._get_eta_and_speed(full_size, transfered_size,
|
eta, speed = self._get_eta_and_speed(full_size, transfered_size,
|
||||||
file_props)
|
file_props)
|
||||||
|
|
||||||
self.model.set(iter_, C_PROGRESS, text)
|
self.model.set(iter_, Column.PROGRESS, text)
|
||||||
self.model.set(iter_, C_PERCENT, int(percent))
|
self.model.set(iter_, Column.PERCENT, int(percent))
|
||||||
text = self._format_time(eta)
|
text = self._format_time(eta)
|
||||||
text += '\n'
|
text += '\n'
|
||||||
#This should make the string Kb/s,
|
#This should make the string Kb/s,
|
||||||
|
@ -640,7 +643,7 @@ class FileTransfersWindow:
|
||||||
#Only the 's' after / (which means second) should be translated.
|
#Only the 's' after / (which means second) should be translated.
|
||||||
text += _('(%(filesize_unit)s/s)') % {'filesize_unit':
|
text += _('(%(filesize_unit)s/s)') % {'filesize_unit':
|
||||||
helpers.convert_bytes(speed)}
|
helpers.convert_bytes(speed)}
|
||||||
self.model.set(iter_, C_TIME, text)
|
self.model.set(iter_, Column.TIME, text)
|
||||||
|
|
||||||
# try to guess what should be the status image
|
# try to guess what should be the status image
|
||||||
if file_props.type_ == 'r':
|
if file_props.type_ == 'r':
|
||||||
|
@ -673,7 +676,7 @@ class FileTransfersWindow:
|
||||||
"""
|
"""
|
||||||
iter_ = self.model.get_iter_first()
|
iter_ = self.model.get_iter_first()
|
||||||
while iter_:
|
while iter_:
|
||||||
if typ + sid == self.model[iter_][C_SID]:
|
if typ + sid == self.model[iter_][Column.SID]:
|
||||||
return iter_
|
return iter_
|
||||||
iter_ = self.model.iter_next(iter_)
|
iter_ = self.model.iter_next(iter_)
|
||||||
|
|
||||||
|
@ -736,7 +739,7 @@ class FileTransfersWindow:
|
||||||
file_name = file_props.name
|
file_name = file_props.name
|
||||||
text_props = GLib.markup_escape_text(file_name) + '\n'
|
text_props = GLib.markup_escape_text(file_name) + '\n'
|
||||||
text_props += contact.get_shown_name()
|
text_props += contact.get_shown_name()
|
||||||
self.model.set(iter_, 1, text_labels, 2, text_props, C_PULSE, -1, C_SID,
|
self.model.set(iter_, 1, text_labels, 2, text_props, Column.PULSE, -1, Column.SID,
|
||||||
file_props.type_ + file_props.sid)
|
file_props.type_ + file_props.sid)
|
||||||
self.set_progress(file_props.type_, file_props.sid, 0, iter_)
|
self.set_progress(file_props.type_, file_props.sid, 0, iter_)
|
||||||
if file_props.started is False:
|
if file_props.started is False:
|
||||||
|
@ -767,7 +770,7 @@ class FileTransfersWindow:
|
||||||
except Exception:
|
except Exception:
|
||||||
self.tooltip.hide_tooltip()
|
self.tooltip.hide_tooltip()
|
||||||
return
|
return
|
||||||
sid = self.model[iter_][C_SID]
|
sid = self.model[iter_][Column.SID]
|
||||||
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
||||||
if file_props is not None:
|
if file_props is not None:
|
||||||
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
|
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
|
||||||
|
@ -825,7 +828,7 @@ class FileTransfersWindow:
|
||||||
self.set_all_insensitive()
|
self.set_all_insensitive()
|
||||||
return
|
return
|
||||||
current_iter = self.model.get_iter(path)
|
current_iter = self.model.get_iter(path)
|
||||||
sid = self.model[current_iter][C_SID]
|
sid = self.model[current_iter][Column.SID]
|
||||||
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
||||||
self.remove_menuitem.set_sensitive(is_row_selected)
|
self.remove_menuitem.set_sensitive(is_row_selected)
|
||||||
self.open_folder_menuitem.set_sensitive(is_row_selected)
|
self.open_folder_menuitem.set_sensitive(is_row_selected)
|
||||||
|
@ -883,7 +886,7 @@ class FileTransfersWindow:
|
||||||
i = len(self.model) - 1
|
i = len(self.model) - 1
|
||||||
while i >= 0:
|
while i >= 0:
|
||||||
iter_ = self.model.get_iter((i))
|
iter_ = self.model.get_iter((i))
|
||||||
sid = self.model[iter_][C_SID]
|
sid = self.model[iter_][Column.SID]
|
||||||
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
||||||
if is_transfer_stopped(file_props):
|
if is_transfer_stopped(file_props):
|
||||||
self._remove_transfer(iter_, sid, file_props)
|
self._remove_transfer(iter_, sid, file_props)
|
||||||
|
@ -918,7 +921,7 @@ class FileTransfersWindow:
|
||||||
if selected is None or selected[1] is None:
|
if selected is None or selected[1] is None:
|
||||||
return
|
return
|
||||||
s_iter = selected[1]
|
s_iter = selected[1]
|
||||||
sid = self.model[s_iter][C_SID]
|
sid = self.model[s_iter][Column.SID]
|
||||||
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
||||||
if is_transfer_paused(file_props):
|
if is_transfer_paused(file_props):
|
||||||
file_props.last_time = time.time()
|
file_props.last_time = time.time()
|
||||||
|
@ -940,7 +943,7 @@ class FileTransfersWindow:
|
||||||
if selected is None or selected[1] is None:
|
if selected is None or selected[1] is None:
|
||||||
return
|
return
|
||||||
s_iter = selected[1]
|
s_iter = selected[1]
|
||||||
sid = self.model[s_iter][C_SID]
|
sid = self.model[s_iter][Column.SID]
|
||||||
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
||||||
account = file_props.tt_account
|
account = file_props.tt_account
|
||||||
if account not in gajim.connections:
|
if account not in gajim.connections:
|
||||||
|
@ -966,7 +969,7 @@ class FileTransfersWindow:
|
||||||
# as it was before setting the timeout
|
# as it was before setting the timeout
|
||||||
if props and self.tooltip.id == props[0]:
|
if props and self.tooltip.id == props[0]:
|
||||||
iter_ = self.model.get_iter(props[0])
|
iter_ = self.model.get_iter(props[0])
|
||||||
sid = self.model[iter_][C_SID]
|
sid = self.model[iter_][Column.SID]
|
||||||
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
||||||
# bounding rectangle of coordinates for the cell within the treeview
|
# bounding rectangle of coordinates for the cell within the treeview
|
||||||
rect = self.tree.get_cell_area(props[0], props[1])
|
rect = self.tree.get_cell_area(props[0], props[1])
|
||||||
|
@ -1054,7 +1057,7 @@ class FileTransfersWindow:
|
||||||
if not selected or not selected[1]:
|
if not selected or not selected[1]:
|
||||||
return
|
return
|
||||||
s_iter = selected[1]
|
s_iter = selected[1]
|
||||||
sid = self.model[s_iter][C_SID]
|
sid = self.model[s_iter][Column.SID]
|
||||||
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
||||||
if not file_props.file_name:
|
if not file_props.file_name:
|
||||||
return
|
return
|
||||||
|
@ -1076,7 +1079,7 @@ class FileTransfersWindow:
|
||||||
if not selected or not selected[1]:
|
if not selected or not selected[1]:
|
||||||
return
|
return
|
||||||
s_iter = selected[1]
|
s_iter = selected[1]
|
||||||
sid = self.model[s_iter][C_SID]
|
sid = self.model[s_iter][Column.SID]
|
||||||
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
file_props = FilesProp.getFilePropByType(sid[0], sid[1:])
|
||||||
self._remove_transfer(s_iter, sid, file_props)
|
self._remove_transfer(s_iter, sid, file_props)
|
||||||
self.set_all_insensitive()
|
self.set_all_insensitive()
|
||||||
|
|
|
@ -46,6 +46,8 @@ import cell_renderer_image
|
||||||
import dataforms_widget
|
import dataforms_widget
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
|
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
from common import events
|
from common import events
|
||||||
from common import gajim
|
from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
|
@ -63,14 +65,12 @@ from common.connection_handlers_events import GcMessageOutgoingEvent
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger('gajim.groupchat_control')
|
log = logging.getLogger('gajim.groupchat_control')
|
||||||
|
|
||||||
#(status_image, type, nick, shown_nick)
|
class Column(IntEnum):
|
||||||
(
|
IMG = 0 # image to show state (online, new message etc)
|
||||||
C_IMG, # image to show state (online, new message etc)
|
NICK = 1 # contact nickame or ROLE name
|
||||||
C_NICK, # contact nickame or ROLE name
|
TYPE = 2 # type of the row ('contact' or 'role')
|
||||||
C_TYPE, # type of the row ('contact' or 'role')
|
TEXT = 3 # text shown in the cellrenderer
|
||||||
C_TEXT, # text shown in the cellrenderer
|
AVATAR = 4 # avatar of the contact
|
||||||
C_AVATAR, # avatar of the contact
|
|
||||||
) = range(5)
|
|
||||||
|
|
||||||
empty_pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 1, 1)
|
empty_pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 1, 1)
|
||||||
empty_pixbuf.fill(0xffffff00)
|
empty_pixbuf.fill(0xffffff00)
|
||||||
|
@ -99,7 +99,7 @@ def tree_cell_data_func(column, renderer, model, iter_, tv=None):
|
||||||
renderer.set_property('xalign', 1) # align pixbuf to the right
|
renderer.set_property('xalign', 1) # align pixbuf to the right
|
||||||
else:
|
else:
|
||||||
renderer.set_property('xalign', 0.5)
|
renderer.set_property('xalign', 0.5)
|
||||||
if parent_iter and (model[iter_][C_AVATAR] or avatar_position == \
|
if parent_iter and (model[iter_][Column.AVATAR] or avatar_position == \
|
||||||
'left'):
|
'left'):
|
||||||
renderer.set_property('visible', True)
|
renderer.set_property('visible', True)
|
||||||
renderer.set_property('width', gajim.config.get(
|
renderer.set_property('width', gajim.config.get(
|
||||||
|
@ -448,8 +448,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
#status_image, shown_nick, type, nickname, avatar
|
#status_image, shown_nick, type, nickname, avatar
|
||||||
self.columns = [Gtk.Image, str, str, str, GdkPixbuf.Pixbuf]
|
self.columns = [Gtk.Image, str, str, str, GdkPixbuf.Pixbuf]
|
||||||
self.model = Gtk.TreeStore(*self.columns)
|
self.model = Gtk.TreeStore(*self.columns)
|
||||||
self.model.set_sort_func(C_NICK, self.tree_compare_iters)
|
self.model.set_sort_func(Column.NICK, self.tree_compare_iters)
|
||||||
self.model.set_sort_column_id(C_NICK, Gtk.SortType.ASCENDING)
|
self.model.set_sort_column_id(Column.NICK, Gtk.SortType.ASCENDING)
|
||||||
|
|
||||||
# columns
|
# columns
|
||||||
column = Gtk.TreeViewColumn()
|
column = Gtk.TreeViewColumn()
|
||||||
|
@ -469,14 +469,14 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.renderers_list += (
|
self.renderers_list += (
|
||||||
# status img
|
# status img
|
||||||
('icon', renderer_image, False,
|
('icon', renderer_image, False,
|
||||||
'image', C_IMG, tree_cell_data_func, self.list_treeview),
|
'image', Column.IMG, tree_cell_data_func, self.list_treeview),
|
||||||
# contact name
|
# contact name
|
||||||
('name', renderer_text, True,
|
('name', renderer_text, True,
|
||||||
'markup', C_TEXT, tree_cell_data_func, self.list_treeview))
|
'markup', Column.TEXT, tree_cell_data_func, self.list_treeview))
|
||||||
|
|
||||||
# avatar img
|
# avatar img
|
||||||
avater_renderer = ('avatar', Gtk.CellRendererPixbuf(),
|
avater_renderer = ('avatar', Gtk.CellRendererPixbuf(),
|
||||||
False, 'pixbuf', C_AVATAR,
|
False, 'pixbuf', Column.AVATAR,
|
||||||
tree_cell_data_func, self.list_treeview)
|
tree_cell_data_func, self.list_treeview)
|
||||||
|
|
||||||
if gajim.config.get('avatar_position_in_roster') == 'right':
|
if gajim.config.get('avatar_position_in_roster') == 'right':
|
||||||
|
@ -549,8 +549,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
typ = self.model[iter_][C_TYPE]
|
typ = self.model[iter_][Column.TYPE]
|
||||||
nick = self.model[iter_][C_NICK]
|
nick = self.model[iter_][Column.NICK]
|
||||||
|
|
||||||
if typ != 'contact':
|
if typ != 'contact':
|
||||||
return False
|
return False
|
||||||
|
@ -589,12 +589,12 @@ class GroupchatControl(ChatControlBase):
|
||||||
"""
|
"""
|
||||||
Compare two iters to sort them
|
Compare two iters to sort them
|
||||||
"""
|
"""
|
||||||
type1 = model[iter1][C_TYPE]
|
type1 = model[iter1][Column.TYPE]
|
||||||
type2 = model[iter2][C_TYPE]
|
type2 = model[iter2][Column.TYPE]
|
||||||
if not type1 or not type2:
|
if not type1 or not type2:
|
||||||
return 0
|
return 0
|
||||||
nick1 = model[iter1][C_NICK]
|
nick1 = model[iter1][Column.NICK]
|
||||||
nick2 = model[iter2][C_NICK]
|
nick2 = model[iter2][Column.NICK]
|
||||||
if not nick1 or not nick2:
|
if not nick1 or not nick2:
|
||||||
return 0
|
return 0
|
||||||
if type1 == 'role':
|
if type1 == 'role':
|
||||||
|
@ -700,7 +700,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
"""
|
"""
|
||||||
# Get the room_jid from treeview
|
# Get the room_jid from treeview
|
||||||
for contact in self.iter_contact_rows():
|
for contact in self.iter_contact_rows():
|
||||||
nick = contact[C_NICK]
|
nick = contact[Column.NICK]
|
||||||
self.draw_contact(nick)
|
self.draw_contact(nick)
|
||||||
|
|
||||||
def on_list_treeview_selection_changed(self, selection):
|
def on_list_treeview_selection_changed(self, selection):
|
||||||
|
@ -712,9 +712,9 @@ class GroupchatControl(ChatControlBase):
|
||||||
self._last_selected_contact = None
|
self._last_selected_contact = None
|
||||||
return
|
return
|
||||||
contact = model[selected_iter]
|
contact = model[selected_iter]
|
||||||
nick = contact[C_NICK]
|
nick = contact[Column.NICK]
|
||||||
self._last_selected_contact = nick
|
self._last_selected_contact = nick
|
||||||
if contact[C_TYPE] != 'contact':
|
if contact[Column.TYPE] != 'contact':
|
||||||
return
|
return
|
||||||
self.draw_contact(nick, selected=True, focus=True)
|
self.draw_contact(nick, selected=True, focus=True)
|
||||||
|
|
||||||
|
@ -782,7 +782,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.draw_contact(nick)
|
self.draw_contact(nick)
|
||||||
|
|
||||||
def _change_style(self, model, path, iter_, option):
|
def _change_style(self, model, path, iter_, option):
|
||||||
model[iter_][C_NICK] = model[iter_][C_NICK]
|
model[iter_][Column.NICK] = model[iter_][Column.NICK]
|
||||||
|
|
||||||
def change_roster_style(self):
|
def change_roster_style(self):
|
||||||
self.model.foreach(self._change_style, None)
|
self.model.foreach(self._change_style, None)
|
||||||
|
@ -1100,7 +1100,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
gajim.interface.roster.get_appropriate_state_images(
|
gajim.interface.roster.get_appropriate_state_images(
|
||||||
self.room_jid, icon_name='event')
|
self.room_jid, icon_name='event')
|
||||||
image = state_images['event']
|
image = state_images['event']
|
||||||
self.model[iter_][C_IMG] = image
|
self.model[iter_][Column.IMG] = image
|
||||||
if self.parent_win:
|
if self.parent_win:
|
||||||
self.parent_win.show_title()
|
self.parent_win.show_title()
|
||||||
self.parent_win.redraw_tab(self)
|
self.parent_win.redraw_tab(self)
|
||||||
|
@ -1122,7 +1122,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
while role_iter:
|
while role_iter:
|
||||||
user_iter = self.model.iter_children(role_iter)
|
user_iter = self.model.iter_children(role_iter)
|
||||||
while user_iter:
|
while user_iter:
|
||||||
if nick == self.model[user_iter][C_NICK]:
|
if nick == self.model[user_iter][Column.NICK]:
|
||||||
return user_iter
|
return user_iter
|
||||||
else:
|
else:
|
||||||
user_iter = self.model.iter_next(user_iter)
|
user_iter = self.model.iter_next(user_iter)
|
||||||
|
@ -1486,7 +1486,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
contact in a room
|
contact in a room
|
||||||
"""
|
"""
|
||||||
if nick is None:
|
if nick is None:
|
||||||
nick = model[iter_][C_NICK]
|
nick = model[iter_][Column.NICK]
|
||||||
|
|
||||||
ctrl = self._start_private_message(nick)
|
ctrl = self._start_private_message(nick)
|
||||||
if ctrl and msg:
|
if ctrl and msg:
|
||||||
|
@ -1548,8 +1548,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
pixbuf2.get_property('height'), 0, 0, 1.0, 1.0,
|
pixbuf2.get_property('height'), 0, 0, 1.0, 1.0,
|
||||||
GdkPixbuf.InterpType.HYPER, 127)
|
GdkPixbuf.InterpType.HYPER, 127)
|
||||||
image = Gtk.Image.new_from_pixbuf(pixbuf1)
|
image = Gtk.Image.new_from_pixbuf(pixbuf1)
|
||||||
self.model[iter_][C_IMG] = image
|
self.model[iter_][Column.IMG] = image
|
||||||
self.model[iter_][C_TEXT] = name
|
self.model[iter_][Column.TEXT] = name
|
||||||
|
|
||||||
def draw_avatar(self, nick):
|
def draw_avatar(self, nick):
|
||||||
if not gajim.config.get('show_avatars_in_roster'):
|
if not gajim.config.get('show_avatars_in_roster'):
|
||||||
|
@ -1565,7 +1565,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'roster')
|
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'roster')
|
||||||
if not scaled_pixbuf:
|
if not scaled_pixbuf:
|
||||||
scaled_pixbuf = empty_pixbuf
|
scaled_pixbuf = empty_pixbuf
|
||||||
self.model[iter_][C_AVATAR] = scaled_pixbuf
|
self.model[iter_][Column.AVATAR] = scaled_pixbuf
|
||||||
|
|
||||||
def draw_role(self, role):
|
def draw_role(self, role):
|
||||||
role_iter = self.get_role_iter(role)
|
role_iter = self.get_role_iter(role)
|
||||||
|
@ -1576,7 +1576,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
nbr_role, nbr_total = gajim.contacts.get_nb_role_total_gc_contacts(
|
nbr_role, nbr_total = gajim.contacts.get_nb_role_total_gc_contacts(
|
||||||
self.account, self.room_jid, role)
|
self.account, self.room_jid, role)
|
||||||
role_name += ' (%s/%s)' % (repr(nbr_role), repr(nbr_total))
|
role_name += ' (%s/%s)' % (repr(nbr_role), repr(nbr_total))
|
||||||
self.model[role_iter][C_TEXT] = role_name
|
self.model[role_iter][Column.TEXT] = role_name
|
||||||
|
|
||||||
def draw_all_roles(self):
|
def draw_all_roles(self):
|
||||||
for role in ('visitor', 'participant', 'moderator'):
|
for role in ('visitor', 'participant', 'moderator'):
|
||||||
|
@ -1967,7 +1967,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
def get_role_iter(self, role):
|
def get_role_iter(self, role):
|
||||||
role_iter = self.model.get_iter_first()
|
role_iter = self.model.get_iter_first()
|
||||||
while role_iter:
|
while role_iter:
|
||||||
role_name = self.model[role_iter][C_NICK]
|
role_name = self.model[role_iter][Column.NICK]
|
||||||
if role == role_name:
|
if role == role_name:
|
||||||
return role_iter
|
return role_iter
|
||||||
role_iter = self.model.iter_next(role_iter)
|
role_iter = self.model.iter_next(role_iter)
|
||||||
|
@ -2429,7 +2429,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
"""
|
"""
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
image = gajim.interface.jabber_state_images['16']['opened']
|
image = gajim.interface.jabber_state_images['16']['opened']
|
||||||
model[iter_][C_IMG] = image
|
model[iter_][Column.IMG] = image
|
||||||
|
|
||||||
def on_list_treeview_row_collapsed(self, widget, iter_, path):
|
def on_list_treeview_row_collapsed(self, widget, iter_, path):
|
||||||
"""
|
"""
|
||||||
|
@ -2437,7 +2437,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
"""
|
"""
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
image = gajim.interface.jabber_state_images['16']['closed']
|
image = gajim.interface.jabber_state_images['16']['closed']
|
||||||
model[iter_][C_IMG] = image
|
model[iter_][Column.IMG] = image
|
||||||
|
|
||||||
def kick(self, widget, nick):
|
def kick(self, widget, nick):
|
||||||
"""
|
"""
|
||||||
|
@ -2456,7 +2456,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
"""
|
"""
|
||||||
Make contact's popup menu
|
Make contact's popup menu
|
||||||
"""
|
"""
|
||||||
nick = self.model[iter_][C_NICK]
|
nick = self.model[iter_][Column.NICK]
|
||||||
c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
c = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
||||||
fjid = self.room_jid + '/' + nick
|
fjid = self.room_jid + '/' + nick
|
||||||
jid = c.jid
|
jid = c.jid
|
||||||
|
@ -2619,7 +2619,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
else:
|
else:
|
||||||
widget.expand_row(path, False)
|
widget.expand_row(path, False)
|
||||||
else: # We want to send a private message
|
else: # We want to send a private message
|
||||||
nick = self.model[path][C_NICK]
|
nick = self.model[path][Column.NICK]
|
||||||
self._start_private_message(nick)
|
self._start_private_message(nick)
|
||||||
|
|
||||||
def on_list_treeview_row_activated(self, widget, path, col=0):
|
def on_list_treeview_row_activated(self, widget, path, col=0):
|
||||||
|
@ -2650,7 +2650,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
widget.get_selection().select_path(path)
|
widget.get_selection().select_path(path)
|
||||||
iter_ = self.model.get_iter(path)
|
iter_ = self.model.get_iter(path)
|
||||||
if path.get_depth() == 2:
|
if path.get_depth() == 2:
|
||||||
nick = self.model[iter_][C_NICK]
|
nick = self.model[iter_][Column.NICK]
|
||||||
self._start_private_message(nick)
|
self._start_private_message(nick)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -2660,7 +2660,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
iter_ = self.model.get_iter(path)
|
iter_ = self.model.get_iter(path)
|
||||||
nick = self.model[iter_][C_NICK]
|
nick = self.model[iter_][Column.NICK]
|
||||||
if not nick in gajim.contacts.get_nick_list(self.account,
|
if not nick in gajim.contacts.get_nick_list(self.account,
|
||||||
self.room_jid):
|
self.room_jid):
|
||||||
# it's a group
|
# it's a group
|
||||||
|
|
|
@ -99,13 +99,13 @@ status = dict((constants.__dict__[i], i[5:].lower()) for i in \
|
||||||
from common import helpers
|
from common import helpers
|
||||||
import dialogs
|
import dialogs
|
||||||
|
|
||||||
# time, message, subject
|
from enum import IntEnum
|
||||||
(
|
|
||||||
C_UNIXTIME,
|
class Column(IntEnum):
|
||||||
C_MESSAGE,
|
UNIXTIME = 2
|
||||||
C_SUBJECT,
|
MESSAGE = 3
|
||||||
C_NICKNAME
|
SUBJECT = 4
|
||||||
) = range(2, 6)
|
NICKNAME = 5
|
||||||
|
|
||||||
|
|
||||||
import sqlite3 as sqlite
|
import sqlite3 as sqlite
|
||||||
|
@ -176,32 +176,32 @@ class HistoryManager:
|
||||||
self.logs_listview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
|
self.logs_listview.get_selection().set_mode(Gtk.SelectionMode.MULTIPLE)
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText() # holds time
|
renderer_text = Gtk.CellRendererText() # holds time
|
||||||
col = Gtk.TreeViewColumn(_('Date'), renderer_text, text=C_UNIXTIME)
|
col = Gtk.TreeViewColumn(_('Date'), renderer_text, text=Column.UNIXTIME)
|
||||||
# user can click this header and sort
|
# user can click this header and sort
|
||||||
col.set_sort_column_id(C_UNIXTIME)
|
col.set_sort_column_id(Column.UNIXTIME)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
self.logs_listview.append_column(col)
|
self.logs_listview.append_column(col)
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText() # holds nickname
|
renderer_text = Gtk.CellRendererText() # holds nickname
|
||||||
col = Gtk.TreeViewColumn(_('Nickname'), renderer_text, text=C_NICKNAME)
|
col = Gtk.TreeViewColumn(_('Nickname'), renderer_text, text=Column.NICKNAME)
|
||||||
# user can click this header and sort
|
# user can click this header and sort
|
||||||
col.set_sort_column_id(C_NICKNAME)
|
col.set_sort_column_id(Column.NICKNAME)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
col.set_visible(False)
|
col.set_visible(False)
|
||||||
self.nickname_col_for_logs = col
|
self.nickname_col_for_logs = col
|
||||||
self.logs_listview.append_column(col)
|
self.logs_listview.append_column(col)
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText() # holds message
|
renderer_text = Gtk.CellRendererText() # holds message
|
||||||
col = Gtk.TreeViewColumn(_('Message'), renderer_text, markup=C_MESSAGE)
|
col = Gtk.TreeViewColumn(_('Message'), renderer_text, markup=Column.MESSAGE)
|
||||||
# user can click this header and sort
|
# user can click this header and sort
|
||||||
col.set_sort_column_id(C_MESSAGE)
|
col.set_sort_column_id(Column.MESSAGE)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
self.message_col_for_logs = col
|
self.message_col_for_logs = col
|
||||||
self.logs_listview.append_column(col)
|
self.logs_listview.append_column(col)
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText() # holds subject
|
renderer_text = Gtk.CellRendererText() # holds subject
|
||||||
col = Gtk.TreeViewColumn(_('Subject'), renderer_text, text=C_SUBJECT)
|
col = Gtk.TreeViewColumn(_('Subject'), renderer_text, text=Column.SUBJECT)
|
||||||
col.set_sort_column_id(C_SUBJECT) # user can click this header and sort
|
col.set_sort_column_id(Column.SUBJECT) # user can click this header and sort
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
col.set_visible(False)
|
col.set_visible(False)
|
||||||
self.subject_col_for_logs = col
|
self.subject_col_for_logs = col
|
||||||
|
@ -220,28 +220,28 @@ class HistoryManager:
|
||||||
self.search_results_listview.append_column(col)
|
self.search_results_listview.append_column(col)
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText() # holds time
|
renderer_text = Gtk.CellRendererText() # holds time
|
||||||
col = Gtk.TreeViewColumn(_('Date'), renderer_text, text=C_UNIXTIME)
|
col = Gtk.TreeViewColumn(_('Date'), renderer_text, text=Column.UNIXTIME)
|
||||||
# user can click this header and sort
|
# user can click this header and sort
|
||||||
col.set_sort_column_id(C_UNIXTIME)
|
col.set_sort_column_id(Column.UNIXTIME)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
self.search_results_listview.append_column(col)
|
self.search_results_listview.append_column(col)
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText() # holds message
|
renderer_text = Gtk.CellRendererText() # holds message
|
||||||
col = Gtk.TreeViewColumn(_('Message'), renderer_text, text=C_MESSAGE)
|
col = Gtk.TreeViewColumn(_('Message'), renderer_text, text=Column.MESSAGE)
|
||||||
col.set_sort_column_id(C_MESSAGE) # user can click this header and sort
|
col.set_sort_column_id(Column.MESSAGE) # user can click this header and sort
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
self.search_results_listview.append_column(col)
|
self.search_results_listview.append_column(col)
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText() # holds subject
|
renderer_text = Gtk.CellRendererText() # holds subject
|
||||||
col = Gtk.TreeViewColumn(_('Subject'), renderer_text, text=C_SUBJECT)
|
col = Gtk.TreeViewColumn(_('Subject'), renderer_text, text=Column.SUBJECT)
|
||||||
col.set_sort_column_id(C_SUBJECT) # user can click this header and sort
|
col.set_sort_column_id(Column.SUBJECT) # user can click this header and sort
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
self.search_results_listview.append_column(col)
|
self.search_results_listview.append_column(col)
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText() # holds nickname
|
renderer_text = Gtk.CellRendererText() # holds nickname
|
||||||
col = Gtk.TreeViewColumn(_('Nickname'), renderer_text, text=C_NICKNAME)
|
col = Gtk.TreeViewColumn(_('Nickname'), renderer_text, text=Column.NICKNAME)
|
||||||
# user can click this header and sort
|
# user can click this header and sort
|
||||||
col.set_sort_column_id(C_NICKNAME)
|
col.set_sort_column_id(Column.NICKNAME)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
self.search_results_listview.append_column(col)
|
self.search_results_listview.append_column(col)
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ from gi.repository import GLib
|
||||||
import time
|
import time
|
||||||
import calendar
|
import calendar
|
||||||
|
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
import conversation_textview
|
import conversation_textview
|
||||||
import dialogs
|
import dialogs
|
||||||
|
@ -39,26 +41,21 @@ from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import exceptions
|
from common import exceptions
|
||||||
|
|
||||||
from common.logger import Constants
|
from common.logger import ShowConstant, KindConstant
|
||||||
|
|
||||||
constants = Constants()
|
class InfoColumn(IntEnum):
|
||||||
|
'''Completion dict'''
|
||||||
|
JID = 0
|
||||||
|
ACCOUNT = 1
|
||||||
|
NAME = 2
|
||||||
|
COMPLETION = 3
|
||||||
|
|
||||||
# Completion dict
|
class Column(IntEnum):
|
||||||
(
|
LOG_JID = 0
|
||||||
C_INFO_JID,
|
CONTACT_NAME = 1
|
||||||
C_INFO_ACCOUNT,
|
UNIXTIME = 2
|
||||||
C_INFO_NAME,
|
MESSAGE = 3
|
||||||
C_INFO_COMPLETION
|
TIME = 4
|
||||||
) = range(4)
|
|
||||||
|
|
||||||
# contact_name, date, message, time
|
|
||||||
(
|
|
||||||
C_LOG_JID,
|
|
||||||
C_CONTACT_NAME,
|
|
||||||
C_UNIXTIME,
|
|
||||||
C_MESSAGE,
|
|
||||||
C_TIME
|
|
||||||
) = range(5)
|
|
||||||
|
|
||||||
class HistoryWindow:
|
class HistoryWindow:
|
||||||
"""
|
"""
|
||||||
|
@ -95,23 +92,23 @@ class HistoryWindow:
|
||||||
self.results_treeview.append_column(col)
|
self.results_treeview.append_column(col)
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col.pack_start(renderer, True)
|
col.pack_start(renderer, True)
|
||||||
col.add_attribute(renderer, 'text', C_CONTACT_NAME)
|
col.add_attribute(renderer, 'text', Column.CONTACT_NAME)
|
||||||
col.set_sort_column_id(C_CONTACT_NAME) # user can click this header and sort
|
col.set_sort_column_id(Column.CONTACT_NAME) # user can click this header and sort
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
|
|
||||||
col = Gtk.TreeViewColumn(_('Date'))
|
col = Gtk.TreeViewColumn(_('Date'))
|
||||||
self.results_treeview.append_column(col)
|
self.results_treeview.append_column(col)
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col.pack_start(renderer, True)
|
col.pack_start(renderer, True)
|
||||||
col.add_attribute(renderer, 'text', C_UNIXTIME)
|
col.add_attribute(renderer, 'text', Column.UNIXTIME)
|
||||||
col.set_sort_column_id(C_UNIXTIME) # user can click this header and sort
|
col.set_sort_column_id(Column.UNIXTIME) # user can click this header and sort
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
|
|
||||||
col = Gtk.TreeViewColumn(_('Message'))
|
col = Gtk.TreeViewColumn(_('Message'))
|
||||||
self.results_treeview.append_column(col)
|
self.results_treeview.append_column(col)
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col.pack_start(renderer, True)
|
col.pack_start(renderer, True)
|
||||||
col.add_attribute(renderer, 'text', C_MESSAGE)
|
col.add_attribute(renderer, 'text', Column.MESSAGE)
|
||||||
col.set_resizable(True)
|
col.set_resizable(True)
|
||||||
|
|
||||||
self.jid = None # The history we are currently viewing
|
self.jid = None # The history we are currently viewing
|
||||||
|
@ -372,17 +369,17 @@ class HistoryWindow:
|
||||||
widget.mark_day(day)
|
widget.mark_day(day)
|
||||||
|
|
||||||
def _get_string_show_from_constant_int(self, show):
|
def _get_string_show_from_constant_int(self, show):
|
||||||
if show == constants.SHOW_ONLINE:
|
if show == ShowConstant.ONLINE:
|
||||||
show = 'online'
|
show = 'online'
|
||||||
elif show == constants.SHOW_CHAT:
|
elif show == ShowConstant.CHAT:
|
||||||
show = 'chat'
|
show = 'chat'
|
||||||
elif show == constants.SHOW_AWAY:
|
elif show == ShowConstant.AWAY:
|
||||||
show = 'away'
|
show = 'away'
|
||||||
elif show == constants.SHOW_XA:
|
elif show == ShowConstant.XA:
|
||||||
show = 'xa'
|
show = 'xa'
|
||||||
elif show == constants.SHOW_DND:
|
elif show == ShowConstant.DND:
|
||||||
show = 'dnd'
|
show = 'dnd'
|
||||||
elif show == constants.SHOW_OFFLINE:
|
elif show == ShowConstant.OFFLINE:
|
||||||
show = 'offline'
|
show = 'offline'
|
||||||
|
|
||||||
return show
|
return show
|
||||||
|
@ -402,8 +399,8 @@ class HistoryWindow:
|
||||||
# line[0] is contact_name, line[1] is time of message
|
# line[0] is contact_name, line[1] is time of message
|
||||||
# line[2] is kind, line[3] is show, line[4] is message, line[5] is subject
|
# line[2] is kind, line[3] is show, line[4] is message, line[5] is subject
|
||||||
# line[6] is additional_data
|
# line[6] is additional_data
|
||||||
if not show_status and line[2] in (constants.KIND_GCSTATUS,
|
if not show_status and line[2] in (KindConstant.GCSTATUS,
|
||||||
constants.KIND_STATUS):
|
KindConstant.STATUS):
|
||||||
continue
|
continue
|
||||||
self._add_new_line(line[0], line[1], line[2], line[3], line[4],
|
self._add_new_line(line[0], line[1], line[2], line[3], line[4],
|
||||||
line[5], line[6])
|
line[5], line[6])
|
||||||
|
@ -412,8 +409,8 @@ class HistoryWindow:
|
||||||
"""
|
"""
|
||||||
Add a new line in textbuffer
|
Add a new line in textbuffer
|
||||||
"""
|
"""
|
||||||
if not message and kind not in (constants.KIND_STATUS,
|
if not message and kind not in (KindConstant.STATUS,
|
||||||
constants.KIND_GCSTATUS):
|
KindConstant.GCSTATUS):
|
||||||
return
|
return
|
||||||
buf = self.history_buffer
|
buf = self.history_buffer
|
||||||
end_iter = buf.get_end_iter()
|
end_iter = buf.get_end_iter()
|
||||||
|
@ -444,15 +441,15 @@ class HistoryWindow:
|
||||||
|
|
||||||
show = self._get_string_show_from_constant_int(show)
|
show = self._get_string_show_from_constant_int(show)
|
||||||
|
|
||||||
if kind == constants.KIND_GC_MSG:
|
if kind == KindConstant.GC_MSG:
|
||||||
tag_name = 'incoming'
|
tag_name = 'incoming'
|
||||||
elif kind in (constants.KIND_SINGLE_MSG_RECV,
|
elif kind in (KindConstant.SINGLE_MSG_RECV,
|
||||||
constants.KIND_CHAT_MSG_RECV):
|
KindConstant.CHAT_MSG_RECV):
|
||||||
contact_name = self.completion_dict[self.jid][C_INFO_NAME]
|
contact_name = self.completion_dict[self.jid][InfoColumn.NAME]
|
||||||
tag_name = 'incoming'
|
tag_name = 'incoming'
|
||||||
tag_msg = 'incomingtxt'
|
tag_msg = 'incomingtxt'
|
||||||
elif kind in (constants.KIND_SINGLE_MSG_SENT,
|
elif kind in (KindConstant.SINGLE_MSG_SENT,
|
||||||
constants.KIND_CHAT_MSG_SENT):
|
KindConstant.CHAT_MSG_SENT):
|
||||||
if self.account:
|
if self.account:
|
||||||
contact_name = gajim.nicks[self.account]
|
contact_name = gajim.nicks[self.account]
|
||||||
else:
|
else:
|
||||||
|
@ -462,7 +459,7 @@ class HistoryWindow:
|
||||||
contact_name = gajim.nicks[account]
|
contact_name = gajim.nicks[account]
|
||||||
tag_name = 'outgoing'
|
tag_name = 'outgoing'
|
||||||
tag_msg = 'outgoingtxt'
|
tag_msg = 'outgoingtxt'
|
||||||
elif kind == constants.KIND_GCSTATUS:
|
elif kind == KindConstant.GCSTATUS:
|
||||||
# message here (if not None) is status message
|
# message here (if not None) is status message
|
||||||
if message:
|
if message:
|
||||||
message = _('%(nick)s is now %(status)s: %(status_msg)s') %\
|
message = _('%(nick)s is now %(status)s: %(status_msg)s') %\
|
||||||
|
@ -492,7 +489,7 @@ class HistoryWindow:
|
||||||
else:
|
else:
|
||||||
# do not do this if gcstats, avoid dupping contact_name
|
# do not do this if gcstats, avoid dupping contact_name
|
||||||
# eg. nkour: nkour is now Offline
|
# eg. nkour: nkour is now Offline
|
||||||
if contact_name and kind != constants.KIND_GCSTATUS:
|
if contact_name and kind != KindConstant.GCSTATUS:
|
||||||
# add stuff before and after contact name
|
# add stuff before and after contact name
|
||||||
before_str = gajim.config.get('before_nickname')
|
before_str = gajim.config.get('before_nickname')
|
||||||
before_str = helpers.from_one_line(before_str)
|
before_str = helpers.from_one_line(before_str)
|
||||||
|
@ -532,7 +529,7 @@ class HistoryWindow:
|
||||||
# perform search in preselected jids
|
# perform search in preselected jids
|
||||||
# jids are preselected with the query_entry
|
# jids are preselected with the query_entry
|
||||||
for jid in self.jids_to_search:
|
for jid in self.jids_to_search:
|
||||||
account = self.completion_dict[jid][C_INFO_ACCOUNT]
|
account = self.completion_dict[jid][InfoColumn.ACCOUNT]
|
||||||
if account is None:
|
if account is None:
|
||||||
# We do not know an account. This can only happen if the contact is offine,
|
# We do not know an account. This can only happen if the contact is offine,
|
||||||
# or if we browse a groupchat history. The account is not needed, a dummy can
|
# or if we browse a groupchat history. The account is not needed, a dummy can
|
||||||
|
@ -554,16 +551,16 @@ class HistoryWindow:
|
||||||
# add "subject: | message: " in message column if kind is single
|
# add "subject: | message: " in message column if kind is single
|
||||||
# also do we need show at all? (we do not search on subject)
|
# also do we need show at all? (we do not search on subject)
|
||||||
for row in results:
|
for row in results:
|
||||||
if not show_status and row[2] in (constants.KIND_GCSTATUS,
|
if not show_status and row[2] in (KindConstant.GCSTATUS,
|
||||||
constants.KIND_STATUS):
|
KindConstant.STATUS):
|
||||||
continue
|
continue
|
||||||
contact_name = row[0]
|
contact_name = row[0]
|
||||||
if not contact_name:
|
if not contact_name:
|
||||||
kind = row[2]
|
kind = row[2]
|
||||||
if kind == constants.KIND_CHAT_MSG_SENT: # it's us! :)
|
if kind == KindConstant.CHAT_MSG_SENT: # it's us! :)
|
||||||
contact_name = gajim.nicks[account]
|
contact_name = gajim.nicks[account]
|
||||||
else:
|
else:
|
||||||
contact_name = self.completion_dict[jid][C_INFO_NAME]
|
contact_name = self.completion_dict[jid][InfoColumn.NAME]
|
||||||
tim = row[1]
|
tim = row[1]
|
||||||
message = row[4]
|
message = row[4]
|
||||||
local_time = time.localtime(tim)
|
local_time = time.localtime(tim)
|
||||||
|
@ -583,14 +580,14 @@ class HistoryWindow:
|
||||||
cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
|
cur_month = gtkgui_helpers.make_gtk_month_python_month(cur_month)
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
# make it a tupple (Y, M, D, 0, 0, 0...)
|
# make it a tupple (Y, M, D, 0, 0, 0...)
|
||||||
tim = time.strptime(model[path][C_UNIXTIME], '%Y-%m-%d')
|
tim = time.strptime(model[path][Column.UNIXTIME], '%Y-%m-%d')
|
||||||
year = tim[0]
|
year = tim[0]
|
||||||
gtk_month = tim[1]
|
gtk_month = tim[1]
|
||||||
month = gtkgui_helpers.make_python_month_gtk_month(gtk_month)
|
month = gtkgui_helpers.make_python_month_gtk_month(gtk_month)
|
||||||
day = tim[2]
|
day = tim[2]
|
||||||
|
|
||||||
# switch to belonging logfile if necessary
|
# switch to belonging logfile if necessary
|
||||||
log_jid = model[path][C_LOG_JID]
|
log_jid = model[path][Column.LOG_JID]
|
||||||
if log_jid != self.jid:
|
if log_jid != self.jid:
|
||||||
self._load_history(log_jid, None)
|
self._load_history(log_jid, None)
|
||||||
|
|
||||||
|
@ -599,7 +596,7 @@ class HistoryWindow:
|
||||||
self.calendar.select_month(month, year)
|
self.calendar.select_month(month, year)
|
||||||
|
|
||||||
self.calendar.select_day(day)
|
self.calendar.select_day(day)
|
||||||
unix_time = model[path][C_TIME]
|
unix_time = model[path][Column.TIME]
|
||||||
self._scroll_to_result(unix_time)
|
self._scroll_to_result(unix_time)
|
||||||
#FIXME: one day do not search just for unix_time but the whole and user
|
#FIXME: one day do not search just for unix_time but the whole and user
|
||||||
# specific format of the textbuffer line [time] nick: message
|
# specific format of the textbuffer line [time] nick: message
|
||||||
|
|
|
@ -32,6 +32,8 @@ from gi.repository import GdkPixbuf
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
from dialogs import WarningDialog, YesNoDialog, ArchiveChooserDialog
|
from dialogs import WarningDialog, YesNoDialog, ArchiveChooserDialog
|
||||||
from htmltextview import HtmlTextView
|
from htmltextview import HtmlTextView
|
||||||
|
@ -41,13 +43,12 @@ from plugins.helpers import GajimPluginActivateException
|
||||||
from plugins.plugins_i18n import _
|
from plugins.plugins_i18n import _
|
||||||
from common.exceptions import PluginsystemError
|
from common.exceptions import PluginsystemError
|
||||||
|
|
||||||
(
|
class Column(IntEnum):
|
||||||
PLUGIN,
|
PLUGIN = 0
|
||||||
NAME,
|
NAME = 1
|
||||||
ACTIVE,
|
ACTIVE = 2
|
||||||
ACTIVATABLE,
|
ACTIVATABLE = 3
|
||||||
ICON,
|
ICON = 4
|
||||||
) = range(5)
|
|
||||||
|
|
||||||
|
|
||||||
class PluginsWindow(object):
|
class PluginsWindow(object):
|
||||||
|
@ -78,19 +79,19 @@ class PluginsWindow(object):
|
||||||
self.installed_plugins_treeview.set_rules_hint(True)
|
self.installed_plugins_treeview.set_rules_hint(True)
|
||||||
|
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
col = Gtk.TreeViewColumn(_('Plugin'))#, renderer, text=NAME)
|
col = Gtk.TreeViewColumn(_('Plugin'))#, renderer, text=Column.NAME)
|
||||||
cell = Gtk.CellRendererPixbuf()
|
cell = Gtk.CellRendererPixbuf()
|
||||||
col.pack_start(cell, False)
|
col.pack_start(cell, False)
|
||||||
col.add_attribute(cell, 'pixbuf', ICON)
|
col.add_attribute(cell, 'pixbuf', Column.ICON)
|
||||||
col.pack_start(renderer, True)
|
col.pack_start(renderer, True)
|
||||||
col.add_attribute(renderer, 'text', NAME)
|
col.add_attribute(renderer, 'text', Column.NAME)
|
||||||
col.set_property('expand', True)
|
col.set_property('expand', True)
|
||||||
self.installed_plugins_treeview.append_column(col)
|
self.installed_plugins_treeview.append_column(col)
|
||||||
|
|
||||||
renderer = Gtk.CellRendererToggle()
|
renderer = Gtk.CellRendererToggle()
|
||||||
renderer.connect('toggled', self.installed_plugins_toggled_cb)
|
renderer.connect('toggled', self.installed_plugins_toggled_cb)
|
||||||
col = Gtk.TreeViewColumn(_('Active'), renderer, active=ACTIVE,
|
col = Gtk.TreeViewColumn(_('Active'), renderer, active=Column.ACTIVE,
|
||||||
activatable=ACTIVATABLE)
|
activatable=Column.ACTIVATABLE)
|
||||||
self.installed_plugins_treeview.append_column(col)
|
self.installed_plugins_treeview.append_column(col)
|
||||||
|
|
||||||
self.def_icon = gtkgui_helpers.get_icon_pixmap('preferences-desktop')
|
self.def_icon = gtkgui_helpers.get_icon_pixmap('preferences-desktop')
|
||||||
|
@ -124,9 +125,9 @@ class PluginsWindow(object):
|
||||||
def installed_plugins_treeview_selection_changed(self, treeview_selection):
|
def installed_plugins_treeview_selection_changed(self, treeview_selection):
|
||||||
model, iter = treeview_selection.get_selected()
|
model, iter = treeview_selection.get_selected()
|
||||||
if iter:
|
if iter:
|
||||||
plugin = model.get_value(iter, PLUGIN)
|
plugin = model.get_value(iter, Column.PLUGIN)
|
||||||
plugin_name = model.get_value(iter, NAME)
|
plugin_name = model.get_value(iter, Column.NAME)
|
||||||
is_active = model.get_value(iter, ACTIVE)
|
is_active = model.get_value(iter, Column.ACTIVE)
|
||||||
|
|
||||||
self._display_installed_plugin_info(plugin)
|
self._display_installed_plugin_info(plugin)
|
||||||
else:
|
else:
|
||||||
|
@ -195,8 +196,8 @@ class PluginsWindow(object):
|
||||||
|
|
||||||
@log_calls('PluginsWindow')
|
@log_calls('PluginsWindow')
|
||||||
def installed_plugins_toggled_cb(self, cell, path):
|
def installed_plugins_toggled_cb(self, cell, path):
|
||||||
is_active = self.installed_plugins_model[path][ACTIVE]
|
is_active = self.installed_plugins_model[path][Column.ACTIVE]
|
||||||
plugin = self.installed_plugins_model[path][PLUGIN]
|
plugin = self.installed_plugins_model[path][Column.PLUGIN]
|
||||||
|
|
||||||
if is_active:
|
if is_active:
|
||||||
gajim.plugin_manager.deactivate_plugin(plugin)
|
gajim.plugin_manager.deactivate_plugin(plugin)
|
||||||
|
@ -208,7 +209,7 @@ class PluginsWindow(object):
|
||||||
transient_for=self.window)
|
transient_for=self.window)
|
||||||
return
|
return
|
||||||
|
|
||||||
self.installed_plugins_model[path][ACTIVE] = not is_active
|
self.installed_plugins_model[path][Column.ACTIVE] = not is_active
|
||||||
|
|
||||||
@log_calls('PluginsWindow')
|
@log_calls('PluginsWindow')
|
||||||
def on_plugins_window_destroy(self, widget):
|
def on_plugins_window_destroy(self, widget):
|
||||||
|
@ -224,9 +225,9 @@ class PluginsWindow(object):
|
||||||
selection = self.installed_plugins_treeview.get_selection()
|
selection = self.installed_plugins_treeview.get_selection()
|
||||||
model, iter = selection.get_selected()
|
model, iter = selection.get_selected()
|
||||||
if iter:
|
if iter:
|
||||||
plugin = model.get_value(iter, PLUGIN)
|
plugin = model.get_value(iter, Column.PLUGIN)
|
||||||
plugin_name = model.get_value(iter, NAME)
|
plugin_name = model.get_value(iter, Column.NAME)
|
||||||
is_active = model.get_value(iter, ACTIVE)
|
is_active = model.get_value(iter, Column.ACTIVE)
|
||||||
|
|
||||||
|
|
||||||
result = plugin.config_dialog.run(self.window)
|
result = plugin.config_dialog.run(self.window)
|
||||||
|
@ -242,9 +243,9 @@ class PluginsWindow(object):
|
||||||
selection = self.installed_plugins_treeview.get_selection()
|
selection = self.installed_plugins_treeview.get_selection()
|
||||||
model, iter = selection.get_selected()
|
model, iter = selection.get_selected()
|
||||||
if iter:
|
if iter:
|
||||||
plugin = model.get_value(iter, PLUGIN)
|
plugin = model.get_value(iter, Column.PLUGIN)
|
||||||
plugin_name = model.get_value(iter, NAME)
|
plugin_name = model.get_value(iter, Column.NAME)
|
||||||
is_active = model.get_value(iter, ACTIVE)
|
is_active = model.get_value(iter, Column.ACTIVE)
|
||||||
try:
|
try:
|
||||||
gajim.plugin_manager.remove_plugin(plugin)
|
gajim.plugin_manager.remove_plugin(plugin)
|
||||||
except PluginsystemError as e:
|
except PluginsystemError as e:
|
||||||
|
@ -271,8 +272,8 @@ class PluginsWindow(object):
|
||||||
model = self.installed_plugins_model
|
model = self.installed_plugins_model
|
||||||
|
|
||||||
for i, row in enumerate(model):
|
for i, row in enumerate(model):
|
||||||
if plugin == row[PLUGIN]:
|
if plugin == row[Column.PLUGIN]:
|
||||||
model.remove(model.get_iter((i, PLUGIN)))
|
model.remove(model.get_iter((i, Column.PLUGIN)))
|
||||||
break
|
break
|
||||||
|
|
||||||
iter_ = model.append([plugin, plugin.name, False,
|
iter_ = model.append([plugin, plugin.name, False,
|
||||||
|
|
|
@ -43,6 +43,8 @@ import sys
|
||||||
import time
|
import time
|
||||||
import locale
|
import locale
|
||||||
|
|
||||||
|
from enum import IntEnum
|
||||||
|
|
||||||
import common.sleepy
|
import common.sleepy
|
||||||
import history_window
|
import history_window
|
||||||
import dialogs
|
import dialogs
|
||||||
|
@ -72,20 +74,18 @@ from message_window import MessageWindowMgr
|
||||||
|
|
||||||
from nbxmpp.protocol import NS_FILE, NS_ROSTERX, NS_CONFERENCE
|
from nbxmpp.protocol import NS_FILE, NS_ROSTERX, NS_CONFERENCE
|
||||||
|
|
||||||
#(icon, name, type, jid, account, editable, second pixbuf)
|
class Column(IntEnum):
|
||||||
(
|
IMG = 0 # image to show state (online, new message etc)
|
||||||
C_IMG, # image to show state (online, new message etc)
|
NAME = 1 # cellrenderer text that holds contact nickame
|
||||||
C_NAME, # cellrenderer text that holds contact nickame
|
TYPE = 2 # account, group or contact?
|
||||||
C_TYPE, # account, group or contact?
|
JID = 3 # the jid of the row
|
||||||
C_JID, # the jid of the row
|
ACCOUNT = 4 # cellrenderer text that holds account name
|
||||||
C_ACCOUNT, # cellrenderer text that holds account name
|
MOOD_PIXBUF = 5
|
||||||
C_MOOD_PIXBUF,
|
ACTIVITY_PIXBUF = 6
|
||||||
C_ACTIVITY_PIXBUF,
|
TUNE_PIXBUF = 7
|
||||||
C_TUNE_PIXBUF,
|
LOCATION_PIXBUF = 8
|
||||||
C_LOCATION_PIXBUF,
|
AVATAR_PIXBUF = 9 # avatar_pixbuf
|
||||||
C_AVATAR_PIXBUF, # avatar_pixbuf
|
PADLOCK_PIXBUF = 10 # use for account row only
|
||||||
C_PADLOCK_PIXBUF, # use for account row only
|
|
||||||
) = range(11)
|
|
||||||
|
|
||||||
empty_pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 1, 1)
|
empty_pixbuf = GdkPixbuf.Pixbuf.new(GdkPixbuf.Colorspace.RGB, True, 8, 1, 1)
|
||||||
empty_pixbuf.fill(0xffffff00)
|
empty_pixbuf.fill(0xffffff00)
|
||||||
|
@ -434,7 +434,7 @@ class RosterWindow:
|
||||||
assert iters, '%s shall be removed but is not in roster' % contact.jid
|
assert iters, '%s shall be removed but is not in roster' % contact.jid
|
||||||
|
|
||||||
parent_iter = self.model.iter_parent(iters[0])
|
parent_iter = self.model.iter_parent(iters[0])
|
||||||
parent_type = self.model[parent_iter][C_TYPE]
|
parent_type = self.model[parent_iter][Column.TYPE]
|
||||||
|
|
||||||
if groups:
|
if groups:
|
||||||
# Only remove from specified groups
|
# Only remove from specified groups
|
||||||
|
@ -451,12 +451,12 @@ class RosterWindow:
|
||||||
return False
|
return False
|
||||||
# Remove us and empty groups from the model
|
# Remove us and empty groups from the model
|
||||||
for i in iters:
|
for i in iters:
|
||||||
assert self.model[i][C_JID] == contact.jid and \
|
assert self.model[i][Column.JID] == contact.jid and \
|
||||||
self.model[i][C_ACCOUNT] == account, \
|
self.model[i][Column.ACCOUNT] == account, \
|
||||||
"Invalidated iters of %s" % contact.jid
|
"Invalidated iters of %s" % contact.jid
|
||||||
|
|
||||||
parent_i = self.model.iter_parent(i)
|
parent_i = self.model.iter_parent(i)
|
||||||
parent_type = self.model[parent_i][C_TYPE]
|
parent_type = self.model[parent_i][Column.TYPE]
|
||||||
|
|
||||||
to_be_removed = i
|
to_be_removed = i
|
||||||
while parent_type == 'group' and \
|
while parent_type == 'group' and \
|
||||||
|
@ -465,13 +465,13 @@ class RosterWindow:
|
||||||
account_group = 'MERGED'
|
account_group = 'MERGED'
|
||||||
else:
|
else:
|
||||||
account_group = account
|
account_group = account
|
||||||
group = self.model[parent_i][C_JID]
|
group = self.model[parent_i][Column.JID]
|
||||||
if group in gajim.groups[account]:
|
if group in gajim.groups[account]:
|
||||||
del gajim.groups[account][group]
|
del gajim.groups[account][group]
|
||||||
to_be_removed = parent_i
|
to_be_removed = parent_i
|
||||||
del self._iters[account_group]['groups'][group]
|
del self._iters[account_group]['groups'][group]
|
||||||
parent_i = self.model.iter_parent(parent_i)
|
parent_i = self.model.iter_parent(parent_i)
|
||||||
parent_type = self.model[parent_i][C_TYPE]
|
parent_type = self.model[parent_i][Column.TYPE]
|
||||||
self.model.remove(to_be_removed)
|
self.model.remove(to_be_removed)
|
||||||
|
|
||||||
del self._iters[account]['contacts'][contact.jid]
|
del self._iters[account]['contacts'][contact.jid]
|
||||||
|
@ -555,7 +555,7 @@ class RosterWindow:
|
||||||
family_in_roster = True
|
family_in_roster = True
|
||||||
|
|
||||||
parent_iter = self.model.iter_parent(iters[0])
|
parent_iter = self.model.iter_parent(iters[0])
|
||||||
parent_type = self.model[parent_iter][C_TYPE]
|
parent_type = self.model[parent_iter][Column.TYPE]
|
||||||
|
|
||||||
if parent_type != 'contact':
|
if parent_type != 'contact':
|
||||||
# The contact on top
|
# The contact on top
|
||||||
|
@ -603,7 +603,7 @@ class RosterWindow:
|
||||||
big_brother_account, model=self.model)
|
big_brother_account, model=self.model)
|
||||||
if child_iters:
|
if child_iters:
|
||||||
parent_iter = self.model.iter_parent(child_iters[0])
|
parent_iter = self.model.iter_parent(child_iters[0])
|
||||||
parent_type = self.model[parent_iter][C_TYPE]
|
parent_type = self.model[parent_iter][Column.TYPE]
|
||||||
|
|
||||||
# Check if the current BigBrother has even been before.
|
# Check if the current BigBrother has even been before.
|
||||||
if parent_type == 'contact':
|
if parent_type == 'contact':
|
||||||
|
@ -629,7 +629,7 @@ class RosterWindow:
|
||||||
if not child_iters:
|
if not child_iters:
|
||||||
continue
|
continue
|
||||||
parent_iter = self.model.iter_parent(child_iters[0])
|
parent_iter = self.model.iter_parent(child_iters[0])
|
||||||
parent_type = self.model[parent_iter][C_TYPE]
|
parent_type = self.model[parent_iter][Column.TYPE]
|
||||||
if parent_type != 'contact':
|
if parent_type != 'contact':
|
||||||
_contact = gajim.contacts.get_contact(_account, _jid)
|
_contact = gajim.contacts.get_contact(_account, _jid)
|
||||||
self._remove_entity(_contact, _account)
|
self._remove_entity(_contact, _account)
|
||||||
|
@ -810,7 +810,7 @@ class RosterWindow:
|
||||||
self_iter = self._get_self_contact_iter(account, model=self.model)
|
self_iter = self._get_self_contact_iter(account, model=self.model)
|
||||||
if not self_iter:
|
if not self_iter:
|
||||||
return
|
return
|
||||||
self.model[self_iter][C_JID] = new_jid
|
self.model[self_iter][Column.JID] = new_jid
|
||||||
self.draw_contact(new_jid, account)
|
self.draw_contact(new_jid, account)
|
||||||
|
|
||||||
def add_groupchat(self, jid, account, status=''):
|
def add_groupchat(self, jid, account, status=''):
|
||||||
|
@ -1048,9 +1048,9 @@ class RosterWindow:
|
||||||
# the only way to create a pixbuf from stock
|
# the only way to create a pixbuf from stock
|
||||||
# tls_pixbuf = self.window.render_icon_pixbuf(
|
# tls_pixbuf = self.window.render_icon_pixbuf(
|
||||||
# Gtk.STOCK_DIALOG_AUTHENTICATION, Gtk.IconSize.MENU)
|
# Gtk.STOCK_DIALOG_AUTHENTICATION, Gtk.IconSize.MENU)
|
||||||
self.model[child_iter][C_PADLOCK_PIXBUF] = tls_pixbuf
|
self.model[child_iter][Column.PADLOCK_PIXBUF] = tls_pixbuf
|
||||||
else:
|
else:
|
||||||
self.model[child_iter][C_PADLOCK_PIXBUF] = empty_pixbuf
|
self.model[child_iter][Column.PADLOCK_PIXBUF] = empty_pixbuf
|
||||||
|
|
||||||
if self.regroup:
|
if self.regroup:
|
||||||
account_name = _('Merged accounts')
|
account_name = _('Merged accounts')
|
||||||
|
@ -1070,34 +1070,34 @@ class RosterWindow:
|
||||||
accounts = accounts)
|
accounts = accounts)
|
||||||
account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total))
|
account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total))
|
||||||
|
|
||||||
self.model[child_iter][C_NAME] = account_name
|
self.model[child_iter][Column.NAME] = account_name
|
||||||
|
|
||||||
pep_dict = gajim.connections[account].pep
|
pep_dict = gajim.connections[account].pep
|
||||||
if gajim.config.get('show_mood_in_roster') and 'mood' in pep_dict:
|
if gajim.config.get('show_mood_in_roster') and 'mood' in pep_dict:
|
||||||
self.model[child_iter][C_MOOD_PIXBUF] = \
|
self.model[child_iter][Column.MOOD_PIXBUF] = \
|
||||||
gtkgui_helpers.get_pep_as_pixbuf(pep_dict['mood'])
|
gtkgui_helpers.get_pep_as_pixbuf(pep_dict['mood'])
|
||||||
else:
|
else:
|
||||||
self.model[child_iter][C_MOOD_PIXBUF] = empty_pixbuf
|
self.model[child_iter][Column.MOOD_PIXBUF] = empty_pixbuf
|
||||||
|
|
||||||
if gajim.config.get('show_activity_in_roster') and 'activity' in \
|
if gajim.config.get('show_activity_in_roster') and 'activity' in \
|
||||||
pep_dict:
|
pep_dict:
|
||||||
self.model[child_iter][C_ACTIVITY_PIXBUF] = \
|
self.model[child_iter][Column.ACTIVITY_PIXBUF] = \
|
||||||
gtkgui_helpers.get_pep_as_pixbuf(pep_dict['activity'])
|
gtkgui_helpers.get_pep_as_pixbuf(pep_dict['activity'])
|
||||||
else:
|
else:
|
||||||
self.model[child_iter][C_ACTIVITY_PIXBUF] = empty_pixbuf
|
self.model[child_iter][Column.ACTIVITY_PIXBUF] = empty_pixbuf
|
||||||
|
|
||||||
if gajim.config.get('show_tunes_in_roster') and 'tune' in pep_dict:
|
if gajim.config.get('show_tunes_in_roster') and 'tune' in pep_dict:
|
||||||
self.model[child_iter][C_TUNE_PIXBUF] = \
|
self.model[child_iter][Column.TUNE_PIXBUF] = \
|
||||||
gtkgui_helpers.get_pep_as_pixbuf(pep_dict['tune'])
|
gtkgui_helpers.get_pep_as_pixbuf(pep_dict['tune'])
|
||||||
else:
|
else:
|
||||||
self.model[child_iter][C_TUNE_PIXBUF] = empty_pixbuf
|
self.model[child_iter][Column.TUNE_PIXBUF] = empty_pixbuf
|
||||||
|
|
||||||
if gajim.config.get('show_location_in_roster') and 'location' in \
|
if gajim.config.get('show_location_in_roster') and 'location' in \
|
||||||
pep_dict:
|
pep_dict:
|
||||||
self.model[child_iter][C_LOCATION_PIXBUF] = \
|
self.model[child_iter][Column.LOCATION_PIXBUF] = \
|
||||||
gtkgui_helpers.get_pep_as_pixbuf(pep_dict['location'])
|
gtkgui_helpers.get_pep_as_pixbuf(pep_dict['location'])
|
||||||
else:
|
else:
|
||||||
self.model[child_iter][C_LOCATION_PIXBUF] = empty_pixbuf
|
self.model[child_iter][Column.LOCATION_PIXBUF] = empty_pixbuf
|
||||||
|
|
||||||
def _really_draw_accounts(self):
|
def _really_draw_accounts(self):
|
||||||
for acct in self.accounts_to_draw:
|
for acct in self.accounts_to_draw:
|
||||||
|
@ -1130,7 +1130,7 @@ class RosterWindow:
|
||||||
accounts = accounts, groups = [group])
|
accounts = accounts, groups = [group])
|
||||||
text += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total))
|
text += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total))
|
||||||
|
|
||||||
self.model[child_iter][C_NAME] = text
|
self.model[child_iter][Column.NAME] = text
|
||||||
|
|
||||||
def _really_draw_groups(self):
|
def _really_draw_groups(self):
|
||||||
for ag in self.groups_to_draw.values():
|
for ag in self.groups_to_draw.values():
|
||||||
|
@ -1153,11 +1153,11 @@ class RosterWindow:
|
||||||
if not child_iters:
|
if not child_iters:
|
||||||
return False
|
return False
|
||||||
parent_iter = self.model.iter_parent(child_iters[0])
|
parent_iter = self.model.iter_parent(child_iters[0])
|
||||||
if self.model[parent_iter][C_TYPE] != 'contact':
|
if self.model[parent_iter][Column.TYPE] != 'contact':
|
||||||
# parent is not a contact
|
# parent is not a contact
|
||||||
return
|
return
|
||||||
parent_jid = self.model[parent_iter][C_JID]
|
parent_jid = self.model[parent_iter][Column.JID]
|
||||||
parent_account = self.model[parent_iter][C_ACCOUNT]
|
parent_account = self.model[parent_iter][Column.ACCOUNT]
|
||||||
self.draw_contact(parent_jid, parent_account)
|
self.draw_contact(parent_jid, parent_account)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1269,8 +1269,8 @@ class RosterWindow:
|
||||||
iterC = self.model.iter_children(child_iter)
|
iterC = self.model.iter_children(child_iter)
|
||||||
while iterC:
|
while iterC:
|
||||||
# a child has awaiting messages?
|
# a child has awaiting messages?
|
||||||
jidC = self.model[iterC][C_JID]
|
jidC = self.model[iterC][Column.JID]
|
||||||
accountC = self.model[iterC][C_ACCOUNT]
|
accountC = self.model[iterC][Column.ACCOUNT]
|
||||||
if len(gajim.events.get_events(accountC, jidC)):
|
if len(gajim.events.get_events(accountC, jidC)):
|
||||||
icon_name = 'event'
|
icon_name = 'event'
|
||||||
break
|
break
|
||||||
|
@ -1288,8 +1288,8 @@ class RosterWindow:
|
||||||
# Expand/collapse icon might differ per iter
|
# Expand/collapse icon might differ per iter
|
||||||
# (group)
|
# (group)
|
||||||
img = state_images[icon_name]
|
img = state_images[icon_name]
|
||||||
self.model[child_iter][C_IMG] = img
|
self.model[child_iter][Column.IMG] = img
|
||||||
self.model[child_iter][C_NAME] = name
|
self.model[child_iter][Column.NAME] = name
|
||||||
else:
|
else:
|
||||||
# A normal contact or little brother
|
# A normal contact or little brother
|
||||||
state_images = self.get_appropriate_state_images(jid,
|
state_images = self.get_appropriate_state_images(jid,
|
||||||
|
@ -1298,8 +1298,8 @@ class RosterWindow:
|
||||||
# All iters have the same icon (no expand/collapse)
|
# All iters have the same icon (no expand/collapse)
|
||||||
img = state_images[icon_name]
|
img = state_images[icon_name]
|
||||||
for child_iter in child_iters:
|
for child_iter in child_iters:
|
||||||
self.model[child_iter][C_IMG] = img
|
self.model[child_iter][Column.IMG] = img
|
||||||
self.model[child_iter][C_NAME] = name
|
self.model[child_iter][Column.NAME] = name
|
||||||
|
|
||||||
# We are a little brother
|
# We are a little brother
|
||||||
if family and not is_big_brother and not self.starting:
|
if family and not is_big_brother and not self.starting:
|
||||||
|
@ -1316,7 +1316,7 @@ class RosterWindow:
|
||||||
iterG = self._get_group_iter(g, account, model=self.model)
|
iterG = self._get_group_iter(g, account, model=self.model)
|
||||||
if iterG:
|
if iterG:
|
||||||
# it's not self contact
|
# it's not self contact
|
||||||
self.model[iterG][C_JID] = self.model[iterG][C_JID]
|
self.model[iterG][Column.JID] = self.model[iterG][Column.JID]
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
gajim.plugin_manager.gui_extension_point('roster_draw_contact', self,
|
gajim.plugin_manager.gui_extension_point('roster_draw_contact', self,
|
||||||
|
@ -1363,14 +1363,14 @@ class RosterWindow:
|
||||||
iters = self._get_contact_iter(jid, account, model=self.model)
|
iters = self._get_contact_iter(jid, account, model=self.model)
|
||||||
if not iters or not gajim.config.get('show_avatars_in_roster'):
|
if not iters or not gajim.config.get('show_avatars_in_roster'):
|
||||||
return
|
return
|
||||||
jid = self.model[iters[0]][C_JID]
|
jid = self.model[iters[0]][Column.JID]
|
||||||
pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid)
|
pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid)
|
||||||
if pixbuf in (None, 'ask'):
|
if pixbuf in (None, 'ask'):
|
||||||
scaled_pixbuf = empty_pixbuf
|
scaled_pixbuf = empty_pixbuf
|
||||||
else:
|
else:
|
||||||
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'roster')
|
scaled_pixbuf = gtkgui_helpers.get_scaled_pixbuf(pixbuf, 'roster')
|
||||||
for child_iter in iters:
|
for child_iter in iters:
|
||||||
self.model[child_iter][C_AVATAR_PIXBUF] = scaled_pixbuf
|
self.model[child_iter][Column.AVATAR_PIXBUF] = scaled_pixbuf
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def draw_completely(self, jid, account):
|
def draw_completely(self, jid, account):
|
||||||
|
@ -1513,9 +1513,9 @@ class RosterWindow:
|
||||||
|
|
||||||
def _readjust_expand_collapse_state(self):
|
def _readjust_expand_collapse_state(self):
|
||||||
def func(model, path, iter_, param):
|
def func(model, path, iter_, param):
|
||||||
type_ = model[iter_][C_TYPE]
|
type_ = model[iter_][Column.TYPE]
|
||||||
acct = model[iter_][C_ACCOUNT]
|
acct = model[iter_][Column.ACCOUNT]
|
||||||
jid = model[iter_][C_JID]
|
jid = model[iter_][Column.JID]
|
||||||
key = None
|
key = None
|
||||||
if type_ == 'account':
|
if type_ == 'account':
|
||||||
key = acct
|
key = acct
|
||||||
|
@ -1523,9 +1523,9 @@ class RosterWindow:
|
||||||
key = acct + jid
|
key = acct + jid
|
||||||
elif type_ == 'contact':
|
elif type_ == 'contact':
|
||||||
parent_iter = model.iter_parent(iter_)
|
parent_iter = model.iter_parent(iter_)
|
||||||
ptype = model[parent_iter][C_TYPE]
|
ptype = model[parent_iter][Column.TYPE]
|
||||||
if ptype == 'group':
|
if ptype == 'group':
|
||||||
grp = model[parent_iter][C_JID]
|
grp = model[parent_iter][Column.JID]
|
||||||
key = acct + grp + jid
|
key = acct + grp + jid
|
||||||
if key:
|
if key:
|
||||||
if key in self.collapsed_rows:
|
if key in self.collapsed_rows:
|
||||||
|
@ -1620,18 +1620,18 @@ class RosterWindow:
|
||||||
"""
|
"""
|
||||||
if self.starting_filtering:
|
if self.starting_filtering:
|
||||||
return False
|
return False
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
if not type_:
|
if not type_:
|
||||||
return False
|
return False
|
||||||
if type_ == 'account':
|
if type_ == 'account':
|
||||||
# Always show account
|
# Always show account
|
||||||
return True
|
return True
|
||||||
|
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
if not account:
|
if not account:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
if not jid:
|
if not jid:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1662,7 +1662,7 @@ class RosterWindow:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if self.regroup:
|
if self.regroup:
|
||||||
# C_ACCOUNT for groups depends on the order
|
# Column.ACCOUNT for groups depends on the order
|
||||||
# accounts were connected
|
# accounts were connected
|
||||||
# Check all accounts for online group contacts
|
# Check all accounts for online group contacts
|
||||||
accounts = gajim.contacts.get_accounts()
|
accounts = gajim.contacts.get_accounts()
|
||||||
|
@ -1685,10 +1685,10 @@ class RosterWindow:
|
||||||
if model.iter_has_child(titer):
|
if model.iter_has_child(titer):
|
||||||
iter_c = model.iter_children(titer)
|
iter_c = model.iter_children(titer)
|
||||||
while iter_c:
|
while iter_c:
|
||||||
if self.rfilter_string in model[iter_c][C_NAME].lower():
|
if self.rfilter_string in model[iter_c][Column.NAME].lower():
|
||||||
return True
|
return True
|
||||||
iter_c = model.iter_next(iter_c)
|
iter_c = model.iter_next(iter_c)
|
||||||
return self.rfilter_string in model[titer][C_NAME].lower()
|
return self.rfilter_string in model[titer][Column.NAME].lower()
|
||||||
if gajim.config.get('showoffline'):
|
if gajim.config.get('showoffline'):
|
||||||
return True
|
return True
|
||||||
bb_jid = None
|
bb_jid = None
|
||||||
|
@ -1713,7 +1713,7 @@ class RosterWindow:
|
||||||
return self.contact_is_visible(contact, account)
|
return self.contact_is_visible(contact, account)
|
||||||
if type_ == 'agent':
|
if type_ == 'agent':
|
||||||
if self.rfilter_enabled:
|
if self.rfilter_enabled:
|
||||||
return self.rfilter_string in model[titer][C_NAME].lower()
|
return self.rfilter_string in model[titer][Column.NAME].lower()
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account,
|
contact = gajim.contacts.get_contact_with_highest_priority(account,
|
||||||
jid)
|
jid)
|
||||||
return self.contact_has_pending_roster_events(contact, account) or \
|
return self.contact_has_pending_roster_events(contact, account) or \
|
||||||
|
@ -1721,30 +1721,30 @@ class RosterWindow:
|
||||||
(gajim.account_is_connected(account) or \
|
(gajim.account_is_connected(account) or \
|
||||||
gajim.config.get('showoffline')))
|
gajim.config.get('showoffline')))
|
||||||
if type_ == 'groupchat' and self.rfilter_enabled:
|
if type_ == 'groupchat' and self.rfilter_enabled:
|
||||||
return self.rfilter_string in model[titer][C_NAME].lower()
|
return self.rfilter_string in model[titer][Column.NAME].lower()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _compareIters(self, model, iter1, iter2, data=None):
|
def _compareIters(self, model, iter1, iter2, data=None):
|
||||||
"""
|
"""
|
||||||
Compare two iters to sort them
|
Compare two iters to sort them
|
||||||
"""
|
"""
|
||||||
name1 = model[iter1][C_NAME]
|
name1 = model[iter1][Column.NAME]
|
||||||
name2 = model[iter2][C_NAME]
|
name2 = model[iter2][Column.NAME]
|
||||||
if not name1 or not name2:
|
if not name1 or not name2:
|
||||||
return 0
|
return 0
|
||||||
name1 = name1
|
name1 = name1
|
||||||
name2 = name2
|
name2 = name2
|
||||||
type1 = model[iter1][C_TYPE]
|
type1 = model[iter1][Column.TYPE]
|
||||||
type2 = model[iter2][C_TYPE]
|
type2 = model[iter2][Column.TYPE]
|
||||||
if type1 == 'self_contact':
|
if type1 == 'self_contact':
|
||||||
return -1
|
return -1
|
||||||
if type2 == 'self_contact':
|
if type2 == 'self_contact':
|
||||||
return 1
|
return 1
|
||||||
if type1 == 'group':
|
if type1 == 'group':
|
||||||
name1 = model[iter1][C_JID]
|
name1 = model[iter1][Column.JID]
|
||||||
if name1:
|
if name1:
|
||||||
name1 = name1
|
name1 = name1
|
||||||
name2 = model[iter2][C_JID]
|
name2 = model[iter2][Column.JID]
|
||||||
if name2:
|
if name2:
|
||||||
name2 = name2
|
name2 = name2
|
||||||
if name1 == _('Transports'):
|
if name1 == _('Transports'):
|
||||||
|
@ -1759,16 +1759,16 @@ class RosterWindow:
|
||||||
return 1
|
return 1
|
||||||
if name2 == _('Groupchats'):
|
if name2 == _('Groupchats'):
|
||||||
return -1
|
return -1
|
||||||
account1 = model[iter1][C_ACCOUNT]
|
account1 = model[iter1][Column.ACCOUNT]
|
||||||
account2 = model[iter2][C_ACCOUNT]
|
account2 = model[iter2][Column.ACCOUNT]
|
||||||
if not account1 or not account2:
|
if not account1 or not account2:
|
||||||
return 0
|
return 0
|
||||||
account1 = account1
|
account1 = account1
|
||||||
account2 = account2
|
account2 = account2
|
||||||
if type1 == 'account':
|
if type1 == 'account':
|
||||||
return locale.strcoll(account1, account2)
|
return locale.strcoll(account1, account2)
|
||||||
jid1 = model[iter1][C_JID]
|
jid1 = model[iter1][Column.JID]
|
||||||
jid2 = model[iter2][C_JID]
|
jid2 = model[iter2][Column.JID]
|
||||||
if type1 == 'contact':
|
if type1 == 'contact':
|
||||||
lcontact1 = gajim.contacts.get_contacts(account1, jid1)
|
lcontact1 = gajim.contacts.get_contacts(account1, jid1)
|
||||||
contact1 = gajim.contacts.get_first_contact_from_jid(account1, jid1)
|
contact1 = gajim.contacts.get_first_contact_from_jid(account1, jid1)
|
||||||
|
@ -2287,7 +2287,7 @@ class RosterWindow:
|
||||||
else:
|
else:
|
||||||
# No need to redraw contacts if we're quitting
|
# No need to redraw contacts if we're quitting
|
||||||
if child_iterA:
|
if child_iterA:
|
||||||
self.model[child_iterA][C_AVATAR_PIXBUF] = empty_pixbuf
|
self.model[child_iterA][Column.AVATAR_PIXBUF] = empty_pixbuf
|
||||||
if account in gajim.con_types:
|
if account in gajim.con_types:
|
||||||
gajim.con_types[account] = None
|
gajim.con_types[account] = None
|
||||||
for jid in list(gajim.contacts.get_jid_list(account)):
|
for jid in list(gajim.contacts.get_jid_list(account)):
|
||||||
|
@ -3049,7 +3049,7 @@ class RosterWindow:
|
||||||
win.redraw_tab(ctrl)
|
win.redraw_tab(ctrl)
|
||||||
win.show_title()
|
win.show_title()
|
||||||
elif row_type == 'group':
|
elif row_type == 'group':
|
||||||
# in C_JID column, we hold the group name (which is not escaped)
|
# in Column.JID column, we hold the group name (which is not escaped)
|
||||||
self.rename_group(old_text, new_text, account)
|
self.rename_group(old_text, new_text, account)
|
||||||
|
|
||||||
def on_canceled():
|
def on_canceled():
|
||||||
|
@ -3327,10 +3327,10 @@ class RosterWindow:
|
||||||
if len(list_of_paths) != 1:
|
if len(list_of_paths) != 1:
|
||||||
return
|
return
|
||||||
path = list_of_paths[0]
|
path = list_of_paths[0]
|
||||||
type_ = model[path][C_TYPE]
|
type_ = model[path][Column.TYPE]
|
||||||
if type_ in ('contact', 'group', 'agent'):
|
if type_ in ('contact', 'group', 'agent'):
|
||||||
jid = model[path][C_JID]
|
jid = model[path][Column.JID]
|
||||||
account = model[path][C_ACCOUNT]
|
account = model[path][Column.ACCOUNT]
|
||||||
self.on_rename(widget, type_, jid, account)
|
self.on_rename(widget, type_, jid, account)
|
||||||
|
|
||||||
elif event.keyval == Gdk.KEY_Delete:
|
elif event.keyval == Gdk.KEY_Delete:
|
||||||
|
@ -3338,17 +3338,17 @@ class RosterWindow:
|
||||||
model, list_of_paths = treeselection.get_selected_rows()
|
model, list_of_paths = treeselection.get_selected_rows()
|
||||||
if not len(list_of_paths):
|
if not len(list_of_paths):
|
||||||
return
|
return
|
||||||
type_ = model[list_of_paths[0]][C_TYPE]
|
type_ = model[list_of_paths[0]][Column.TYPE]
|
||||||
account = model[list_of_paths[0]][C_ACCOUNT]
|
account = model[list_of_paths[0]][Column.ACCOUNT]
|
||||||
if type_ in ('account', 'group', 'self_contact') or \
|
if type_ in ('account', 'group', 'self_contact') or \
|
||||||
account == gajim.ZEROCONF_ACC_NAME:
|
account == gajim.ZEROCONF_ACConstant.NAME:
|
||||||
return
|
return
|
||||||
list_ = []
|
list_ = []
|
||||||
for path in list_of_paths:
|
for path in list_of_paths:
|
||||||
if model[path][C_TYPE] != type_:
|
if model[path][Column.TYPE] != type_:
|
||||||
return
|
return
|
||||||
jid = model[path][C_JID]
|
jid = model[path][Column.JID]
|
||||||
account = model[path][C_ACCOUNT]
|
account = model[path][Column.ACCOUNT]
|
||||||
if not gajim.account_is_connected(account):
|
if not gajim.account_is_connected(account):
|
||||||
continue
|
continue
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(
|
contact = gajim.contacts.get_contact_with_highest_priority(
|
||||||
|
@ -3462,11 +3462,11 @@ class RosterWindow:
|
||||||
if list_of_paths != [path]:
|
if list_of_paths != [path]:
|
||||||
self.tree.get_selection().unselect_all()
|
self.tree.get_selection().unselect_all()
|
||||||
self.tree.get_selection().select_path(path)
|
self.tree.get_selection().select_path(path)
|
||||||
type_ = model[path][C_TYPE]
|
type_ = model[path][Column.TYPE]
|
||||||
if type_ in ('agent', 'contact', 'self_contact', 'groupchat'):
|
if type_ in ('agent', 'contact', 'self_contact', 'groupchat'):
|
||||||
self.on_row_activated(widget, path)
|
self.on_row_activated(widget, path)
|
||||||
elif type_ == 'account':
|
elif type_ == 'account':
|
||||||
account = model[path][C_ACCOUNT]
|
account = model[path][Column.ACCOUNT]
|
||||||
if account != 'all':
|
if account != 'all':
|
||||||
show = gajim.connections[account].connected
|
show = gajim.connections[account].connected
|
||||||
if show > 1: # We are connected
|
if show > 1: # We are connected
|
||||||
|
@ -3491,7 +3491,7 @@ class RosterWindow:
|
||||||
|
|
||||||
elif event.button == 1: # Left click
|
elif event.button == 1: # Left click
|
||||||
model = self.modelfilter
|
model = self.modelfilter
|
||||||
type_ = model[path][C_TYPE]
|
type_ = model[path][Column.TYPE]
|
||||||
# x_min is the x start position of status icon column
|
# x_min is the x start position of status icon column
|
||||||
if gajim.config.get('avatar_position_in_roster') == 'left':
|
if gajim.config.get('avatar_position_in_roster') == 'left':
|
||||||
x_min = gajim.config.get('roster_avatar_width')
|
x_min = gajim.config.get('roster_avatar_width')
|
||||||
|
@ -3532,9 +3532,9 @@ class RosterWindow:
|
||||||
iter = self.modelfilter.get_iter(path)
|
iter = self.modelfilter.get_iter(path)
|
||||||
child_iter = self.modelfilter.iter_children(iter)
|
child_iter = self.modelfilter.iter_children(iter)
|
||||||
while child_iter:
|
while child_iter:
|
||||||
type_ = self.modelfilter[child_iter][C_TYPE]
|
type_ = self.modelfilter[child_iter][Column.TYPE]
|
||||||
account = self.modelfilter[child_iter][C_ACCOUNT]
|
account = self.modelfilter[child_iter][Column.ACCOUNT]
|
||||||
group = self.modelfilter[child_iter][C_JID]
|
group = self.modelfilter[child_iter][Column.JID]
|
||||||
if type_ == 'group' and account + group not in self.collapsed_rows:
|
if type_ == 'group' and account + group not in self.collapsed_rows:
|
||||||
self.expand_group_row(self.modelfilter.get_path(child_iter))
|
self.expand_group_row(self.modelfilter.get_path(child_iter))
|
||||||
child_iter = self.modelfilter.iter_next(child_iter)
|
child_iter = self.modelfilter.iter_next(child_iter)
|
||||||
|
@ -3940,10 +3940,10 @@ class RosterWindow:
|
||||||
treeselection = self.tree.get_selection()
|
treeselection = self.tree.get_selection()
|
||||||
model, list_of_paths = treeselection.get_selected_rows()
|
model, list_of_paths = treeselection.get_selected_rows()
|
||||||
for path in list_of_paths:
|
for path in list_of_paths:
|
||||||
type_ = model[path][C_TYPE]
|
type_ = model[path][Column.TYPE]
|
||||||
if type_ in ('contact', 'agent'):
|
if type_ in ('contact', 'agent'):
|
||||||
jid = model[path][C_JID]
|
jid = model[path][Column.JID]
|
||||||
account = model[path][C_ACCOUNT]
|
account = model[path][Column.ACCOUNT]
|
||||||
contact = gajim.contacts.get_first_contact_from_jid(account,
|
contact = gajim.contacts.get_first_contact_from_jid(account,
|
||||||
jid)
|
jid)
|
||||||
self.on_info(widget, contact, account)
|
self.on_info(widget, contact, account)
|
||||||
|
@ -3954,10 +3954,10 @@ class RosterWindow:
|
||||||
if len(list_of_paths) != 1:
|
if len(list_of_paths) != 1:
|
||||||
return
|
return
|
||||||
path = list_of_paths[0]
|
path = list_of_paths[0]
|
||||||
type_ = model[path][C_TYPE]
|
type_ = model[path][Column.TYPE]
|
||||||
if type_ in ('contact', 'agent'):
|
if type_ in ('contact', 'agent'):
|
||||||
jid = model[path][C_JID]
|
jid = model[path][Column.JID]
|
||||||
account = model[path][C_ACCOUNT]
|
account = model[path][Column.ACCOUNT]
|
||||||
contact = gajim.contacts.get_first_contact_from_jid(account,
|
contact = gajim.contacts.get_first_contact_from_jid(account,
|
||||||
jid)
|
jid)
|
||||||
self.on_history(widget, contact, account)
|
self.on_history(widget, contact, account)
|
||||||
|
@ -3972,8 +3972,8 @@ class RosterWindow:
|
||||||
this way)
|
this way)
|
||||||
"""
|
"""
|
||||||
model = self.modelfilter
|
model = self.modelfilter
|
||||||
account = model[path][C_ACCOUNT]
|
account = model[path][Column.ACCOUNT]
|
||||||
type_ = model[path][C_TYPE]
|
type_ = model[path][Column.TYPE]
|
||||||
if type_ in ('group', 'account'):
|
if type_ in ('group', 'account'):
|
||||||
if self.tree.row_expanded(path):
|
if self.tree.row_expanded(path):
|
||||||
self.tree.collapse_row(path)
|
self.tree.collapse_row(path)
|
||||||
|
@ -3982,7 +3982,7 @@ class RosterWindow:
|
||||||
return
|
return
|
||||||
if self.rfilter_enabled:
|
if self.rfilter_enabled:
|
||||||
GObject.idle_add(self.disable_rfilter)
|
GObject.idle_add(self.disable_rfilter)
|
||||||
jid = model[path][C_JID]
|
jid = model[path][Column.JID]
|
||||||
resource = None
|
resource = None
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
titer = model.get_iter(path)
|
titer = model.get_iter(path)
|
||||||
|
@ -4009,7 +4009,7 @@ class RosterWindow:
|
||||||
if not first_ev and model.iter_has_child(titer):
|
if not first_ev and model.iter_has_child(titer):
|
||||||
child_iter = model.iter_children(titer)
|
child_iter = model.iter_children(titer)
|
||||||
while not first_ev and child_iter:
|
while not first_ev and child_iter:
|
||||||
child_jid = model[child_iter][C_JID]
|
child_jid = model[child_iter][Column.JID]
|
||||||
first_ev = gajim.events.get_first_event(account, child_jid)
|
first_ev = gajim.events.get_first_event(account, child_jid)
|
||||||
if first_ev:
|
if first_ev:
|
||||||
jid = child_jid
|
jid = child_jid
|
||||||
|
@ -4054,12 +4054,12 @@ class RosterWindow:
|
||||||
if self.regroup: # merged accounts
|
if self.regroup: # merged accounts
|
||||||
accounts = list(gajim.connections.keys())
|
accounts = list(gajim.connections.keys())
|
||||||
else:
|
else:
|
||||||
accounts = [model[titer][C_ACCOUNT]]
|
accounts = [model[titer][Column.ACCOUNT]]
|
||||||
|
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
if type_ == 'group':
|
if type_ == 'group':
|
||||||
group = model[titer][C_JID]
|
group = model[titer][Column.JID]
|
||||||
child_model[child_iter][C_IMG] = \
|
child_model[child_iter][Column.IMG] = \
|
||||||
gajim.interface.jabber_state_images['16']['opened']
|
gajim.interface.jabber_state_images['16']['opened']
|
||||||
if self.rfilter_enabled:
|
if self.rfilter_enabled:
|
||||||
return
|
return
|
||||||
|
@ -4091,8 +4091,8 @@ class RosterWindow:
|
||||||
self.tree.expand_row(path, False)
|
self.tree.expand_row(path, False)
|
||||||
elif type_ == 'contact':
|
elif type_ == 'contact':
|
||||||
# Metacontact got toggled, update icon
|
# Metacontact got toggled, update icon
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
contact = gajim.contacts.get_contact(account, jid)
|
contact = gajim.contacts.get_contact(account, jid)
|
||||||
for group in contact.groups:
|
for group in contact.groups:
|
||||||
if account + group + jid in self.collapsed_rows:
|
if account + group + jid in self.collapsed_rows:
|
||||||
|
@ -4118,15 +4118,15 @@ class RosterWindow:
|
||||||
if self.regroup: # merged accounts
|
if self.regroup: # merged accounts
|
||||||
accounts = list(gajim.connections.keys())
|
accounts = list(gajim.connections.keys())
|
||||||
else:
|
else:
|
||||||
accounts = [model[titer][C_ACCOUNT]]
|
accounts = [model[titer][Column.ACCOUNT]]
|
||||||
|
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
if type_ == 'group':
|
if type_ == 'group':
|
||||||
child_model[child_iter][C_IMG] = gajim.interface.\
|
child_model[child_iter][Column.IMG] = gajim.interface.\
|
||||||
jabber_state_images['16']['closed']
|
jabber_state_images['16']['closed']
|
||||||
if self.rfilter_enabled:
|
if self.rfilter_enabled:
|
||||||
return
|
return
|
||||||
group = model[titer][C_JID]
|
group = model[titer][Column.JID]
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
if group in gajim.groups[account]: # This account has this group
|
if group in gajim.groups[account]: # This account has this group
|
||||||
gajim.groups[account][group]['expand'] = False
|
gajim.groups[account][group]['expand'] = False
|
||||||
|
@ -4139,8 +4139,8 @@ class RosterWindow:
|
||||||
self.draw_account(account)
|
self.draw_account(account)
|
||||||
elif type_ == 'contact':
|
elif type_ == 'contact':
|
||||||
# Metacontact got toggled, update icon
|
# Metacontact got toggled, update icon
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
contact = gajim.contacts.get_contact(account, jid)
|
contact = gajim.contacts.get_contact(account, jid)
|
||||||
groups = contact.groups
|
groups = contact.groups
|
||||||
if not groups:
|
if not groups:
|
||||||
|
@ -4167,8 +4167,8 @@ class RosterWindow:
|
||||||
# Signal is emitted when we write to our model
|
# Signal is emitted when we write to our model
|
||||||
return
|
return
|
||||||
|
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
if not account:
|
if not account:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -4179,10 +4179,10 @@ class RosterWindow:
|
||||||
# redraw us to show/hide expand icon
|
# redraw us to show/hide expand icon
|
||||||
if self.filtering:
|
if self.filtering:
|
||||||
# Prevent endless loops
|
# Prevent endless loops
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
GLib.idle_add(self.draw_contact, jid, account)
|
GLib.idle_add(self.draw_contact, jid, account)
|
||||||
elif type_ == 'group':
|
elif type_ == 'group':
|
||||||
group = model[titer][C_JID]
|
group = model[titer][Column.JID]
|
||||||
GLib.idle_add(self._adjust_group_expand_collapse_state, group, account)
|
GLib.idle_add(self._adjust_group_expand_collapse_state, group, account)
|
||||||
elif type_ == 'account':
|
elif type_ == 'account':
|
||||||
GLib.idle_add(self._adjust_account_expand_collapse_state, account)
|
GLib.idle_add(self._adjust_account_expand_collapse_state, account)
|
||||||
|
@ -4209,11 +4209,11 @@ class RosterWindow:
|
||||||
# return
|
# return
|
||||||
# for path in list_of_paths:
|
# for path in list_of_paths:
|
||||||
# row = model[path]
|
# row = model[path]
|
||||||
# if row[C_TYPE] != 'contact':
|
# if row[Column.TYPE] != 'contact':
|
||||||
# self._last_selected_contact = []
|
# self._last_selected_contact = []
|
||||||
# return
|
# return
|
||||||
# jid = row[C_JID]
|
# jid = row[Column.JID]
|
||||||
# account = row[C_ACCOUNT]
|
# account = row[Column.ACCOUNT]
|
||||||
# self._last_selected_contact.append((jid, account))
|
# self._last_selected_contact.append((jid, account))
|
||||||
# GLib.idle_add(self.draw_contact, jid, account, True)
|
# GLib.idle_add(self.draw_contact, jid, account, True)
|
||||||
|
|
||||||
|
@ -4283,8 +4283,8 @@ class RosterWindow:
|
||||||
# select first row
|
# select first row
|
||||||
self.tree.get_selection().unselect_all()
|
self.tree.get_selection().unselect_all()
|
||||||
def _func(model, path, iter_, param):
|
def _func(model, path, iter_, param):
|
||||||
if model[iter_][C_TYPE] == 'contact' and self.rfilter_string in \
|
if model[iter_][Column.TYPE] == 'contact' and self.rfilter_string in \
|
||||||
model[iter_][C_NAME].lower():
|
model[iter_][Column.NAME].lower():
|
||||||
col = self.tree.get_column(0)
|
col = self.tree.get_column(0)
|
||||||
self.tree.set_cursor_on_cell(path, col, None, False)
|
self.tree.set_cursor_on_cell(path, col, None, False)
|
||||||
return True
|
return True
|
||||||
|
@ -4361,7 +4361,7 @@ class RosterWindow:
|
||||||
path = list_of_paths[0]
|
path = list_of_paths[0]
|
||||||
data = ''
|
data = ''
|
||||||
if path.get_depth() >= 2:
|
if path.get_depth() >= 2:
|
||||||
data = model[path][C_JID]
|
data = model[path][Column.JID]
|
||||||
selection.set_text(data, -1)
|
selection.set_text(data, -1)
|
||||||
|
|
||||||
def drag_begin(self, treeview, context):
|
def drag_begin(self, treeview, context):
|
||||||
|
@ -4570,9 +4570,9 @@ class RosterWindow:
|
||||||
path_dest = (path_dest[0], path_dest[1]-1)
|
path_dest = (path_dest[0], path_dest[1]-1)
|
||||||
# destination: the row something got dropped on
|
# destination: the row something got dropped on
|
||||||
iter_dest = model.get_iter(path_dest)
|
iter_dest = model.get_iter(path_dest)
|
||||||
type_dest = model[iter_dest][C_TYPE]
|
type_dest = model[iter_dest][Column.TYPE]
|
||||||
jid_dest = model[iter_dest][C_JID]
|
jid_dest = model[iter_dest][Column.JID]
|
||||||
account_dest = model[iter_dest][C_ACCOUNT]
|
account_dest = model[iter_dest][Column.ACCOUNT]
|
||||||
|
|
||||||
# drop on account row in merged mode, we cannot know the desired account
|
# drop on account row in merged mode, we cannot know the desired account
|
||||||
if account_dest == 'all':
|
if account_dest == 'all':
|
||||||
|
@ -4635,8 +4635,8 @@ class RosterWindow:
|
||||||
# source: the row that was dragged
|
# source: the row that was dragged
|
||||||
path_source = treeview.get_selection().get_selected_rows()[1][0]
|
path_source = treeview.get_selection().get_selected_rows()[1][0]
|
||||||
iter_source = model.get_iter(path_source)
|
iter_source = model.get_iter(path_source)
|
||||||
type_source = model[iter_source][C_TYPE]
|
type_source = model[iter_source][Column.TYPE]
|
||||||
account_source = model[iter_source][C_ACCOUNT]
|
account_source = model[iter_source][Column.ACCOUNT]
|
||||||
|
|
||||||
if gajim.config.get_per('accounts', account_source, 'is_zeroconf'):
|
if gajim.config.get_per('accounts', account_source, 'is_zeroconf'):
|
||||||
return
|
return
|
||||||
|
@ -4654,18 +4654,18 @@ class RosterWindow:
|
||||||
if account_source != account_dest:
|
if account_source != account_dest:
|
||||||
# drop on another account
|
# drop on another account
|
||||||
return
|
return
|
||||||
grp_source = model[iter_source][C_JID]
|
grp_source = model[iter_source][Column.JID]
|
||||||
delimiter = gajim.connections[account_source].nested_group_delimiter
|
delimiter = gajim.connections[account_source].nested_group_delimiter
|
||||||
grp_source_list = grp_source.split(delimiter)
|
grp_source_list = grp_source.split(delimiter)
|
||||||
new_grp = None
|
new_grp = None
|
||||||
if type_dest == 'account':
|
if type_dest == 'account':
|
||||||
new_grp = grp_source_list[-1]
|
new_grp = grp_source_list[-1]
|
||||||
elif type_dest == 'group':
|
elif type_dest == 'group':
|
||||||
grp_dest = model[iter_dest][C_JID]
|
grp_dest = model[iter_dest][Column.JID]
|
||||||
grp_dest_list = grp_dest.split(delimiter)
|
grp_dest_list = grp_dest.split(delimiter)
|
||||||
# Do not allow to drop on a subgroup of source group
|
# Do not allow to drop on a subgroup of source group
|
||||||
if grp_source_list[0] != grp_dest_list[0]:
|
if grp_source_list[0] != grp_dest_list[0]:
|
||||||
new_grp = model[iter_dest][C_JID] + delimiter + \
|
new_grp = model[iter_dest][Column.JID] + delimiter + \
|
||||||
grp_source_list[-1]
|
grp_source_list[-1]
|
||||||
if new_grp:
|
if new_grp:
|
||||||
self.move_group(grp_source, new_grp, account_source)
|
self.move_group(grp_source, new_grp, account_source)
|
||||||
|
@ -4685,9 +4685,9 @@ class RosterWindow:
|
||||||
|
|
||||||
# Get valid source group, jid and contact
|
# Get valid source group, jid and contact
|
||||||
it = iter_source
|
it = iter_source
|
||||||
while model[it][C_TYPE] == 'contact':
|
while model[it][Column.TYPE] == 'contact':
|
||||||
it = model.iter_parent(it)
|
it = model.iter_parent(it)
|
||||||
grp_source = model[it][C_JID]
|
grp_source = model[it][Column.JID]
|
||||||
if grp_source in helpers.special_groups and \
|
if grp_source in helpers.special_groups and \
|
||||||
grp_source not in ('Not in Roster', 'Observers'):
|
grp_source not in ('Not in Roster', 'Observers'):
|
||||||
# a transport or a minimized groupchat was dragged
|
# a transport or a minimized groupchat was dragged
|
||||||
|
@ -4701,12 +4701,12 @@ class RosterWindow:
|
||||||
# Get destination group
|
# Get destination group
|
||||||
grp_dest = None
|
grp_dest = None
|
||||||
if type_dest == 'group':
|
if type_dest == 'group':
|
||||||
grp_dest = model[iter_dest][C_JID]
|
grp_dest = model[iter_dest][Column.JID]
|
||||||
elif type_dest in ('contact', 'agent'):
|
elif type_dest in ('contact', 'agent'):
|
||||||
it = iter_dest
|
it = iter_dest
|
||||||
while model[it][C_TYPE] != 'group':
|
while model[it][Column.TYPE] != 'group':
|
||||||
it = model.iter_parent(it)
|
it = model.iter_parent(it)
|
||||||
grp_dest = model[it][C_JID]
|
grp_dest = model[it][Column.JID]
|
||||||
if grp_dest in helpers.special_groups:
|
if grp_dest in helpers.special_groups:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -4865,7 +4865,7 @@ class RosterWindow:
|
||||||
show = gajim.SHOW_LIST[status]
|
show = gajim.SHOW_LIST[status]
|
||||||
else: # accounts merged
|
else: # accounts merged
|
||||||
show = helpers.get_global_show()
|
show = helpers.get_global_show()
|
||||||
self.model[child_iterA][C_IMG] = gajim.interface.jabber_state_images[
|
self.model[child_iterA][Column.IMG] = gajim.interface.jabber_state_images[
|
||||||
'16'][show]
|
'16'][show]
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -4906,9 +4906,9 @@ class RosterWindow:
|
||||||
gtkgui_helpers.set_unset_urgency_hint(self.window, nb_unread)
|
gtkgui_helpers.set_unset_urgency_hint(self.window, nb_unread)
|
||||||
|
|
||||||
def _change_style(self, model, path, titer, option):
|
def _change_style(self, model, path, titer, option):
|
||||||
if option is None or model[titer][C_TYPE] == option:
|
if option is None or model[titer][Column.TYPE] == option:
|
||||||
# We changed style for this type of row
|
# We changed style for this type of row
|
||||||
model[titer][C_NAME] = model[titer][C_NAME]
|
model[titer][Column.NAME] = model[titer][Column.NAME]
|
||||||
|
|
||||||
def change_roster_style(self, option):
|
def change_roster_style(self, option):
|
||||||
self.model.foreach(self._change_style, option)
|
self.model.foreach(self._change_style, option)
|
||||||
|
@ -4954,7 +4954,7 @@ class RosterWindow:
|
||||||
When a row is added, set properties for icon renderer
|
When a row is added, set properties for icon renderer
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return
|
return
|
||||||
if type_ == 'account':
|
if type_ == 'account':
|
||||||
|
@ -4963,20 +4963,20 @@ class RosterWindow:
|
||||||
elif type_ == 'group':
|
elif type_ == 'group':
|
||||||
self._set_group_row_background_color(renderer)
|
self._set_group_row_background_color(renderer)
|
||||||
parent_iter = model.iter_parent(titer)
|
parent_iter = model.iter_parent(titer)
|
||||||
if model[parent_iter][C_TYPE] == 'group':
|
if model[parent_iter][Column.TYPE] == 'group':
|
||||||
renderer.set_property('xalign', 0.4)
|
renderer.set_property('xalign', 0.4)
|
||||||
else:
|
else:
|
||||||
renderer.set_property('xalign', 0.2)
|
renderer.set_property('xalign', 0.2)
|
||||||
elif type_:
|
elif type_:
|
||||||
# prevent type_ = None, see http://trac.gajim.org/ticket/2534
|
# prevent type_ = None, see http://trac.gajim.org/ticket/2534
|
||||||
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
|
if not model[titer][Column.JID] or not model[titer][Column.ACCOUNT]:
|
||||||
# This can append when at the moment we add the row
|
# This can append when at the moment we add the row
|
||||||
return
|
return
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
self._set_contact_row_background_color(renderer, jid, account)
|
self._set_contact_row_background_color(renderer, jid, account)
|
||||||
parent_iter = model.iter_parent(titer)
|
parent_iter = model.iter_parent(titer)
|
||||||
if model[parent_iter][C_TYPE] == 'contact':
|
if model[parent_iter][Column.TYPE] == 'contact':
|
||||||
renderer.set_property('xalign', 1)
|
renderer.set_property('xalign', 1)
|
||||||
else:
|
else:
|
||||||
renderer.set_property('xalign', 0.6)
|
renderer.set_property('xalign', 0.6)
|
||||||
|
@ -4987,7 +4987,7 @@ class RosterWindow:
|
||||||
When a row is added, set properties for name renderer
|
When a row is added, set properties for name renderer
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return
|
return
|
||||||
theme = gajim.config.get('roster_theme')
|
theme = gajim.config.get('roster_theme')
|
||||||
|
@ -5011,18 +5011,18 @@ class RosterWindow:
|
||||||
renderer.set_property('font',
|
renderer.set_property('font',
|
||||||
gtkgui_helpers.get_theme_font_for_option(theme, 'groupfont'))
|
gtkgui_helpers.get_theme_font_for_option(theme, 'groupfont'))
|
||||||
parent_iter = model.iter_parent(titer)
|
parent_iter = model.iter_parent(titer)
|
||||||
if model[parent_iter][C_TYPE] == 'group':
|
if model[parent_iter][Column.TYPE] == 'group':
|
||||||
renderer.set_property('xpad', 8)
|
renderer.set_property('xpad', 8)
|
||||||
else:
|
else:
|
||||||
renderer.set_property('xpad', 4)
|
renderer.set_property('xpad', 4)
|
||||||
self._set_group_row_background_color(renderer)
|
self._set_group_row_background_color(renderer)
|
||||||
elif type_:
|
elif type_:
|
||||||
# prevent type_ = None, see http://trac.gajim.org/ticket/2534
|
# prevent type_ = None, see http://trac.gajim.org/ticket/2534
|
||||||
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
|
if not model[titer][Column.JID] or not model[titer][Column.ACCOUNT]:
|
||||||
# This can append when at the moment we add the row
|
# This can append when at the moment we add the row
|
||||||
return
|
return
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
color = None
|
color = None
|
||||||
if type_ == 'groupchat':
|
if type_ == 'groupchat':
|
||||||
ctrl = gajim.interface.minimized_controls[account].get(jid,
|
ctrl = gajim.interface.minimized_controls[account].get(jid,
|
||||||
|
@ -5042,7 +5042,7 @@ class RosterWindow:
|
||||||
renderer.set_property('font',
|
renderer.set_property('font',
|
||||||
gtkgui_helpers.get_theme_font_for_option(theme, 'contactfont'))
|
gtkgui_helpers.get_theme_font_for_option(theme, 'contactfont'))
|
||||||
parent_iter = model.iter_parent(titer)
|
parent_iter = model.iter_parent(titer)
|
||||||
if model[parent_iter][C_TYPE] == 'contact':
|
if model[parent_iter][Column.TYPE] == 'contact':
|
||||||
renderer.set_property('xpad', 16)
|
renderer.set_property('xpad', 16)
|
||||||
else:
|
else:
|
||||||
renderer.set_property('xpad', 12)
|
renderer.set_property('xpad', 12)
|
||||||
|
@ -5053,7 +5053,7 @@ class RosterWindow:
|
||||||
When a row is added, draw the respective pep icon
|
When a row is added, draw the respective pep icon
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -5067,11 +5067,11 @@ class RosterWindow:
|
||||||
self._set_account_row_background_color(renderer)
|
self._set_account_row_background_color(renderer)
|
||||||
renderer.set_property('xalign', 1)
|
renderer.set_property('xalign', 1)
|
||||||
elif type_:
|
elif type_:
|
||||||
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
|
if not model[titer][Column.JID] or not model[titer][Column.ACCOUNT]:
|
||||||
# This can append at the moment we add the row
|
# This can append at the moment we add the row
|
||||||
return
|
return
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
self._set_contact_row_background_color(renderer, jid, account)
|
self._set_contact_row_background_color(renderer, jid, account)
|
||||||
|
|
||||||
def _fill_avatar_pixbuf_renderer(self, column, renderer, model, titer,
|
def _fill_avatar_pixbuf_renderer(self, column, renderer, model, titer,
|
||||||
|
@ -5080,7 +5080,7 @@ class RosterWindow:
|
||||||
When a row is added, set properties for avatar renderer
|
When a row is added, set properties for avatar renderer
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -5089,20 +5089,20 @@ class RosterWindow:
|
||||||
return
|
return
|
||||||
|
|
||||||
# allocate space for the icon only if needed
|
# allocate space for the icon only if needed
|
||||||
if model[titer][C_AVATAR_PIXBUF] or \
|
if model[titer][Column.AVATAR_PIXBUF] or \
|
||||||
gajim.config.get('avatar_position_in_roster') == 'left':
|
gajim.config.get('avatar_position_in_roster') == 'left':
|
||||||
renderer.set_property('visible', True)
|
renderer.set_property('visible', True)
|
||||||
if type_:
|
if type_:
|
||||||
# prevent type_ = None, see http://trac.gajim.org/ticket/2534
|
# prevent type_ = None, see http://trac.gajim.org/ticket/2534
|
||||||
if not model[titer][C_JID] or not model[titer][C_ACCOUNT]:
|
if not model[titer][Column.JID] or not model[titer][Column.ACCOUNT]:
|
||||||
# This can append at the moment we add the row
|
# This can append at the moment we add the row
|
||||||
return
|
return
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
self._set_contact_row_background_color(renderer, jid, account)
|
self._set_contact_row_background_color(renderer, jid, account)
|
||||||
else:
|
else:
|
||||||
renderer.set_property('visible', False)
|
renderer.set_property('visible', False)
|
||||||
if model[titer][C_AVATAR_PIXBUF] == empty_pixbuf and \
|
if model[titer][Column.AVATAR_PIXBUF] == empty_pixbuf and \
|
||||||
gajim.config.get('avatar_position_in_roster') != 'left':
|
gajim.config.get('avatar_position_in_roster') != 'left':
|
||||||
renderer.set_property('visible', False)
|
renderer.set_property('visible', False)
|
||||||
|
|
||||||
|
@ -5119,12 +5119,12 @@ class RosterWindow:
|
||||||
When a row is added, set properties for padlock renderer
|
When a row is added, set properties for padlock renderer
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
type_ = model[titer][C_TYPE]
|
type_ = model[titer][Column.TYPE]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return
|
return
|
||||||
|
|
||||||
# allocate space for the icon only if needed
|
# allocate space for the icon only if needed
|
||||||
if type_ == 'account' and model[titer][C_PADLOCK_PIXBUF]:
|
if type_ == 'account' and model[titer][Column.PADLOCK_PIXBUF]:
|
||||||
renderer.set_property('visible', True)
|
renderer.set_property('visible', True)
|
||||||
self._set_account_row_background_color(renderer)
|
self._set_account_row_background_color(renderer)
|
||||||
renderer.set_property('xalign', 1) # align pixbuf to the right
|
renderer.set_property('xalign', 1) # align pixbuf to the right
|
||||||
|
@ -5596,7 +5596,7 @@ class RosterWindow:
|
||||||
Make account's popup menu
|
Make account's popup menu
|
||||||
"""
|
"""
|
||||||
model = self.modelfilter
|
model = self.modelfilter
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
|
|
||||||
if account != 'all': # not in merged mode
|
if account != 'all': # not in merged mode
|
||||||
menu = self.build_account_menu(account)
|
menu = self.build_account_menu(account)
|
||||||
|
@ -5627,14 +5627,14 @@ class RosterWindow:
|
||||||
"""
|
"""
|
||||||
model = self.modelfilter
|
model = self.modelfilter
|
||||||
path = model.get_path(titer)
|
path = model.get_path(titer)
|
||||||
group = model[titer][C_JID]
|
group = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
|
|
||||||
list_ = [] # list of (contact, account) tuples
|
list_ = [] # list of (contact, account) tuples
|
||||||
list_online = [] # list of (contact, account) tuples
|
list_online = [] # list of (contact, account) tuples
|
||||||
|
|
||||||
show_bookmarked = True
|
show_bookmarked = True
|
||||||
group = model[titer][C_JID]
|
group = model[titer][Column.JID]
|
||||||
for jid in gajim.contacts.get_jid_list(account):
|
for jid in gajim.contacts.get_jid_list(account):
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account,
|
contact = gajim.contacts.get_contact_with_highest_priority(account,
|
||||||
jid)
|
jid)
|
||||||
|
@ -5773,8 +5773,8 @@ class RosterWindow:
|
||||||
Make contact's popup menu
|
Make contact's popup menu
|
||||||
"""
|
"""
|
||||||
model = self.modelfilter
|
model = self.modelfilter
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
menu = gui_menu_builder.get_contact_menu(contact, account)
|
menu = gui_menu_builder.get_contact_menu(contact, account)
|
||||||
event_button = gtkgui_helpers.get_possible_button_event(event)
|
event_button = gtkgui_helpers.get_possible_button_event(event)
|
||||||
|
@ -5791,8 +5791,8 @@ class RosterWindow:
|
||||||
is_blocked = True
|
is_blocked = True
|
||||||
privacy_rules_supported = True
|
privacy_rules_supported = True
|
||||||
for titer in iters:
|
for titer in iters:
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
if gajim.connections[account].connected < 2:
|
if gajim.connections[account].connected < 2:
|
||||||
one_account_offline = True
|
one_account_offline = True
|
||||||
if not gajim.connections[account].privacy_rules_supported:
|
if not gajim.connections[account].privacy_rules_supported:
|
||||||
|
@ -5881,9 +5881,9 @@ class RosterWindow:
|
||||||
Make transport's popup menu
|
Make transport's popup menu
|
||||||
"""
|
"""
|
||||||
model = self.modelfilter
|
model = self.modelfilter
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
path = model.get_path(titer)
|
path = model.get_path(titer)
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
menu = gui_menu_builder.get_transport_menu(contact, account)
|
menu = gui_menu_builder.get_transport_menu(contact, account)
|
||||||
event_button = gtkgui_helpers.get_possible_button_event(event)
|
event_button = gtkgui_helpers.get_possible_button_event(event)
|
||||||
|
@ -5893,8 +5893,8 @@ class RosterWindow:
|
||||||
def make_groupchat_menu(self, event, titer):
|
def make_groupchat_menu(self, event, titer):
|
||||||
model = self.modelfilter
|
model = self.modelfilter
|
||||||
|
|
||||||
jid = model[titer][C_JID]
|
jid = model[titer][Column.JID]
|
||||||
account = model[titer][C_ACCOUNT]
|
account = model[titer][Column.ACCOUNT]
|
||||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||||
menu = Gtk.Menu()
|
menu = Gtk.Menu()
|
||||||
|
|
||||||
|
@ -6063,9 +6063,9 @@ class RosterWindow:
|
||||||
def show_appropriate_context_menu(self, event, iters):
|
def show_appropriate_context_menu(self, event, iters):
|
||||||
# iters must be all of the same type
|
# iters must be all of the same type
|
||||||
model = self.modelfilter
|
model = self.modelfilter
|
||||||
type_ = model[iters[0]][C_TYPE]
|
type_ = model[iters[0]][Column.TYPE]
|
||||||
for titer in iters[1:]:
|
for titer in iters[1:]:
|
||||||
if model[titer][C_TYPE] != type_:
|
if model[titer][Column.TYPE] != type_:
|
||||||
return
|
return
|
||||||
if type_ == 'group' and len(iters) == 1:
|
if type_ == 'group' and len(iters) == 1:
|
||||||
self.make_group_menu(event, iters[0])
|
self.make_group_menu(event, iters[0])
|
||||||
|
@ -6137,9 +6137,9 @@ class RosterWindow:
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
typ = model[iter_][C_TYPE]
|
typ = model[iter_][Column.TYPE]
|
||||||
account = model[iter_][C_ACCOUNT]
|
account = model[iter_][Column.ACCOUNT]
|
||||||
jid = model[iter_][C_JID]
|
jid = model[iter_][Column.JID]
|
||||||
connected_contacts = []
|
connected_contacts = []
|
||||||
|
|
||||||
if typ in ('contact', 'self_contact'):
|
if typ in ('contact', 'self_contact'):
|
||||||
|
@ -6340,9 +6340,9 @@ class RosterWindow:
|
||||||
# cell_data_func, func_arg)
|
# cell_data_func, func_arg)
|
||||||
self.renderers_list = []
|
self.renderers_list = []
|
||||||
self.renderers_propertys ={}
|
self.renderers_propertys ={}
|
||||||
self._pep_type_to_model_column = {'mood': C_MOOD_PIXBUF,
|
self._pep_type_to_model_column = {'mood': Column.MOOD_PIXBUF,
|
||||||
'activity': C_ACTIVITY_PIXBUF, 'tune': C_TUNE_PIXBUF,
|
'activity': Column.ACTIVITY_PIXBUF, 'tune': Column.TUNE_PIXBUF,
|
||||||
'location': C_LOCATION_PIXBUF}
|
'location': Column.LOCATION_PIXBUF}
|
||||||
|
|
||||||
renderer_text = Gtk.CellRendererText()
|
renderer_text = Gtk.CellRendererText()
|
||||||
self.renderers_propertys[renderer_text] = ('ellipsize',
|
self.renderers_propertys[renderer_text] = ('ellipsize',
|
||||||
|
@ -6350,7 +6350,7 @@ class RosterWindow:
|
||||||
|
|
||||||
def add_avatar_renderer():
|
def add_avatar_renderer():
|
||||||
self.renderers_list.append(('avatar', Gtk.CellRendererPixbuf(),
|
self.renderers_list.append(('avatar', Gtk.CellRendererPixbuf(),
|
||||||
False, 'pixbuf', C_AVATAR_PIXBUF,
|
False, 'pixbuf', Column.AVATAR_PIXBUF,
|
||||||
self._fill_avatar_pixbuf_renderer, None))
|
self._fill_avatar_pixbuf_renderer, None))
|
||||||
|
|
||||||
if gajim.config.get('avatar_position_in_roster') == 'left':
|
if gajim.config.get('avatar_position_in_roster') == 'left':
|
||||||
|
@ -6358,32 +6358,32 @@ class RosterWindow:
|
||||||
|
|
||||||
self.renderers_list += (
|
self.renderers_list += (
|
||||||
('icon', cell_renderer_image.CellRendererImage(0, 0), False,
|
('icon', cell_renderer_image.CellRendererImage(0, 0), False,
|
||||||
'image', C_IMG, self._iconCellDataFunc, None),
|
'image', Column.IMG, self._iconCellDataFunc, None),
|
||||||
|
|
||||||
('name', renderer_text, True,
|
('name', renderer_text, True,
|
||||||
'markup', C_NAME, self._nameCellDataFunc, None),
|
'markup', Column.NAME, self._nameCellDataFunc, None),
|
||||||
|
|
||||||
('mood', Gtk.CellRendererPixbuf(), False,
|
('mood', Gtk.CellRendererPixbuf(), False,
|
||||||
'pixbuf', C_MOOD_PIXBUF,
|
'pixbuf', Column.MOOD_PIXBUF,
|
||||||
self._fill_pep_pixbuf_renderer, C_MOOD_PIXBUF),
|
self._fill_pep_pixbuf_renderer, Column.MOOD_PIXBUF),
|
||||||
|
|
||||||
('activity', Gtk.CellRendererPixbuf(), False,
|
('activity', Gtk.CellRendererPixbuf(), False,
|
||||||
'pixbuf', C_ACTIVITY_PIXBUF,
|
'pixbuf', Column.ACTIVITY_PIXBUF,
|
||||||
self._fill_pep_pixbuf_renderer, C_ACTIVITY_PIXBUF),
|
self._fill_pep_pixbuf_renderer, Column.ACTIVITY_PIXBUF),
|
||||||
|
|
||||||
('tune', Gtk.CellRendererPixbuf(), False,
|
('tune', Gtk.CellRendererPixbuf(), False,
|
||||||
'pixbuf', C_TUNE_PIXBUF,
|
'pixbuf', Column.TUNE_PIXBUF,
|
||||||
self._fill_pep_pixbuf_renderer, C_TUNE_PIXBUF),
|
self._fill_pep_pixbuf_renderer, Column.TUNE_PIXBUF),
|
||||||
|
|
||||||
('location', Gtk.CellRendererPixbuf(), False,
|
('location', Gtk.CellRendererPixbuf(), False,
|
||||||
'pixbuf', C_LOCATION_PIXBUF,
|
'pixbuf', Column.LOCATION_PIXBUF,
|
||||||
self._fill_pep_pixbuf_renderer, C_LOCATION_PIXBUF))
|
self._fill_pep_pixbuf_renderer, Column.LOCATION_PIXBUF))
|
||||||
|
|
||||||
if gajim.config.get('avatar_position_in_roster') == 'right':
|
if gajim.config.get('avatar_position_in_roster') == 'right':
|
||||||
add_avatar_renderer()
|
add_avatar_renderer()
|
||||||
|
|
||||||
self.renderers_list.append(('padlock', Gtk.CellRendererPixbuf(), False,
|
self.renderers_list.append(('padlock', Gtk.CellRendererPixbuf(), False,
|
||||||
'pixbuf', C_PADLOCK_PIXBUF,
|
'pixbuf', Column.PADLOCK_PIXBUF,
|
||||||
self._fill_padlock_pixbuf_renderer, None))
|
self._fill_padlock_pixbuf_renderer, None))
|
||||||
|
|
||||||
# fill and append column
|
# fill and append column
|
||||||
|
|
Loading…
Add table
Reference in a new issue