Python gi.repository.GLib 模块,source_remove() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用gi.repository.GLib.source_remove()

项目:sc-controller    作者:kozec    | 项目源码 | 文件源码
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)
项目:python-gui    作者:neovim    | 项目源码 | 文件源码
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)
项目:backlight-indicator    作者:atareao    | 项目源码 | 文件源码
def on_working_menu_item(self, widget):
        if self.wid == 0:
            self.working_menu_item.set_label(_('Stop'))
            self.indicator.set_icon(comun.STATUS_ICON[self.theme][0])
            if self.show_notifications:
                self.notification.update('Backlight-Indicator',
                                         _('Session starts'),
                                         comun.STATUS_ICON[self.theme][0])
            self.do_the_work()
            self.wid = GLib.timeout_add_seconds(self.sample_time * 60,
                                                self.do_the_work)
        else:
            self.working_menu_item.set_label(_('Start'))
            self.indicator.set_icon(comun.STATUS_ICON[self.theme][1])
            if self.show_notifications:
                self.notification.update('Backlight-Indicator',
                                         _('Session stops'),
                                         comun.STATUS_ICON[self.theme][1])
            GLib.source_remove(self.wid)
            self.wid = 0
        if self.show_notifications:
            self.notification.show()