Logo Search packages:      
Sourcecode: gajim version File versions  Download package

def roster_window::RosterWindow::make_contact_menu (   self,
  event,
  iter 
)

Make contact's popup menu

Definition at line 1236 of file roster_window.py.

01236                                               :
            '''Make contact's popup menu'''
            model = self.tree.get_model()
            jid = model[iter][C_JID].decode('utf-8')
            path = model.get_path(iter)
            account = model[iter][C_ACCOUNT].decode('utf-8')
            contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
            if not contact:
                  return

            xml = gtk.glade.XML(GTKGUI_GLADE, 'roster_contact_context_menu',
                  APP)
            roster_contact_context_menu = xml.get_widget(
                  'roster_contact_context_menu')

            start_chat_menuitem = xml.get_widget('start_chat_menuitem')
            send_single_message_menuitem = xml.get_widget(
                  'send_single_message_menuitem')
            rename_menuitem = xml.get_widget('rename_menuitem')
            edit_groups_menuitem = xml.get_widget('edit_groups_menuitem')
            # separator has with send file, assign_openpgp_key_menuitem, etc..
            above_send_file_separator = xml.get_widget('above_send_file_separator')
            send_file_menuitem = xml.get_widget('send_file_menuitem')
            assign_openpgp_key_menuitem = xml.get_widget(
                  'assign_openpgp_key_menuitem')
            add_special_notification_menuitem = xml.get_widget(
                  'add_special_notification_menuitem')
            
            add_special_notification_menuitem.hide()
            add_special_notification_menuitem.set_no_show_all(True)
            
            # add a special img for rename menuitem
            path_to_kbd_input_img = os.path.join(gajim.DATA_DIR, 'pixmaps',
                  'kbd_input.png')
            img = gtk.Image()
            img.set_from_file(path_to_kbd_input_img)
            rename_menuitem.set_image(img)

            # skip a separator
            subscription_menuitem = xml.get_widget('subscription_menuitem')
            send_auth_menuitem, ask_auth_menuitem, revoke_auth_menuitem =\
                  subscription_menuitem.get_submenu().get_children()
            add_to_roster_menuitem = xml.get_widget('add_to_roster_menuitem')
            remove_from_roster_menuitem = xml.get_widget('remove_from_roster_menuitem')
            # skip a separator
            information_menuitem = xml.get_widget('information_menuitem')
            history_menuitem = xml.get_widget('history_menuitem')

            contacts = gajim.contacts.get_contact(account, jid)
            if len(contacts) > 1: # sevral resources
                  sub_menu = gtk.Menu()
                  start_chat_menuitem.set_submenu(sub_menu)

                  iconset = gajim.config.get('iconset')
                  if not iconset:
                        iconset = DEFAULT_ICONSET
                  path = os.path.join(gajim.DATA_DIR, 'iconsets', iconset, '16x16')
                  for c in contacts:
                        # icon MUST be different instance for every item
                        state_images = self.load_iconset(path)
                        item = gtk.ImageMenuItem(c.resource + ' (' + str(c.priority) + ')')
                        icon_name = helpers.get_icon_name_to_show(c, account)
                        icon = state_images[icon_name]
                        item.set_image(icon)
                        sub_menu.append(item)
                        item.connect('activate', self.on_open_chat_window, c, account,
                              c.resource)

            else: # one resource
                  start_chat_menuitem.connect('activate',
                        self.on_roster_treeview_row_activated, path)

            if contact.resource:
                  send_file_menuitem.connect('activate',
                        self.on_send_file_menuitem_activate, account, contact)
            else: # if we do not have resource we cannot send file
                  send_file_menuitem.hide()
                  send_file_menuitem.set_no_show_all(True)

            send_single_message_menuitem.connect('activate',
                  self.on_send_single_message_menuitem_activate, account, contact)
            rename_menuitem.connect('activate', self.on_rename, iter, path)
            remove_from_roster_menuitem.connect('activate', self.on_req_usub,
                  contact, account)
            information_menuitem.connect('activate', self.on_info, contact,
                  account)
            history_menuitem.connect('activate', self.on_history, contact,
                  account)

            if _('Not in Roster') not in contact.groups:
                  #contact is in normal group
                  edit_groups_menuitem.set_no_show_all(False)
                  assign_openpgp_key_menuitem.set_no_show_all(False)
                  add_to_roster_menuitem.hide()
                  add_to_roster_menuitem.set_no_show_all(True)
                  edit_groups_menuitem.connect('activate', self.on_edit_groups, contact,
                        account)

                  if gajim.config.get('usegpg'):
                        assign_openpgp_key_menuitem.connect('activate',
                              self.on_assign_pgp_key, contact, account)

                  if contact.sub in ('from', 'both'):
                        send_auth_menuitem.set_sensitive(False)
                  else:
                        send_auth_menuitem.connect('activate', self.authorize, jid, account)
                  if contact.sub in ('to', 'both'):
                        ask_auth_menuitem.set_sensitive(False)
                        add_special_notification_menuitem.connect('activate',
                              self.on_add_special_notification_menuitem_activate, jid)
                  else:
                        ask_auth_menuitem.connect('activate', self.req_sub, jid,
                              _('I would like to add you to my roster'), account)
                  if contact.sub in ('to', 'none'):
                        revoke_auth_menuitem.set_sensitive(False)
                  else:
                        revoke_auth_menuitem.connect('activate', self.revoke_auth, jid,
                              account)

            else: # contact is in group 'Not in Roster'
                  add_to_roster_menuitem.set_no_show_all(False)
                  edit_groups_menuitem.hide()
                  edit_groups_menuitem.set_no_show_all(True)
                  # hide first of the two consecutive separators
                  above_send_file_separator.hide()
                  above_send_file_separator.set_no_show_all(True)
                  assign_openpgp_key_menuitem.hide()
                  assign_openpgp_key_menuitem.set_no_show_all(True)
                  subscription_menuitem.hide()
                  subscription_menuitem.set_no_show_all(True)

                  add_to_roster_menuitem.connect('activate',
                        self.on_add_to_roster, contact, account)

            # Unsensitive many items when account is offline
            if gajim.connections[account].connected < 2:
                  for widget in [start_chat_menuitem, send_single_message_menuitem,
                  rename_menuitem, edit_groups_menuitem, send_file_menuitem,
                  subscription_menuitem, add_to_roster_menuitem,
                  remove_from_roster_menuitem]:
                        widget.set_sensitive(False)

            #FIXME: create menu for sub contacts

            event_button = gtkgui_helpers.get_possible_button_event(event)

            roster_contact_context_menu.attach_to_widget(self.tree, None)
            roster_contact_context_menu.connect('selection-done',
                  gtkgui_helpers.destroy_widget)
            roster_contact_context_menu.popup(None, None, None, event_button,
                  event.time)
            roster_contact_context_menu.show_all()

      def make_group_menu(self, event, iter):


Generated by  Doxygen 1.6.0   Back to index