本文整理汇总了Python中gi.repository.GLib.source_remove方法的典型用法代码示例。如果您正苦于以下问题:Python GLib.source_remove方法的具体用法?Python GLib.source_remove怎么用?Python GLib.source_remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.GLib
的用法示例。
在下文中一共展示了GLib.source_remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do_server_disconnected
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def do_server_disconnected(self):
"""
Clean up the connections to the server and disconnect. This logs out of
the RPC, closes the server event socket, and stops the SSH forwarder.
"""
if self.rpc is not None:
if self.server_events is not None:
self.server_events.reconnect = False
GLib.source_remove(self._rpc_ping_event)
try:
self.rpc.async_call('logout')
except advancedhttpserver.RPCError as error:
self.logger.warning('failed to logout, rpc error: ' + error.message)
else:
if self.server_events is not None:
self.server_events.shutdown()
self.server_events = None
self.rpc.shutdown()
self.rpc = None
if self._ssh_forwarder:
self._ssh_forwarder.stop()
self._ssh_forwarder = None
return
示例2: _gtk_configure
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def _gtk_configure(self, widget, event):
def resize(*args):
self._resize_timer_id = None
width, height = self._window.get_size()
columns = width // self._cell_pixel_width
rows = height // self._cell_pixel_height
if self._screen.columns == columns and self._screen.rows == rows:
return
self._bridge.resize(columns, rows)
if not self._screen:
return
if event.width == self._pixel_width and \
event.height == self._pixel_height:
return
if self._resize_timer_id is not None:
GLib.source_remove(self._resize_timer_id)
self._resize_timer_id = GLib.timeout_add(250, resize)
示例3: connect
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def connect(self):
"""Handle btn_action clicked when it's in the Connect state."""
self.host = self.ent_host.get_text().strip()
pid = os.getpid()
share_terminal = self.cmb_method.get_active() != 0
if share_terminal:
cmd = ['xterm', '-e', os.path.dirname(__file__) +
'/share-terminal', self.host]
subprocess.Popen(cmd)
self.on_btn_close_clicked(None)
return
cmd = ['x11vnc', '-q', '-nopw', '-connect_or_exit', self.host,
'-afteraccept', 'kill -USR1 {}'.format(pid)]
self.proc = subprocess.Popen(cmd)
# Set the status as "Connecting"
if self.retry_timeout_id:
GLib.source_remove(self.retry_timeout_id)
self.retry_timeout_id = None
self.set_state('connecting')
# Start polling the process every 1 second to see if it's still alive
GLib.timeout_add(1000, self.poll_process)
示例4: show_family_name
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def show_family_name(self, handle, event):
"""
Popup menu for node (family).
"""
if handle:
family = self.dbstate.db.get_family_from_handle(handle)
else:
return False
if family:
if not self.timeout:
self.save_tooltip = handle
self.scrolledwindow.set_property("has-tooltip", True)
tooltip = self.get_family_name(handle)
self.scrolledwindow.set_tooltip_text(tooltip)
self.timeout = GLib.timeout_add(3*1000, self.remove_tooltip)
elif handle != self.save_tooltip:
self.save_tooltip = handle
GLib.source_remove(self.timeout)
tooltip = self.get_family_name(handle)
self.scrolledwindow.set_tooltip_text(tooltip)
self.timeout = GLib.timeout_add(3*1000, self.remove_tooltip)
示例5: on_touch
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def on_touch(self, widget, event):
"""Clear mouse connection when touching screen.
This stops calling the ButtonX bindings when using the touch screen.
Reasoning: We do not want to e.g. move to the next image when trying to
zoom in.
"""
try:
self._app["window"].disconnect_by_func(self.on_click)
# Was already disconnected
except TypeError:
pass
if self._timer_id_touch:
GLib.source_remove(self._timer_id_touch)
self._timer_id_touch = GLib.timeout_add(5, self._reconnect_click)
return True
示例6: num_append
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def num_append(self, num, remove_by_timeout=True):
"""Add a new char to num_str.
Args:
num: The number to append to the string.
remove_by_timeout: If True, add a timeout to clear the num_str.
"""
# Remove old timers if we have new numbers
if self._timer_id:
GLib.source_remove(self._timer_id)
self._timer_id = GLib.timeout_add_seconds(1, self.num_clear)
self._num_str += num
self._convert_trailing_zeros()
# Write number to log file in debug mode
if self._app.debug:
self._app["log"].write_message("number", num + "->" + self._num_str)
self._app["statusbar"].update_info()
示例7: __callback__
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def __callback__(self, handle, status):
try:
pid = self._handles.pop(handle)
source, callback, args, handle = self._sources.pop(pid)
except KeyError:
return
self._close_process_handle(handle)
GLib.source_remove(source)
if hasattr(os, "WIFSIGNALED") and os.WIFSIGNALED(status):
returncode = -os.WTERMSIG(status)
elif hasattr(os, "WIFEXITED") and os.WIFEXITED(status):
returncode = os.WEXITSTATUS(status)
# FIXME: Hack for adjusting invalid status returned by GLIB
# Looks like there is a bug in glib or in pygobject
if returncode > 128:
returncode = 128 - returncode
else:
returncode = status
callback(pid, returncode, *args)
示例8: timer
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def timer(self, name, delay, callback, *data, **kwdata):
"""
Runs callback after specified number of seconds. Uses
GLib.timeout_add_seconds with small wrapping to allow named
timers to be canceled by reset() call
"""
method = GLib.timeout_add_seconds
if delay < 1 and delay > 0:
method = GLib.timeout_add
delay = delay * 1000.0
if name is None:
# No wrapping is needed, call GLib directly
method(delay, callback, *data, **kwdata)
else:
if name in self._timers:
# Cancel old timer
GLib.source_remove(self._timers[name])
# Create new one
self._timers[name] = method(delay, self._callback, name, callback, *data, **kwdata)
示例9: state_loop
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def state_loop(self, scroll_scale=None, delay=16): # 16ms ~ 60hz
# Remove any pending callbacks
if self.timeout_id:
GLib.source_remove(self.timeout_id)
self.timeout_id = None
# Set scroll scale if specified, and the state is not dirty
if not self.state_discard_read and scroll_scale not in (None, self.scroll_scale):
self.scroll_scale = scroll_scale
if self.scroll_scale != -1:
self.emit("scroll-scale-changed", self.scroll_scale)
self.state_discard_read = False
# Handle the current state
if not self.state_loaded or self.state_load_failed or self.state_waiting:
return
elif self.state_dirty or delay == 0:
self.sync_scroll_scale(self.scroll_scale, self.state_dirty)
self.state_dirty = False
else:
self.timeout_id = GLib.timeout_add(delay, self.state_loop, None, 0)
示例10: stop
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def stop(self):
GLib.source_remove(self.watcher)
if is_unix_socket(self.server_socket):
unix_socket_path = self.server_socket.getsockname()
else:
unix_socket_path = None
self.server_socket.shutdown(socket.SHUT_RDWR)
self.server_socket.close()
# clean up the socket file
if unix_socket_path is not None:
os.unlink(unix_socket_path)
示例11: disable_timeout
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def disable_timeout(self):
"""Deactivate timeout mechanism."""
if self.timeout_id is None:
return
GLib.source_remove(self.timeout_id)
self.timeout_id = None
示例12: disable_recv
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def disable_recv(self):
if self.recv_id is None:
return
GLib.source_remove(self.recv_id)
self.recv_id = None
示例13: disable_send
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def disable_send(self):
if self.send_id is None:
return
GLib.source_remove(self.send_id)
self.send_id = None
示例14: _start_blinking
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def _start_blinking(self):
def blink(*args):
self._blink = not self._blink
self._screen_invalid()
self._blink_timer_id = GLib.timeout_add(500, blink)
if self._blink_timer_id:
GLib.source_remove(self._blink_timer_id)
self._blink = False
blink()
示例15: disconnect
# 需要导入模块: from gi.repository import GLib [as 别名]
# 或者: from gi.repository.GLib import source_remove [as 别名]
def disconnect(self):
"""Handle btn_action clicked when it's in the Disconnect state."""
self.manually_stopped = True
if self.retry_timeout_id is not None:
self.set_state('disconnected')
GLib.source_remove(self.retry_timeout_id)
self.retry_timeout_id = None
if self.proc:
self.proc.kill()
self.btn_action.set_label(Gtk.STOCK_CONNECT)