def _spawnSearch(self, term): signals.emit(signals.PROGRESS_START) search = timeline.SearchesTimeline(self.api, parent=self.widget_tree.get_widget('DeckHBox'), term=term) self.timelines.append(search) search.start()
def toggle_replies(self, button, **kwargs): if not button.get_active(): # Remove the RepliesTimeline from our list and destroy the object self.timelines = [t for t in self.timelines if not t is self.replies] self.replies.destroy() return signals.emit(signals.PROGRESS_START) self.replies = timeline.RepliesTimeline(self.api, parent=self.widget_tree.get_widget('DeckHBox')) self.timelines.append(self.replies) self.replies.start()
def _timerUpdatedCallback(self, data, **kwargs): signals.emit(signals.PROGRESS_STOP) if not self.rendered: self.renderTo(self.parent) self.rendered = True odd = True try: if data: logging.debug('_timerUpdatedCallback [%s], # items: %s' % (self.timeline, len(data))) notify.notify('%s updated' % self.name, '%d new tweets :)' % len(data), None) self.since_id = data[0]['id'] data.reverse() for i, status in enumerate(data): what = status['text'] # *Very* crude dupe checking if i > 0: prev = data[i-1] if prev['text'] == what: continue renderer = None for view in util.get_global('views'): if not view.matchForText(status): continue renderer = view break logging.debug('rendering %s with %s' % (status['id'], renderer)) if not renderer: continue row = renderer.rowForText(status) self.users.add(row.who) self.rows.insert(0, row) row.renderTo(self.timeline_widget) finally: gobject.timeout_add_seconds(INTERVAL, self._timerCallback)
def retweet(self, status_id, callback=None): logging.debug('retweet(%s)' % status_id) signals.emit(signals.PROGRESS_START) headers = { 'Content-type' : 'application/x-www-form-urlencoded', 'Accept' : 'text/plain', } headers['Authorization'] = self._auth_header() connection = httplib.HTTPSConnection(TWITTER_DOMAIN) connection.request('POST', '/statuses/retweet/%s.json' % status_id, '', headers) try: response = connection.getresponse() data = json.loads(response.read()) if not callback: return data else: gobject.idle_add(callback, data) finally: connection.close() signals.emit(signals.PROGRESS_STOP)
def update(self, status, in_reply_to=None, callback=None): logging.debug('update("%s", in_reply_to=%s)' % (status, in_reply_to)) signals.emit(signals.PROGRESS_START) args = {'status' : status} if in_reply_to: args['in_reply_to_status_id'] = in_reply_to args = urllib.urlencode(args) headers = { 'Content-type' : 'application/x-www-form-urlencoded', 'Accept' : 'text/plain', } headers['Authorization'] = self._auth_header() connection = httplib.HTTPSConnection(TWITTER_DOMAIN) connection.request('POST', '/statuses/update.json', args, headers) try: response = connection.getresponse() data = json.loads(response.read()) if not callback: return data else: gobject.idle_add(callback, data) finally: connection.close() signals.emit(signals.PROGRESS_STOP)
def main(self): signals.emit(signals.PROGRESS_START) gtk.main()