import gobject
import board_data
-import thread_window
+import uri_opener
import misc
from threadlistmodel import ThreadListModel
from BbsType import bbs_type_judge_uri
"..", "data")
GLADE_FILENAME = "board_window.glade"
-def open_board(uri):
+def open_board(uri, update=False):
if not uri:
raise ValueError, "parameter must not be empty"
if winwrap:
# already opened
winwrap.window.present()
- pass
+ if update:
+ winwrap.load(update)
else:
- win_wrap = WinWrap(uri)
- session.window_created(uri, win_wrap)
+ winwrap = WinWrap(uri)
+ session.window_created(uri, winwrap)
+ winwrap.load(update)
class WinWrap:
"on_popup_menu_open_activate": self.on_open_thread}
self.widget_tree.signal_autoconnect(sigdic)
- t = board_data.LoadLocal(self.bbs, self.board, self.update_datastore)
- t.start()
-
def updated_thread_highlight(self, column, cell, model, iter):
def is_updated_thread():
iter, ThreadListModel.column_names.index("title"))
print thread + ':"' + title + '"', "activated"
+ res = model.get_value(iter, ThreadListModel.column_names.index("res"))
+ lineCount = model.get_value(
+ iter, ThreadListModel.column_names.index("lineCount"))
+
+ update = res > lineCount
+
bbs_type_for_thread = self.bbs_type.clone_with_thread(thread)
- thread_window.open_thread(bbs_type_for_thread.get_thread_uri())
+ uri_opener.open_uri(bbs_type_for_thread.get_thread_uri(), update)
def on_treeview_button_press_event(self, widget, event):
if event.button == 3:
except ValueError:
idx_dic["lastModified"] = 0
model.modify_row(idx_dic)
+
+ def load(self, update=False):
+ sbj_path = misc.get_board_subjecttxt_path(
+ self.bbs_type.bbs_type, self.bbs_type.board)
+ sbj_exists = os.path.exists(sbj_path)
+
+ if update or not sbj_exists:
+ t = board_data.GetRemote(
+ self.bbs, self.board, self.bbs_type.get_subject_txt_uri(),
+ self.update_datastore)
+ t.start()
+ else:
+ t = board_data.LoadLocal(
+ self.bbs, self.board, self.update_datastore)
+ t.start()
"..", "data")
GLADE_FILENAME = "thread_window.glade"
-def open_thread(uri):
+def open_thread(uri, update=False):
if not uri:
raise ValueError, "parameter must not be empty"
if winwrap:
# already opened
winwrap.window.present()
+ if update:
+ winwrap.load(update)
else:
winwrap = WinWrap(bbs_type.uri) # pass original uri
session.window_created(uri, winwrap)
+ winwrap.load(update)
# jump to the res if necessary.
winwrap.jump_to_res(bbs_type.uri)
self.textview.connect("visibility-notify-event",
self.on_visibility_notify_event)
- self.load_dat()
-
def on_compose_clicked(self, widget):
import submit_window
submit_window.open(self.bbs_type.get_thread_uri())
mark = self.textbuffer.get_mark(resnum)
if mark:
self.textview.scroll_to_mark(mark, 0, True, 0, 0)
+
+ def load(self, update=False):
+ dat_path = misc.get_thread_dat_path(
+ self.bbs_type.bbs_type, self.bbs_type.board, self.bbs_type.thread)
+ dat_exists = os.path.exists(dat_path)
+ if update or not dat_exists:
+ self.update()
+ else:
+ self.load_dat()
import thread_window
from BbsType import bbs_type_judge_uri
-def open_uri(uri):
+def open_uri(uri, update=False):
bbs_type = bbs_type_judge_uri.get_type(uri)
if bbs_type.is_board():
- board_window.open_board(uri)
+ board_window.open_board(uri, update)
elif bbs_type.is_thread():
- thread_window.open_thread(uri)
+ thread_window.open_thread(uri, update)
else:
print "the uri represents neither board nor thread: ", uri