Use get_icon_name() instead of get_iconset_name_for()
This commit is contained in:
parent
9734e7bdea
commit
960008a69a
|
@ -54,6 +54,7 @@ from gajim import dialogs
|
|||
|
||||
from gajim.gtk.dialogs import ConfirmationDialog
|
||||
from gajim.gtk.add_contact import AddNewContactWindow
|
||||
from gajim.gtk.util import get_icon_name
|
||||
|
||||
from gajim.command_system.implementation.hosts import ChatCommands
|
||||
from gajim.command_system.framework import CommandHost # pylint: disable=unused-import
|
||||
|
@ -612,7 +613,7 @@ class ChatControl(ChatControlBase):
|
|||
show = contact.show
|
||||
|
||||
# Set banner image
|
||||
icon = gtkgui_helpers.get_iconset_name_for(show)
|
||||
icon = get_icon_name(show)
|
||||
banner_status_img = self.xml.get_object('banner_status_image')
|
||||
banner_status_img.set_from_icon_name(icon, Gtk.IconSize.DND)
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ from gajim.common.exceptions import GajimGeneralException
|
|||
# Compat with Gajim 1.0.3 for plugins
|
||||
from gajim.gtk.dialogs import *
|
||||
from gajim.gtk.add_contact import AddNewContactWindow
|
||||
from gajim.gtk.util import get_icon_name
|
||||
|
||||
|
||||
log = logging.getLogger('gajim.dialogs')
|
||||
|
@ -1439,7 +1440,7 @@ class TransformChatToMUC:
|
|||
# Add contact if it can be invited
|
||||
if invitable(contact, contact_transport) and \
|
||||
contact.show not in ('offline', 'error'):
|
||||
icon_name = gtkgui_helpers.get_iconset_name_for(contact.show)
|
||||
icon_name = get_icon_name(contact.show)
|
||||
name = contact.name
|
||||
if name == '':
|
||||
name = jid.split('@')[0]
|
||||
|
|
|
@ -39,7 +39,6 @@ from gi.repository import Pango
|
|||
from gi.repository import GLib
|
||||
from gi.repository import Gio
|
||||
|
||||
|
||||
from gajim import gtkgui_helpers
|
||||
from gajim import gui_menu_builder
|
||||
from gajim import message_control
|
||||
|
@ -77,6 +76,8 @@ from gajim.gtk.dialogs import ChangeNickDialog
|
|||
from gajim.gtk.filechoosers import AvatarChooserDialog
|
||||
from gajim.gtk.add_contact import AddNewContactWindow
|
||||
from gajim.gtk.tooltips import GCTooltip
|
||||
from gajim.gtk.util import get_icon_name
|
||||
from gajim.gtk.util import get_image_from_icon_name
|
||||
|
||||
|
||||
log = logging.getLogger('gajim.groupchat_control')
|
||||
|
@ -1092,9 +1093,9 @@ class GroupchatControl(ChatControlBase):
|
|||
def get_tab_image(self, count_unread=True):
|
||||
tab_image = None
|
||||
if self.is_connected:
|
||||
tab_image = gtkgui_helpers.get_iconset_name_for('muc-active')
|
||||
tab_image = get_icon_name('muc-active')
|
||||
else:
|
||||
tab_image = gtkgui_helpers.get_iconset_name_for('muc-inactive')
|
||||
tab_image = get_icon_name('muc-inactive')
|
||||
return tab_image
|
||||
|
||||
def update_ui(self):
|
||||
|
@ -1156,9 +1157,9 @@ class GroupchatControl(ChatControlBase):
|
|||
self.scale_factor)
|
||||
banner_status_img.set_from_surface(surface)
|
||||
return
|
||||
icon = gtkgui_helpers.get_iconset_name_for('muc-active')
|
||||
icon = get_icon_name('muc-active')
|
||||
else:
|
||||
icon = gtkgui_helpers.get_iconset_name_for('muc-inactive')
|
||||
icon = get_icon_name('muc-inactive')
|
||||
banner_status_img.set_from_icon_name(icon, Gtk.IconSize.DND)
|
||||
|
||||
def get_continued_conversation_name(self):
|
||||
|
@ -1761,10 +1762,10 @@ class GroupchatControl(ChatControlBase):
|
|||
nick)
|
||||
theme = Gtk.IconTheme.get_default()
|
||||
if app.events.get_events(self.account, self.room_jid + '/' + nick):
|
||||
icon_name = gtkgui_helpers.get_iconset_name_for('event')
|
||||
icon_name = get_icon_name('event')
|
||||
surface = theme.load_surface(icon_name, 16, self.scale_factor, None, 0)
|
||||
else:
|
||||
icon_name = gtkgui_helpers.get_iconset_name_for(gc_contact.show)
|
||||
icon_name = get_icon_name(gc_contact.show)
|
||||
surface = theme.load_surface(icon_name, 16, self.scale_factor, None, 0)
|
||||
|
||||
name = GLib.markup_escape_text(gc_contact.name)
|
||||
|
@ -2123,8 +2124,7 @@ class GroupchatControl(ChatControlBase):
|
|||
# Create Role
|
||||
role_iter = self.get_role_iter(role)
|
||||
if not role_iter:
|
||||
image = gtkgui_helpers.get_image_from_icon_name('closed',
|
||||
self.scale_factor)
|
||||
image = get_image_from_icon_name('closed', self.scale_factor)
|
||||
ext_columns = [None] * self.nb_ext_renderers
|
||||
row = [image, role, 'role', role_name, None] + ext_columns
|
||||
role_iter = self.model.append(None, row)
|
||||
|
@ -2590,8 +2590,7 @@ class GroupchatControl(ChatControlBase):
|
|||
When a row is expanded: change the icon of the arrow
|
||||
"""
|
||||
model = widget.get_model()
|
||||
image = gtkgui_helpers.get_image_from_icon_name(
|
||||
'opened', self.scale_factor)
|
||||
image = get_image_from_icon_name('opened', self.scale_factor)
|
||||
model[iter_][Column.IMG] = image
|
||||
|
||||
def on_list_treeview_row_collapsed(self, widget, iter_, path):
|
||||
|
@ -2599,8 +2598,7 @@ class GroupchatControl(ChatControlBase):
|
|||
When a row is collapsed: change the icon of the arrow
|
||||
"""
|
||||
model = widget.get_model()
|
||||
image = gtkgui_helpers.get_image_from_icon_name(
|
||||
'closed', self.scale_factor)
|
||||
image = get_image_from_icon_name('closed', self.scale_factor)
|
||||
model[iter_][Column.IMG] = image
|
||||
|
||||
def kick(self, widget, nick):
|
||||
|
|
|
@ -38,6 +38,7 @@ from gajim.options_dialog import OptionsBox
|
|||
|
||||
from gajim.gtk.dialogs import ConfirmationDialog
|
||||
from gajim.gtk.dialogs import YesNoDialog
|
||||
from gajim.gtk.util import get_icon_name
|
||||
|
||||
|
||||
class AccountsWindow(Gtk.ApplicationWindow):
|
||||
|
@ -425,7 +426,7 @@ class Account(Gtk.Box):
|
|||
|
||||
def _update_image(self):
|
||||
show = helpers.get_current_show(self.account)
|
||||
icon = gtkgui_helpers.get_iconset_name_for(show)
|
||||
icon = get_icon_name(show)
|
||||
self.image.set_from_icon_name(icon, Gtk.IconSize.MENU)
|
||||
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ from gajim.common import app
|
|||
from gajim.common import helpers
|
||||
from gajim.common.i18n import _
|
||||
from gajim.gtk.util import get_builder
|
||||
from gajim.gtk.util import get_icon_name
|
||||
from gajim.gtk.single_message import SingleMessageWindow
|
||||
from gajim.gtk.tooltips import NotificationAreaTooltip
|
||||
|
||||
|
@ -133,14 +134,14 @@ class StatusIcon:
|
|||
if app.events.get_nb_systray_events():
|
||||
self.status_icon.set_visible(True)
|
||||
|
||||
icon_name = gtkgui_helpers.get_iconset_name_for('event')
|
||||
icon_name = get_icon_name('event')
|
||||
self.status_icon.set_from_icon_name(icon_name)
|
||||
return
|
||||
|
||||
if app.config.get('trayicon') == 'on_event':
|
||||
self.status_icon.set_visible(False)
|
||||
|
||||
icon_name = gtkgui_helpers.get_iconset_name_for(self.status)
|
||||
icon_name = get_icon_name(self.status)
|
||||
self.status_icon.set_from_icon_name(icon_name)
|
||||
|
||||
def change_status(self, global_status):
|
||||
|
|
|
@ -239,6 +239,12 @@ def get_image_button(icon_name, tooltip, toggle=False):
|
|||
return button
|
||||
|
||||
|
||||
def get_image_from_icon_name(icon_name: str, scale: int) -> Any:
|
||||
icon = get_icon_name(icon_name)
|
||||
surface = _icon_theme.load_surface(icon, 16, scale, None, 0)
|
||||
return Gtk.Image.new_from_surface(surface)
|
||||
|
||||
|
||||
def python_month(month: int) -> int:
|
||||
return month + 1
|
||||
|
||||
|
|
|
@ -609,14 +609,6 @@ def get_pep_as_pixbuf(pep_class):
|
|||
|
||||
return None
|
||||
|
||||
def get_iconset_name_for(name):
|
||||
if name == 'not in roster':
|
||||
name = 'notinroster'
|
||||
iconset = app.config.get('iconset')
|
||||
if not iconset:
|
||||
iconset = app.config.DEFAULT_ICONSET
|
||||
return '%s-%s' % (iconset, name)
|
||||
|
||||
def load_icons_meta():
|
||||
"""
|
||||
Load and return - AND + small icons to put on top left of an icon for meta
|
||||
|
@ -804,11 +796,6 @@ def draw_affiliation(surface, affiliation):
|
|||
ctx.set_source_rgb(0, 255/255, 0)
|
||||
ctx.fill()
|
||||
|
||||
def get_image_from_icon_name(icon_name, scale):
|
||||
icon = get_iconset_name_for(icon_name)
|
||||
surface = gtk_icon_theme.load_surface(icon, 16, scale, None, 0)
|
||||
return Gtk.Image.new_from_surface(surface)
|
||||
|
||||
def pango_to_css_weight(number):
|
||||
# Pango allows for weight values between 100 and 1000
|
||||
# CSS allows only full hundred numbers like 100, 200 ..
|
||||
|
|
|
@ -41,6 +41,7 @@ from gajim.chat_control_base import ChatControlBase
|
|||
from gajim.chat_control import ChatControl
|
||||
|
||||
from gajim.gtk.dialogs import YesNoDialog
|
||||
from gajim.gtk.util import get_icon_name
|
||||
|
||||
####################
|
||||
|
||||
|
@ -470,7 +471,7 @@ class MessageWindow:
|
|||
if window_mode in (MessageWindowMgr.ONE_MSG_WINDOW_PERTYPE,
|
||||
MessageWindowMgr.ONE_MSG_WINDOW_NEVER):
|
||||
if self.type_ == 'gc':
|
||||
icon = gtkgui_helpers.get_iconset_name_for('muc-active')
|
||||
icon = get_icon_name('muc-active')
|
||||
|
||||
self.window.set_icon_name(icon)
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ from gajim.common import helpers
|
|||
from gajim.common import ged
|
||||
from gajim.common.i18n import _
|
||||
|
||||
from gajim.gtk.util import get_icon_name
|
||||
|
||||
log = logging.getLogger('gajim.notify')
|
||||
|
||||
|
||||
|
@ -149,7 +151,7 @@ class Notification:
|
|||
elif obj.notif_type == 'pres':
|
||||
if obj.transport_name is not None:
|
||||
return '%s-%s' % (obj.transport_name, obj.show)
|
||||
return gtkgui_helpers.get_iconset_name_for(obj.show)
|
||||
return get_icon_name(obj.show)
|
||||
|
||||
def popup(self, event_type, jid, account, type_='', icon_name=None,
|
||||
title=None, text=None, timeout=-1, room_jid=None):
|
||||
|
|
|
@ -82,6 +82,7 @@ from gajim.gtk.service_registration import ServiceRegistration
|
|||
from gajim.gtk.history import HistoryWindow
|
||||
from gajim.gtk.accounts import AccountsWindow
|
||||
from gajim.gtk.tooltips import RosterTooltip
|
||||
from gajim.gtk.util import get_icon_name
|
||||
|
||||
|
||||
log = logging.getLogger('gajim.roster')
|
||||
|
@ -257,7 +258,7 @@ class RosterWindow:
|
|||
if tree_model[iter_][2] == 'status':
|
||||
cell.set_property('icon_name', icon_name)
|
||||
else:
|
||||
iconset_name = gtkgui_helpers.get_iconset_name_for(icon_name)
|
||||
iconset_name = get_icon_name(icon_name)
|
||||
cell.set_property('icon_name', iconset_name)
|
||||
else:
|
||||
show = tree_model[iter_][0]
|
||||
|
|
Loading…
Reference in New Issue