Remove old iconset code

This commit is contained in:
Philipp Hörist 2018-11-18 16:09:32 +01:00
parent 619793a085
commit 3ba34fa396
6 changed files with 2 additions and 174 deletions

View File

@ -1098,12 +1098,6 @@ def get_current_show(account):
status = app.connections[account].connected
return app.SHOW_LIST[status]
def get_iconset_path(iconset):
if os.path.isdir(os.path.join(configpaths.get('DATA'), 'iconsets', iconset)):
return os.path.join(configpaths.get('DATA'), 'iconsets', iconset)
if os.path.isdir(os.path.join(configpaths.get('MY_ICONSETS'), iconset)):
return os.path.join(configpaths.get('MY_ICONSETS'), iconset)
def get_mood_iconset_path(iconset):
if os.path.isdir(os.path.join(configpaths.get('DATA'), 'moods', iconset)):
return os.path.join(configpaths.get('DATA'), 'moods', iconset)
@ -1118,16 +1112,6 @@ def get_activity_iconset_path(iconset):
iconset)):
return os.path.join(configpaths.get('MY_ACTIVITY_ICONSETS'), iconset)
def get_transport_path(transport):
if os.path.isdir(os.path.join(configpaths.get('DATA'), 'iconsets', 'transports',
transport)):
return os.path.join(configpaths.get('DATA'), 'iconsets', 'transports', transport)
if os.path.isdir(os.path.join(configpaths.get('MY_ICONSETS'), 'transports',
transport)):
return os.path.join(configpaths.get('MY_ICONSETS'), 'transports', transport)
# No transport folder found, use default jabber one
return get_iconset_path(app.config.get('iconset'))
def prepare_and_validate_gpg_keyID(account, jid, keyID):
"""
Return an eight char long keyID that can be used with for GPG encryption

View File

@ -27,7 +27,6 @@ from gajim.common import idle
from gajim.common.i18n import _
from gajim import message_control
from gajim import gtkgui_helpers
from gajim.chat_control_base import ChatControlBase
@ -951,11 +950,10 @@ class Preferences(Gtk.ApplicationWindow):
active = widget.get_active()
icon_string = model[active][1]
app.config.set('iconset', icon_string)
gtkgui_helpers.reload_jabber_state_images()
app.interface.roster.update_icons()
def on_transports_iconsets_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'use_transports_iconsets')
gtkgui_helpers.reload_jabber_state_images()
### Audio/Video tab ###
def on_av_combobox_changed(self, combobox, config_name):

View File

@ -23,7 +23,6 @@
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
import cairo
import os
import sys
import math
@ -312,24 +311,6 @@ def create_list_multi(value_list, selected_values=None):
treeview.show_all()
return treeview
def load_iconset(path, pixbuf2=None, transport=False):
"""
Load full iconset from the given path, and add pixbuf2 on top left of each
static images
"""
path += '/'
if transport:
list_ = ('online', 'chat', 'away', 'xa', 'dnd', 'offline',
'not in roster')
else:
list_ = ('connecting', 'online', 'chat', 'away', 'xa', 'dnd',
'invisible', 'offline', 'error', 'requested', 'event', 'opened',
'closed', 'not in roster', 'muc_active', 'muc_inactive')
if pixbuf2:
list_ = ('connecting', 'online', 'chat', 'away', 'xa', 'dnd',
'offline', 'error', 'requested', 'event', 'not in roster')
return _load_icon_list(list_, path, pixbuf2)
def load_mood_icon(icon_name):
"""
Load an icon from the mood iconset in 16x16
@ -382,31 +363,6 @@ def get_pep_icon(pep_class):
return None
def load_icons_meta():
"""
Load and return - AND + small icons to put on top left of an icon for meta
contacts
"""
iconset = app.config.get('iconset')
path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
# try to find opened_meta.png file, else opened.png else nopixbuf merge
path_opened = os.path.join(path, 'opened_meta.png')
if not os.path.isfile(path_opened):
path_opened = os.path.join(path, 'opened.png')
if os.path.isfile(path_opened):
pixo = GdkPixbuf.Pixbuf.new_from_file(path_opened)
else:
pixo = None
# Same thing for closed
path_closed = os.path.join(path, 'opened_meta.png')
if not os.path.isfile(path_closed):
path_closed = os.path.join(path, 'closed.png')
if os.path.isfile(path_closed):
pixc = GdkPixbuf.Pixbuf.new_from_file(path_closed)
else:
pixc = None
return pixo, pixc
def _load_icon_list(icons_list, path, pixbuf2=None):
"""
Load icons in icons_list from the given path, and add pixbuf2 on top left of
@ -436,64 +392,6 @@ def _load_icon_list(icons_list, path, pixbuf2=None):
break
return imgs
def make_jabber_state_images():
"""
Initialize jabber_state_images dictionary
"""
iconset = app.config.get('iconset')
if iconset:
if helpers.get_iconset_path(iconset):
path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
if not os.path.exists(path):
iconset = app.config.DEFAULT_ICONSET
app.config.set('iconset', iconset)
else:
iconset = app.config.DEFAULT_ICONSET
app.config.set('iconset', iconset)
else:
iconset = app.config.DEFAULT_ICONSET
app.config.set('iconset', iconset)
path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
app.interface.jabber_state_images['16'] = load_iconset(path)
pixo, pixc = load_icons_meta()
app.interface.jabber_state_images['opened'] = load_iconset(path, pixo)
app.interface.jabber_state_images['closed'] = load_iconset(path, pixc)
path = os.path.join(helpers.get_iconset_path(iconset), '32x32')
app.interface.jabber_state_images['32'] = load_iconset(path)
path = os.path.join(helpers.get_iconset_path(iconset), '24x24')
if os.path.exists(path):
app.interface.jabber_state_images['24'] = load_iconset(path)
else:
# Resize 32x32 icons to 24x24
for each in app.interface.jabber_state_images['32']:
img = Gtk.Image()
pix = app.interface.jabber_state_images['32'][each]
pix_type = pix.get_storage_type()
if pix_type == Gtk.ImageType.ANIMATION:
animation = pix.get_animation()
pixbuf = animation.get_static_image()
elif pix_type == Gtk.ImageType.EMPTY:
pix = app.interface.jabber_state_images['16'][each]
pix_16_type = pix.get_storage_type()
if pix_16_type == Gtk.ImageType.ANIMATION:
animation = pix.get_animation()
pixbuf = animation.get_static_image()
else:
pixbuf = pix.get_pixbuf()
else:
pixbuf = pix.get_pixbuf()
scaled_pix = pixbuf.scale_simple(24, 24, GdkPixbuf.InterpType.BILINEAR)
img.set_from_pixbuf(scaled_pix)
app.interface.jabber_state_images['24'][each] = img
def reload_jabber_state_images():
make_jabber_state_images()
app.interface.roster.update_jabber_state_images()
def label_set_autowrap(widget):
"""
Make labels automatically re-wrap if their containers are resized.

View File

@ -2544,8 +2544,6 @@ class Interface:
app.thread_interface = ThreadInterface
# This is the manager and factory of message windows set by the module
self.msg_win_mgr = None
self.jabber_state_images = {'16': {}, '24': {}, '32': {}, 'opened': {},
'closed': {}}
self.minimized_controls = {}
self.status_sent_to_users = {}
self.status_sent_to_groups = {}
@ -2692,8 +2690,6 @@ class Interface:
idle.Monitor.set_interval(app.config.get('autoawaytime') * 60,
app.config.get('autoxatime') * 60)
gtkgui_helpers.make_jabber_state_images()
self.systray_enabled = False
from gajim.gtk import statusicon

View File

@ -4574,45 +4574,7 @@ class RosterWindow:
### Cleanup assigned to Jim++ :-)
################################################################################
def get_appropriate_state_images(self, jid, size='16', icon_name='online'):
"""
Check jid and return the appropriate state images dict for the demanded
size. icon_name is taken into account when jid is from transport:
transport iconset doesn't contain all icons, so we fall back to jabber
one
"""
transport = app.get_transport_name_from_jid(jid)
if transport and size in self.transports_state_images:
if transport not in self.transports_state_images[size]:
# we don't have iconset for this transport loaded yet. Let's do
# it
self.make_transport_state_images(transport)
if transport in self.transports_state_images[size] and \
icon_name in self.transports_state_images[size][transport]:
return self.transports_state_images[size][transport]
return app.interface.jabber_state_images[size]
def make_transport_state_images(self, transport):
"""
Initialize opened and closed 'transport' iconset dict
"""
if not app.config.get('use_transports_iconsets'):
return
folder = os.path.join(helpers.get_transport_path(transport), '32x32')
self.transports_state_images['32'][transport] = \
gtkgui_helpers.load_iconset(folder, transport=True)
folder = os.path.join(helpers.get_transport_path(transport), '16x16')
self.transports_state_images['16'][transport] = \
gtkgui_helpers.load_iconset(folder, transport=True)
pixo, pixc = gtkgui_helpers.load_icons_meta()
self.transports_state_images['opened'][transport] = \
gtkgui_helpers.load_iconset(folder, pixo, transport=True)
self.transports_state_images['closed'][transport] = \
gtkgui_helpers.load_iconset(folder, pixc, transport=True)
def update_jabber_state_images(self):
def update_icons(self):
# Update the roster
self.setup_and_draw_roster()
# Update the status combobox

View File

@ -107,16 +107,6 @@ class MockInterface(Mock):
self.minimized_controls = {}
self.status_sent_to_users = Mock()
if app.use_x:
self.jabber_state_images = {'16': {}, '24': {}, '32': {},
'opened': {}, 'closed': {}}
from gajim import gtkgui_helpers
gtkgui_helpers.make_jabber_state_images()
else:
self.jabber_state_images = {'16': Mock(), '24': Mock(),
'32': Mock(), 'opened': Mock(), 'closed': Mock()}
class MockLogger(Mock):
def __init__(self):