def __init__(self, liststore, notebook, api, name='', page=-1): super(FeedView, self).__init__() self.name = name self.api = api self.liststore = liststore self.window = liststore.window # access from RetweetMenuItem self.theme = self.window.theme self.feed_counter = 1 # numbers of feeds self.webview = FeedWebView(self, api, notebook.group_name) self.notification = self.window.notification self.id_history = CacheList() SETTINGS_VIEW.connect("changed::theme", self.id_history.clear) self.box = Gtk.VBox() self.profile = ProfilePane() self.append(notebook, page)
class FeedView(FeedScrolledWindow): def __init__(self, liststore, notebook, api, name='', page=-1): super(FeedView, self).__init__() self.name = name self.api = api self.liststore = liststore self.window = liststore.window # access from RetweetMenuItem self.theme = self.window.theme self.feed_counter = 1 # numbers of feeds self.webview = FeedWebView(self, api, notebook.group_name) self.notification = self.window.notification self.id_history = CacheList() SETTINGS_VIEW.connect("changed::theme", self.id_history.clear) self.box = Gtk.VBox() self.profile = ProfilePane() self.append(notebook, page) def append(self, notebook, page=-1): self.notebook = notebook self.box.pack_start(self.profile.widget, False, False, 10) self.box.pack_start(self, True, True, 0) self.box.show() self.tab_label = notebook.append_page(self.box, self.name, page) self.tab_label.set_sensitive(False) def set_profile(self, entry): self.profile.set_profile(entry) def move(self, notebook, page=-1): self.remove() self.append(notebook, page) def remove(self): self.feed_counter -= 1 if self.feed_counter == 0: self.force_remove() def force_remove(self): page = self.notebook.page_num(self.box) print "removed %s page!" % page self.notebook.remove_page(page) def update(self, entry_dict, style='status', has_notify=False, is_first_call=False, is_new_update=True): if entry_dict.get('styles').find('event') < 0: is_dupulicated = entry_dict['id'] in self.id_history self.id_history.append(entry_dict['id']) if is_dupulicated: return text = self.theme.template[style].substitute(entry_dict) if has_notify and not is_first_call: self.notification.notify(entry_dict, self.api) self.tab_label.set_sensitive(is_new_update) self.webview.update(text, entry_dict.get('is_reversed')) def jump_to_bottom(self, is_bottom=True): self.webview.jump_to_bottom(is_bottom) def change_font(self, font, size): self.webview.change_font(font, size) def clear_buffer(self): self.webview.clear_buffer() self.tab_label.set_sensitive(False) def execute_script(self, js): self.webview.execute_script(js)