OSDN Git Service

Rearrange. logic is not changed.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Tue, 19 Sep 2006 10:23:29 +0000 (19:23 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Tue, 19 Sep 2006 10:23:29 +0000 (19:23 +0900)
src/FukuiNoNamari/board_window.py

index 0c29bab..f1aed31 100644 (file)
@@ -63,23 +63,16 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
 
         self.bbs_type = bbs_type_judge_uri.get_type(uri)
         board_data.BoardData.__init__(self, self.bbs_type)
-        
+
         glade_path = os.path.join(config.glade_dir, GLADE_FILENAME)
         self.widget_tree = gtk.glade.XML(glade_path)
+        self._get_widgets()
 
-        self.window = self.widget_tree.get_widget("window_board")
+        self.widget_tree.signal_autoconnect(self)
 
         self.window.set_title(self.bbs_type.uri)
-
-        self.treeview = self.widget_tree.get_widget("treeview")
         self.treeview.set_model(ThreadListModel())
-
-        self.popupmenu = self.widget_tree.get_widget("popup_treeview_menu")
-        self.toolbar = self.widget_tree.get_widget("toolbar")
         self.toolbar.unset_style()
-        self.statusbar = self.widget_tree.get_widget("appbar")
-        self.filterbar = self.widget_tree.get_widget("bonobodockitem_filterbar")
-        self.entry_filterbar = self.widget_tree.get_widget("entry_filterbar")
 
         renderer = gtk.CellRendererText()
 
@@ -88,17 +81,25 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
 
         self.treeview.set_fixed_height_mode(True)
 
-        self.widget_tree.signal_autoconnect(self)
-
         # menu plugins
-        self.edit1 = self.widget_tree.get_widget("menu_edit").get_submenu()
-        board_plugins.load(self.treeview, self.edit1)
+        board_plugins.load(self.treeview, self.menu_edit)
 
         self.restore()
         self.window.show()
 
         self.created()
 
+    def _get_widgets(self):
+        self.window = self.widget_tree.get_widget("window_board")
+        self.treeview = self.widget_tree.get_widget("treeview")
+        self.popupmenu = self.widget_tree.get_widget("popup_treeview_menu")
+        self.toolbar = self.widget_tree.get_widget("toolbar")
+        self.statusbar = self.widget_tree.get_widget("appbar")
+        self.filterbar = self.widget_tree.get_widget(
+            "bonobodockitem_filterbar")
+        self.entry_filterbar = self.widget_tree.get_widget("entry_filterbar")
+        self.menu_edit = self.widget_tree.get_widget("menu_edit").get_submenu()
+
     def set_status(self, text):
         self.statusbar.set_status(text)
 
@@ -109,69 +110,6 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
     def get_uri(self):
         return self.bbs_type.get_uri_base()
 
-    def on_menu_toolbar_activate(self, widget):
-        if self.toolbar.parent.get_property("visible"):
-            self.toolbar.parent.hide()
-        else:
-            self.toolbar.parent.show()
-
-    def on_menu_statusbar_activate(self, widget):
-        if self.statusbar.get_property("visible"):
-            self.statusbar.hide()
-        else:
-            self.statusbar.show()
-
-    def on_menu_filter_activate(self, widget):
-        self.filterbar.show()
-        self.entry_filterbar.grab_focus()
-
-    def on_entry_filterbar_activate(self, widget):
-        text = widget.get_text()
-
-        def func(model, item):
-            try:
-                item["title"].index(text)
-            except ValueError:
-                return False
-            else:
-                return True
-
-        model = self.treeview.get_model()
-        if model:
-            if text:
-                filter_func = func
-            else:
-                filter_func = None
-            model.refilter(filter_func)
-
-    def on_toolbutton_filterbar_close_clicked(self, widget):
-        self.filterbar.hide()
-
-    def on_button_filterbar_clear_clicked(self, widget):
-        self.entry_filterbar.set_text("")
-        model = self.treeview.get_model()
-        if model:
-            model.refilter(None)
-
-    def on_window_board_delete_event(self, widget, event):
-        self.save()
-        return False
-
-    def on_window_board_destroy(self, widget):
-        self.destroyed()
-
-    def on_menu_quit_activate(self, widget):
-        session.main_quit()
-
-    def on_menu_close_activate(self, widget):
-        self.destroy()
-
-    def on_menu_refresh_activate(self, widget):
-        self.load(True)
-
-    def on_menu_open_activate(self, widget):
-        self.open_thread()
-
     def open_thread(self):
         treeselection = self.treeview.get_selection()
         model, iter = treeselection.get_selected()
@@ -192,55 +130,6 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
         bbs_type_for_thread = self.bbs_type.clone_with_thread(thread)
         uri_opener.open_uri(bbs_type_for_thread.get_thread_uri(), update)
 
-    def on_menu_add_bookmark_activate(self, widget):
-        bookmark_list.bookmark_list.add_bookmark_with_edit(
-            uri=self.bbs_type.uri)
-
-    def on_menu_manage_bookmarks_activate(self, widget):
-        bookmark_window.open()
-
-    def on_menu_delete_activate(self, widget):
-        selection = self.treeview.get_selection()
-        model, iter = selection.get_selected()
-        if not iter:
-            return
-        thread = model.get_value(
-            iter, ThreadListModel.column_names.index("id"))
-        
-        bbs_type_for_thread = self.bbs_type.clone_with_thread(thread)
-
-        dat_path = misc.get_thread_dat_path(bbs_type_for_thread)
-        try:
-            os.remove(dat_path)
-        except OSError:
-            traceback.print_exc()
-        idx_path = misc.get_thread_idx_path(bbs_type_for_thread)
-        try:
-            os.remove(idx_path)
-        except OSError:
-            traceback.print_exc()
-        states_path = misc.get_thread_states_path(bbs_type_for_thread)
-        try:
-            os.remove(states_path)
-        except OSError:
-            traceback.print_exc()
-
-    def on_treeview_row_activated(self, widget, path, view_column):
-        self.open_thread()
-
-    def on_treeview_button_press_event(self, widget, event):
-        if event.button == 3:
-            x = int(event.x)
-            y = int(event.y)
-            time = event.time
-            pthinfo = widget.get_path_at_pos(x, y)
-            if pthinfo is not None:
-                path, col, cellx, celly = pthinfo
-                widget.grab_focus()
-                widget.set_cursor(path, col, 0)
-                self.popupmenu.popup(None, None, None, event.button, time)
-            return 1
-
     def update_datastore(self, datalist):
         print "reflesh datastore"
 
@@ -456,3 +345,129 @@ class WinWrap(winwrapbase.WinWrapBase, board_data.BoardData):
                                  priority=gobject.PRIORITY_HIGH)
         except:
             traceback.print_exc()
+
+    def on_menu_toolbar_activate(self, widget):
+        if self.toolbar.parent.get_property("visible"):
+            self.toolbar.parent.hide()
+        else:
+            self.toolbar.parent.show()
+
+    def on_menu_statusbar_activate(self, widget):
+        if self.statusbar.get_property("visible"):
+            self.statusbar.hide()
+        else:
+            self.statusbar.show()
+
+
+    # signal handlers
+
+    # menu and toolbutton
+
+    def on_menu_add_bookmark_activate(self, widget):
+        bookmark_list.bookmark_list.add_bookmark_with_edit(
+            uri=self.bbs_type.uri)
+
+    def on_menu_close_activate(self, widget):
+        self.destroy()
+
+    def on_menu_delete_activate(self, widget):
+        selection = self.treeview.get_selection()
+        model, iter = selection.get_selected()
+        if not iter:
+            return
+        thread = model.get_value(
+            iter, ThreadListModel.column_names.index("id"))
+        
+        bbs_type_for_thread = self.bbs_type.clone_with_thread(thread)
+
+        dat_path = misc.get_thread_dat_path(bbs_type_for_thread)
+        try:
+            os.remove(dat_path)
+        except OSError:
+            traceback.print_exc()
+        idx_path = misc.get_thread_idx_path(bbs_type_for_thread)
+        try:
+            os.remove(idx_path)
+        except OSError:
+            traceback.print_exc()
+        states_path = misc.get_thread_states_path(bbs_type_for_thread)
+        try:
+            os.remove(states_path)
+        except OSError:
+            traceback.print_exc()
+
+    def on_menu_filter_activate(self, widget):
+        self.filterbar.show()
+        self.entry_filterbar.grab_focus()
+
+    def on_menu_manage_bookmarks_activate(self, widget):
+        bookmark_window.open()
+
+    def on_menu_open_activate(self, widget):
+        self.open_thread()
+
+    def on_menu_quit_activate(self, widget):
+        session.main_quit()
+
+    def on_menu_refresh_activate(self, widget):
+        self.load(True)
+
+
+    # window
+
+    def on_window_board_delete_event(self, widget, event):
+        self.save()
+        return False
+
+    def on_window_board_destroy(self, widget):
+        self.destroyed()
+
+
+    # treeview
+
+    def on_treeview_row_activated(self, widget, path, view_column):
+        self.open_thread()
+
+    def on_treeview_button_press_event(self, widget, event):
+        if event.button == 3:
+            x = int(event.x)
+            y = int(event.y)
+            time = event.time
+            pthinfo = widget.get_path_at_pos(x, y)
+            if pthinfo is not None:
+                path, col, cellx, celly = pthinfo
+                widget.grab_focus()
+                widget.set_cursor(path, col, 0)
+                self.popupmenu.popup(None, None, None, event.button, time)
+            return 1
+
+
+    # filterbar
+
+    def on_entry_filterbar_activate(self, widget):
+        text = widget.get_text()
+
+        def func(model, item):
+            try:
+                item["title"].index(text)
+            except ValueError:
+                return False
+            else:
+                return True
+
+        model = self.treeview.get_model()
+        if model:
+            if text:
+                filter_func = func
+            else:
+                filter_func = None
+            model.refilter(filter_func)
+
+    def on_toolbutton_filterbar_close_clicked(self, widget):
+        self.filterbar.hide()
+
+    def on_button_filterbar_clear_clicked(self, widget):
+        self.entry_filterbar.set_text("")
+        model = self.treeview.get_model()
+        if model:
+            model.refilter(None)