Python gi.repository.GLib.source_remove() Examples
The following are 30
code examples of gi.repository.GLib.source_remove().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.GLib
, or try the search function
.
Example #1
Source File: eventhandler.py From vimiv with MIT License | 6 votes |
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
Example #2
Source File: preview_web_view.py From Apostrophe with GNU General Public License v3.0 | 6 votes |
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)
Example #3
Source File: timermanager.py From syncthing-gtk with GNU General Public License v2.0 | 6 votes |
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)
Example #4
Source File: glib_events.py From pychess with GNU General Public License v3.0 | 6 votes |
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)
Example #5
Source File: gtk_ui.py From python-gui with Apache License 2.0 | 6 votes |
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)
Example #6
Source File: eventhandler.py From vimiv with MIT License | 6 votes |
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()
Example #7
Source File: application.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
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
Example #8
Source File: remote_assistance.py From epoptes with GNU General Public License v3.0 | 6 votes |
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)
Example #9
Source File: QuiltView.py From addons-source with GNU General Public License v2.0 | 6 votes |
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)
Example #10
Source File: pomodoro_indicator.py From pomodoro-indicator with GNU General Public License v3.0 | 5 votes |
def start_working_process(self, interval, countdown): if self.pw > 0: GLib.source_remove(self.pw) print('interval', interval) print('pomodoros', self.pomodoros) self.pw = GLib.timeout_add_seconds(interval, countdown)
Example #11
Source File: cpug.py From cpu-g with GNU General Public License v3.0 | 5 votes |
def stop_ram_updater(self): if self.ram_updater > 0: GLib.source_remove(self.ram_updater) self.ram_updater = 0
Example #12
Source File: cpug.py From cpu-g with GNU General Public License v3.0 | 5 votes |
def start_ram_updater(self): if self.ram_updater > 0: GLib.source_remove(self.ram_updater) self.ram_update() self.ram_updater = GLib.timeout_add_seconds(1, self.ram_update)
Example #13
Source File: backend_gtk3.py From ImageFusion with MIT License | 5 votes |
def destroy(self): #Gtk.DrawingArea.destroy(self) self.close_event() GLib.source_remove(self._idle_event_id) if self._idle_draw_id != 0: GLib.source_remove(self._idle_draw_id)
Example #14
Source File: backend_gtk3.py From ImageFusion with MIT License | 5 votes |
def _timer_stop(self): if self._timer is not None: GLib.source_remove(self._timer) self._timer = None
Example #15
Source File: blink1.py From king-phisher-plugins with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _blink1_set_color(self, color): try: self._blink1.fade_to_color(375, color) except usb.core.USBError as error: self.logger.warning("encountered a USB error '{0}' while setting the color of the blink(1)".format(error.strerror)) return if color != 'black': if self._gsrc_id is not None: GLib.source_remove(self._gsrc_id) self._gsrc_id = GLib.timeout_add(1625, self._blink1_off) self._color = color
Example #16
Source File: sftp_utilities.py From king-phisher-plugins with BSD 3-Clause "New" or "Revised" License | 5 votes |
def changed(self, *args): with self._lock: if self._event_id is not None: GLib.source_remove(self._event_id) self._event_id = GLib.timeout_add(self.delay, self._changed, args)
Example #17
Source File: cpug.py From cpu-g with GNU General Public License v3.0 | 5 votes |
def start_battery_updater(self): if self.battery_updater > 0: GLib.source_remove(self.battery_updater) if self.exists_battery is True: self.get_battery_duration() self.battery_updater = GLib.timeout_add_seconds( 300, self.get_battery_duration)
Example #18
Source File: pomodoro_indicator.py From pomodoro-indicator with GNU General Public License v3.0 | 5 votes |
def stop_working_process(self): if self.pw > 0: GLib.source_remove(self.pw) self.pw = 0
Example #19
Source File: timermanager.py From syncthing-gtk with GNU General Public License v2.0 | 5 votes |
def cancel_all(self): """ Cancels all active timers """ for x in self._timers: GLib.source_remove(self._timers[x]) self._timers = {}
Example #20
Source File: cpug.py From cpu-g with GNU General Public License v3.0 | 5 votes |
def start_uptime_update(self): if self.uptime_updater > 0: GLib.source_remove(self.uptime_updater) self.uptime_update() self.uptime_updater = GLib.timeout_add_seconds(60, self.uptime_update)
Example #21
Source File: cpug.py From cpu-g with GNU General Public License v3.0 | 5 votes |
def stop_uptime_updater(self): if self.uptime_updater > 0: GLib.source_remove(self.uptime_updater) self.uptime_updater = 0
Example #22
Source File: glib_events.py From pychess with GNU General Public License v3.0 | 5 votes |
def remove_child_handler(self, pid): try: source, callback, args, handle = self._sources.pop(pid) assert self._handles.pop(handle) == pid except KeyError: return False self._close_process_handle(handle) GLib.source_remove(source) return True
Example #23
Source File: editor.py From runsqlrun with MIT License | 5 votes |
def on_buffer_changed_delayed(self, buf): if self._parse_timeout is not None: GLib.source_remove(self._parse_timeout) self._parse_timeout = GLib.timeout_add( 200, self.on_buffer_changed, buf)
Example #24
Source File: exchange.py From coinprice-indicator with MIT License | 5 votes |
def stop(self): if self.timeout_id: GLib.source_remove(self.timeout_id) self.started = False self.indicator.alarm.deactivate() self.error.reset() return self ## # Restarts the exchange. This is necessary for restoring normal frequency as # False must be returned for the restart operation to be done only once #
Example #25
Source File: xdot.py From bokken with GNU General Public License v2.0 | 5 votes |
def stop(self): self.dot_widget.animation = NoAnimation(self.dot_widget) if self.timeout_id is not None: GLib.source_remove(self.timeout_id) self.timeout_id = None
Example #26
Source File: myweatherindicator.py From my-weather-indicator with MIT License | 5 votes |
def start_widgets_updater(self): if self.widgets_updater > 0: GLib.source_remove(self.widgets_updater) self.update_widgets() self.widgets_updater = GLib.timeout_add(500, self.update_widgets)
Example #27
Source File: myweatherindicator.py From my-weather-indicator with MIT License | 5 votes |
def stop_widgets_updater(self): if self.widgets_updater > 0: GLib.source_remove(self.widgets_updater) self.widgets_updater = 0
Example #28
Source File: myweatherindicator.py From my-weather-indicator with MIT License | 5 votes |
def start_weather_updater(self): if self.weather_updater > 0: GLib.source_remove(self.weather_updater) self.update_weather() self.weather_updater = GLib.timeout_add_seconds(self.refresh * 3600, self.update_weather)
Example #29
Source File: myweatherindicator.py From my-weather-indicator with MIT License | 5 votes |
def stop_weather_updater(self): if self.weather_updater > 0: GLib.source_remove(self.weather_updater) self.weather_updater = 0
Example #30
Source File: myweatherindicator.py From my-weather-indicator with MIT License | 5 votes |
def start_looking_for_internet(self): if self.internet_updater > 0: GLib.source_remove(self.internet_updater) if self.looking_for_internet(): self.internet_updater = GLib.timeout_add_seconds( TIME_TO_CHECK, self.looking_for_internet)