ability to load transport iconsets from ~/.gajim/iconsets/transports. Fixes #3390

This commit is contained in:
Yann Leboulanger 2007-08-22 22:46:31 +00:00
parent 77eabc215d
commit 2419bd509c
4 changed files with 44 additions and 31 deletions

View File

@ -1050,3 +1050,11 @@ def get_iconset_path(iconset):
return os.path.join(gajim.DATA_DIR, 'iconsets', iconset) return os.path.join(gajim.DATA_DIR, 'iconsets', iconset)
elif os.path.isdir(os.path.join(gajim.MY_ICONSETS_PATH, iconset)): elif os.path.isdir(os.path.join(gajim.MY_ICONSETS_PATH, iconset)):
return os.path.join(gajim.MY_ICONSETS_PATH, iconset) return os.path.join(gajim.MY_ICONSETS_PATH, iconset)
def get_transport_path(transport):
if os.path.isdir(os.path.join(gajim.DATA_DIR, 'iconsets', 'transports',
transport)):
return os.path.join(gajim.DATA_DIR, 'iconsets', 'transports', transport)
elif os.path.isdir(os.path.join(gajim.MY_ICONSETS_PATH, 'transports',
transport)):
return os.path.join(gajim.MY_ICONSETS_PATH, 'transports', transport)

View File

@ -191,12 +191,12 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
transport_name = gajim.get_transport_name_from_jid(jid) transport_name = gajim.get_transport_name_from_jid(jid)
img = None img = None
if transport_name: if transport_name:
img = os.path.join(gajim.DATA_DIR, 'iconsets', img = os.path.join(helpers.get_transport_path(transport_name),
'transports', transport_name, '48x48', show_image) '48x48', show_image)
if not img or not os.path.isfile(img): if not img or not os.path.isfile(img):
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
img = os.path.join(gajim.DATA_DIR, 'iconsets', img = os.path.join(helpers.get_iconset_path(iconset), '48x48',
iconset, '48x48', show_image) show_image)
path = gtkgui_helpers.get_path_to_generic_or_avatar(img, path = gtkgui_helpers.get_path_to_generic_or_avatar(img,
jid = jid, suffix = suffix) jid = jid, suffix = suffix)
if event == 'status_change': if event == 'status_change':
@ -206,7 +206,7 @@ def notify(event, jid, account, parameters, advanced_notif_num = None):
{'nick': gajim.get_name_from_jid(account, jid),\ {'nick': gajim.get_name_from_jid(account, jid),\
'status': helpers.get_uf_show(gajim.SHOW_LIST[new_show])} 'status': helpers.get_uf_show(gajim.SHOW_LIST[new_show])}
if status_message: if status_message:
text = text + " : " + status_message text = text + " : " + status_message
popup(_('Contact Changed Status'), jid, account, popup(_('Contact Changed Status'), jid, account,
path_to_image = path, title = title, text = text) path_to_image = path, title = title, text = text)
elif event == 'contact_connected': elif event == 'contact_connected':

View File

@ -756,9 +756,9 @@ class RosterWindow:
'''joins the room immediatelly''' '''joins the room immediatelly'''
if gajim.interface.msg_win_mgr.has_window(room_jid, account) and \ if gajim.interface.msg_win_mgr.has_window(room_jid, account) and \
gajim.gc_connected[account][room_jid]: gajim.gc_connected[account][room_jid]:
win = gajim.interface.msg_win_mgr.get_window(room_jid, account) win = gajim.interface.msg_win_mgr.get_window(room_jid, account)
win.window.present() win.window.present()
win.set_active_tab(room_jid, account) win.set_active_tab(room_jid, account)
dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid) dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid)
return return
minimized_control_exists = False minimized_control_exists = False
@ -1345,7 +1345,7 @@ class RosterWindow:
ctrl.print_conversation(_('%s is now %s') % (name, uf_show), ctrl.print_conversation(_('%s is now %s') % (name, uf_show),
'status') 'status')
# unset custom status # unset custom status
if gajim.interface.status_sent_to_users.has_key(account) and \ if gajim.interface.status_sent_to_users.has_key(account) and \
contact.jid in gajim.interface.status_sent_to_users[account]: contact.jid in gajim.interface.status_sent_to_users[account]:
del gajim.interface.status_sent_to_users[account][contact.jid] del gajim.interface.status_sent_to_users[account][contact.jid]
@ -1564,7 +1564,7 @@ class RosterWindow:
accounts.append(account) accounts.append(account)
self.send_status(account, 'offline', msg, to = jid) self.send_status(account, 'offline', msg, to = jid)
new_rule = {'order': u'1', 'type': u'jid', 'action': u'deny', new_rule = {'order': u'1', 'type': u'jid', 'action': u'deny',
'value' : jid, 'child': [u'message', u'iq', u'presence-out']} 'value' : jid, 'child': [u'message', u'iq', u'presence-out']}
gajim.connections[account].blocked_list.append(new_rule) gajim.connections[account].blocked_list.append(new_rule)
# needed for draw_contact: # needed for draw_contact:
gajim.connections[account].blocked_contacts.append(jid) gajim.connections[account].blocked_contacts.append(jid)
@ -1578,8 +1578,8 @@ class RosterWindow:
accounts.append(account) accounts.append(account)
self.send_status(account, 'offline', msg, to=contact.jid) self.send_status(account, 'offline', msg, to=contact.jid)
new_rule = {'order': u'1', 'type': u'jid', new_rule = {'order': u'1', 'type': u'jid',
'action': u'deny', 'value' : contact.jid, 'action': u'deny', 'value' : contact.jid,
'child': [u'message', u'iq', u'presence-out']} 'child': [u'message', u'iq', u'presence-out']}
gajim.connections[account].blocked_list.append(new_rule) gajim.connections[account].blocked_list.append(new_rule)
# needed for draw_contact: # needed for draw_contact:
gajim.connections[account].blocked_contacts.append(contact.jid) gajim.connections[account].blocked_contacts.append(contact.jid)
@ -1597,7 +1597,7 @@ class RosterWindow:
self.send_status(account, 'offline', msg, to=contact.jid) self.send_status(account, 'offline', msg, to=contact.jid)
self.draw_contact(contact.jid, account) self.draw_contact(contact.jid, account)
new_rule = {'order': u'1', 'type': u'group', 'action': u'deny', new_rule = {'order': u'1', 'type': u'group', 'action': u'deny',
'value' : group, 'child': [u'message', u'iq', u'presence-out']} 'value' : group, 'child': [u'message', u'iq', u'presence-out']}
gajim.connections[account].blocked_list.append(new_rule) gajim.connections[account].blocked_list.append(new_rule)
for account in accounts: for account in accounts:
gajim.connections[account].set_privacy_list( gajim.connections[account].set_privacy_list(
@ -3197,7 +3197,7 @@ class RosterWindow:
self.make_transport_menu(event, iters[0]) self.make_transport_menu(event, iters[0])
elif type_ in ('contact', 'self_contact') and len(iters) == 1: elif type_ in ('contact', 'self_contact') and len(iters) == 1:
self.make_contact_menu(event, iters[0]) self.make_contact_menu(event, iters[0])
elif type_ == 'contact': elif type_ == 'contact':
self.make_multiple_contact_menu(event, iters) self.make_multiple_contact_menu(event, iters)
elif type_ == 'account' and len(iters) == 1: elif type_ == 'account' and len(iters) == 1:
self.make_account_menu(event, iters[0]) self.make_account_menu(event, iters[0])
@ -4307,7 +4307,7 @@ class RosterWindow:
self.tree.expand_row(pathG, False) self.tree.expand_row(pathG, False)
self.draw_account(account) self.draw_account(account)
elif type_ == 'contact': elif type_ == 'contact':
jid = model[iter][C_JID].decode('utf-8') jid = model[iter][C_JID].decode('utf-8')
account = model[iter][C_ACCOUNT].decode('utf-8') account = model[iter][C_ACCOUNT].decode('utf-8')
self.draw_contact(jid, account) self.draw_contact(jid, account)
@ -4334,7 +4334,7 @@ class RosterWindow:
self.collapsed_rows.append(account) self.collapsed_rows.append(account)
self.draw_account(account) self.draw_account(account)
elif type_ == 'contact': elif type_ == 'contact':
jid = model[iter][C_JID].decode('utf-8') jid = model[iter][C_JID].decode('utf-8')
account = model[iter][C_ACCOUNT].decode('utf-8') account = model[iter][C_ACCOUNT].decode('utf-8')
self.draw_contact(jid, account) self.draw_contact(jid, account)
@ -4439,10 +4439,13 @@ class RosterWindow:
# standard transport iconsets are loaded one time in init() # standard transport iconsets are loaded one time in init()
t_path = os.path.join(gajim.DATA_DIR, 'iconsets', 'transports') t_path = os.path.join(gajim.DATA_DIR, 'iconsets', 'transports')
folders = os.listdir(t_path) folders = os.listdir(t_path)
t_path = os.path.join(gajim.MY_ICONSETS_PATH, 'transports')
folders += os.listdir(t_path)
for transport in folders: for transport in folders:
if transport == '.svn': if transport == '.svn':
continue continue
folder = os.path.join(t_path, transport, '16x16') folder = os.path.join(helpers.get_transport_path(transport),
'16x16')
self.transports_state_images['opened'][transport] = \ self.transports_state_images['opened'][transport] = \
self.load_iconset(folder, pixo, transport = True) self.load_iconset(folder, pixo, transport = True)
self.transports_state_images['closed'][transport] = \ self.transports_state_images['closed'][transport] = \
@ -4913,7 +4916,7 @@ class RosterWindow:
account, c, path) account, c, path)
# Popup dialog to confirm sending # Popup dialog to confirm sending
prim_text = 'Send file?' prim_text = 'Send file?'
sec_text = i18n.ngettext('Do you want to send that file to %s:', sec_text = i18n.ngettext('Do you want to send that file to %s:',
'Do you want to send those files to %s:', nb_uri) %\ 'Do you want to send those files to %s:', nb_uri) %\
c_dest.get_shown_name() c_dest.get_shown_name()
for uri in uri_splitted: for uri in uri_splitted:
@ -4998,7 +5001,7 @@ class RosterWindow:
return return
# Is the contact we drag a meta contact? # Is the contact we drag a meta contact?
is_big_brother = gajim.contacts.is_big_brother(account_source, jid_source) is_big_brother = gajim.contacts.is_big_brother(account_source, jid_source)
# Contact drop on group row or between two contacts # Contact drop on group row or between two contacts
if type_dest == 'group' or position == gtk.TREE_VIEW_DROP_BEFORE or \ if type_dest == 'group' or position == gtk.TREE_VIEW_DROP_BEFORE or \
@ -5109,7 +5112,7 @@ class RosterWindow:
'closed': {}} 'closed': {}}
self.last_save_dir = None self.last_save_dir = None
self.editing_path = None # path of row with cell in edit mode self.editing_path = None # path of row with cell in edit mode
self.add_new_contact_handler_id = False self.add_new_contact_handler_id = False
self.service_disco_handler_id = False self.service_disco_handler_id = False
self.new_chat_menuitem_handler_id = False self.new_chat_menuitem_handler_id = False
@ -5146,13 +5149,15 @@ class RosterWindow:
path = os.path.join(gajim.DATA_DIR, 'iconsets', 'transports') path = os.path.join(gajim.DATA_DIR, 'iconsets', 'transports')
folders = os.listdir(path) folders = os.listdir(path)
path = os.path.join(gajim.MY_ICONSETS_PATH, 'transports')
folders += os.listdir(path)
for transport in folders: for transport in folders:
if transport == '.svn': if transport == '.svn':
continue continue
folder = os.path.join(path, transport, '32x32') folder = os.path.join(helpers.get_transport_path(transport), '32x32')
self.transports_state_images['32'][transport] = self.load_iconset( self.transports_state_images['32'][transport] = self.load_iconset(
folder, transport = True) folder, transport = True)
folder = os.path.join(path, transport, '16x16') folder = os.path.join(helpers.get_transport_path(transport), '16x16')
self.transports_state_images['16'][transport] = self.load_iconset( self.transports_state_images['16'][transport] = self.load_iconset(
folder, transport = True) folder, transport = True)

View File

@ -89,7 +89,7 @@ class BaseTooltip:
half_width = requisition.width / 2 + 1 half_width = requisition.width / 2 + 1
if self.preferred_position[0] < half_width: if self.preferred_position[0] < half_width:
self.preferred_position[0] = 0 self.preferred_position[0] = 0
elif self.preferred_position[0] + requisition.width > \ elif self.preferred_position[0] + requisition.width > \
self.screen.get_width() + half_width: self.screen.get_width() + half_width:
self.preferred_position[0] = self.screen.get_width() - \ self.preferred_position[0] = self.screen.get_width() - \
requisition.width requisition.width
@ -99,7 +99,7 @@ class BaseTooltip:
if self.preferred_position[1] + requisition.height > \ if self.preferred_position[1] + requisition.height > \
self.screen.get_height(): self.screen.get_height():
# flip tooltip up # flip tooltip up
self.preferred_position[1] -= requisition.height + \ self.preferred_position[1] -= requisition.height + \
self.widget_height + 8 self.widget_height + 8
if self.preferred_position[1] < 0: if self.preferred_position[1] < 0:
self.preferred_position[1] = 0 self.preferred_position[1] = 0
@ -436,8 +436,8 @@ class RosterTooltip(NotificationAreaTooltip):
transport = gajim.get_transport_name_from_jid( transport = gajim.get_transport_name_from_jid(
prim_contact.jid) prim_contact.jid)
if transport: if transport:
file_path = os.path.join(gajim.DATA_DIR, 'iconsets', file_path = os.path.join(helpers.get_transport_path(transport),
'transports', transport , '16x16') '16x16')
else: else:
iconset = gajim.config.get('iconset') iconset = gajim.config.get('iconset')
if not iconset: if not iconset:
@ -535,7 +535,7 @@ class RosterTooltip(NotificationAreaTooltip):
if property[1]: if property[1]:
label.set_markup(property[0]) label.set_markup(property[0])
vcard_table.attach(label, 1, 2, vcard_current_row, vcard_table.attach(label, 1, 2, vcard_current_row,
vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0) vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0)
label = gtk.Label() label = gtk.Label()
label.set_alignment(0, 0) label.set_alignment(0, 0)
label.set_markup(property[1]) label.set_markup(property[1])
@ -576,7 +576,7 @@ class FileTransfersTooltip(BaseTooltip):
properties.append((_('Name: '), properties.append((_('Name: '),
gobject.markup_escape_text(file_name))) gobject.markup_escape_text(file_name)))
if file_props['type'] == 'r': if file_props['type'] == 'r':
type = _('Download') type = _('Download')
actor = _('Sender: ') actor = _('Sender: ')
sender = unicode(file_props['sender']).split('/')[0] sender = unicode(file_props['sender']).split('/')[0]
name = gajim.contacts.get_first_contact_from_jid( name = gajim.contacts.get_first_contact_from_jid(
@ -598,7 +598,7 @@ class FileTransfersTooltip(BaseTooltip):
properties.append((_('Transferred: '), helpers.convert_bytes(transfered_len))) properties.append((_('Transferred: '), helpers.convert_bytes(transfered_len)))
status = '' status = ''
if not file_props.has_key('started') or not file_props['started']: if not file_props.has_key('started') or not file_props['started']:
status = _('Not started') status = _('Not started')
elif file_props.has_key('connected'): elif file_props.has_key('connected'):
if file_props.has_key('stopped') and \ if file_props.has_key('stopped') and \
file_props['stopped'] == True: file_props['stopped'] == True:
@ -609,7 +609,7 @@ class FileTransfersTooltip(BaseTooltip):
if file_props['completed']: if file_props['completed']:
status = _('Completed') status = _('Completed')
else: else:
if file_props.has_key('paused') and \ if file_props.has_key('paused') and \
file_props['paused'] == True: file_props['paused'] == True:
status = _('?transfer status:Paused') status = _('?transfer status:Paused')
elif file_props.has_key('stalled') and \ elif file_props.has_key('stalled') and \
@ -619,7 +619,7 @@ class FileTransfersTooltip(BaseTooltip):
else: else:
status = _('Transferring') status = _('Transferring')
else: else:
status = _('Not started') status = _('Not started')
properties.append((_('Status: '), status)) properties.append((_('Status: '), status))
while properties: while properties:
property = properties.pop(0) property = properties.pop(0)
@ -628,7 +628,7 @@ class FileTransfersTooltip(BaseTooltip):
label.set_alignment(0, 0) label.set_alignment(0, 0)
label.set_markup(property[0]) label.set_markup(property[0])
ft_table.attach(label, 1, 2, current_row, current_row + 1, ft_table.attach(label, 1, 2, current_row, current_row + 1,
gtk.FILL, gtk.FILL, 0, 0) gtk.FILL, gtk.FILL, 0, 0)
label = gtk.Label() label = gtk.Label()
label.set_alignment(0, 0) label.set_alignment(0, 0)
label.set_line_wrap(True) label.set_line_wrap(True)