+
+ RESPONSE_NEW, RESPONSE_EDIT, RESPONSE_DELETE = range(3)
+
+ dialog = gtk.Dialog()
+ dialog.set_transient_for(window)
+ dialog.set_title("Settings")
+
+ vbox = dialog.vbox
+
+ acctsLabel = gtk.Label("Accounts:")
+ acctsLabel.set_justify(gtk.JUSTIFY_LEFT)
+
+ vbox.pack_start(acctsLabel, False, False, 1)
+
+ self.accounts_model = models.AccountsModel(self.controller)
+
+ accounts_treeview = gtk.TreeView(model = self.accounts_model)
+ self.add_columns_to_accounts(accounts_treeview)
+ vbox.pack_start(accounts_treeview, False, False, 1)
+
+ # all stock responses are negative, so we can use any positive value
+ new_button = dialog.add_button("New", RESPONSE_NEW)
+ #TODO: get edit button working
+ #edit_button = dialog.add_button("Edit", RESPONSE_EDIT)
+ delete_button = dialog.add_button("Delete", RESPONSE_DELETE)
+ ok_button = dialog.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
+ cancel_button = dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
+
+ #TODO: for some reason the scrollbar shows up in the middle of the
+ # dialog. Why?
+ #scrollbar = gtk.VScrollbar()
+ #vbox.add(scrollbar)
+
+ dialog.show_all()
+
+ result = dialog.run()
+
+ while(result != gtk.RESPONSE_CANCEL):
+ if result == RESPONSE_NEW:
+ self.new_account_clicked(window)
+ elif result == RESPONSE_EDIT:
+ # get the selected treeview item and pop up the account_box
+ self.edit_account(accounts_treeview)
+ elif result == RESPONSE_DELETE:
+ # get the selected treeview item, and delete the gconf keys
+ self.delete_account(accounts_treeview)
+ elif result == gtk.RESPONSE_OK:
+ self.char_model.get_characters()
+ break
+
+ result = dialog.run()
+
+ dialog.destroy()
+
+
+
+ def get_selected_item(self, treeview, column):
+ selection = treeview.get_selection()
+ model, miter = selection.get_selected()
+
+ value = model.get_value(miter, column)
+
+ return value
+
+ def edit_account(self, treeview):
+ uid = self.get_selected_item(treeview, 0)
+ # pop up the account dialog
+
+ self.accounts_model.get_accounts()
+
+ def delete_account(self, treeview):
+ uid = self.get_selected_item(treeview, 0)
+ self.controller.remove_account(uid)
+ # refresh model
+ self.accounts_model.get_accounts()
+
+
+ def add_columns_to_accounts(self, treeview):
+ #Column 0 for the treeview
+ renderer = gtk.CellRendererText()
+ column = gtk.TreeViewColumn('Account ID', renderer, text=0)
+ column.set_property("expand", True)
+ treeview.append_column(column)
+
+
+ def new_account_clicked(self, window):