def _setup_layout(self): hpaned = HPaned() label = Label(_("Are you sure you want to install/remove those packages?")) label.show() inst_frame = Frame(_("Packages to install")) rem_frame = Frame(_("Packages to remove")) inst_frame.add(self.install_tree) rem_frame.add(self.remove_tree) hpaned.add1(inst_frame) hpaned.add2(rem_frame) hpaned.show_all() self.vbox.pack_start(label, False, False, 0) self.vbox.pack_start(hpaned, True, True, 0) return
class do_dialog(Window): def __init__(self, queues, icon): Window.__init__(self, WINDOW_TOPLEVEL) self.set_property("skip-taskbar-hint", True) self.set_property("destroy-with-parent", True) self.set_modal(True) self.connect("delete-event", self._stop_closing) self.set_position(WIN_POS_CENTER) self.set_icon(pixbuf_new_from_file(icon)) self._setup_trees(queues) self._setup_layout() self.queues = queues def _setup_trees(self, queues): self._setup_install_tree(queues["add"]) self._setup_remove_tree(queues["remove"]) def _setup_install_tree(self, add_queue): self.inst_model = ListStore(str, str, str) for pac in add_queue: if pac.isold: image = "yellow" elif pac.installed: image = "green" else: image = "red" self.inst_model.append([image, pac.name, pac.version]) continue self.inst_tree = TreeView() self.inst_tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(), stock_id = 0) self.inst_tree.insert_column_with_attributes(-1, _("Package"), CellRendererText(), text = 1) self.inst_tree.insert_column_with_attributes(-1, _("Version"), CellRendererText(), text = 2) self.inst_tree.set_model(self.inst_model) def _setup_remove_tree(self, remove_queue): self.rem_model = ListStore(str, str, str) for pac in remove_queue: if pac.isold: image = "yellow" elif pac.installed: image = "green" else: image = "red" self.rem_model.append([image, pac.name, pac.inst_ver]) continue self.rem_tree = TreeView() self.rem_tree.insert_column_with_attributes(-1, "", CellRendererPixbuf(), stock_id = 0) self.rem_tree.insert_column_with_attributes(-1, _("Package"), CellRendererText(), text = 1) self.rem_tree.insert_column_with_attributes(-1, _("Installed Version"), CellRendererText(), text = 2) self.rem_tree.set_model(self.rem_model) def _set_size (self, widget, event, data=None): if self.expander.get_expanded(): self.size = self.get_size() self.expander.add(self.terminal) self.terminal.show() else: self.expander.remove(self.terminal) self.resize(self.size[0], self.size[1]) self.show_all() def _setup_layout(self): self.hpaned = HPaned() self.hpaned.add1(self.inst_tree) self.hpaned.add2(self.rem_tree) self.hpaned.show_all() self.close_button = Button(stock=STOCK_CLOSE) self.close_button.connect("clicked", lambda _: self.destroy()) self.terminal = terminal() self.terminal.connect("child-exited", lambda _: self.close_button.show()) self.expander = Expander(_("Terminal")) self.expander.connect("notify::expanded", self._set_size) self.expander.show() self.vbox = VBox(False, 0) self.vbox.show() self.vbox.pack_start(self.hpaned, False, False, 0) self.vbox.pack_start(self.expander, False, False, 0) self.vbox.pack_start(self.close_button, False, False, 0) self.add(self.vbox) def run(self): self.show() self.terminal.do(self.queues) return def _stop_closing(self, widget, event): self.stop_emission("delete-event") return True