Exemplo n.º 1
0
 def __init__(self):
     self.list = TimeLineList()
     self.list.title_icons = [self.dialog_image_init]
     self.list.hint_icons = [self.reply_image_init, self.retweet_image_init]
     self.list.on_next_clicked = self.on_next
     self.view = self.list.widget()
Exemplo n.º 2
0
class TimeLineBasePage(object):
    RETWEET_IMAGE = package_path + '/data/retweet.png'
    REPLY_IMAGE = package_path + '/data/reply.png'
    
    def __init__(self):
        self.list = TimeLineList()
        self.list.title_icons = [self.dialog_image_init]
        self.list.hint_icons = [self.reply_image_init, self.retweet_image_init]
        self.list.on_next_clicked = self.on_next
        self.view = self.list.widget()

    def on_switched_to(self):
        self.list.refresh(self.controller.items)
        self.view = self.list.widget()

    def on_next(self, btn, event):
        def pipeline_work():
            self.controller.next()
            
        def pipeline_ui_work():
            gtk.threads_enter()
            self.list.refresh(self.controller.items)
            tabmgr = TabManager()
            if tabmgr.is_current(self):
                cur_adj = tabmgr.ui.scrwindow.get_vadjustment().get_value()
                tabmgr.switch_to_current_tab()
                def hack():
                    tabmgr.ui.scrwindow.get_vadjustment().set_value(cur_adj)
                gtk.timeout_add(100, hack)
            gtk.threads_leave()
            
        btn.set_sensitive(False)
        Pipeline().add_handler(pipeline_work, 'fetching timeline...')
        Pipeline().add_handler(pipeline_ui_work)
        
    def on_refresh(self):
        def pipeline_work():
            self.controller.refresh()
            gtk.threads_enter()
            self.list.refresh(self.controller.items)
            gtk.threads_leave()
        Pipeline().add_handler(pipeline_work, 'fetching timeline...')
        
    def reply_image_init(self, entry):
        def cb(widget, event, author):
            TabManager().ui.editor.reply(entry)
        return self.list.create_image_button(self.REPLY_IMAGE, entry.color, cb, entry)
    
    def retweet_image_init(self, entry):
        def cb(widget, event, entry):
            def pipeline_work():
                self.controller.retweet(entry)
                gtk.threads_enter()
                TabManager().switch_to_if_current(self)
                gtk.threads_leave()
            Pipeline().add_handler(pipeline_work, 'retweeting message...')
        return self.list.create_image_button(self.RETWEET_IMAGE, entry.color, cb, entry)

    def dialog_image_init(self, entry):
        def cb(widget, event, entry):
            idx, page = TabManager().find_tab(DialogPage)
            TabManager().switch_to(idx)
            print 'callback'
            page.show_conversations(entry.id)
        return self.list.create_image_button(self.RETWEET_IMAGE, entry.color, cb, entry)