diff options
Diffstat (limited to '')
-rw-r--r-- | portato/gui/windows/main.py | 86 |
1 files changed, 73 insertions, 13 deletions
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py index ca88b04..3c868e8 100644 --- a/portato/gui/windows/main.py +++ b/portato/gui/windows/main.py @@ -3,7 +3,7 @@ # File: portato/gui/windows/main.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -29,7 +29,8 @@ from ... import get_listener from ...helper import debug, warning, error, info from ...session import Session from ...db import Database -from ...constants import CONFIG_LOCATION, VERSION, APP_ICON +from ...db.database import UnsupportedSearchTypeError +from ...constants import CONFIG_LOCATION, VERSION, APP_ICON, ICON_DIR from ...backend.exceptions import PackageNotFoundException, BlockedException, VersionsNotFoundException # plugin stuff @@ -434,18 +435,27 @@ class MainWindow (Window): self.window.set_geometry_hints (self.window, max_height = gtk.gdk.screen_height(), max_width = gtk.gdk.screen_width()) # app icon - self.window.set_icon_from_file(APP_ICON) - gtk.window_set_default_icon(self.window.get_icon()) + gtk.window_set_default_icon_from_file(APP_ICON) # booleans self.doUpdate = False self.showAll = True # show only installed or all packages? self.__searchChanged = False + # our own icon factory + fac = gtk.IconFactory() + iSet = gtk.IconSet() + iSource = gtk.IconSource() + iSource.set_filename(os.path.abspath(os.path.join(ICON_DIR, "better-package.svg"))) + iSet.add_source(iSource) + fac.add("portato-better-pkg", iSet) + fac.add_default() + # icons self.icons = {} self.icons["installed"] = self.window.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) self.icons["or"] = self.window.render_icon(gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU) + self.icons["better"] = self.window.render_icon("portato-better-pkg", gtk.ICON_SIZE_MENU) # get the logging window as soon as possible self.logView = LogView(self.tree.get_widget("logView")) @@ -556,6 +566,10 @@ class MainWindow (Window): splash(_("Finishing startup")) + # depends on session + self.typeCombo = self.tree.get_widget("typeCombo") + self.build_type_combo() + self.window.show_all() def show_package (self, pkg = None, cpv = None, cp = None, version = None, **kwargs): @@ -782,10 +796,14 @@ class MainWindow (Window): if not packages: raise VersionsNotFoundException(cp) + best = system.find_best_match(cp) + # append versions for vers, inst, slot in ((x.get_version(), x.is_installed(), get_slot(x)) for x in packages): if inst: icon = self.icons["installed"] + elif best is not None and vers == best.get_version(): + icon = self.icons["better"] else: icon = None @@ -871,6 +889,26 @@ class MainWindow (Window): else: # no selCatName -> so no category selected --> ignore debug("No category selected --> should be no harm.") + def build_type_combo (self): + model = gtk.ListStore(int, str) + for k,v in self.db.TYPES.iteritems(): + model.append((k,v)) + + self.typeCombo.set_model(model) + cell = gtk.CellRendererText() + self.typeCombo.pack_start(cell) + self.typeCombo.set_attributes(cell, text = 1) + + + for i, (k, v) in enumerate(model): + if k == self.db.type: break + + self.typeCombo.set_active(i) + + types = self.db.search_types() + if types == 1 or types % 2 == 0: + self.typeCombo.set_sensitive(False) + def load_session(self, sessionEx = None, defaults_only = False): """ Loads the session data. @@ -987,6 +1025,14 @@ class MainWindow (Window): return _save + # SEARCH TYPE + def load_search_type (t): + t = int(t) + try: + self.db.type = t + except UnsupportedSearchTypeError: + info("Cannot set search type. '%s' not supported by database '%s'.", t, self.db.__class__.__name__) + # SESSION VERSION def load_session_version (version): @@ -1015,7 +1061,8 @@ class MainWindow (Window): (["width", "height"], lambda w,h: self.window.resize(int(w), int(h)), self.window.get_size), (["vpanedpos", "hpanedpos"], load_paned, save_paned), (["catsel"], load_cat_selection, save_cat_selection, ["app-portage@0"]), - (["pkgsel"], load_pkg_selection, save_pkg_selection, ["portato@0"]) + (["pkgsel"], load_pkg_selection, save_pkg_selection, ["portato@0"]), + (["searchtype"], load_search_type, lambda: self.db.type) #([("merge", "queue"), ("unmerge", "queue"), ("oneshot", "queue")], load_queue, save_queue), ]) @@ -1023,7 +1070,7 @@ class MainWindow (Window): queue = plugin.get_plugin_queue() if queue: for p in queue.get_plugins(): - self.session.add_handler(([(p.name.replace(" ","_"), "plugins")], load_plugin(p), save_plugin(p))) + self.session.add_handler(([(p.name.replace(" ","_").replace(":","_"), "plugins")], load_plugin(p), save_plugin(p))) # the other things def load_cfg ((name, cat)): @@ -1387,8 +1434,8 @@ class MainWindow (Window): """Execute the current queue.""" if len(flags.newUseFlags) > 0: - if not self.session.get_boolean("useflags", "dialogs"): - self.session.set("useflags", dialogs.changed_flags_dialog(_("use flags"))[1], "dialogs") + if not self.session.get_bool("useflags", "dialogs"): + self.session.set("useflags", str(dialogs.changed_flags_dialog(_("use flags"))[1]), "dialogs") try: flags.write_use_flags() except IOError, e: @@ -1399,8 +1446,8 @@ class MainWindow (Window): debug("new masked: %s",flags.new_masked) debug("new unmasked: %s", flags.new_unmasked) debug("new testing: %s", flags.newTesting) - if not self.session.get_boolean("keywords", "dialogs"): - self.session.set("keywords", dialogs.changed_flags_dialog(_("masking keywords"))[1], "dialogs") + if not self.session.get_bool("keywords", "dialogs"): + self.session.set("keywords", str(dialogs.changed_flags_dialog(_("masking keywords"))[1]), "dialogs") try: flags.write_masked() flags.write_testing() @@ -1464,8 +1511,15 @@ class MainWindow (Window): gobject.idle_add(cb_idle_append, updating) finally: self.window.window.set_cursor(None) - - GtkThread(name="Update-Thread", target=__update).start() + + # for some reason, I have to create the thread before displaying the dialog + # else the GUI hangs + t = GtkThread(name="Update-Thread", target=__update) + + if not self.session.get_bool("update_world_warning", "dialogs"): + self.session.set("update_world_warning", str(dialogs.update_world_warning_dialog()[1]), "dialogs") + + t.start() return True @@ -1562,7 +1616,13 @@ class MainWindow (Window): return False # not again ;) - gobject.timeout_add(100, __update) + gobject.timeout_add(200, __update) + + def cb_type_combo_changed (self, *args): + model = self.typeCombo.get_model() + active = self.typeCombo.get_active() + + self.db.type = model[active][0] def cb_delete_search_clicked (self, *args): self.searchEntry.set_text("") |