improve function name; move it to where we keep those
This commit is contained in:
parent
c220fed809
commit
9e35ac7aeb
|
@ -190,8 +190,23 @@ def get_resource_from_jid(jid):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def get_number_of_accounts():
|
def get_number_of_accounts():
|
||||||
|
'''returns the number of ALL accounts'''
|
||||||
return len(connections.keys())
|
return len(connections.keys())
|
||||||
|
|
||||||
|
def get_number_of_connected_accounts(accounts_list = None):
|
||||||
|
'''returns the number of CONNECTED accounts
|
||||||
|
you can optionally pass an accounts_list
|
||||||
|
and if you do those will be checked, else all will be checked'''
|
||||||
|
connected_accounts = 0
|
||||||
|
if accounts_list is None:
|
||||||
|
accounts = connections.keys()
|
||||||
|
else:
|
||||||
|
accounts = accounts_list
|
||||||
|
for acct in accounts:
|
||||||
|
if gajim.connections[acct].connected > 1:
|
||||||
|
connected_accounts = connected_accounts + 1
|
||||||
|
return connected_accounts
|
||||||
|
|
||||||
def get_transport_name_from_jid(jid, use_config_setting = True):
|
def get_transport_name_from_jid(jid, use_config_setting = True):
|
||||||
'''returns 'aim', 'gg', 'irc' etc
|
'''returns 'aim', 'gg', 'irc' etc
|
||||||
if JID is not from transport returns None'''
|
if JID is not from transport returns None'''
|
||||||
|
|
|
@ -460,18 +460,6 @@ def get_xmpp_show(show):
|
||||||
return None
|
return None
|
||||||
return show
|
return show
|
||||||
|
|
||||||
def connected_accounts(account_list = None):
|
|
||||||
'''returns the number of connected accounts'''
|
|
||||||
connected_accounts = 0
|
|
||||||
if account_list is None:
|
|
||||||
accounts = gajim.connections.keys()
|
|
||||||
else:
|
|
||||||
accounts = account_list
|
|
||||||
for acct in accounts:
|
|
||||||
if gajim.connections[acct].connected > 1:
|
|
||||||
connected_accounts = connected_accounts + 1
|
|
||||||
return connected_accounts
|
|
||||||
|
|
||||||
def get_output_of_command(command):
|
def get_output_of_command(command):
|
||||||
try:
|
try:
|
||||||
child_stdin, child_stdout = os.popen2(command)
|
child_stdin, child_stdout = os.popen2(command)
|
||||||
|
|
|
@ -667,7 +667,7 @@ class RosterWindow:
|
||||||
gc_sub_menu = gtk.Menu() # gc is always a submenu
|
gc_sub_menu = gtk.Menu() # gc is always a submenu
|
||||||
join_gc_menuitem.set_submenu(gc_sub_menu)
|
join_gc_menuitem.set_submenu(gc_sub_menu)
|
||||||
|
|
||||||
connected_accounts = helpers.connected_accounts()
|
connected_accounts = gajim.get_number_of_connected_accounts()
|
||||||
if connected_accounts > 1: # 2 or more accounts? make submenus
|
if connected_accounts > 1: # 2 or more accounts? make submenus
|
||||||
add_sub_menu = gtk.Menu()
|
add_sub_menu = gtk.Menu()
|
||||||
disco_sub_menu = gtk.Menu()
|
disco_sub_menu = gtk.Menu()
|
||||||
|
@ -1969,7 +1969,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid)
|
||||||
for acct in accounts:
|
for acct in accounts:
|
||||||
if gajim.config.get_per('accounts', acct, 'sync_with_global_status'):
|
if gajim.config.get_per('accounts', acct, 'sync_with_global_status'):
|
||||||
global_sync_accounts.append(acct)
|
global_sync_accounts.append(acct)
|
||||||
global_sync_connected_accounts = helpers.connected_accounts(
|
global_sync_connected_accounts = gajim.get_number_of_connected_accounts(
|
||||||
global_sync_accounts)
|
global_sync_accounts)
|
||||||
for acct in accounts:
|
for acct in accounts:
|
||||||
if not gajim.config.get_per('accounts', acct, 'sync_with_global_status'):
|
if not gajim.config.get_per('accounts', acct, 'sync_with_global_status'):
|
||||||
|
|
|
@ -155,7 +155,7 @@ class Systray:
|
||||||
item.set_image(img)
|
item.set_image(img)
|
||||||
sub_menu.append(item)
|
sub_menu.append(item)
|
||||||
item.connect('activate', self.on_change_status_message_activate)
|
item.connect('activate', self.on_change_status_message_activate)
|
||||||
connected_accounts = helpers.connected_accounts()
|
connected_accounts = gajim.get_number_of_connected_accounts()
|
||||||
if connected_accounts < 1:
|
if connected_accounts < 1:
|
||||||
item.set_sensitive(False)
|
item.set_sensitive(False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue