1 # Copyright (C) 2006 by Aiwota Programmer
2 # aiwotaprog@tetteke.tk
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 GLADE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)),
31 GLADE_FILENAME = "brdlist_window.glade"
33 def open_brdlist(bbs):
35 raise ValueError, "parameter must not be empty"
38 winwrap = windowlist.get_window(key)
42 win_wrap = WinWrap(bbs)
43 windowlist.window_created(key, win_wrap)
48 def __init__(self, bbs):
51 glade_path = os.path.join(GLADE_DIR, GLADE_FILENAME)
52 self.widget_tree = gtk.glade.XML(glade_path)
54 self.window = self.widget_tree.get_widget("brdlist_window")
55 self.treeview = self.widget_tree.get_widget("treeview")
56 self.model = gtk.ListStore(str, str, str)
57 self.treeview.set_model(self.model)
59 renderer = gtk.CellRendererText()
60 column_names = ["id", "host", "name"]
62 self.treeviewcolumn = gtk.TreeViewColumn(column_names[i],
64 self.treeviewcolumn.set_sort_column_id(i)
65 self.treeviewcolumn.set_resizable(True)
66 self.treeviewcolumn.set_reorderable(True)
67 self.treeview.append_column(self.treeviewcolumn)
69 self.treeview.connect("row-activated", self.on_row_activated)
71 sigdict = {"on_close_activate": self.on_close_activate,
72 "on_quit_activate": self.on_quit_activate}
73 self.widget_tree.signal_autoconnect(sigdict)
78 key_root = "/apps/" + config.APPNAME.lower() + "/boards/" + self.bbs
79 client = gconf.client_get_default()
82 for board_dir in client.all_dirs(key_root):
83 bbs_dir, board = os.path.split(board_dir)
85 key = board_dir + "/host"
86 host = client.get_string(key)
88 key = board_dir + "/name"
89 name = client.get_string(key)
90 if board and host and name:
91 self.modify(board, host, name)
93 def modify(self, board, name, host):
94 self.model.append([board, name, host])
96 def on_close_activate(self, widget):
99 def on_quit_activate(self, widget):
102 def on_row_activated(self, widget, path, view_column):
103 model = widget.get_model()
105 iter = model.get_iter(path)
107 board = model.get_value(iter, 0)
108 self.open_board(board)
110 def open_board(self, board):
111 board_window.open_board(self.bbs, board)