diff options
Diffstat (limited to 'gui.py')
-rwxr-xr-x | gui.py | 130 |
1 files changed, 69 insertions, 61 deletions
@@ -41,7 +41,7 @@ class EmergeQueue: self.mergequeue.update({sth : pkg.get_dep_packages()}) except geneticone.BlockedException, e : blocks = e[0] - blockedDialog(sth, blocks) + blocked_dialog(sth, blocks) return else: # update tree @@ -58,9 +58,9 @@ class EmergeQueue: """Calls emerge and updates the terminal.""" # open pty (master, slave) = pty.openpty() - Popen("emerge "+options, stdout = slave, stderr = STDOUT, shell = True) - self.removeAll(it) self.console.set_pty(master) + self.process = Popen("emerge "+options, stdout = slave, stderr = STDOUT, shell = True) + self.remove_all(it) def emerge (self, force = False): """Emerges everything in the merge-queue. If force is 'False' (default) only 'emerge -pv' is called.""" @@ -84,7 +84,7 @@ class EmergeQueue: if not force: s = "-pv " self._emerge("-C "+s+list, self.unmergeIt) - def removeAll (self, parentIt): + def remove_all (self, parentIt): """Removes all children of a given parent TreeIter.""" childIt = self.tree.iter_children(parentIt) @@ -105,21 +105,21 @@ class EmergeQueue: class PackageWindow: """A window with data about a specfic package.""" - def cbChanged (self, combo, data = None): + def cb_changed (self, combo, data = None): """Callback for the changed ComboBox. It then rebuilds the useList and the checkboxes.""" # remove old useList self.useListScroll.remove(self.useList) # build new - self.useList = self.buildUseList() + self.useList = self.build_use_list() self.useListScroll.add(self.useList) - self.updateCheckBoxes() + self.update_checkboxes() self.useListScroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER) # set emerge-button-label - if not self.actualPackage().is_installed(): + if not self.actual_package().is_installed(): self.emergeBtn.set_label("_Emerge") else: self.emergeBtn.set_label("_Unmerge") @@ -129,7 +129,7 @@ class PackageWindow: self.window.resize(1,1) return True - def buildVersCombo (self): + def build_vers_combo (self): """Creates the combo box with the different versions.""" combo = gtk.combo_box_new_text() @@ -151,42 +151,42 @@ class PackageWindow: except AttributeError: # no package found combo.set_active(0) - combo.connect("changed", self.cbChanged) + combo.connect("changed", self.cb_changed) return combo - def actualPackage (self): + def actual_package (self): """Returns the actual package (a geneticone.Package-object).""" return self.packages[self.vCombo.get_active()] - def cbButtonPressed (self, b, event, data = None): + def cb_button_pressed (self, b, event, data = None): """Callback for pressed checkboxes. Just quits the event-loop - no redrawing.""" b.emit_stop_by_name("button-press-event") return True - def cbEmergeClicked (self, button, data = None): + def cb_emerge_clicked (self, button, data = None): """Adds the package to the EmergeQueue.""" if not geneticone.am_i_root(): errorMB = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "You cannot (un)merge without being root.") errorMB.run() errorMB.destroy() else: - unmerge = self.actualPackage().is_installed() - self.queue.append(self.actualPackage().get_cpv(), unmerge) + unmerge = self.actual_package().is_installed() + self.queue.append(self.actual_package().get_cpv(), unmerge) self.window.destroy() return True - def updateCheckBoxes (self): + def update_checkboxes (self): """Updates the checkboxes.""" - self.installedCheck.set_active(self.actualPackage().is_installed()) - self.maskedCheck.set_active(self.actualPackage().is_masked()) - self.testingCheck.set_active((self.actualPackage().get_mask_status() % 3) == 1) + self.installedCheck.set_active(self.actual_package().is_installed()) + self.maskedCheck.set_active(self.actual_package().is_masked()) + self.testingCheck.set_active((self.actual_package().get_mask_status() % 3) == 1) - def buildUseList (self): + def build_use_list (self): """Builds the useList.""" store = gtk.ListStore(bool, str, str) - pkg = self.actualPackage() + pkg = self.actual_package() for use in pkg.get_all_useflags(): if pkg.is_installed() and use in pkg.get_set_useflags(): # flags set during install enabled = True @@ -210,7 +210,7 @@ class PackageWindow: view.set_child_visible(True) return view - def cbSizeCheck (self, event, data = None): + def cb_size_check (self, event, data = None): if self.useListScroll: width, height = self.window.get_size() if height > gtk.gdk.screen_height(): @@ -247,11 +247,11 @@ class PackageWindow: self.window.add(self.table) # version-combo-box - self.vCombo = self.buildVersCombo() + self.vCombo = self.build_vers_combo() self.table.attach(self.vCombo, 0, 1, 1, 2, yoptions = gtk.FILL) # the label (must be here, because it depends on the combo box) - desc = self.actualPackage().get_env_var("DESCRIPTION") + desc = self.actual_package().get_env_var("DESCRIPTION") use_markup = True if not desc: desc = "<no description>" @@ -269,22 +269,22 @@ class PackageWindow: self.table.attach(checkHB, 1, 2, 1, 2, yoptions = gtk.FILL) self.installedCheck = gtk.CheckButton() - self.installedCheck.connect("button-press-event", self.cbButtonPressed) + self.installedCheck.connect("button-press-event", self.cb_button_pressed) self.installedCheck.set_label("Installed") checkHB.pack_start(self.installedCheck, True, False) self.maskedCheck = gtk.CheckButton() - self.maskedCheck.connect("button-press-event", self.cbButtonPressed) + self.maskedCheck.connect("button-press-event", self.cb_button_pressed) self.maskedCheck.set_label("Masked") checkHB.pack_start(self.maskedCheck, True, False) self.testingCheck = gtk.CheckButton() - self.testingCheck.connect("button-press-event", self.cbButtonPressed) + self.testingCheck.connect("button-press-event", self.cb_button_pressed) self.testingCheck.set_label("Testing") checkHB.pack_start(self.testingCheck, True, False) # use list - self.useList = self.buildUseList() + self.useList = self.build_use_list() self.useListScroll = gtk.ScrolledWindow() self.useListScroll.add(self.useList) self.useListScroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER) # XXX: make this work correctly @@ -299,12 +299,12 @@ class PackageWindow: if not self.queue: self.emergeBtn.set_sensitive(False) self.cancelBtn = gtk.Button("_Cancel") self.cancelBtn.connect("clicked", lambda x: self.window.destroy()) - self.emergeBtn.connect("clicked", self.cbEmergeClicked) + self.emergeBtn.connect("clicked", self.cb_emerge_clicked) buttonHB.pack_start(self.emergeBtn) buttonHB.pack_start(self.cancelBtn) # current status - self.cbChanged(self.vCombo) + self.cb_changed(self.vCombo) # show self.window.show_all() @@ -312,26 +312,26 @@ class PackageWindow: class MainWindow: """Application main window.""" - def cbDelete (self, widget, data = None): + def cb_delete (self, widget, data = None): """Returns false -> window is deleted.""" return False - def cbDestroy (self, widget, data = None): + def cb_destroy (self, widget, data = None): """Calls main_quit().""" gtk.main_quit() - def createMainMenu (self): + def create_main_menu (self): """Creates the main menu.""" # the menu-list mainMenuDesc = [ ( "/_File", None, None, 0, "<Branch>"), - ( "/File/_Close", None, self.cbDestroy, 0, "") + ( "/File/_Close", None, self.cb_destroy, 0, "") ] self.itemFactory = gtk.ItemFactory(gtk.MenuBar, "<main>", None) self.itemFactory.create_items(mainMenuDesc) return self.itemFactory.get_widget("<main>") - def cbCatListSelection (self, view, data = None): + def cb_cat_list_selection (self, view, data = None): """Callback for a category-list selection. Updates the package list with these packages in the category.""" if view == self.catList: # be sure it is the catList # get the selected category @@ -343,12 +343,12 @@ class MainWindow: self.scroll_2.remove(self.pkgList) # create new package list - self.pkgList = self.createPkgList(store.get_value(it,0)) + self.pkgList = self.create_pkg_list(store.get_value(it,0)) self.scroll_2.add(self.pkgList) self.scroll_2.show_all() return False - def cbRowActivated (self, view, path, col, store = None): + def cb_row_activated (self, view, path, col, store = None): """Callback for an activated row in the pkgList. Opens a package window.""" if view == self.pkgList: package = store.get_value(store.get_iter(path), 0) @@ -361,7 +361,7 @@ class MainWindow: PackageWindow(self.window, cat+"/"+name, queue = None, version = vers+"-"+rev) return True - def createCatList (self): + def create_cat_list (self): """Creates the category list.""" store = gtk.ListStore(str) @@ -375,14 +375,14 @@ class MainWindow: cell = gtk.CellRendererText() col = gtk.TreeViewColumn("Categories", cell, text = 0) view.append_column(col) - view.connect("cursor-changed", self.cbCatListSelection) - view.connect("row-activated", lambda v,p,c : self.cbCatListSelection(v)) + view.connect("cursor-changed", self.cb_cat_list_selection) + view.connect("row-activated", lambda v,p,c : self.cb_cat_list_selection(v)) view.set_search_column(0) return view packages = {} # directory category -> [packages] - def createPkgList (self, name = None): + def create_pkg_list (self, name = None): """Creates the package list. Gets the name of the category.""" self.selCatName = name # actual category @@ -408,11 +408,11 @@ class MainWindow: cell = gtk.CellRendererText() col = gtk.TreeViewColumn("Packages", cell, text = 0) pkgList.append_column(col) - pkgList.connect("row-activated", self.cbRowActivated, store) + pkgList.connect("row-activated", self.cb_row_activated, store) return pkgList - def cbRemoveClicked (self, button, data = None): + def cb_remove_clicked (self, button, data = None): selected = self.emergeView.get_selection() if selected: @@ -422,7 +422,7 @@ class MainWindow: if model.iter_n_children(iter) > 0: # and has children which can be removed :) askMB = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, "Do you really want to clear the whole queue?") if askMB.run() == gtk.RESPONSE_YES : - self.queue.removeAll(iter) + self.queue.remove_all(iter) askMB.destroy() elif model.iter_parent(model.iter_parent(iter)): # this is in the 3rd level => dependency infoMB = gtk.MessageDialog(self.window, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "You cannot remove dependencies. :)") @@ -433,14 +433,22 @@ class MainWindow: return True + def cb_emerge_clicked (self, button, data = None): + if button == self.emergeBtn: + self.queue.emerge(force=True) + elif button == self.unmergeBtn: + self.queue.unmerge(force=True) + + return True + def __init__ (self): """Build up window""" # window self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) - self.window.set_title("Genetic") - self.window.connect("delete_event", self.cbDelete) - self.window.connect("destroy", self.cbDestroy) + self.window.set_title("Genetic/One") + self.window.connect("delete_event", self.cb_delete) + self.window.connect("destroy", self.cb_destroy) self.window.set_border_width(2) self.window.set_geometry_hints (self.window, min_width = 600, min_height = 700, max_height = gtk.gdk.screen_height(), max_width = gtk.gdk.screen_width()) self.window.set_resizable(True) @@ -450,7 +458,7 @@ class MainWindow: self.window.add(vb) # menubar - menubar = self.createMainMenu() + menubar = self.create_main_menu() vb.pack_start(menubar, False) # VPaned holding the lists and the Terminal @@ -473,11 +481,11 @@ class MainWindow: hb.pack_start(self.scroll_2, True, True) # create cat List - self.catList = self.createCatList() + self.catList = self.create_cat_list() self.scroll_1.add(self.catList) # create pkg list - self.pkgList = self.createPkgList() + self.pkgList = self.create_pkg_list() self.scroll_2.add(self.pkgList) # queue list @@ -489,21 +497,21 @@ class MainWindow: cell = gtk.CellRendererText() col = gtk.TreeViewColumn("Queue", cell, text = 0) self.emergeView.append_column(col) - self.emergeView.connect("row-activated", self.cbRowActivated, emergeStore) + self.emergeView.connect("row-activated", self.cb_row_activated, emergeStore) queueVB.pack_start(self.emergeView, True, True) # buttons right unter the queue list buttonBox = gtk.HButtonBox() queueVB.pack_start(buttonBox, False) - emergeBtn = gtk.Button("_Emerge") - emergeBtn.connect("clicked", lambda a: self.queue.emerge(force=True)) - unmergeBtn = gtk.Button("_Unmerge") - unmergeBtn.connect("clicked", lambda a: self.queue.unmerge(force=True)) - removeBtn = gtk.Button("_Remove") - removeBtn.connect("clicked", self.cbRemoveClicked) - buttonBox.pack_start(emergeBtn) - buttonBox.pack_start(removeBtn) - buttonBox.pack_start(unmergeBtn) + self.emergeBtn = gtk.Button("_Emerge") + self.emergeBtn.connect("clicked", self.cb_emerge_clicked) + self.unmergeBtn = gtk.Button("_Unmerge") + self.unmergeBtn.connect("clicked", self.cb_emerge_clicked) + self.removeBtn = gtk.Button("_Remove") + self.removeBtn.connect("clicked", self.cb_remove_clicked) + buttonBox.pack_start(self.emergeBtn) + buttonBox.pack_start(self.removeBtn) + buttonBox.pack_start(self.unmergeBtn) # the terminal term = vte.Terminal() @@ -529,7 +537,7 @@ class MainWindow: """Main.""" gtk.main() -def blockedDialog (blocked, blocks): +def blocked_dialog (blocked, blocks): dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, blocked+" is blocked by "+blocks+".\nPlease unmerge the blocking package.") dialog.run() dialog.destroy() |