def scroll_to_current(self):
        if self.scroll_event_id:
            GObject.source_remove(self.scroll_event_id)
            self.scroll_event_id = None

        try:
            current_widget = self.track_widgets[self.current_track]
        except IndexError:
            return False
        
        allocation = current_widget.get_allocation()
        
        time_step = 2 #msecs    
        
        if allocation.y > self.scroll_y:
            self.scrollto_direction = 1
        else:
            self.scrollto_direction = -1
        
        self.scrollto_step_size = 3

        self.scrollto_steps = abs((self.scroll_y - allocation.y) // self.scrollto_step_size)
        
        self.scroll_event_id = GObject.timeout_add(
            time_step, 
            self.do_scroll_to, 
        )
Пример #2
0
    def _button_clicked_cb(self, widget):
        self.set_enabled()

        if self.activity.player.is_playing():
            self.activity.player.pause()
            self.set_button_play()
            GObject.source_remove(self._scale_update_id)
            self._scale_update_id = -1
        else:
            if self.activity.player.error:
                self.set_disabled()
            else:
                if self.activity.player.player.props.current_uri is None:
                    # There is no stream selected to be played
                    # yet. Select the first one
                    available = self.activity.playlist_widget.\
                        _items[0]['available']
                    if available:
                        path = self.activity.playlist_widget._items[0]['path']
                        self.activity.playlist_widget.emit(
                            'play-index', 0, path)
                        self.activity.playlist_widget.set_current_playing(0)
                else:
                    self.activity.player.play()
                    self.activity._switch_canvas(True)
                    self._scale_update_id = GObject.timeout_add(
                        self.SCALE_UPDATE_INTERVAL, self.__update_scale_cb)
Пример #3
0
    def __key_release_event_cb(self, window, event):
        if self.__is_alt(event) and self._alt_timeout_sid:
            self._home_box.set_resume_mode(True)
            GObject.source_remove(self._alt_timeout_sid)
            self._alt_timeout_sid = None

        return False
Пример #4
0
 def disconnect_handlers(self):
     self.disconnect(self.sc_id)
     self.disconnect(self.sa_id)
     self.icon_theme.disconnect(self.tc_id)
     for id in self.resize_id, self.fade_id, self.anim_id:
         if id != 0:
             GObject.source_remove(id)
Пример #5
0
	def on_autorefresh_toggled(self, autorefresh):
		if self.autorefresh_id != 0:
			GObject.source_remove(self.autorefresh_id)
			self.autorefresh_id = 0
			
		if autorefresh.get_active():
			self.autorefresh_id = GObject.timeout_add(AUTOREFRESH_TIMEOUT, self.on_refresh_chart, True)
Пример #6
0
 def set_text(self, text):
     """Show `text` in the label."""
     if self._hide_id is not None:
         GObject.source_remove(self._hide_id)
     if not text: return self.hide()
     self._label.set_text(text)
     self.show()
Пример #7
0
    def _move(self, up=False):
        text = self._search_entry.get_text()
        if not text:
            return

        if up and self.__selected_search_result == 1:
            return False

        model = self._treeview.get_model()
        selection = self._treeview.get_selection()
        # disable flush timeout while searching
        if self._entry_flush_timeout:
            GObject.source_remove(self._entry_flush_timeout)
            self._entry_flush_timeout = 0
        # search
        start_count = self.__selected_search_result + (-1 if up else 1)
        start_iter = model.get_iter_first()
        found_iter = self.search_iter(selection, start_iter, text, 0,
                                      start_count)
        if found_iter:
            self.__selected_search_result += (-1 if up else 1)
            return True
        else:
            # Return to old iter
            self.search_iter(selection, start_iter, text, 0,
                             self.__selected_search_result)
            return False
        # renew flush timeout
        self._renew_flush_timeout()
        return
Пример #8
0
 def __notify_cb(self, device, name):
     """Defer response to notifications; they arrive in a burst,
     but without any indication that the burst is complete, so we
     use a timeout to respond."""
     if self._timeout_sid:
         GObject.source_remove(self._timeout_sid)
     self._timeout_sid = GObject.timeout_add(100, self.__timeout_cb)
Пример #9
0
    def stop(self):
        if self._play_hid is None:
            return False

        GObject.source_remove(self._play_hid)
        self._play_hid = None
        return True
Пример #10
0
    def cancel(self):
        """
        Cancel animation.
        """

        GObject.source_remove(self.timer_id)
        self.timer_id = None
Пример #11
0
 def get_key(self, line):
     logging.debug("got a key press")
     logging.debug("line: %s" % line)
     code, count, cmd, device = line.split(" ")[:4]
     timestamp = self.last_ts
     previous_key = self.last_key
     self.last_key = cmd
     self.last_ts = time.time()
     if count != "0":
         logging.debug('repeated keypress')
         return
     elif (self.last_ts - timestamp < self.delta_t and
           self.last_key == previous_key):
         logging.debug('ignoring keypress within min_delta')
         return
     else:
         try:
             logging.debug("remove main.timer")
             GObject.source_remove(self.main.timer)
         except:
             logging.debug("could not remove timer")
     logging.debug('Key press: %s', cmd)
     logging.debug("current frontend: %s", self.main.current)
     if self.main.current == 'vdr':
         self.vdr_key_action(code, count, cmd, device)
     elif self.main.current == 'kodi':
         self.kodi_key_action(code, count, cmd, device)
     else:
         logging.debug("keypress for other frontend")
         logging.debug("current frontend is: %s" % self.main.current)
         logging.debug("vdrStatus is: %s" % self.main.vdrStatus)
         logging.debug("frontend status is: %s" % self.main.status())
Пример #12
0
 def _entry_activated_cb(self, entry):
     if self._autosearch_timer:
         GObject.source_remove(self._autosearch_timer)
     new_query = entry.props.text
     if self._query != new_query:
         self._query = new_query
         self.emit('query-changed', self._query)
Пример #13
0
    def _quit_handler(self):
        """Start scanning for a new bus object."""

        if self.__watchdog_id is not None:
            GObject.source_remove(self.__watchdog_id)
            self.emit("quit", self.__profile, self.__pid)
        self._start_probing()
Пример #14
0
    def process(self):
        """
        Return elements to process

        At the moment, it returns just one element. In the future more
        elements may be better to return (to speed it up).

        If there is no request left, disable processing.
        """

        self._lock.acquire()
        if len(self._vip_queue) > 0:
            toreturn = [self._vip_queue.pop(0)]
        elif len(self._queue) > 0:
            toreturn = [self._queue.pop(0)]
        elif len(self._low_queue) > 0:
            toreturn = [self._low_queue.pop(0)]
        else:
            toreturn = []

        if len(self._queue) == 0 and len(self._vip_queue) == 0 and\
                                        len(self._low_queue) == 0 and\
                                        self._handler is not None:
            GObject.source_remove(self._handler)
            self._handler = None
        self._lock.release()
        return toreturn
Пример #15
0
 def stop(self):
     if self._pulse_hid is not None:
         GObject.source_remove(self._pulse_hid)
         self._pulse_hid = None
     self._icon.xo_color = self._icon.get_base_color()
     self._phase = 0
     self._icon.alpha = 1.0
Пример #16
0
    def finish_search(self, button, entry):
        self.show_find_button()
        GObject.source_remove(self.search_progress_id)
        self.search_progress_done(entry)
        self.search_progress_id = 0

        return False
Пример #17
0
    def search_entry_destroyed(self, widget):
        if self.finish_search_id != 0:
            GObject.source_remove(self.finish_search_id)
        if self.search_progress_id != 0:
            GObject.source_remove(self.search_progress_id)

        self.window = None
Пример #18
0
def on_entry_changed(widget, data):

    def _work():
        new_text = widget.get_text()
        (view, enquirer) = data

        with ExecutionTime("total time"):
            with ExecutionTime("enquire.set_query()"):
                enquirer.set_query(get_query_from_search_entry(new_text),
                                  limit=100*1000,
                                  nonapps_visible=NonAppVisibility.ALWAYS_VISIBLE)

            store = view.tree_view.get_model()
            with ExecutionTime("store.clear()"):
                store.clear()

            with ExecutionTime("store.set_documents()"):
                store.set_from_matches(enquirer.matches)

            with ExecutionTime("model settle (size=%s)" % len(store)):
                while Gtk.events_pending():
                    Gtk.main_iteration()
        return

    if widget.stamp: GObject.source_remove(widget.stamp)
    widget.stamp = GObject.timeout_add(250, _work)
Пример #19
0
 def _stop_progress(self):
     if self.timeout_source_id:
         GObject.source_remove(self.timeout_source_id)
         self.timeout_source_id = None
         self.progress.set_fraction(0.0)
         self.approot.jingles.nb_effects_box.remove(self.tabwidget)
         self.approot.effect_stopped(self.num)
Пример #20
0
Файл: view.py Проект: i5o/sugar
 def apply(self):
     if self._corner_delay_sid:
         GObject.source_remove(self._corner_delay_sid)
         self.__corner_delay_timeout_cb(self._corner_delay_slider)
     if self._edge_delay_sid:
         GObject.source_remove(self._edge_delay_sid)
         self.__edge_delay_timeout_cb(self._edge_delay_slider)
Пример #21
0
    def new_question(self):
        """returns:
               self.ERR_PICKY : if the question is not yet solved and the
                                   teacher is picky (== you have to solve the
                                   question before a new is asked).
               self.OK : if a new question was created.
               self.ERR_NO_ELEMS : if no elements are set to be practised.
        """
        if self.m_timeout_handle:
            GObject.source_remove(self.m_timeout_handle)
            self.m_timeout_handle = None

        if self.get_bool('config/picky_on_new_question') \
                 and self.q_status in [self.QSTATUS_NEW, self.QSTATUS_WRONG]:
            return self.ERR_PICKY

        self.q_status = self.QSTATUS_NO

        norest_v = []
        v = []
        for x in self.m_P.header.rhythm_elements:
            if not (const.RHYTHMS[x][0] == "r"
                    and self.get_bool("not_start_with_rest")):
                norest_v.append(x)
            v.append(x)
        if not v:
            return self.ERR_NO_ELEMS
        if not norest_v:
            return self.ERR_NO_ELEMS
        self.m_question = [random.choice(norest_v)]
        for x in range(1, self.get_int("num_beats")):
            self.m_question.append(random.choice(v))
        self.q_status = self.QSTATUS_NEW
        return self.OK
Пример #22
0
Файл: batch.py Проект: 4nto/bba
 def callback_parser (*args):
     with io.open(stdout) as out, io.open(stderr) as err:
         self.callback((args[1] >> 8) & 0xFF, out.read())
         self.__error_parser (err.read())
       
     if mseconds > 0:
         GObject.source_remove (timeout_id)          
Пример #23
0
    def cancel(self):

        if self.source_id is None:
            return

        GObject.source_remove(self.source_id)
        self.source_id = None
Пример #24
0
	def cancel_clicked(self,widget,temp=False):
		
		newtree=devede_other.create_tree(self,"wcancel_job_dialog",self.gladefile,False)
		window=newtree.get_object("wcancel_job_dialog")
		window.show()
		value=window.run()
		window.hide()
		window.destroy()
		if value!=-5: # no
			return True

		self.runner.cancel()
		self.runner.wait_end()
		GObject.source_remove(self.timer)
		self.window.hide()
		self.window.destroy()
		newtree=devede_other.create_tree(self,"waborted_dialog",self.gladefile,False)
		window=newtree.get_object("waborted_dialog")
		window.show()
		window.run()
		window.hide()
		window.destroy()
		window=None
		gc.collect()
		(self.main_window_callback)() # show the main window
		return True
	def show_pulse(self):
		if self.progressbar is not None:
			self.vbox.remove(self.progressbar)
			GObject.source_remove(self.timeout)
		self.vbox.pack_end(self.progressbar, expand = False, fill = True, padding = 0)
		self.timeout = GObject.timeout_add(100, self.start_pulse)
		self.start_pulse()
Пример #26
0
    def stop_animation(self, *args):
        self.animating = False
        if self.timer:
            GObject.source_remove(self.timer)
            self.timer = None

        self.drawing.queue_draw()
Пример #27
0
 def _search_entry_activated_cb(self, search_entry):
     if self._autosearch_timer:
         GObject.source_remove(self._autosearch_timer)
     new_query = self._build_query()
     if self._query != new_query:
         self._query = new_query
         self.emit('query-changed', self._query)
Пример #28
0
 def on_timeout (self):
     self.progressbar.pulse()
     if self.unoconv_thread.poll() is not None:
         GObject.source_remove(self.timeout_id)
         self.hide()
         Gtk.main_quit()
     return True
Пример #29
0
    def change_agent(self, agent_name):
        assert agent_name == "" or agent_name in os.listdir(self._app.agents_path)

        if self._pending_agent_change is not None:
            self._pending_agent_change = agent_name
            return

        if self._name == agent_name:
            return

        self._pending_agent_change = agent_name

        if self._name == "":
            self._do_change_agent()
            return

        self._pending_animations.clear()
        if "GoodBye" in self._prop["animations"]:
            self._pending_animations.append("GoodBye")
        elif "Hide" in self._prop["animations"]:
            self._pending_animations.append("Hide")

        if self._aplay is not None:
            self._aplay_exiting = True
        else:
            if len(self._pending_animations) == 0:
                if self._pa_timeout_cb is not None:
                    GObject.source_remove(self._pa_timeout_cb)
                    self._pa_timeout_cb = None
                self._do_change_agent()
            else:
                if self._pa_timeout_cb is None:
                    self._pa_timeout_cb = GObject.timeout_add(self._animation_spacing_time, self._pa_timeout_callback)
Пример #30
0
    def _flush(self, force=False):
        """Called after any database mutation"""
        logging.debug('IndexStore.flush: force=%r _pending_writes=%r',
                force, self._pending_writes)

        self._set_index_updated(False)

        if self._flush_timeout is not None:
            GObject.source_remove(self._flush_timeout)
            self._flush_timeout = None

        self._pending_writes += 1
        if force or self._pending_writes > _FLUSH_THRESHOLD:
            try:
                logging.debug("Start database flush")
                self._database.flush()
                logging.debug("Completed database flush")
            except Exception as e:
                logging.exception(e)
                logging.error("Exception during database.flush()")
                # bail out to trigger a reindex
                sys.exit(1)
            self._pending_writes = 0
            self._set_index_updated(True)
        else:
            self._flush_timeout = GObject.timeout_add_seconds(_FLUSH_TIMEOUT,
                                                      self._flush_timeout_cb)
Пример #31
0
def destroy_splash_screen():
    splash_screen.destroy()
    GObject.source_remove(splash_timeout_id)
Пример #32
0
 def on_my_value_changed(self, widget):
     if self._value_changed_timer:
         GObject.source_remove(self._value_changed_timer)
     self._value_changed_timer = GObject.timeout_add(
         100, self.update_settings_value)
Пример #33
0
 def on_entry_changed(self, widget):
     if self._value_changed_timer:
         GObject.source_remove(self._value_changed_timer)
     self._value_changed_timer = GObject.timeout_add(
         100, self.update_from_entry)
Пример #34
0
 def count_down(self):
     self.time_left -= 1
     if self.time_left <= 0:
         GObject.source_remove(self.countdown)
         self._show_text('', countdown=False)
     return True
Пример #35
0
 def stop(self):
     """ stop background process which load thumbs """
     if self.hdl:
         GObject.source_remove(self.hdl)
         self.hdl = None
Пример #36
0
 def stop_search(self, button, entry):
     GObject.source_remove(self.finish_search_id)
     self.finish_search(button, entry)
Пример #37
0
 def on_finished(self):
     if self.dialog is not None:
         self.dialog.destroy()
     GObject.source_remove(self.source_id)
Пример #38
0
def _do_window_resized_update():
    GObject.source_remove(resize_timeout_id)
    updater.window_resized()
Пример #39
0
def __window_manager_failed_cb(fd, condition):
    logging.error('window manager did fail, restarting')
    GObject.source_remove(_metacity_sid)
    GObject.timeout_add(1000, _restart_window_manager)
    return False
Пример #40
0
def stop_autosave():
    global autosave_timeout_id
    if autosave_timeout_id == -1:
        return
    GObject.source_remove(autosave_timeout_id)
    autosave_timeout_id = -1
Пример #41
0
 def set_rate(self, rate):
     self._rate = rate
     if self._save_timeout_id != -1:
         GObject.source_remove(self._save_timeout_id)
     self._save_timeout_id = GObject.timeout_add(_SAVE_TIMEOUT, self.save)
Пример #42
0
def open_assoc_file():
    GObject.source_remove(assoc_timeout_id)
    projectaction.actually_load_project(assoc_file_path,
                                        block_recent_files=False)
Пример #43
0
    def stop_rec(self):

        self.Play = False
        self.seconds = 0
        GObject.source_remove(self.source_id)
Пример #44
0
 def stop(self):
     if self.refresh_timeout_id > 0:
         GObject.source_remove(self.refresh_timeout_id)
         self.refresh_timeout_id = -1
     self.cache.save(force=True)
     self.config.save_config()
Пример #45
0
    def _update_from_episodes(self, episodes, include_description):
        if self.background_update_tag is not None:
            GObject.source_remove(self.background_update_tag)

        self.background_update = BackgroundUpdate(self, episodes, include_description)
        self.background_update_tag = GObject.idle_add(self._update_background)
Пример #46
0
 def set_pitch(self, pitch):
     self._pitch = pitch
     if self._save_timeout_id != -1:
         GObject.source_remove(self._save_timeout_id)
     self._save_timeout_id = GObject.timeout_add(_SAVE_TIMEOUT, self.save)
Пример #47
0
 def __totranslate_changed_cb(self, totranslate):
     if self._autosearch_timer:
         GObject.source_remove(self._autosearch_timer)
     self._autosearch_timer = GObject.timeout_add(_AUTOSEARCH_TIMEOUT,
                                                  self._autosearch_timer_cb)
Пример #48
0
 def stop_timer_cb(self, *args):
     if hasattr(self, "_timer"):
         GObject.source_remove(self._timer)
Пример #49
0
 def resume_monitor(self):
     if self.resume_timeout:
         GObject.source_remove(self.resume_timeout)
     self.resume_timeout = GObject.timeout_add(2000, self.do_resume)
Пример #50
0
 def __totranslate_activated_cb(self, totranslate):
     if self._autosearch_timer:
         GObject.source_remove(self._autosearch_timer)
         self._autosearch_timer = None
     self._translate()
Пример #51
0
 def destroy(self):
     #Gtk.DrawingArea.destroy(self)
     self.close_event()
     GObject.source_remove(self._idle_event_id)
     if self._idle_draw_id != 0:
         GObject.source_remove(self._idle_draw_id)
Пример #52
0
 def reconnect(self):
     self._sock.close()
     self.connected = False
     GObject.source_remove(self._watch_id)
     GObject.timeout_add(5000, self._connectToSocketServer)
Пример #53
0
 def _search_entry_changed_cb(self, entry):
     if self._autosearch_timer:
         GObject.source_remove(self._autosearch_timer)
     self._autosearch_timer = GObject.timeout_add(_AUTOSEARCH_TIMEOUT,
                                                  self.__autosearch_cb)
Пример #54
0
 def _timer_stop(self):
     if self._timer is not None:
         GObject.source_remove(self._timer)
         self._timer = None
Пример #55
0
 def __nick_changed_cb(self, widget, data=None):
     if self._nick_sid:
         GObject.source_remove(self._nick_sid)
     self._nick_sid = GObject.timeout_add(self._APPLY_TIMEOUT,
                                          self.__nick_timeout_cb, widget)
Пример #56
0
 def unregister_listener_event(self):
     if self.listener_source_id == -1:
         return
     GObject.source_remove(self.listener_source_id)
Пример #57
0
 def _leave_notify_cb(self, widget, event):
     if widget in self._sids:
         GObject.source_remove(self._sids[widget])
         del self._sids[widget]
     self._notify_leave()
Пример #58
0
 def _search_entry_activate_cb(self, entry):
     if self._autosearch_timer:
         GObject.source_remove(self._autosearch_timer)
     self.viewer.set_search_text(entry.props.text)
     self._update_search_buttons()
Пример #59
0
 def _enter_notify_cb(self, widget, event, delay):
     if widget in self._sids:
         GObject.source_remove(self._sids[widget])
     self._sids[widget] = GObject.timeout_add(delay,
                                              self.__delay_cb,
                                              widget)
Пример #60
0
 def on_file_changed(self, file, other, event, data):
     if self.file_changed_timeout:
         GObject.source_remove(self.file_changed_timeout)
     self.file_changed_timeout = GObject.timeout_add(300, self.do_reload)