From 2419bd509c3355606cbf57a909dfc16577ce19c6 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Wed, 22 Aug 2007 22:46:31 +0000 Subject: [PATCH] ability to load transport iconsets from ~/.gajim/iconsets/transports. Fixes #3390 --- src/common/helpers.py | 8 ++++++++ src/notify.py | 10 +++++----- src/roster_window.py | 37 +++++++++++++++++++++---------------- src/tooltips.py | 20 ++++++++++---------- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/src/common/helpers.py b/src/common/helpers.py index c768d10f8..35f782ded 100644 --- a/src/common/helpers.py +++ b/src/common/helpers.py @@ -1050,3 +1050,11 @@ def get_iconset_path(iconset): return os.path.join(gajim.DATA_DIR, 'iconsets', iconset) elif os.path.isdir(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) diff --git a/src/notify.py b/src/notify.py index 36555b04c..a359bd5ff 100644 --- a/src/notify.py +++ b/src/notify.py @@ -191,12 +191,12 @@ def notify(event, jid, account, parameters, advanced_notif_num = None): transport_name = gajim.get_transport_name_from_jid(jid) img = None if transport_name: - img = os.path.join(gajim.DATA_DIR, 'iconsets', - 'transports', transport_name, '48x48', show_image) + img = os.path.join(helpers.get_transport_path(transport_name), + '48x48', show_image) if not img or not os.path.isfile(img): iconset = gajim.config.get('iconset') - img = os.path.join(gajim.DATA_DIR, 'iconsets', - iconset, '48x48', show_image) + img = os.path.join(helpers.get_iconset_path(iconset), '48x48', + show_image) path = gtkgui_helpers.get_path_to_generic_or_avatar(img, jid = jid, suffix = suffix) 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),\ 'status': helpers.get_uf_show(gajim.SHOW_LIST[new_show])} if status_message: - text = text + " : " + status_message + text = text + " : " + status_message popup(_('Contact Changed Status'), jid, account, path_to_image = path, title = title, text = text) elif event == 'contact_connected': diff --git a/src/roster_window.py b/src/roster_window.py index 57dd785c8..9544c8ce7 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -756,9 +756,9 @@ class RosterWindow: '''joins the room immediatelly''' if gajim.interface.msg_win_mgr.has_window(room_jid, account) and \ 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.set_active_tab(room_jid, account) + win.set_active_tab(room_jid, account) dialogs.ErrorDialog(_('You are already in group chat %s') % room_jid) return minimized_control_exists = False @@ -1345,7 +1345,7 @@ class RosterWindow: ctrl.print_conversation(_('%s is now %s') % (name, uf_show), 'status') - # unset custom status + # unset custom status if gajim.interface.status_sent_to_users.has_key(account) and \ contact.jid in gajim.interface.status_sent_to_users[account]: del gajim.interface.status_sent_to_users[account][contact.jid] @@ -1564,7 +1564,7 @@ class RosterWindow: accounts.append(account) self.send_status(account, 'offline', msg, to = jid) 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) # needed for draw_contact: gajim.connections[account].blocked_contacts.append(jid) @@ -1578,8 +1578,8 @@ class RosterWindow: accounts.append(account) self.send_status(account, 'offline', msg, to=contact.jid) new_rule = {'order': u'1', 'type': u'jid', - 'action': u'deny', 'value' : contact.jid, - 'child': [u'message', u'iq', u'presence-out']} + 'action': u'deny', 'value' : contact.jid, + 'child': [u'message', u'iq', u'presence-out']} gajim.connections[account].blocked_list.append(new_rule) # needed for draw_contact: gajim.connections[account].blocked_contacts.append(contact.jid) @@ -1597,7 +1597,7 @@ class RosterWindow: self.send_status(account, 'offline', msg, to=contact.jid) self.draw_contact(contact.jid, account) 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) for account in accounts: gajim.connections[account].set_privacy_list( @@ -3197,7 +3197,7 @@ class RosterWindow: self.make_transport_menu(event, iters[0]) elif type_ in ('contact', 'self_contact') and len(iters) == 1: self.make_contact_menu(event, iters[0]) - elif type_ == 'contact': + elif type_ == 'contact': self.make_multiple_contact_menu(event, iters) elif type_ == 'account' and len(iters) == 1: self.make_account_menu(event, iters[0]) @@ -4307,7 +4307,7 @@ class RosterWindow: self.tree.expand_row(pathG, False) self.draw_account(account) 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') self.draw_contact(jid, account) @@ -4334,7 +4334,7 @@ class RosterWindow: self.collapsed_rows.append(account) self.draw_account(account) 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') self.draw_contact(jid, account) @@ -4439,10 +4439,13 @@ class RosterWindow: # standard transport iconsets are loaded one time in init() t_path = os.path.join(gajim.DATA_DIR, 'iconsets', 'transports') folders = os.listdir(t_path) + t_path = os.path.join(gajim.MY_ICONSETS_PATH, 'transports') + folders += os.listdir(t_path) for transport in folders: if transport == '.svn': 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.load_iconset(folder, pixo, transport = True) self.transports_state_images['closed'][transport] = \ @@ -4913,7 +4916,7 @@ class RosterWindow: account, c, path) # Popup dialog to confirm sending 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) %\ c_dest.get_shown_name() for uri in uri_splitted: @@ -4998,7 +5001,7 @@ class RosterWindow: return # 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 if type_dest == 'group' or position == gtk.TREE_VIEW_DROP_BEFORE or \ @@ -5109,7 +5112,7 @@ class RosterWindow: 'closed': {}} 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.service_disco_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') folders = os.listdir(path) + path = os.path.join(gajim.MY_ICONSETS_PATH, 'transports') + folders += os.listdir(path) for transport in folders: if transport == '.svn': 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( 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( folder, transport = True) diff --git a/src/tooltips.py b/src/tooltips.py index b5e5399dd..301fb1e4a 100644 --- a/src/tooltips.py +++ b/src/tooltips.py @@ -89,7 +89,7 @@ class BaseTooltip: half_width = requisition.width / 2 + 1 if self.preferred_position[0] < half_width: 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.preferred_position[0] = self.screen.get_width() - \ requisition.width @@ -99,7 +99,7 @@ class BaseTooltip: if self.preferred_position[1] + requisition.height > \ self.screen.get_height(): # flip tooltip up - self.preferred_position[1] -= requisition.height + \ + self.preferred_position[1] -= requisition.height + \ self.widget_height + 8 if self.preferred_position[1] < 0: self.preferred_position[1] = 0 @@ -436,8 +436,8 @@ class RosterTooltip(NotificationAreaTooltip): transport = gajim.get_transport_name_from_jid( prim_contact.jid) if transport: - file_path = os.path.join(gajim.DATA_DIR, 'iconsets', - 'transports', transport , '16x16') + file_path = os.path.join(helpers.get_transport_path(transport), + '16x16') else: iconset = gajim.config.get('iconset') if not iconset: @@ -535,7 +535,7 @@ class RosterTooltip(NotificationAreaTooltip): if property[1]: label.set_markup(property[0]) 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.set_alignment(0, 0) label.set_markup(property[1]) @@ -576,7 +576,7 @@ class FileTransfersTooltip(BaseTooltip): properties.append((_('Name: '), gobject.markup_escape_text(file_name))) if file_props['type'] == 'r': - type = _('Download') + type = _('Download') actor = _('Sender: ') sender = unicode(file_props['sender']).split('/')[0] name = gajim.contacts.get_first_contact_from_jid( @@ -598,7 +598,7 @@ class FileTransfersTooltip(BaseTooltip): properties.append((_('Transferred: '), helpers.convert_bytes(transfered_len))) status = '' if not file_props.has_key('started') or not file_props['started']: - status = _('Not started') + status = _('Not started') elif file_props.has_key('connected'): if file_props.has_key('stopped') and \ file_props['stopped'] == True: @@ -609,7 +609,7 @@ class FileTransfersTooltip(BaseTooltip): if file_props['completed']: status = _('Completed') else: - if file_props.has_key('paused') and \ + if file_props.has_key('paused') and \ file_props['paused'] == True: status = _('?transfer status:Paused') elif file_props.has_key('stalled') and \ @@ -619,7 +619,7 @@ class FileTransfersTooltip(BaseTooltip): else: status = _('Transferring') else: - status = _('Not started') + status = _('Not started') properties.append((_('Status: '), status)) while properties: property = properties.pop(0) @@ -628,7 +628,7 @@ class FileTransfersTooltip(BaseTooltip): label.set_alignment(0, 0) label.set_markup(property[0]) 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.set_alignment(0, 0) label.set_line_wrap(True)