GObject.* -> GLib.*

This commit is contained in:
Yann Leboulanger 2013-07-28 20:50:30 +02:00
parent 8c7ee7a12b
commit fd0ff877a3
22 changed files with 215 additions and 215 deletions

View File

@ -25,7 +25,7 @@
# FIXME: think if we need caching command list. it may be wrong if there will
# be entities that often change the list, it may be slow to fetch it every time
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gtk
import nbxmpp
@ -555,14 +555,14 @@ class CommandWindow:
return True # important to keep callback be called back!
# 12 times per second (80 miliseconds)
self.pulse_id = GObject.timeout_add(80, callback)
self.pulse_id = GLib.timeout_add(80, callback)
def remove_pulsing(self):
"""
Stop pulsing, useful when especially when removing widget
"""
if self.pulse_id:
GObject.source_remove(self.pulse_id)
GLib.source_remove(self.pulse_id)
self.pulse_id = None
# handling xml stanzas

View File

@ -25,7 +25,7 @@
from gi.repository import Gtk
import gtkgui_helpers
from gi.repository import GObject
from gi.repository import GLib
from common import gajim
from common import helpers
@ -51,12 +51,12 @@ def rate_limit(rate):
timeout = [None]
def f(*args, **kwargs):
if timeout[0] is not None:
GObject.source_remove(timeout[0])
GLib.source_remove(timeout[0])
timeout[0] = None
def timeout_func():
func(*args, **kwargs)
timeout[0] = None
timeout[0] = GObject.timeout_add(int(1000.0 / rate), timeout_func)
timeout[0] = GLib.timeout_add(int(1000.0 / rate), timeout_func)
return f
return decorator

View File

@ -77,7 +77,7 @@ class CellRendererImage(Gtk.CellRendererPixbuf):
if model:
model.foreach(self.func, (image, tree))
if self.redraw:
GObject.timeout_add(iter_.get_delay_time(),
GLib.timeout_add(iter_.get_delay_time(),
self.animation_timeout, tree, image)
elif image in self.iters:
del self.iters[image]
@ -95,8 +95,8 @@ class CellRendererImage(Gtk.CellRendererPixbuf):
timeval.tv_sec = GLib.get_current_time()
iter_ = animation.get_iter(timeval)
self.iters[self.image] = iter_
GObject.timeout_add(iter_.get_delay_time(),
self.animation_timeout, widget, self.image)
GLib.timeout_add(iter_.get_delay_time(), self.animation_timeout,
widget, self.image)
pix = self.iters[self.image].get_pixbuf()
elif self.image.get_storage_type() == Gtk.ImageType.PIXBUF:

View File

@ -34,6 +34,7 @@ from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import Pango
from gi.repository import GObject
from gi.repository import GLib
import gtkgui_helpers
import gui_menu_builder
import message_control
@ -1286,7 +1287,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
visible_rect = textview.get_visible_rect()
# scroll only if expected end is not visible
if end_rect.y >= (visible_rect.y + visible_rect.height + diff_y):
self.scroll_to_end_id = GObject.idle_add(self.scroll_to_end_iter,
self.scroll_to_end_id = GLib.idle_add(self.scroll_to_end_iter,
textview)
def scroll_to_end_iter(self, textview):
@ -1482,7 +1483,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
"""
# make the last message visible, when changing to "full view"
if not state:
GObject.idle_add(self.conv_textview.scroll_to_end_iter)
GLib.idle_add(self.conv_textview.scroll_to_end_iter)
widget.set_no_show_all(state)
if state:
@ -2048,8 +2049,8 @@ class ChatControl(ChatControlBase):
if avatar_w > scaled_buf_w or avatar_h > scaled_buf_h:
# wait for 0.5 sec in case we leave earlier
if self.show_bigger_avatar_timeout_id is not None:
GObject.source_remove(self.show_bigger_avatar_timeout_id)
self.show_bigger_avatar_timeout_id = GObject.timeout_add(500,
GLib.source_remove(self.show_bigger_avatar_timeout_id)
self.show_bigger_avatar_timeout_id = GLib.timeout_add(500,
self.show_bigger_avatar, widget)
def on_avatar_eventbox_leave_notify_event(self, widget, event):
@ -2058,7 +2059,7 @@ class ChatControl(ChatControlBase):
"""
# did we add a timeout? if yes remove it
if self.show_bigger_avatar_timeout_id is not None:
GObject.source_remove(self.show_bigger_avatar_timeout_id)
GLib.source_remove(self.show_bigger_avatar_timeout_id)
self.show_bigger_avatar_timeout_id = None
def on_avatar_eventbox_button_press_event(self, widget, event):
@ -2100,9 +2101,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_seconds(5,
self.possible_paused_timeout_id = GLib.timeout_add_seconds(5,
self.check_for_possible_paused_chatstate, None)
self.possible_inactive_timeout_id = GObject.timeout_add_seconds(30,
self.possible_inactive_timeout_id = GLib.timeout_add_seconds(30,
self.check_for_possible_inactive_chatstate, None)
def update_ui(self):
@ -2162,7 +2163,7 @@ class ChatControl(ChatControlBase):
name = i18n.direction_mark + _(
'%(nickname)s from group chat %(room_name)s') % \
{'nickname': name, 'room_name': self.room_name}
name = i18n.direction_mark + GObject.markup_escape_text(name)
name = i18n.direction_mark + GLib.markup_escape_text(name)
# We know our contacts nick, but if another contact has the same nick
# in another account we need to also display the account.
@ -2179,7 +2180,7 @@ class ChatControl(ChatControlBase):
if other_contact_.get_shown_name() == \
self.contact.get_shown_name():
acct_info = i18n.direction_mark + ' (%s)' % \
GObject.markup_escape_text(self.account)
GLib.markup_escape_text(self.account)
break
status = contact.status
@ -2189,7 +2190,7 @@ class ChatControl(ChatControlBase):
status_reduced = helpers.reduce_chars_newlines(status, max_lines=1)
else:
status_reduced = ''
status_escaped = GObject.markup_escape_text(status_reduced)
status_escaped = GLib.markup_escape_text(status_reduced)
font_attrs, font_attrs_small = self.get_font_attrs()
st = gajim.config.get('displayed_chat_state_notifications')
@ -2407,8 +2408,8 @@ class ChatControl(ChatControlBase):
chatstate_to_send = 'active'
contact.our_chatstate = 'active'
GObject.source_remove(self.possible_paused_timeout_id)
GObject.source_remove(self.possible_inactive_timeout_id)
GLib.source_remove(self.possible_paused_timeout_id)
GLib.source_remove(self.possible_inactive_timeout_id)
self._schedule_activity_timers()
def _on_sent(msg_stanza, message, encrypted, xhtml, label, old_txt):
@ -2671,7 +2672,7 @@ class ChatControl(ChatControlBase):
name = self.contact.get_shown_name()
if self.resource:
name += '/' + self.resource
label_str = GObject.markup_escape_text(name)
label_str = GLib.markup_escape_text(name)
if num_unread: # if unread, text in the label becomes bold
label_str = '<b>' + unread + label_str + '</b>'
return (label_str, color)
@ -2809,8 +2810,8 @@ class ChatControl(ChatControlBase):
self.session.control = None
# Disconnect timer callbacks
GObject.source_remove(self.possible_paused_timeout_id)
GObject.source_remove(self.possible_inactive_timeout_id)
GLib.source_remove(self.possible_paused_timeout_id)
GLib.source_remove(self.possible_inactive_timeout_id)
# Remove bigger avatar window
if self.bigger_avatar_window:
self.bigger_avatar_window.destroy()
@ -2893,8 +2894,8 @@ class ChatControl(ChatControlBase):
else:
self.send_chatstate('active', self.contact)
self.reset_kbd_mouse_timeout_vars()
GObject.source_remove(self.possible_paused_timeout_id)
GObject.source_remove(self.possible_inactive_timeout_id)
GLib.source_remove(self.possible_paused_timeout_id)
GLib.source_remove(self.possible_inactive_timeout_id)
self._schedule_activity_timers()
else:
self.send_chatstate('inactive', self.contact)
@ -3479,6 +3480,6 @@ class ChatControl(ChatControlBase):
self.info_bar.set_no_show_all(True)
self.info_bar.hide()
# show next one?
GObject.idle_add(self._info_bar_show_message)
GLib.idle_add(self._info_bar_show_message)
break
i += 1

View File

@ -36,7 +36,7 @@ import sys
import re
import copy
from common import defs
from gi.repository import GObject
from gi.repository import GLib
(
OPT_TYPE,
@ -802,7 +802,7 @@ class Config:
def _timeout_save(self):
if self.save_timeout_id:
return
self.save_timeout_id = GObject.timeout_add(1000, self._really_save)
self.save_timeout_id = GLib.timeout_add(1000, self._really_save)
def __init__(self):
#init default values

View File

@ -33,7 +33,7 @@ import base64
import sys
import operator
import hashlib
from gi.repository import GObject
from gi.repository import GLib
from time import (altzone, daylight, gmtime, localtime, mktime, strftime,
time as time_time, timezone, tzname)
@ -560,7 +560,7 @@ class ConnectionVcard:
self.discover_ft_proxies()
gajim.nec.push_incoming_event(RosterReceivedEvent(None,
conn=self))
GObject.timeout_add_seconds(10, self.discover_servers)
GLib.timeout_add_seconds(10, self.discover_servers)
elif self.awaiting_answers[id_][0] == PRIVACY_ARRIVED:
if iq_obj.getType() != 'error':
self.privacy_rules_supported = True

View File

@ -17,7 +17,7 @@ Handles Jingle RTP sessions (XEP 0167)
from collections import deque
from gi.repository import GObject
from gi.repository import GLib
import socket
import nbxmpp
@ -130,13 +130,13 @@ class JingleRTPContent(JingleContent):
events = deque(events)
self._dtmf_running = True
self._start_dtmf(events.popleft())
GObject.timeout_add(500, self._next_dtmf, events)
GLib.timeout_add(500, self._next_dtmf, events)
def _next_dtmf(self, events):
self._stop_dtmf()
if events:
self._start_dtmf(events.popleft())
GObject.timeout_add(500, self._next_dtmf, events)
GLib.timeout_add(500, self._next_dtmf, events)
else:
self._dtmf_running = False

View File

@ -34,7 +34,7 @@ import time
import datetime
from gzip import GzipFile
from io import BytesIO
from gi.repository import GObject
from gi.repository import GLib
from common import exceptions
from common import gajim
@ -177,7 +177,7 @@ class Logger:
def _timeout_commit(self):
if self.commit_timout_id:
return
self.commit_timout_id = GObject.timeout_add(500, self._really_commit)
self.commit_timout_id = GLib.timeout_add(500, self._really_commit)
def simple_commit(self, sql_to_commit):
"""

View File

@ -317,7 +317,7 @@ class NsLookup(IdleCommand):
# below lines is on how to use API and assist in testing
if __name__ == '__main__':
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gtk
from nbxmpp import idlequeue
@ -342,7 +342,7 @@ if __name__ == '__main__':
but.connect('clicked', clicked)
win.add(hbox)
win.show_all()
GObject.timeout_add(200, idlequeue.process)
GLib.timeout_add(200, idlequeue.process)
if USE_LIBASYNCNS:
GObject.timeout_add(200, resolver.process)
GLib.timeout_add(200, resolver.process)
Gtk.main()

View File

@ -35,6 +35,7 @@ from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import Pango
from gi.repository import GObject
from gi.repository import GLib
import os, sys
import common.config
import common.sleepy
@ -588,7 +589,7 @@ class PreferencesWindow:
gtkgui_helpers.possibly_move_window_in_current_desktop(self.window)
def on_preferences_notebook_switch_page(self, widget, page, page_num):
GObject.idle_add(self.xml.get_object('close_button').grab_focus)
GLib.idle_add(self.xml.get_object('close_button').grab_focus)
def on_preferences_window_key_press_event(self, widget, event):
if event.keyval == Gdk.KEY_Escape:
@ -1661,7 +1662,7 @@ class AccountsWindow:
status_before = gajim.connections[account].status
gajim.interface.roster.send_status(account, 'offline',
_('Be right back.'))
GObject.timeout_add(500, login, account, show_before, status_before)
GLib.timeout_add(500, login, account, show_before, status_before)
def on_yes(checked, account):
relog(account)
@ -2162,7 +2163,7 @@ class AccountsWindow:
if not widget.is_focus():
pritext = _('Invalid Jabber ID')
dialogs.ErrorDialog(pritext, str(s))
GObject.idle_add(lambda: widget.grab_focus())
GLib.idle_add(lambda: widget.grab_focus())
return True
jid_splited = jid.split('@', 1)
@ -2172,7 +2173,7 @@ class AccountsWindow:
pritext = _('Invalid Jabber ID')
sectext = _('A Jabber ID must be in the form "user@servername".')
dialogs.ErrorDialog(pritext, sectext)
GObject.idle_add(lambda: widget.grab_focus())
GLib.idle_add(lambda: widget.grab_focus())
return True
@ -2237,7 +2238,7 @@ class AccountsWindow:
if not widget.is_focus():
pritext = _('Invalid Jabber ID')
dialogs.ErrorDialog(pritext, str(s))
GObject.idle_add(lambda: widget.grab_focus())
GLib.idle_add(lambda: widget.grab_focus())
return True
if self.option_changed('resource', resource):
@ -2393,7 +2394,7 @@ class AccountsWindow:
if not widget.is_focus():
dialogs.ErrorDialog(_('Invalid entry'),
_('Custom port must be a port number.'))
GObject.idle_add(lambda: widget.grab_focus())
GLib.idle_add(lambda: widget.grab_focus())
return True
if self.option_changed('custom_port', custom_port):
self.need_relogin = True
@ -3701,7 +3702,7 @@ class AccountCreationWizardWindow:
self.notebook.set_current_page(5) # show creating page
self.back_button.hide()
self.forward_button.hide()
self.update_progressbar_timeout_id = GObject.timeout_add(100,
self.update_progressbar_timeout_id = GLib.timeout_add(100,
self.update_progressbar)
# Get form from serveur
con = connection.Connection(self.account)
@ -3743,7 +3744,7 @@ class AccountCreationWizardWindow:
self.notebook.set_current_page(5) # show creating page
self.back_button.hide()
self.forward_button.hide()
self.update_progressbar_timeout_id = GObject.timeout_add(100,
self.update_progressbar_timeout_id = GLib.timeout_add(100,
self.update_progressbar)
def update_proxy_list(self):
@ -3779,7 +3780,7 @@ class AccountCreationWizardWindow:
if obj.conn.name != self.account:
return
if self.update_progressbar_timeout_id is not None:
GObject.source_remove(self.update_progressbar_timeout_id)
GLib.source_remove(self.update_progressbar_timeout_id)
self.back_button.show()
self.forward_button.show()
self.is_form = obj.is_form
@ -3837,7 +3838,7 @@ class AccountCreationWizardWindow:
if self.account not in gajim.connections:
return
if self.update_progressbar_timeout_id is not None:
GObject.source_remove(self.update_progressbar_timeout_id)
GLib.source_remove(self.update_progressbar_timeout_id)
del gajim.connections[self.account]
if self.account in gajim.config.get_per('accounts'):
gajim.config.del_per('accounts', self.account)
@ -3863,7 +3864,7 @@ class AccountCreationWizardWindow:
self.show_finish_page()
if self.update_progressbar_timeout_id is not None:
GObject.source_remove(self.update_progressbar_timeout_id)
GLib.source_remove(self.update_progressbar_timeout_id)
def _nec_acc_is_not_ok(self, obj):
"""
@ -3887,7 +3888,7 @@ class AccountCreationWizardWindow:
self.notebook.set_current_page(6) # show finish page
if self.update_progressbar_timeout_id is not None:
GObject.source_remove(self.update_progressbar_timeout_id)
GLib.source_remove(self.update_progressbar_timeout_id)
def on_advanced_button_clicked(self, widget):
if 'accounts' in gajim.interface.instances:

View File

@ -34,6 +34,7 @@ from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import Pango
from gi.repository import GObject
from gi.repository import GLib
import time
import os
import tooltips
@ -404,14 +405,14 @@ class ConversationTextview(GObject.GObject):
return True
def smooth_scroll_timeout(self):
GObject.idle_add(self.do_smooth_scroll_timeout)
GLib.idle_add(self.do_smooth_scroll_timeout)
return
def do_smooth_scroll_timeout(self):
if not self.smooth_id:
# we finished scrolling
return
GObject.source_remove(self.smooth_id)
GLib.source_remove(self.smooth_id)
self.smooth_id = None
parent = self.tv.get_parent()
if parent:
@ -423,7 +424,7 @@ class ConversationTextview(GObject.GObject):
def smooth_scroll_to_end(self):
if None != self.smooth_id: # already scrolling
return False
self.smooth_id = GObject.timeout_add(self.SCROLL_DELAY,
self.smooth_id = GLib.timeout_add(self.SCROLL_DELAY,
self.smooth_scroll)
self.smooth_scroll_timer = Timer(self.MAX_SCROLL_TIME,
self.smooth_scroll_timeout)
@ -453,9 +454,9 @@ class ConversationTextview(GObject.GObject):
# scroll only if expected end is not visible
if end_rect.y >= (visible_rect.y + visible_rect.height + diff_y):
if use_smooth:
GObject.idle_add(self.smooth_scroll_to_end)
GLib.idle_add(self.smooth_scroll_to_end)
else:
GObject.idle_add(self.scroll_to_end_iter)
GLib.idle_add(self.scroll_to_end_iter)
def scroll_to_end_iter(self):
buffer_ = self.tv.get_buffer()
@ -467,7 +468,7 @@ class ConversationTextview(GObject.GObject):
def stop_scrolling(self):
if self.smooth_id:
GObject.source_remove(self.smooth_id)
GLib.source_remove(self.smooth_id)
self.smooth_id = None
self.smooth_scroll_timer.cancel()
@ -548,7 +549,7 @@ class ConversationTextview(GObject.GObject):
self.xep0184_shown[id_] = SHOWN
return False
GObject.timeout_add_seconds(3, show_it)
GLib.timeout_add_seconds(3, show_it)
buffer_.end_user_action()
@ -647,7 +648,7 @@ class ConversationTextview(GObject.GObject):
if scroll:
# scroll to the end (via idle in case the scrollbar has
# appeared)
GObject.idle_add(self.scroll_to_end)
GLib.idle_add(self.scroll_to_end)
def show_xep0184_warning_tooltip(self):
pointer = self.tv.get_pointer()
@ -751,13 +752,13 @@ class ConversationTextview(GObject.GObject):
if not xep0184_warning:
self.xep0184_warning_tooltip.hide_tooltip()
if over_line and not self.line_tooltip.win:
self.line_tooltip.timeout = GObject.timeout_add(500,
self.line_tooltip.timeout = GLib.timeout_add(500,
self.show_line_tooltip)
self.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor(
Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR))
self.change_cursor = True
if xep0184_warning and not self.xep0184_warning_tooltip.win:
self.xep0184_warning_tooltip.timeout = GObject.timeout_add(500,
self.xep0184_warning_tooltip.timeout = GLib.timeout_add(500,
self.show_xep0184_warning_tooltip)
self.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor(
Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR))
@ -1384,9 +1385,9 @@ class ConversationTextview(GObject.GObject):
# we are at the end or we are sending something
# scroll to the end (via idle in case the scrollbar has appeared)
if gajim.config.get('use_smooth_scrolling'):
GObject.idle_add(self.smooth_scroll_to_end)
GLib.idle_add(self.smooth_scroll_to_end)
else:
GObject.idle_add(self.scroll_to_end)
GLib.idle_add(self.scroll_to_end)
self.just_cleared = False
buffer_.end_user_action()

View File

@ -33,6 +33,7 @@ from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import GObject
from gi.repository import GLib
import cairo
import os
@ -566,7 +567,7 @@ class TimeoutDialog:
def run_timeout(self):
if self.countdown_left > 0:
self.countdown()
GObject.timeout_add_seconds(1, self.countdown)
GLib.timeout_add_seconds(1, self.countdown)
def on_timeout():
"""
@ -2871,7 +2872,7 @@ class PopupNotificationWindow:
event_type_label.set_markup(
'<span foreground="black" weight="bold">%s</span>' %
GObject.markup_escape_text(title))
GLib.markup_escape_text(title))
# set colors [ http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html ]
self.window.modify_bg(Gtk.StateType.NORMAL, Gdk.color_parse('black'))
@ -2904,7 +2905,7 @@ class PopupNotificationWindow:
close_button.modify_bg(Gtk.StateType.NORMAL, popup_bg_color)
eventbox.modify_bg(Gtk.StateType.NORMAL, popup_bg_color)
event_description_label.set_markup('<span foreground="black">%s</span>' %
GObject.markup_escape_text(text))
GLib.markup_escape_text(text))
# set the image
image.set_from_file(path_to_image)
@ -2924,7 +2925,7 @@ class PopupNotificationWindow:
xml.connect_signals(self)
self.window.show_all()
if timeout > 0:
GObject.timeout_add_seconds(timeout, self.on_timeout)
GLib.timeout_add_seconds(timeout, self.on_timeout)
def on_close_button_clicked(self, widget):
self.adjust_height_and_move_popup_notification_windows()
@ -3122,7 +3123,7 @@ class SingleMessageWindow:
self.cancel_button.hide()
self.close_button.show()
self.message_tv_buffer.set_text(self.message)
GObject.idle_add(self.set_cursor_to_end)
GLib.idle_add(self.set_cursor_to_end)
else: # we write a new message (not from reply)
self.close_button.hide()
if self.to: # do we already have jid?
@ -3400,7 +3401,7 @@ class XMLConsoleWindow:
buffer.insert_with_tags_by_name(end_iter, stanza.replace('><', '>\n<') \
+ '\n\n', type_)
if at_the_end:
GObject.idle_add(self.scroll_to_end)
GLib.idle_add(self.scroll_to_end)
def _nec_stanza_received(self, obj):
if obj.conn.name != self.account:
@ -3782,8 +3783,8 @@ class ItemArchivingPreferencesWindow:
def launch_progressbar(self):
self.progressbar.show()
self.update_progressbar_timeout_id = GObject.timeout_add(
100, self.update_progressbar)
self.update_progressbar_timeout_id = GLib.timeout_add(100,
self.update_progressbar)
def response_arrived(self, data):
if self.waiting:
@ -4082,7 +4083,7 @@ class PrivacyListWindow:
self.privacy_lists_title_label.set_label(
_('Privacy List <b><i>%s</i></b>') % \
GObject.markup_escape_text(self.privacy_list_name))
GLib.markup_escape_text(self.privacy_list_name))
if len(gajim.connections) > 1:
title = _('Privacy List for %s') % self.account
@ -4566,7 +4567,7 @@ class InvitationReceivedDialog:
sectext = sectext.replace('$Contact', contact_text)
if comment: # only if not None and not ''
comment = GObject.markup_escape_text(comment)
comment = GLib.markup_escape_text(comment)
comment = _('Comment: %s') % comment
sectext += '\n\n%s' % comment
sectext += '\n\n' + _('Do you want to accept the invitation?')
@ -4605,7 +4606,7 @@ class ProgressDialog:
self.dialog.show_all()
self.xml.connect_signals(self)
self.update_progressbar_timeout_id = GObject.timeout_add(100,
self.update_progressbar_timeout_id = GLib.timeout_add(100,
self.update_progressbar)
def update_progressbar(self):

View File

@ -47,7 +47,7 @@
import os
import types
import weakref
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
@ -153,7 +153,7 @@ class CacheDictionary:
for key in list(self.cache.keys()):
item = self.cache[key]
if item.source:
GObject.source_remove(item.source)
GLib.source_remove(item.source)
del self.cache[key]
def _expire_timeout(self, key):
@ -170,9 +170,9 @@ class CacheDictionary:
"""
item = self.cache[key]
if item.source:
GObject.source_remove(item.source)
GLib.source_remove(item.source)
if self.lifetime:
source = GObject.timeout_add_seconds(int(self.lifetime/1000), self._expire_timeout, key)
source = GLib.timeout_add_seconds(int(self.lifetime/1000), self._expire_timeout, key)
item.source = source
def __getitem__(self, key):
@ -189,7 +189,7 @@ class CacheDictionary:
def __delitem__(self, key):
item = self.cache[key]
if item.source:
GObject.source_remove(item.source)
GLib.source_remove(item.source)
del self.cache[key]
def __contains__(self, key):
@ -1059,7 +1059,7 @@ class AgentBrowser:
self.model.clear()
self._total_items = self._progress = 0
self.window.progressbar.show()
self._pulse_timeout = GObject.timeout_add(250, self._pulse_timeout_cb)
self._pulse_timeout = GLib.timeout_add(250, self._pulse_timeout_cb)
self.cache.get_items(self.jid, self.node, self._agent_items,
force=force, args=(force,))
@ -1098,7 +1098,7 @@ class AgentBrowser:
self.model.clear()
self.add_self_line()
self._total_items = 0
GObject.source_remove(self._pulse_timeout)
GLib.source_remove(self._pulse_timeout)
self.window.progressbar.hide()
# The server returned an error
if items == 0:
@ -1311,8 +1311,8 @@ class ToplevelAgentBrowser(AgentBrowser):
if jid and state > 0 and \
(self.tooltip.timeout == 0 or self.tooltip.id != props[0]):
self.tooltip.id = row
self.tooltip.timeout = GObject.timeout_add(500,
self._show_tooltip, state)
self.tooltip.timeout = GLib.timeout_add(500, self._show_tooltip,
state)
def on_treeview_event_hide_tooltip(self, widget, event):
"""
@ -1586,7 +1586,7 @@ class ToplevelAgentBrowser(AgentBrowser):
# self.expanding = False
# return False
#self.expanding = True
#GObject.idle_add(expand_all)
#GLib.idle_add(expand_all)
self.window.services_treeview.expand_all()
def _update_progressbar(self):
@ -1595,7 +1595,7 @@ class ToplevelAgentBrowser(AgentBrowser):
"""
# Refresh this every update
if self._progressbar_sourceid:
GObject.source_remove(self._progressbar_sourceid)
GLib.source_remove(self._progressbar_sourceid)
fraction = 0
if self._total_items:
@ -1604,12 +1604,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_seconds(2, self._hide_progressbar_cb)
id_ = GLib.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_seconds(20, self._hide_progressbar_cb)
id_ = GLib.timeout_add_seconds(20, self._hide_progressbar_cb)
self._progressbar_sourceid = id_
self.window.progressbar.set_fraction(fraction)
@ -1706,7 +1706,7 @@ class ToplevelAgentBrowser(AgentBrowser):
if not cat:
cat = self._create_category(*cat_args)
self.model.append(cat, (jid, node, pix, descr, 1))
GObject.idle_add(self._expand_all)
GLib.idle_add(self._expand_all)
# Grab info on the service
self.cache.get_info(jid, node, self._agent_info, force=force)
self._update_progressbar()
@ -1943,7 +1943,7 @@ class MucBrowser(AgentBrowser):
view = self.window.services_treeview
if not view.get_realized():
# Prevent a silly warning, try again in a bit.
self._fetch_source = GObject.timeout_add(100, self._start_info_query)
self._fetch_source = GLib.timeout_add(100, self._start_info_query)
return
range_ = view.get_visible_range()
if not range_:
@ -1994,7 +1994,7 @@ class MucBrowser(AgentBrowser):
def _add_item(self, jid, node, parent_node, item, force):
self.model.append((jid, node, item.get('name', ''), -1, '', '', False))
if not self._fetch_source:
self._fetch_source = GObject.idle_add(self._start_info_query)
self._fetch_source = GLib.idle_add(self._start_info_query)
def _update_info(self, iter_, jid, node, identities, features, data):
name = identities[0].get('name', '')
@ -2125,7 +2125,7 @@ class DiscussionGroupsBrowser(AgentBrowser):
dunno = True
subscribed = False
name = GObject.markup_escape_text(name)
name = GLib.markup_escape_text(name)
name = '<b>%s</b>' % name
if parent_node:

View File

@ -23,7 +23,7 @@
from gi.repository import Gtk
from gi.repository import GdkPixbuf
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Pango
import os
import time
@ -183,8 +183,7 @@ class FileTransfersWindow:
(file_path, file_name) = os.path.split(file_props.file_name)
else:
file_name = file_props.name
sectext = '\t' + _('Filename: %s') % GObject.markup_escape_text(
file_name)
sectext = '\t' + _('Filename: %s') % GLib.markup_escape_text(file_name)
sectext += '\n\t' + _('Size: %s') % \
helpers.convert_bytes(file_props.size)
if file_props.type_ == 'r':
@ -240,8 +239,7 @@ class FileTransfersWindow:
file_name = os.path.basename(file_props.file_name)
else:
file_name = file_props.name
sectext = '\t' + _('Filename: %s') % GObject.markup_escape_text(
file_name)
sectext = '\t' + _('Filename: %s') % GLib.markup_escape_text(file_name)
sectext += '\n\t' + _('Recipient: %s') % jid
if error_msg:
sectext += '\n\t' + _('Error message: %s') % error_msg
@ -384,7 +382,7 @@ class FileTransfersWindow:
if os.path.exists(file_path):
# check if we have write permissions
if not os.access(file_path, os.W_OK):
file_name = GObject.markup_escape_text(os.path.basename(
file_name = GLib.markup_escape_text(os.path.basename(
file_path))
dialogs.ErrorDialog(
_('Cannot overwrite existing file "%s"' % file_name),
@ -448,8 +446,8 @@ class FileTransfersWindow:
"""
if not file_props or not file_props.name:
return
sec_text = '\t' + _('File: %s') % GObject.markup_escape_text(
file_props.name)
sec_text = '\t' + _('File: %s') % GLib.markup_escape_text(
file_props.name)
if file_props.size:
sec_text += '\n\t' + _('Size: %s') % \
helpers.convert_bytes(file_props.size)
@ -495,7 +493,7 @@ class FileTransfersWindow:
text += helpers.convert_bytes(received_size) + '/' + \
helpers.convert_bytes(full_size)
self.model.set(iter_, C_PROGRESS, text)
self.model.set(iter_, C_PULSE, GObject.constants.G_MAXINT)
self.model.set(iter_, C_PULSE, GLib.MAXINT32)
elif status == 'computing':
self.model.set(iter_, C_PULSE, 1)
text = _('Checking file...') + '\n'
@ -506,11 +504,11 @@ class FileTransfersWindow:
self.model.set(iter_, C_PROGRESS, text)
def pulse():
p = self.model.get(iter_, C_PULSE)[0]
if p == GObject.constants.G_MAXINT:
if p == GLib.MAXINT32:
return False
self.model.set(iter_, C_PULSE, p + 1)
return True
GObject.timeout_add(100, pulse)
GLib.timeout_add(100, pulse)
elif status == 'hash_error':
text = _('File error') + '\n'
received_size = int(file_props.received_len)
@ -518,7 +516,7 @@ class FileTransfersWindow:
text += helpers.convert_bytes(received_size) + '/' + \
helpers.convert_bytes(full_size)
self.model.set(iter_, C_PROGRESS, text)
self.model.set(iter_, C_PULSE, GObject.constants.G_MAXINT)
self.model.set(iter_, C_PULSE, GLib.MAXINT32)
self.model.set(iter_, C_IMAGE, self.get_icon(status))
path = self.model.get_path(iter_)
self.select_func(path)
@ -738,7 +736,7 @@ class FileTransfersWindow:
file_name = os.path.split(file_props.file_name)[1]
else:
file_name = file_props.name
text_props = GObject.markup_escape_text(file_name) + '\n'
text_props = GLib.markup_escape_text(file_name) + '\n'
text_props += contact.get_shown_name()
self.model.set(iter_, 1, text_labels, 2, text_props, C_PULSE, -1, C_SID,
file_props.type_ + file_props.sid)
@ -774,7 +772,7 @@ class FileTransfersWindow:
if file_props is not None:
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
self.tooltip.id = row
self.tooltip.timeout = GObject.timeout_add(500,
self.tooltip.timeout = GLib.timeout_add(500,
self.show_tooltip, widget)
def on_transfers_list_leave_notify_event(self, widget=None, event=None):

View File

@ -34,7 +34,7 @@ from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import Pango
from gi.repository import GObject
from gi.repository import GLib
import gtkgui_helpers
import gui_menu_builder
import message_control
@ -606,7 +606,7 @@ class GroupchatControl(ChatControlBase):
self.resize_from_another_muc = False
# Reset the flag when everything will be redrawn, and in particular when
# on_treeview_size_allocate will have been called.
GObject.idle_add(reset_flag)
GLib.idle_add(reset_flag)
def on_hpaned_notify(self, pane, gparamspec):
"""
@ -795,7 +795,7 @@ class GroupchatControl(ChatControlBase):
if self.subject:
subject = helpers.reduce_chars_newlines(self.subject, max_lines=2)
subject = GObject.markup_escape_text(subject)
subject = GLib.markup_escape_text(subject)
subject_text = self.urlfinder.sub(self.make_href, subject)
subject_text = '<span %s>%s</span>' % (font_attrs_small,
subject_text)
@ -1348,7 +1348,7 @@ class GroupchatControl(ChatControlBase):
def got_connected(self):
# Make autorejoin stop.
if self.autorejoin:
GObject.source_remove(self.autorejoin)
GLib.source_remove(self.autorejoin)
self.autorejoin = None
gajim.gc_connected[self.account][self.room_jid] = True
@ -1415,8 +1415,7 @@ class GroupchatControl(ChatControlBase):
if self.autorejoin is None and gajim.account_is_connected(self.account):
ar_to = gajim.config.get('muc_autorejoin_timeout')
if ar_to:
self.autorejoin = GObject.timeout_add_seconds(ar_to,
self.rejoin)
self.autorejoin = GLib.timeout_add_seconds(ar_to, self.rejoin)
def rejoin(self):
if not self.autorejoin:
@ -1469,7 +1468,7 @@ class GroupchatControl(ChatControlBase):
else:
image = state_images[gc_contact.show]
name = GObject.markup_escape_text(gc_contact.name)
name = GLib.markup_escape_text(gc_contact.name)
# Strike name if blocked
fjid = self.room_jid + '/' + nick
@ -1488,7 +1487,7 @@ class GroupchatControl(ChatControlBase):
colorstring = "#%04x%04x%04x" % (color.red, color.green,
color.blue)
name += ('\n<span size="small" style="italic" foreground="%s">'
'%s</span>') % (colorstring, GObject.markup_escape_text(
'%s</span>') % (colorstring, GLib.markup_escape_text(
status))
if image.get_storage_type() == Gtk.ImageType.PIXBUF and \
@ -2671,7 +2670,7 @@ class GroupchatControl(ChatControlBase):
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
self.tooltip.id = row
nick = self.model[iter_][C_NICK]
self.tooltip.timeout = GObject.timeout_add(500,
self.tooltip.timeout = GLib.timeout_add(500,
self.show_tooltip, gajim.contacts.get_gc_contact(
account, self.room_jid, nick))

View File

@ -43,7 +43,7 @@ from subprocess import Popen
from gi.repository import Gtk
from gi.repository import GdkPixbuf
from gi.repository import GObject
from gi.repository import GLib
from common import i18n
from common import gajim
@ -229,8 +229,8 @@ 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_seconds(30,
self.unblock_signed_in_notifications, account)
GLib.timeout_add_seconds(30, self.unblock_signed_in_notifications,
account)
if account in self.show_vcard_when_connect and obj.show not in (
'offline', 'error'):
@ -370,8 +370,8 @@ class Interface:
# popup notifications for 30s
account_jid = account + '/' + jid
gajim.block_signed_in_notifications[account_jid] = True
GObject.timeout_add_seconds(30,
self.unblock_signed_in_notifications, account_jid)
GLib.timeout_add_seconds(30, self.unblock_signed_in_notifications,
account_jid)
highest = gajim.contacts.get_contact_with_highest_priority(account, jid)
is_highest = (highest and highest.resource == resource)
@ -974,13 +974,13 @@ class Interface:
# then the file is not corrupt
jid = file_props.sender
if file_props.hash_ == hash_:
GObject.idle_add(self.popup_ft_result, account, jid, file_props)
GObject.idle_add(ft_win.set_status, file_props, 'ok')
GLib.idle_add(self.popup_ft_result, account, jid, file_props)
GLib.idle_add(ft_win.set_status, file_props, 'ok')
else:
# wrong hash, we need to get the file again!
file_props.error = -10
GObject.idle_add(self.popup_ft_result, account, jid, file_props)
GObject.idle_add(ft_win.set_status, file_props, 'hash_error')
GLib.idle_add(self.popup_ft_result, account, jid, file_props)
GLib.idle_add(ft_win.set_status, file_props, 'hash_error')
# End jingle session
if session:
session.end_session()
@ -1119,7 +1119,7 @@ class Interface:
if gajim.config.get('ask_offline_status_on_connection'):
# Ask offline status in 1 minute so w'are sure we got all online
# presences
GObject.timeout_add_seconds(60, self.ask_offline_status, account)
GLib.timeout_add_seconds(60, self.ask_offline_status, account)
if state != sleepy.STATE_UNKNOWN and connected in (2, 3):
# we go online or free for chat, so we activate auto status
gajim.sleeper_state[account] = 'online'
@ -2189,7 +2189,7 @@ class Interface:
# For JEP-0172
if added_to_roster:
ctrl.user_nick = gajim.nicks[account]
GObject.idle_add(mw.window.grab_focus)
GLib.idle_add(mw.window.grab_focus)
return ctrl
@ -2405,9 +2405,9 @@ class Interface:
# Otherwise, an exception will stop our loop
timeout, in_seconds = gajim.idlequeue.PROCESS_TIMEOUT
if in_seconds:
GObject.timeout_add_seconds(timeout, self.process_connections)
GLib.timeout_add_seconds(timeout, self.process_connections)
else:
GObject.timeout_add(timeout, self.process_connections)
GLib.timeout_add(timeout, self.process_connections)
raise
return True # renew timeout (loop for ever)
@ -2620,18 +2620,18 @@ class Interface:
# get instances for windows/dialogs that will show_all()/hide()
self.instances['file_transfers'] = dialogs.FileTransfersWindow()
GObject.timeout_add(100, self.autoconnect)
GLib.timeout_add(100, self.autoconnect)
timeout, in_seconds = gajim.idlequeue.PROCESS_TIMEOUT
if in_seconds:
GObject.timeout_add_seconds(timeout, self.process_connections)
GLib.timeout_add_seconds(timeout, self.process_connections)
else:
GObject.timeout_add(timeout, self.process_connections)
GObject.timeout_add_seconds(gajim.config.get(
GLib.timeout_add(timeout, self.process_connections)
GLib.timeout_add_seconds(gajim.config.get(
'check_idle_every_foo_seconds'), self.read_sleepy)
# when using libasyncns we need to process resolver in regular intervals
if resolver.USE_LIBASYNCNS:
GObject.timeout_add(200, gajim.resolver.process)
GLib.timeout_add(200, gajim.resolver.process)
def remote_init():
if gajim.config.get('remote_control'):
@ -2640,7 +2640,7 @@ class Interface:
self.remote_ctrl = remote_control.Remote()
except Exception:
pass
GObject.timeout_add_seconds(5, remote_init)
GLib.timeout_add_seconds(5, remote_init)
def __init__(self):
gajim.interface = self
@ -2969,8 +2969,8 @@ class PassphraseRequest:
self.passphrase = passphrase
self.completed = True
if passphrase is not None:
GObject.timeout_add_seconds(30,
gajim.interface.forget_gpg_passphrase, self.keyid)
GLib.timeout_add_seconds(30, gajim.interface.forget_gpg_passphrase,
self.keyid)
for (account, cb) in self.callbacks:
self.run_callback(account, cb)
self.callbacks = []
@ -3021,7 +3021,7 @@ class ThreadInterface:
def thread_function(func, func_args, callback, callback_args):
output = func(*func_args)
if callback:
GObject.idle_add(callback, output, *callback_args)
GLib.idle_add(callback, output, *callback_args)
Thread(target=thread_function, args=(func, func_args, callback,
callback_args)).start()

View File

@ -36,6 +36,7 @@ modular.
"""
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Pango
from gi.repository import Gtk
from gi.repository import Gdk
@ -895,7 +896,7 @@ class HtmlTextView(Gtk.TextView):
window = widget.get_window(Gtk.TextWindowType.TEXT)
window.set_cursor(Gdk.Cursor.new(Gdk.CursorType.HAND2))
self._changed_cursor = True
self.tooltip.timeout = GObject.timeout_add(500, self.show_tooltip,
self.tooltip.timeout = GLib.timeout_add(500, self.show_tooltip,
anchor_tags[0])
elif self._changed_cursor and not anchor_tags:
window = widget.get_window(Gtk.TextWindowType.TEXT)
@ -1020,7 +1021,7 @@ if __name__ == '__main__':
# if not over_line:
# line_tooltip.hide_tooltip()
#if over_line and not line_tooltip.win:
# line_tooltip.timeout = GObject.timeout_add(500,
# line_tooltip.timeout = GLib.timeout_add(500,
# show_line_tooltip)
# htmlview.tv.get_window(Gtk.TextWindowType.TEXT).set_cursor(
# Gdk.Cursor.new(Gdk.CursorType.LEFT_PTR))

View File

@ -30,6 +30,7 @@
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
from gi.repository import GLib
import time
import common
@ -276,7 +277,7 @@ class MessageWindow(object):
scrolled = True
self.notebook.set_show_tabs(True)
if scrolled:
GObject.idle_add(conv_textview.scroll_to_end_iter)
GLib.idle_add(conv_textview.scroll_to_end_iter)
# Add notebook page and connect up to the tab's close button
xml = gtkgui_helpers.get_gtk_builder('message_window.ui', 'chat_tab_ebox')
@ -306,7 +307,7 @@ class MessageWindow(object):
# NOTE: we do not call set_control_active(True) since we don't know
# whether the tab is the active one.
self.show_title()
GObject.timeout_add(500, control.msg_textview.grab_focus)
GLib.timeout_add(500, control.msg_textview.grab_focus)
def on_tab_eventbox_button_press_event(self, widget, event, child):
if event.button == 3: # right click
@ -318,7 +319,7 @@ class MessageWindow(object):
self.remove_tab(ctrl, self.CLOSE_TAB_MIDDLE_CLICK)
else:
ctrl = self._widget_to_control(child)
GObject.idle_add(ctrl.msg_textview.grab_focus)
GLib.idle_add(ctrl.msg_textview.grab_focus)
def _on_message_textview_mykeypress_event(self, widget, event_keyval,
event_keymod):
@ -546,7 +547,7 @@ class MessageWindow(object):
ctrl_page = self.notebook.page_num(ctrl.widget)
self.notebook.set_current_page(ctrl_page)
self.window.present()
GObject.idle_add(ctrl.msg_textview.grab_focus)
GLib.idle_add(ctrl.msg_textview.grab_focus)
def remove_tab(self, ctrl, method, reason = None, force = False):
"""

View File

@ -26,6 +26,7 @@ from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import GObject
from gi.repository import GLib
import base64
import mimetypes
import os
@ -60,7 +61,7 @@ class ProfileWindow:
self.avatar_encoded = None
self.message_id = self.statusbar.push(self.context_id,
_('Retrieving profile...'))
self.update_progressbar_timeout_id = GObject.timeout_add(100,
self.update_progressbar_timeout_id = GLib.timeout_add(100,
self.update_progressbar)
self.remove_statusbar_timeout_id = None
@ -78,7 +79,7 @@ class ProfileWindow:
self.xml.get_object('ok_button').grab_focus()
def on_information_notebook_switch_page(self, widget, page, page_num):
GObject.idle_add(self.xml.get_object('ok_button').grab_focus)
GLib.idle_add(self.xml.get_object('ok_button').grab_focus)
def update_progressbar(self):
self.progressbar.pulse()
@ -90,9 +91,9 @@ class ProfileWindow:
def on_profile_window_destroy(self, widget):
if self.update_progressbar_timeout_id is not None:
GObject.source_remove(self.update_progressbar_timeout_id)
GLib.source_remove(self.update_progressbar_timeout_id)
if self.remove_statusbar_timeout_id is not None:
GObject.source_remove(self.remove_statusbar_timeout_id)
GLib.source_remove(self.remove_statusbar_timeout_id)
gajim.ged.remove_event_handler('vcard-published', ged.GUI1,
self._nec_vcard_published)
gajim.ged.remove_event_handler('vcard-not-published', ged.GUI1,
@ -237,7 +238,7 @@ class ProfileWindow:
pritext = _('Wrong date format')
dialogs.ErrorDialog(pritext, _('Format of the date must be '
'YYYY-MM-DD'))
GObject.idle_add(lambda: widget.grab_focus())
GLib.idle_add(lambda: widget.grab_focus())
return True
def set_value(self, entry_name, value):
@ -294,9 +295,9 @@ 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_seconds(3,
self.remove_statusbar, self.message_id)
GObject.source_remove(self.update_progressbar_timeout_id)
self.remove_statusbar_timeout_id = GLib.timeout_add_seconds(3,
self.remove_statusbar, self.message_id)
GLib.source_remove(self.update_progressbar_timeout_id)
self.progressbar.hide()
self.progressbar.set_fraction(0)
self.update_progressbar_timeout_id = None
@ -386,14 +387,14 @@ class ProfileWindow:
self.message_id = self.statusbar.push(self.context_id,
_('Sending profile...'))
self.progressbar.show()
self.update_progressbar_timeout_id = GObject.timeout_add(100,
self.update_progressbar)
self.update_progressbar_timeout_id = GLib.timeout_add(100,
self.update_progressbar)
def _nec_vcard_published(self, obj):
if obj.conn.name != self.account:
return
if self.update_progressbar_timeout_id is not None:
GObject.source_remove(self.update_progressbar_timeout_id)
GLib.source_remove(self.update_progressbar_timeout_id)
self.update_progressbar_timeout_id = None
self.window.destroy()
@ -404,10 +405,10 @@ 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_seconds(3,
self.remove_statusbar_timeout_id = GLib.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)
GLib.source_remove(self.update_progressbar_timeout_id)
self.progressbar.set_fraction(0)
self.update_progressbar_timeout_id = None
dialogs.InformationDialog(_('vCard publication failed'),

View File

@ -37,6 +37,7 @@ from gi.repository import Gdk
from gi.repository import GdkPixbuf
from gi.repository import Pango
from gi.repository import GObject
from gi.repository import GLib
import os
import sys
import time
@ -267,7 +268,7 @@ class RosterWindow:
it = self.model.append(None, [
gajim.interface.jabber_state_images['16'][show],
GObject.markup_escape_text(account), 'account', our_jid,
GLib.markup_escape_text(account), 'account', our_jid,
account, None, None, None, None, None, tls_pixbuf] +
[None] * self.nb_ext_renderers)
self._iters[account]['account'] = it
@ -327,7 +328,7 @@ class RosterWindow:
iter_parent = self._get_account_iter(account, self.model)
iter_group = self.model.append(iter_parent,
[gajim.interface.jabber_state_images['16']['closed'],
GObject.markup_escape_text(group), 'group', group, account, None,
GLib.markup_escape_text(group), 'group', group, account, None,
None, None, None, None, None] + [None] * self.nb_ext_renderers)
self.draw_group(group, account)
self._iters[account_group]['groups'][group] = iter_group
@ -1103,7 +1104,7 @@ class RosterWindow:
return
self.accounts_to_draw.append(account)
if len(self.accounts_to_draw) == 1:
GObject.timeout_add(200, self._really_draw_accounts)
GLib.timeout_add(200, self._really_draw_accounts)
def _really_draw_group(self, group, account):
child_iter = self._get_group_iter(group, account, model=self.model)
@ -1115,7 +1116,7 @@ class RosterWindow:
accounts = []
else:
accounts = [account]
text = GObject.markup_escape_text(group)
text = GLib.markup_escape_text(group)
if helpers.group_is_blocked(account, group):
text = '<span strikethrough="true">%s</span>' % text
if gajim.config.get('show_contacts_number'):
@ -1139,7 +1140,7 @@ class RosterWindow:
return
self.groups_to_draw[ag] = {'group': group, 'account': account}
if len(self.groups_to_draw) == 1:
GObject.timeout_add(200, self._really_draw_groups)
GLib.timeout_add(200, self._really_draw_groups)
def draw_parent_contact(self, jid, account):
child_iters = self._get_contact_iter(jid, account, model=self.model)
@ -1173,7 +1174,7 @@ class RosterWindow:
if not child_iters:
return False
name = GObject.markup_escape_text(contact.get_shown_name())
name = GLib.markup_escape_text(contact.get_shown_name())
# gets number of unread gc marked messages
if jid in gajim.interface.minimized_controls[account] and \
@ -1226,7 +1227,7 @@ class RosterWindow:
color.blue)
name += '\n<span size="small" style="italic" ' \
'foreground="%s">%s</span>' % (colorstring,
GObject.markup_escape_text(status))
GLib.markup_escape_text(status))
icon_name = helpers.get_icon_name_to_show(contact, account)
# look if another resource has awaiting events
@ -1419,7 +1420,7 @@ class RosterWindow:
yield False
task = _draw_all_contacts(jids, account)
GObject.idle_add(next, task)
GLib.idle_add(next, task)
def _before_fill(self):
self.tree.freeze_child_notify()
@ -2586,11 +2587,11 @@ class RosterWindow:
if jid in jid_list or jid == gajim.get_jid_from_account(account):
if not gajim.jid_is_transport(jid) and len(obj.contact_list) == 1:
if obj.old_show == 0 and obj.new_show > 1:
GObject.timeout_add_seconds(5, self.remove_newly_added, jid,
GLib.timeout_add_seconds(5, self.remove_newly_added, jid,
account)
elif obj.old_show > 1 and obj.new_show == 0 and \
obj.conn.connected > 1:
GObject.timeout_add_seconds(5, self.remove_to_be_removed,
GLib.timeout_add_seconds(5, self.remove_to_be_removed,
jid, account)
if obj.need_redraw:
@ -2613,7 +2614,7 @@ class RosterWindow:
if obj.popup:
ctrl = gajim.interface.msg_win_mgr.search_control(jid, account)
if ctrl:
GObject.idle_add(ctrl.parent_win.set_active_tab, ctrl)
GLib.idle_add(ctrl.parent_win.set_active_tab, ctrl)
else:
ctrl = gajim.interface.new_chat(obj.contact, account)
if len(gajim.events.get_events(account, obj.jid)):
@ -2655,7 +2656,7 @@ class RosterWindow:
account)
gajim.config.set_per('accounts', account,
'opened_chat_controls', '')
GObject.idle_add(self.refilter_shown_roster_items)
GLib.idle_add(self.refilter_shown_roster_items)
def _nec_anonymous_auth(self, obj):
"""
@ -2885,7 +2886,7 @@ class RosterWindow:
# no connected contacts, show the ofline one
connected_contacts = contacts
self.tooltip.account = account
self.tooltip.timeout = GObject.timeout_add(500,
self.tooltip.timeout = GLib.timeout_add(500,
self.show_tooltip, connected_contacts)
elif model[titer][C_TYPE] == 'groupchat':
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
@ -2894,7 +2895,7 @@ class RosterWindow:
self.tooltip.id = row
contact = gajim.contacts.get_contacts(account, jid)
self.tooltip.account = account
self.tooltip.timeout = GObject.timeout_add(500,
self.tooltip.timeout = GLib.timeout_add(500,
self.show_tooltip, contact)
elif model[titer][C_TYPE] == 'account':
# we're on an account entry in the roster
@ -2903,7 +2904,7 @@ class RosterWindow:
if account == 'all':
self.tooltip.id = row
self.tooltip.account = None
self.tooltip.timeout = GObject.timeout_add(500,
self.tooltip.timeout = GLib.timeout_add(500,
self.show_tooltip, [])
return
jid = gajim.get_jid_from_account(account)
@ -2957,7 +2958,7 @@ class RosterWindow:
contacts.append(contact)
self.tooltip.id = row
self.tooltip.account = None
self.tooltip.timeout = GObject.timeout_add(500,
self.tooltip.timeout = GLib.timeout_add(500,
self.show_tooltip, contacts)
def on_agent_logging(self, widget, jid, state, account):
@ -3108,7 +3109,7 @@ class RosterWindow:
old_text = jid
title = _('Rename Group')
message = _('Enter a new name for group %s') % \
GObject.markup_escape_text(jid)
GLib.markup_escape_text(jid)
def on_renamed(new_text, account, row_type, jid, old_text):
if 'rename' in gajim.interface.instances:
@ -4270,7 +4271,7 @@ class RosterWindow:
if self.filtering:
# Prevent endless loops
jid = model[titer][C_JID]
GObject.idle_add(self.draw_contact, jid, account)
GLib.idle_add(self.draw_contact, jid, account)
elif type_ == 'group':
group = model[titer][C_JID]
self._adjust_group_expand_collapse_state(group, account)
@ -4292,7 +4293,7 @@ class RosterWindow:
# if len(self._last_selected_contact):
# # update unselected rows
# for (jid, account) in self._last_selected_contact:
# GObject.idle_add(self.draw_contact, jid,
# GLib.idle_add(self.draw_contact, jid,
# account)
# self._last_selected_contact = []
# if len(list_of_paths) == 0:
@ -4305,7 +4306,7 @@ class RosterWindow:
# jid = row[C_JID]
# account = row[C_ACCOUNT]
# self._last_selected_contact.append((jid, account))
# GObject.idle_add(self.draw_contact, jid, account, True)
# GLib.idle_add(self.draw_contact, jid, account, True)
def on_service_disco_menuitem_activate(self, widget, account):
server_jid = gajim.config.get_per('accounts', account, 'hostname')
@ -6651,7 +6652,7 @@ class RosterWindow:
config.AccountCreationWizardWindow()
# Open wizard only after roster is created, so we can make it
# transient for the roster window
GObject.idle_add(_open_wizard)
GLib.idle_add(_open_wizard)
if not gajim.ZEROCONF_ACC_NAME in gajim.config.get_per('accounts'):
# Create zeroconf in config file
from common.zeroconf import connection_zeroconf

View File

@ -19,7 +19,7 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gtk
from common import gajim
@ -52,7 +52,7 @@ class SearchWindow:
self.xml.connect_signals(self)
self.window.show_all()
self.request_form()
self.pulse_id = GObject.timeout_add(80, self.pulse_callback)
self.pulse_id = GLib.timeout_add(80, self.pulse_callback)
self.is_form = None
@ -77,7 +77,7 @@ class SearchWindow:
def on_search_window_destroy(self, widget):
if self.pulse_id:
GObject.source_remove(self.pulse_id)
GLib.source_remove(self.pulse_id)
del gajim.interface.instances[self.account]['search'][self.jid]
gajim.ged.remove_event_handler('search-form-received', ged.GUI1,
self._nec_search_form_received)
@ -104,7 +104,7 @@ class SearchWindow:
self.progressbar.show()
self.label.set_text(_('Waiting for results'))
self.label.show()
self.pulse_id = GObject.timeout_add(80, self.pulse_callback)
self.pulse_id = GLib.timeout_add(80, self.pulse_callback)
self.search_button.hide()
def on_add_contact_button_clicked(self, widget):
@ -128,7 +128,7 @@ class SearchWindow:
def _nec_search_form_received(self, obj):
if self.pulse_id:
GObject.source_remove(self.pulse_id)
GLib.source_remove(self.pulse_id)
self.progressbar.hide()
self.label.hide()
@ -168,7 +168,7 @@ class SearchWindow:
def _nec_search_result_received(self, obj):
if self.pulse_id:
GObject.source_remove(self.pulse_id)
GLib.source_remove(self.pulse_id)
self.progressbar.hide()
self.label.hide()

View File

@ -30,7 +30,7 @@
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GObject
from gi.repository import GLib
import os
import time
import locale
@ -155,7 +155,7 @@ class BaseTooltip:
def hide_tooltip(self):
if self.timeout > 0:
GObject.source_remove(self.timeout)
GLib.source_remove(self.timeout)
self.timeout = 0
if self.win:
self.win.destroy()
@ -241,8 +241,8 @@ class StatusTable:
if status != '':
# reduce to 100 chars, 1 line
status = helpers.reduce_chars_newlines(status, 100, 1)
str_status = GObject.markup_escape_text(str_status)
status = GObject.markup_escape_text(status)
str_status = GLib.markup_escape_text(str_status)
status = GLib.markup_escape_text(status)
str_status += ' - <i>' + status + '</i>'
return str_status
@ -299,7 +299,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
for acct in accounts:
message = acct['message']
message = helpers.reduce_chars_newlines(message, 100, 1)
message = GObject.markup_escape_text(message)
message = GLib.markup_escape_text(message)
if acct['name'] in gajim.con_types and \
gajim.con_types[acct['name']] in ('tls', 'ssl'):
show_lock = True
@ -307,12 +307,12 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
show_lock = False
if message:
self.add_status_row(file_path, acct['show'],
GObject.markup_escape_text(acct['name']) + \
' - ' + message, show_lock=show_lock, indent=False)
GLib.markup_escape_text(acct['name']) + ' - ' + message,
show_lock=show_lock, indent=False)
else:
self.add_status_row(file_path, acct['show'],
GObject.markup_escape_text(acct['name'])
, show_lock=show_lock, indent=False)
GLib.markup_escape_text(acct['name']), show_lock=show_lock,
indent=False)
for line in acct['event_lines']:
self.add_text_row(' ' + line, 1)
@ -354,9 +354,8 @@ class GCTooltip(BaseTooltip):
vcard_current_row = 1
properties = []
nick_markup = '<b>' + \
GObject.markup_escape_text(contact.get_shown_name()) \
+ '</b>'
nick_markup = '<b>' + GLib.markup_escape_text(contact.get_shown_name())\
+ '</b>'
properties.append((nick_markup, None))
if contact.status: # status message
@ -364,8 +363,7 @@ class GCTooltip(BaseTooltip):
if status != '':
# escape markup entities
status = helpers.reduce_chars_newlines(status, 300, 5)
status = '<i>' +\
GObject.markup_escape_text(status) + '</i>'
status = '<i>' + GLib.markup_escape_text(status) + '</i>'
properties.append((status, None))
show = helpers.get_uf_show(contact.show)
@ -376,8 +374,8 @@ class GCTooltip(BaseTooltip):
properties.append((_('Jabber ID: '), "<b>%s</b>" % contact.jid))
if hasattr(contact, 'resource') and contact.resource.strip():
properties.append((_('Resource: '),
GObject.markup_escape_text(contact.resource)))
properties.append((_('Resource: '), GLib.markup_escape_text(
contact.resource)))
if contact.affiliation != 'none':
uf_affiliation = helpers.get_uf_affiliation(contact.affiliation)
@ -480,13 +478,12 @@ class RosterTooltip(NotificationAreaTooltip):
vcard_current_row = 1
properties = []
name_markup = '<span weight="bold">' + \
GObject.markup_escape_text(prim_contact.get_shown_name())\
+ '</span>'
name_markup = '<span weight="bold">' + GLib.markup_escape_text(
prim_contact.get_shown_name()) + '</span>'
if gajim.config.get('mergeaccounts'):
name_markup += " <span foreground='%s'>(%s)</span>" % (
gajim.config.get('tooltip_account_name_color'),
GObject.markup_escape_text(prim_contact.account.name))
GLib.markup_escape_text(prim_contact.account.name))
if self.account and helpers.jid_is_blocked(self.account,
prim_contact.jid):
@ -586,7 +583,7 @@ class RosterTooltip(NotificationAreaTooltip):
# status is wrapped
status = helpers.reduce_chars_newlines(status, 300, 5)
# escape markup entities.
status = GObject.markup_escape_text(status)
status = GLib.markup_escape_text(status)
properties.append(('<i>%s</i>' % status, None))
properties.append((show, None))
@ -596,15 +593,14 @@ class RosterTooltip(NotificationAreaTooltip):
# contact has only one ressource
if num_resources == 1 and contact.resource:
properties.append((_('Resource: '),
GObject.markup_escape_text(contact.resource) +\
' (' + str(contact.priority) + ')'))
properties.append((_('Resource: '), GLib.markup_escape_text(
contact.resource) + ' (' + str(contact.priority) + ')'))
if self.account and prim_contact.sub and prim_contact.sub != 'both' and\
prim_contact.jid not in gajim.gc_connected[self.account]:
# ('both' is the normal sub so we don't show it)
properties.append(( _('Subscription: '),
GObject.markup_escape_text(helpers.get_uf_sub(prim_contact.sub))))
properties.append(( _('Subscription: '), GLib.markup_escape_text(
helpers.get_uf_sub(prim_contact.sub))))
if prim_contact.keyID:
keyID = None
@ -613,8 +609,8 @@ class RosterTooltip(NotificationAreaTooltip):
elif len(prim_contact.keyID) == 16:
keyID = prim_contact.keyID[8:]
if keyID:
properties.append((_('OpenPGP: '),
GObject.markup_escape_text(keyID)))
properties.append((_('OpenPGP: '), GLib.markup_escape_text(
keyID)))
if contact.last_activity_time:
last_active = datetime(*contact.last_activity_time[:6])
@ -730,8 +726,7 @@ class FileTransfersTooltip(BaseTooltip):
file_name = os.path.split(file_props.file_name)[1]
else:
file_name = file_props.name
properties.append((_('Name: '),
GObject.markup_escape_text(file_name)))
properties.append((_('Name: '), GLib.markup_escape_text(file_name)))
if file_props.type_ == 'r':
type_ = _('Download')
actor = _('Sender: ')
@ -747,7 +742,7 @@ class FileTransfersTooltip(BaseTooltip):
else:
name = receiver.split('/')[0]
properties.append((_('Type: '), type_))
properties.append((actor, GObject.markup_escape_text(name)))
properties.append((actor, GLib.markup_escape_text(name)))
transfered_len = file_props.received_len
if not transfered_len:
@ -775,8 +770,8 @@ class FileTransfersTooltip(BaseTooltip):
status = _('Not started')
properties.append((_('Status: '), status))
file_desc = file_props.desc
properties.append((_('Description: '), GObject.markup_escape_text(
file_desc)))
properties.append((_('Description: '), GLib.markup_escape_text(
file_desc)))
while properties:
property_ = properties.pop(0)
current_row += 1