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

def roster_window::RosterWindow::on_status_combobox_changed (   self,
  widget 
)

When we change our status via the combobox

Definition at line 1964 of file roster_window.py.

01964                                                   :
            '''When we change our status via the combobox'''
            model = self.status_combobox.get_model()
            active = self.status_combobox.get_active()
            if active == -1: # no active item
                  return
            if not self.combobox_callback_active:
                  self.previous_status_combobox_active = active
                  return
            accounts = gajim.connections.keys()
            if len(accounts) == 0:
                  dialogs.ErrorDialog(_('No account available'),
            _('You must create an account before you can chat with other contacts.'))
                  self.update_status_combobox()
                  return
            status = model[active][2].decode('utf-8')

            if active == 7: # We choose change status message (7 is that)
                  # do not change show, just show change status dialog
                  status = model[self.previous_status_combobox_active][2].decode('utf-8')
                  dlg = dialogs.ChangeStatusMessageDialog(status)
                  message = dlg.run()
                  if message is not None: # None if user pressed Cancel
                        for acct in accounts:
                              if not gajim.config.get_per('accounts', acct,
                                    'sync_with_global_status'):
                                    continue
                              current_show = gajim.SHOW_LIST[gajim.connections[acct].connected]
                              self.send_status(acct, current_show, message)
                  self.combobox_callback_active = False
                  self.status_combobox.set_active(self.previous_status_combobox_active)
                  self.combobox_callback_active = True
                  return
            # we are about to change show, so save this new show so in case
            # after user chooses "Change status message" menuitem
            # we can return to this show
            self.previous_status_combobox_active = active
            connected_accounts = gajim.get_number_of_connected_accounts()
            if status == 'invisible':
                  bug_user = False
                  for acct in accounts:
                        if connected_accounts < 1 or gajim.connections[acct].connected > 1:
                              if not gajim.config.get_per('accounts', acct,
                                          'sync_with_global_status'):
                                    continue
                              # We're going to change our status to invisible
                              if self.connected_rooms(acct):
                                    bug_user = True
                                    break
                  if bug_user:
                        dialog = dialogs.ConfirmationDialog(
            _('You are participating in one or more group chats'),
            _('Changing your status to invisible will result in disconnection from those group chats. Are you sure you want to go invisible?'))
                        if dialog.get_response() != gtk.RESPONSE_OK:
                              self.update_status_combobox()
                              return
            message = self.get_status_message(status)
            if message is None: # user pressed Cancel to change status message dialog
                  self.update_status_combobox()
                  return
            global_sync_accounts = []
            for acct in accounts:
                  if gajim.config.get_per('accounts', acct, 'sync_with_global_status'):
                        global_sync_accounts.append(acct)
            global_sync_connected_accounts = gajim.get_number_of_connected_accounts(
                  global_sync_accounts)
            for acct in accounts:
                  if not gajim.config.get_per('accounts', acct, 'sync_with_global_status'):
                        continue
                  # we are connected (so we wanna change show and status)
                  # or no account is connected and we want to connect with new show and status

                  if not global_sync_connected_accounts > 0 or \
                  gajim.connections[acct].connected > 1:
                        self.send_status(acct, status, message)
            self.update_status_combobox()

      def update_status_combobox(self):


Generated by  Doxygen 1.6.0   Back to index