Changeset 7787 for branches/gajim_0.11/src/roster_window.py
- Timestamp:
- 01/06/07 12:00:50 (23 months ago)
- Files:
-
- 1 modified
-
branches/gajim_0.11/src/roster_window.py (modified) (30 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/gajim_0.11/src/roster_window.py
r7682 r7787 151 151 iters = self.get_contact_iter(jid, account) 152 152 path = self.tree.get_model().get_path(iters[0]) 153 if self.dragging: 154 # do not change selection while DND'ing 155 return 153 156 # popup == False so we show awaiting event in roster 154 # show and select contact line in roster (even if he is not in roster) 157 # show and select contact line in roster (even if he is not in roster) 155 158 self.tree.expand_row(path[0:1], False) 156 159 self.tree.expand_row(path[0:2], False) … … 226 229 # account row not expanded 227 230 account_name = '[%s]' % account_name 228 if gajim.account_is_connected(account) or (self.regroup and \ 229 gajim.get_number_of_connected_accounts()): 231 if (gajim.account_is_connected(account) or (self.regroup and \ 232 gajim.get_number_of_connected_accounts())) and gajim.config.get( 233 'show_contacts_number'): 230 234 nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( 231 235 accounts = accounts) … … 387 391 else: 388 392 accounts = [account] 389 nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( 390 accounts = accounts, groups = [group]) 393 text = group 394 if gajim.config.get('show_contacts_number'): 395 nbr_on, nbr_total = gajim.contacts.get_nb_online_total_contacts( 396 accounts = accounts, groups = [group]) 397 text += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total)) 391 398 model = self.tree.get_model() 392 model.set_value(iter, 1 , gtkgui_helpers.escape_for_pango_markup( 393 '%s (%s/%s)' % (group, repr(nbr_on), repr(nbr_total)))) 399 model.set_value(iter, 1 , gtkgui_helpers.escape_for_pango_markup(text)) 394 400 395 401 def add_to_not_in_the_roster(self, account, jid, nick = ''): … … 1152 1158 pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(ji) 1153 1159 if pixbuf == 'ask': 1154 jid_with_resource = contact1.jid 1155 if contact1.resource: 1156 jid_with_resource += '/' + contact1.resource 1157 gajim.connections[account].request_vcard(jid_with_resource) 1160 transport = gajim.get_transport_name_from_jid(contact1.jid) 1161 if not transport or gajim.jid_is_transport(contact1.jid): 1162 jid_with_resource = contact1.jid 1163 if contact1.resource: 1164 jid_with_resource += '/' + contact1.resource 1165 gajim.connections[account].request_vcard(jid_with_resource) 1166 else: 1167 host = gajim.get_server_from_jid(contact1.jid) 1168 if not gajim.transport_avatar[account].has_key(host): 1169 gajim.transport_avatar[account][host] = [contact1.jid] 1170 else: 1171 gajim.transport_avatar[account][host].append(contact1.jid) 1158 1172 # If we already have a chat window opened, update it with new contact 1159 1173 # instance … … 1182 1196 win = gajim.interface.msg_win_mgr.get_window(jid, account) 1183 1197 ctrl = win.get_control(jid, account) 1184 ctrl.contact = contact 1198 ctrl.contact = gajim.contacts.get_contact_with_highest_priority( 1199 account, contact.jid) 1185 1200 ctrl.update_ui() 1186 1201 win.redraw_tab(ctrl) … … 1384 1399 pritext = _('Transport "%s" will be removed') % contact.jid 1385 1400 sectext = _('You will no longer be able to send and receive messages ' 1386 ' to contacts fromthis transport.')1401 'from contacts using this transport.') 1387 1402 else: 1388 1403 pritext = _('Transports will be removed') … … 1473 1488 on_canceled) 1474 1489 1490 def readd_if_needed(self, contact, account): 1491 need_readd = False 1492 if len(gajim.events.get_events(account, contact.jid)): 1493 need_readd = True 1494 elif gajim.interface.msg_win_mgr.has_window(contact.jid, account): 1495 if _('Not in Roster') in contact.groups: 1496 # Close chat window 1497 msg_win = gajim.interface.msg_win_mgr.get_window(contact.jid, 1498 account) 1499 ctrl = gajim.interface.msg_win_mgr.get_control(contact.jid, account) 1500 msg_win.remove_tab(ctrl, msg_win.CLOSE_CLOSE_BUTTON) 1501 else: 1502 need_readd = True 1503 if need_readd: 1504 c = gajim.contacts.create_contact(jid = contact.jid, 1505 name = '', groups = [_('Not in Roster')], 1506 show = 'not in roster', status = '', ask = 'none', 1507 keyID = contact.keyID) 1508 gajim.contacts.add_contact(account, c) 1509 self.add_contact_to_roster(contact.jid, account) 1510 1475 1511 def on_remove_group_item_activated(self, widget, group, account): 1476 1512 dlg = dialogs.ConfirmationDialogCheck(_('Remove Group'), … … 1488 1524 else: 1489 1525 gajim.connections[account].unsubscribe(contact.jid) 1490 1526 for c in gajim.contacts.get_contact(account, contact.jid): 1527 self.remove_contact(c, account) 1528 gajim.contacts.remove_jid(account, c.jid) 1529 self.readd_if_needed(contact, account) 1530 self.draw_account(account) 1531 1491 1532 def on_assign_pgp_key(self, widget, contact, account): 1492 1533 attached_keys = gajim.config.get_per('accounts', account, … … 2431 2472 if not len(list_of_paths): 2432 2473 return 2433 type = model[list_of_paths[0]][C_TYPE]2474 type_ = model[list_of_paths[0]][C_TYPE] 2434 2475 account = model[list_of_paths[0]][C_ACCOUNT] 2435 2476 list_ = [] 2436 2477 for path in list_of_paths: 2437 if model[path][C_TYPE] != type :2478 if model[path][C_TYPE] != type_: 2438 2479 return 2439 2480 jid = model[path][C_JID].decode('utf-8') … … 2442 2483 jid) 2443 2484 list_.append((contact, account)) 2444 if type in ('account', 'group', 'self_contact') or \2485 if type_ in ('account', 'group', 'self_contact') or \ 2445 2486 account == gajim.ZEROCONF_ACC_NAME: 2446 2487 return 2447 if type == 'contact':2488 if type_ == 'contact': 2448 2489 self.on_req_usub(widget, list_) 2449 elif type == 'agent':2490 elif type_ == 'agent': 2450 2491 self.on_remove_agent(widget, list_) 2451 2492 … … 2453 2494 # iters must be all of the same type 2454 2495 model = self.tree.get_model() 2455 type = model[iters[0]][C_TYPE]2496 type_ = model[iters[0]][C_TYPE] 2456 2497 for iter in iters[1:]: 2457 if model[iter][C_TYPE] != type :2498 if model[iter][C_TYPE] != type_: 2458 2499 return 2459 if type == 'group' and len(iters) == 1:2500 if type_ == 'group' and len(iters) == 1: 2460 2501 self.make_group_menu(event, iters[0]) 2461 elif type == 'agent' and len(iters) == 1:2502 elif type_ == 'agent' and len(iters) == 1: 2462 2503 self.make_transport_menu(event, iters[0]) 2463 elif type in ('contact', 'self_contact') and len(iters) == 1:2504 elif type_ in ('contact', 'self_contact') and len(iters) == 1: 2464 2505 self.make_contact_menu(event, iters[0]) 2465 elif type == 'contact':2506 elif type_ == 'contact': 2466 2507 self.make_multiple_contact_menu(event, iters) 2467 elif type == 'account' and len(iters) == 1:2508 elif type_ == 'account' and len(iters) == 1: 2468 2509 self.make_account_menu(event, iters[0]) 2469 2510 … … 2518 2559 self.tree.get_selection().unselect_all() 2519 2560 self.tree.get_selection().select_path(path) 2520 type = model[path][C_TYPE]2521 if type in ('agent', 'contact', 'self_contact'):2561 type_ = model[path][C_TYPE] 2562 if type_ in ('agent', 'contact', 'self_contact'): 2522 2563 self.on_roster_treeview_row_activated(widget, path) 2523 elif type == 'account':2564 elif type_ == 'account': 2524 2565 account = model[path][C_ACCOUNT].decode('utf-8') 2525 2566 if account != 'all': … … 2545 2586 elif event.button == 1: # Left click 2546 2587 model = self.tree.get_model() 2547 type = model[path][C_TYPE]2548 if type == 'group' and x < 27:2588 type_ = model[path][C_TYPE] 2589 if type_ == 'group' and x < 27: 2549 2590 # first cell in 1st column (the arrow SINGLE clicked) 2550 2591 if (self.tree.row_expanded(path)): … … 2553 2594 self.tree.expand_row(path, False) 2554 2595 2555 elif type == 'contact' and x < 27:2596 elif type_ == 'contact' and x < 27: 2556 2597 account = model[path][C_ACCOUNT].decode('utf-8') 2557 2598 jid = model[path][C_JID].decode('utf-8') … … 2584 2625 # redraw account rows for contact numbers 2585 2626 self.draw_account(account) 2586 need_readd = False2587 2627 if not remove_auth and contact.sub == 'both': 2588 2628 contact.name = '' … … 2591 2631 gajim.contacts.add_contact(account, contact) 2592 2632 self.add_contact_to_roster(contact.jid, account) 2593 elif len(gajim.events.get_events(account, contact.jid)): 2594 need_readd = True 2595 elif gajim.interface.msg_win_mgr.has_window(contact.jid, account): 2596 if _('Not in Roster') in contact.groups: 2597 # Close chat window 2598 msg_win = gajim.interface.msg_win_mgr.get_window(contact.jid, 2599 account) 2600 ctrl = gajim.interface.msg_win_mgr.get_control(contact.jid, 2601 account) 2602 msg_win.remove_tab(ctrl, msg_win.CLOSE_CLOSE_BUTTON) 2603 else: 2604 need_readd = True 2605 if need_readd: 2606 c = gajim.contacts.create_contact(jid = contact.jid, 2607 name = '', groups = [_('Not in Roster')], 2608 show = 'not in roster', status = '', ask = 'none', 2609 keyID = contact.keyID) 2610 gajim.contacts.add_contact(account, c) 2611 self.add_contact_to_roster(contact.jid, account) 2633 else: 2634 self.readd_if_needed(contact, account) 2612 2635 if len(list_) == 1: 2613 2636 contact = list_[0][0] … … 2662 2685 if not gajim.connections[account].password: 2663 2686 passphrase = '' 2664 w = dialogs.PassphraseDialog( 2665 _('Password Required'), 2666 _('Enter your password for account %s') % account, 2687 text = _('Enter your password for account %s') % account 2688 if passwords.USER_HAS_GNOMEKEYRING and \ 2689 not passwords.USER_USES_GNOMEKEYRING: 2690 text += '\n' + _('Gnomekeyring is installed but not correctly started (environment variable probably not correctly set)') 2691 w = dialogs.PassphraseDialog(_('Password Required'), text, 2667 2692 _('Save password')) 2668 2693 passphrase, save = w.run() … … 2964 2989 # Get target window, create a control, and associate it with the window 2965 2990 if not private_chat: 2966 type = message_control.TYPE_CHAT2967 else: 2968 type = message_control.TYPE_PM2991 type_ = message_control.TYPE_CHAT 2992 else: 2993 type_ = message_control.TYPE_PM 2969 2994 2970 2995 fjid = contact.jid … … 2973 2998 mw = gajim.interface.msg_win_mgr.get_window(fjid, account) 2974 2999 if not mw: 2975 mw = gajim.interface.msg_win_mgr.create_window(contact, account, type )3000 mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_) 2976 3001 2977 3002 if not private_chat: … … 3102 3127 if not ctrl: 3103 3128 self.new_chat(contact, account, resource = resource_for_chat) 3104 if path :3129 if path and not self.dragging: 3105 3130 # we curently see contact in our roster OR he 3106 3131 # is not in the roster at all. 3107 3132 # show and select his line in roster 3133 # do not change selection while DND'ing 3108 3134 self.tree.expand_row(path[0:1], False) 3109 3135 self.tree.expand_row(path[0:2], False) … … 3413 3439 model = self.tree.get_model() 3414 3440 account = model[path][C_ACCOUNT].decode('utf-8') 3415 type = model[path][C_TYPE]3441 type_ = model[path][C_TYPE] 3416 3442 jid = model[path][C_JID].decode('utf-8') 3417 3443 resource = None 3418 3444 iter = model.get_iter(path) 3419 if type in ('group', 'account'):3445 if type_ in ('group', 'account'): 3420 3446 if self.tree.row_expanded(path): 3421 3447 self.tree.collapse_row(path) … … 3461 3487 else: 3462 3488 accounts = [model[iter][C_ACCOUNT].decode('utf-8')] 3463 type = model[iter][C_TYPE]3464 if type == 'group':3489 type_ = model[iter][C_TYPE] 3490 if type_ == 'group': 3465 3491 model.set_value(iter, 0, self.jabber_state_images['16']['opened']) 3466 3492 jid = model[iter][C_JID].decode('utf-8') … … 3470 3496 if account + jid in self.collapsed_rows: 3471 3497 self.collapsed_rows.remove(account + jid) 3472 elif type == 'account':3498 elif type_ == 'account': 3473 3499 account = accounts[0] # There is only one cause we don't use merge 3474 3500 if account in self.collapsed_rows: … … 3480 3506 self.tree.expand_row(pathG, False) 3481 3507 self.draw_account(account) 3482 elif type == 'contact':3508 elif type_ == 'contact': 3483 3509 jid = model[iter][C_JID].decode('utf-8') 3484 3510 account = model[iter][C_ACCOUNT].decode('utf-8') … … 3493 3519 else: 3494 3520 accounts = [model[iter][C_ACCOUNT].decode('utf-8')] 3495 type = model[iter][C_TYPE]3496 if type == 'group':3521 type_ = model[iter][C_TYPE] 3522 if type_ == 'group': 3497 3523 model.set_value(iter, 0, self.jabber_state_images['16']['closed']) 3498 3524 jid = model[iter][C_JID].decode('utf-8') … … 3502 3528 if not account + jid in self.collapsed_rows: 3503 3529 self.collapsed_rows.append(account + jid) 3504 elif type == 'account':3530 elif type_ == 'account': 3505 3531 account = accounts[0] # There is only one cause we don't use merge 3506 3532 if not account in self.collapsed_rows: 3507 3533 self.collapsed_rows.append(account) 3508 3534 self.draw_account(account) 3509 elif type == 'contact':3535 elif type_ == 'contact': 3510 3536 jid = model[iter][C_JID].decode('utf-8') 3511 3537 account = model[iter][C_ACCOUNT].decode('utf-8') … … 3906 3932 selection.set(selection.target, 8, data) 3907 3933 3934 def drag_begin(self, treeview, context): 3935 self.dragging = True 3936 3937 def drag_end(self, treeview, context): 3938 self.dragging = False 3939 3908 3940 def on_drop_in_contact(self, widget, account_source, c_source, account_dest, 3909 3941 c_dest, was_big_brother, context, etime): … … 3957 3989 ' to continue?') 3958 3990 sectext = _('Metacontacts are a way to regroup several contacts in one ' 3959 'line. General y it is used when the same person has several Jabber '3991 'line. Generally it is used when the same person has several Jabber ' 3960 3992 'accounts or transport accounts.') 3961 3993 dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, … … 4233 4265 self.transports_state_images = {'16': {}, '32': {}, 'opened': {}, 4234 4266 'closed': {}} 4235 4267 4236 4268 self.last_save_dir = None 4237 4269 self.editing_path = None # path of row with cell in edit mode … … 4388 4420 gtk.gdk.ACTION_DEFAULT | gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_COPY) 4389 4421 self.tree.enable_model_drag_dest(TARGETS2, gtk.gdk.ACTION_DEFAULT) 4422 self.tree.connect('drag_begin', self.drag_begin) 4423 self.tree.connect('drag_end', self.drag_end) 4390 4424 self.tree.connect('drag_data_get', self.drag_data_get_data) 4391 4425 self.tree.connect('drag_data_received', self.drag_data_received_data) 4426 self.dragging = False 4392 4427 self.xml.signal_autoconnect(self) 4393 4428 self.combobox_callback_active = True
