use timeout_add_seconds instead of timeout_add (when it's available), more efficient. fixes #3734, #3736
This commit is contained in:
parent
894e752292
commit
7c49600135
|
@ -1134,9 +1134,9 @@ class ChatControl(ChatControlBase):
|
|||
self.mouse_over_in_last_30_secs = True
|
||||
|
||||
def _schedule_activity_timers(self):
|
||||
self.possible_paused_timeout_id = gobject.timeout_add(5000,
|
||||
self.possible_paused_timeout_id = gobject.timeout_add_seconds(5,
|
||||
self.check_for_possible_paused_chatstate, None)
|
||||
self.possible_inactive_timeout_id = gobject.timeout_add(30000,
|
||||
self.possible_inactive_timeout_id = gobject.timeout_add_seconds(30,
|
||||
self.check_for_possible_inactive_chatstate, None)
|
||||
|
||||
def update_ui(self):
|
||||
|
|
|
@ -277,7 +277,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf):
|
|||
|
||||
# refresh all contacts data every five seconds
|
||||
self.call_resolve_timeout = True
|
||||
gobject.timeout_add(5000, self._on_resolve_timeout)
|
||||
gobject.timeout_add_seconds(5, self._on_resolve_timeout)
|
||||
return True
|
||||
|
||||
def disconnect(self, on_purpose = False):
|
||||
|
|
|
@ -1942,8 +1942,8 @@ class PopupNotificationWindow:
|
|||
|
||||
xml.signal_autoconnect(self)
|
||||
self.window.show_all()
|
||||
timeout = gajim.config.get('notification_timeout') * 1000 # make it ms
|
||||
gobject.timeout_add(timeout, self.on_timeout)
|
||||
timeout = gajim.config.get('notification_timeout')
|
||||
gobject.timeout_add_seconds(timeout, self.on_timeout)
|
||||
|
||||
def on_close_button_clicked(self, widget):
|
||||
self.adjust_height_and_move_popup_notification_windows()
|
||||
|
|
|
@ -152,7 +152,7 @@ class CacheDictionary:
|
|||
if item.source:
|
||||
gobject.source_remove(item.source)
|
||||
if self.lifetime:
|
||||
source = gobject.timeout_add(self.lifetime, self._expire_timeout, key)
|
||||
source = gobject.timeout_add_seconds(self.lifetime/1000, self._expire_timeout, key)
|
||||
item.source = source
|
||||
|
||||
def __getitem__(self, key):
|
||||
|
@ -1364,12 +1364,12 @@ class ToplevelAgentBrowser(AgentBrowser):
|
|||
fraction = float(self._progress) / float(self._total_items)
|
||||
if self._progress >= self._total_items:
|
||||
# We show the progressbar for just a bit before hiding it.
|
||||
id = gobject.timeout_add(1500, self._hide_progressbar_cb)
|
||||
id = gobject.timeout_add_seconds(2, self._hide_progressbar_cb)
|
||||
self._progressbar_sourceid = id
|
||||
else:
|
||||
self.window.progressbar.show()
|
||||
# Hide the progressbar if we're timing out anyways. (20 secs)
|
||||
id = gobject.timeout_add(20000, self._hide_progressbar_cb)
|
||||
id = gobject.timeout_add_seconds(20, self._hide_progressbar_cb)
|
||||
self._progressbar_sourceid = id
|
||||
self.window.progressbar.set_fraction(fraction)
|
||||
|
||||
|
|
16
src/gajim.py
16
src/gajim.py
|
@ -218,6 +218,10 @@ if '.svn' in os.listdir(path) or '_svn' in os.listdir(path):
|
|||
del path
|
||||
|
||||
import gobject
|
||||
if not hasattr(gobject, 'timeout_add_seconds'):
|
||||
def timeout_add_seconds_fake(time_sec, *args):
|
||||
return gobject.timeout_add(time_sec * 1000, *args)
|
||||
gobject.timeout_add_seconds = timeout_add_seconds_fake
|
||||
|
||||
import re
|
||||
import signal
|
||||
|
@ -533,7 +537,7 @@ class Interface:
|
|||
# we stop blocking notifications of any kind
|
||||
# this prevents from getting the roster items as 'just signed in'
|
||||
# contacts. 30 seconds should be enough time
|
||||
gobject.timeout_add(30000, self.unblock_signed_in_notifications, account)
|
||||
gobject.timeout_add_seconds(30, self.unblock_signed_in_notifications, account)
|
||||
# sensitivity for this menuitem
|
||||
model[self.roster.status_message_menuitem_iter][3] = True
|
||||
|
||||
|
@ -648,7 +652,7 @@ class Interface:
|
|||
gajim.newly_added[account].append(contact1.jid)
|
||||
if contact1.jid in gajim.to_be_removed[account]:
|
||||
gajim.to_be_removed[account].remove(contact1.jid)
|
||||
gobject.timeout_add(5000, self.roster.remove_newly_added,
|
||||
gobject.timeout_add_seconds(5, self.roster.remove_newly_added,
|
||||
contact1.jid, account)
|
||||
elif old_show > 1 and new_show == 0 and gajim.connections[account].\
|
||||
connected > 1:
|
||||
|
@ -657,7 +661,7 @@ class Interface:
|
|||
if contact1.jid in gajim.newly_added[account]:
|
||||
gajim.newly_added[account].remove(contact1.jid)
|
||||
self.roster.draw_contact(contact1.jid, account)
|
||||
gobject.timeout_add(5000, self.roster.really_remove_contact,
|
||||
gobject.timeout_add_seconds(5, self.roster.really_remove_contact,
|
||||
contact1, account)
|
||||
contact1.show = array[1]
|
||||
contact1.status = status_message
|
||||
|
@ -684,7 +688,7 @@ class Interface:
|
|||
# for 30s
|
||||
account_ji = account + '/' + ji
|
||||
gajim.block_signed_in_notifications[account_ji] = True
|
||||
gobject.timeout_add(30000, self.unblock_signed_in_notifications,
|
||||
gobject.timeout_add_seconds(30, self.unblock_signed_in_notifications,
|
||||
account_ji)
|
||||
locations = (self.instances, self.instances[account])
|
||||
for location in locations:
|
||||
|
@ -2948,8 +2952,8 @@ class Interface:
|
|||
if os.name == 'nt':
|
||||
gobject.timeout_add(200, self.process_connections)
|
||||
else:
|
||||
gobject.timeout_add(2000, self.process_connections)
|
||||
gobject.timeout_add(10000, self.read_sleepy)
|
||||
gobject.timeout_add_seconds(2, self.process_connections)
|
||||
gobject.timeout_add_seconds(10, self.read_sleepy)
|
||||
|
||||
if __name__ == '__main__':
|
||||
def sigint_cb(num, stack):
|
||||
|
|
|
@ -87,13 +87,13 @@ class MusicTrackListener(gobject.GObject):
|
|||
self.current_banshee_title = ''
|
||||
self.banshee_paused_before = False
|
||||
self.banshee_is_here = False
|
||||
gobject.timeout_add(10000, self._check_if_banshee_bus)
|
||||
gobject.timeout_add_seconds(10, self._check_if_banshee_bus)
|
||||
if self.dubus_methods.NameHasOwner('org.gnome.Banshee'):
|
||||
self._get_banshee_bus()
|
||||
self.banshee_is_here = True
|
||||
# Otherwise, it opens Banshee!
|
||||
self.banshee_props ={}
|
||||
gobject.timeout_add(1000, self._banshee_check_track_status)
|
||||
gobject.timeout_add_seconds(1, self._banshee_check_track_status)
|
||||
|
||||
def _check_if_banshee_bus(self):
|
||||
if self.dubus_methods.NameHasOwner('org.gnome.Banshee'):
|
||||
|
|
|
@ -248,7 +248,7 @@ class ProfileWindow:
|
|||
self.statusbar.remove(self.context_id, self.message_id)
|
||||
self.message_id = self.statusbar.push(self.context_id,
|
||||
_('Information received'))
|
||||
self.remove_statusbar_timeout_id = gobject.timeout_add(3000,
|
||||
self.remove_statusbar_timeout_id = gobject.timeout_add_seconds(3,
|
||||
self.remove_statusbar, self.message_id)
|
||||
gobject.source_remove(self.update_progressbar_timeout_id)
|
||||
self.progressbar.hide()
|
||||
|
@ -344,7 +344,7 @@ class ProfileWindow:
|
|||
self.statusbar.remove(self.context_id, self.message_id)
|
||||
self.message_id = self.statusbar.push(self.context_id,
|
||||
_('Information NOT published'))
|
||||
self.remove_statusbar_timeout_id = gobject.timeout_add(3000,
|
||||
self.remove_statusbar_timeout_id = gobject.timeout_add_seconds(3,
|
||||
self.remove_statusbar, self.message_id)
|
||||
if self.update_progressbar_timeout_id is not None:
|
||||
gobject.source_remove(self.update_progressbar_timeout_id)
|
||||
|
|
|
@ -5620,10 +5620,10 @@ class RosterWindow:
|
|||
## accounts has no effect until they are connected.
|
||||
st = gajim.config.get('set_status_msg_from_current_music_track')
|
||||
if st:
|
||||
gobject.timeout_add(1000,
|
||||
gobject.timeout_add_seconds(1,
|
||||
self.enable_syncing_status_msg_from_current_music_track, st)
|
||||
else:
|
||||
gobject.timeout_add(1000,
|
||||
gobject.timeout_add_seconds(1,
|
||||
self.enable_syncing_status_msg_from_lastfm,
|
||||
gajim.config.get('set_status_msg_from_lastfm'))
|
||||
|
||||
|
|
Loading…
Reference in New Issue