diff options
Diffstat (limited to 'portato/gui')
-rw-r--r-- | portato/gui/gtk/exception_handling.py | 2 | ||||
-rw-r--r-- | portato/gui/gtk/windows.py | 38 | ||||
-rw-r--r-- | portato/gui/gui_helper.py | 25 | ||||
-rw-r--r-- | portato/gui/templates/portato.glade | 337 |
4 files changed, 362 insertions, 40 deletions
diff --git a/portato/gui/gtk/exception_handling.py b/portato/gui/gtk/exception_handling.py index 673dd7e..c44f554 100644 --- a/portato/gui/gtk/exception_handling.py +++ b/portato/gui/gtk/exception_handling.py @@ -70,7 +70,7 @@ class UncaughtExceptionDialog(gtk.MessageDialog): textbuffer = self.textview.get_buffer() self.text = get_trace(type, value, tb) if thread: - self.text = _("Exception in thread \"%(thread)s\":\n%(trace)s") % {"thread": thread, "trace": text} + self.text = _("Exception in thread \"%(thread)s\":\n%(trace)s") % {"thread": thread, "trace": self.text} textbuffer.set_text(self.text) self.textview.set_size_request(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/3) diff --git a/portato/gui/gtk/windows.py b/portato/gui/gtk/windows.py index 476411d..ff3c4d1 100644 --- a/portato/gui/gtk/windows.py +++ b/portato/gui/gtk/windows.py @@ -890,6 +890,7 @@ class MainWindow (Window): # booleans self.doUpdate = False + self.showAll = True # show only installed or all packages? # installed pixbuf self.instPixbuf = self.window.render_icon(gtk.STOCK_YES, gtk.ICON_SIZE_MENU) @@ -1024,17 +1025,26 @@ class MainWindow (Window): store = gtk.ListStore(str) - # build categories - for p in system.list_categories(): - store.append([p]) - # sort them alphabetically - store.set_sort_column_id(0, gtk.SORT_ASCENDING) - self.catList.set_model(store) cell = gtk.CellRendererText() col = gtk.TreeViewColumn(_("Categories"), cell, text = 0) self.catList.append_column(col) + self.fill_cat_store(store) + + def fill_cat_store (self, store): + + if self.showAll: + cats = system.list_categories() + else: + cats = self.db.get_installed_categories() + + for p in cats: + store.append([p]) + + # sort them alphabetically + store.set_sort_column_id(0, gtk.SORT_ASCENDING) + def build_pkg_list (self, name = None): """Builds the package list. @@ -1077,6 +1087,8 @@ class MainWindow (Window): for pkg, is_inst in self.db.get_cat(name, self.sortPkgListByName): if is_inst: icon = self.instPixbuf + elif not self.showAll: + continue # ignore not installed packages else: icon = None store.append([icon, pkg]) @@ -1324,6 +1336,20 @@ class MainWindow (Window): GtkThread(name="Show Updates Thread", target = __update).start() return True + def cb_show_installed_toggled (self, *args): + self.showAll = not self.showAll + + store = self.catList.get_model() + store.clear() + self.fill_cat_store(store) + + store = self.pkgList.get_model() + store.clear() + try: + self.fill_pkg_store(store, self.selCatName) + except AttributeError: # no selCatName -> so no category selected --> ignore + debug("AttributeError occured --> should be no harm.") + def cb_right_click (self, object, event): if event.button == 3: x = int(event.x) diff --git a/portato/gui/gui_helper.py b/portato/gui/gui_helper.py index ef7a508..0090c84 100644 --- a/portato/gui/gui_helper.py +++ b/portato/gui/gui_helper.py @@ -188,12 +188,14 @@ class Database: def __init__ (self): """Constructor.""" self._db = {} + self.inst_cats = set() def populate (self, category = None): """Populates the database. @param category: An optional category - so only packages of this category are inserted. - @type category: string""" + @type category: string + """ # get the lists packages = system.find_all_packages(name = category, withVersion = False) @@ -203,7 +205,11 @@ class Database: for p in packages: cat, pkg = p.split("/") if not cat in self._db: self._db[cat] = [] - self._db[cat].append((pkg, p in installed)) + inst = p in installed + self._db[cat].append((pkg, inst)) + + if inst: + self.inst_cats.add(cat) for key in self._db: # sort alphabetically self._db[key].sort(cmp=cmp, key=lambda x: x[0].lower()) @@ -216,7 +222,8 @@ class Database: @param byName: selects whether to return the list sorted by name or by installation @type byName: boolean @return: list of tuples: (name, is_installed) or [] - @rtype: (string, boolean)[]""" + @rtype: (string, boolean)[] + """ try: if byName: @@ -236,11 +243,21 @@ class Database: info(_("Catched KeyError => %s seems not to be an available category. Have you played with rsync-excludes?"), cat) return [] + def get_installed_categories (self): + """Returns all categories which have installed packages in them. + + @returns: the list of categories + @rtype: string[] + """ + + return list(self.inst_cats) + def reload (self, cat): """Reloads the given category. @param cat: category - @type cat: string""" + @type cat: string + """ del self._db[cat] self.populate(cat+"/") diff --git a/portato/gui/templates/portato.glade b/portato/gui/templates/portato.glade index a42bc25..ed33a7e 100644 --- a/portato/gui/templates/portato.glade +++ b/portato/gui/templates/portato.glade @@ -15,12 +15,13 @@ <widget class="GtkMenuBar" id="menubar"> <property name="visible">True</property> <child> - <widget class="GtkMenuItem" id="fileMenu"> + <widget class="GtkMenuItem" id="fileMenuItem"> <property name="visible">True</property> + <property name="submenu">fileMenu</property> <property name="label" translatable="yes">_File</property> <property name="use_underline">True</property> <child> - <widget class="GtkMenu" id="menu1"> + <widget class="GtkMenu" id="fileMenu"> <property name="visible">True</property> <child> <widget class="GtkImageMenuItem" id="prefItem"> @@ -76,12 +77,13 @@ </widget> </child> <child> - <widget class="GtkMenuItem" id="emergeMenu"> + <widget class="GtkMenuItem" id="emergeMenuItem"> <property name="visible">True</property> + <property name="submenu">emergeMenu</property> <property name="label" translatable="yes">_Emerge</property> <property name="use_underline">True</property> <child> - <widget class="GtkMenu" id="menu2"> + <widget class="GtkMenu" id="emergeMenu"> <property name="visible">True</property> <child> <widget class="GtkImageMenuItem" id="emergeItem"> @@ -130,6 +132,16 @@ </widget> </child> <child> + <widget class="GtkCheckMenuItem" id="showInstalledItem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Show Only _Installed Packages</property> + <property name="use_underline">True</property> + <signal name="toggled" handler="cb_show_installed_toggled"/> + <accelerator key="i" modifiers="GDK_CONTROL_MASK" signal="activate"/> + </widget> + </child> + <child> <widget class="GtkSeparatorMenuItem" id="separatormenuitem2"> <property name="visible">True</property> </widget> @@ -205,6 +217,7 @@ <widget class="GtkMenuItem" id="hiddenQueueMenu"> <property name="sensitive">False</property> <property name="no_show_all">True</property> + <property name="submenu">queuePopup</property> <property name="label" translatable="yes">_Queue</property> <property name="use_underline">True</property> <child> @@ -225,6 +238,7 @@ <widget class="GtkMenuItem" id="hiddenConsoleMenu"> <property name="sensitive">False</property> <property name="no_show_all">True</property> + <property name="submenu">consolePopup</property> <property name="label" translatable="yes">_Console</property> <property name="use_underline">True</property> <child> @@ -279,6 +293,7 @@ <child> <widget class="GtkMenuItem" id="pluginMenuItem"> <property name="no_show_all">True</property> + <property name="submenu">pluginMenu</property> <property name="label" translatable="yes">_Plugins</property> <property name="use_underline">True</property> <child> @@ -289,12 +304,13 @@ </widget> </child> <child> - <widget class="GtkMenuItem" id="helpMenu"> + <widget class="GtkMenuItem" id="helpMenuItem"> <property name="visible">True</property> + <property name="submenu">helpMenu</property> <property name="label" translatable="yes">_?</property> <property name="use_underline">True</property> <child> - <widget class="GtkMenu" id="menu3"> + <widget class="GtkMenu" id="helpMenu"> <property name="visible">True</property> <child> <widget class="GtkImageMenuItem" id="aboutItem"> @@ -387,7 +403,6 @@ <child> <widget class="GtkFrame" id="listFrame"> <property name="visible">True</property> - <property name="label_xalign">0</property> <property name="label_yalign">0</property> <property name="shadow_type">GTK_SHADOW_IN</property> <child> @@ -748,7 +763,6 @@ </child> </widget> <packing> - <property name="tab_expand">False</property> <property name="tab_fill">False</property> </packing> </child> @@ -759,7 +773,6 @@ </widget> <packing> <property name="type">tab</property> - <property name="tab_expand">False</property> <property name="tab_fill">False</property> </packing> </child> @@ -896,7 +909,6 @@ </widget> <packing> <property name="position">1</property> - <property name="tab_expand">False</property> </packing> </child> <child> @@ -908,7 +920,6 @@ <packing> <property name="type">tab</property> <property name="position">1</property> - <property name="tab_expand">False</property> <property name="tab_fill">False</property> </packing> </child> @@ -924,7 +935,6 @@ </widget> <packing> <property name="position">2</property> - <property name="tab_expand">False</property> </packing> </child> <child> @@ -936,7 +946,6 @@ <packing> <property name="type">tab</property> <property name="position">2</property> - <property name="tab_expand">False</property> <property name="tab_fill">False</property> </packing> </child> @@ -1087,7 +1096,6 @@ <child> <widget class="GtkFrame" id="generalFrame"> <property name="visible">True</property> - <property name="label_xalign">0</property> <child> <widget class="GtkAlignment" id="alignment1"> <property name="visible">True</property> @@ -1151,7 +1159,6 @@ <child> <widget class="GtkFrame" id="updateFrame"> <property name="visible">True</property> - <property name="label_xalign">0</property> <child> <widget class="GtkAlignment" id="alignment2"> <property name="visible">True</property> @@ -1204,7 +1211,6 @@ <child> <widget class="GtkFrame" id="syncFrame"> <property name="visible">True</property> - <property name="label_xalign">0</property> <child> <widget class="GtkAlignment" id="alignment5"> <property name="visible">True</property> @@ -1253,7 +1259,6 @@ <child> <widget class="GtkFrame" id="keywordFrame"> <property name="visible">True</property> - <property name="label_xalign">0</property> <child> <widget class="GtkAlignment" id="alignment3"> <property name="visible">True</property> @@ -1325,7 +1330,6 @@ <child> <widget class="GtkFrame" id="hintFrame"> <property name="visible">True</property> - <property name="label_xalign">0</property> <property name="shadow_type">GTK_SHADOW_OUT</property> <child> <widget class="GtkLabel" id="hintLabel"> @@ -1480,9 +1484,6 @@ </packing> </child> </widget> - <packing> - <property name="tab_expand">False</property> - </packing> </child> <child> <widget class="GtkLabel" id="label7"> @@ -1492,7 +1493,6 @@ </widget> <packing> <property name="type">tab</property> - <property name="tab_expand">False</property> <property name="tab_fill">False</property> </packing> </child> @@ -1601,7 +1601,6 @@ </widget> <packing> <property name="position">1</property> - <property name="tab_expand">False</property> </packing> </child> <child> @@ -1613,7 +1612,6 @@ <packing> <property name="type">tab</property> <property name="position">1</property> - <property name="tab_expand">False</property> <property name="tab_fill">False</property> </packing> </child> @@ -1668,6 +1666,288 @@ </widget> </child> </widget> + <widget class="GtkMenu" id="fileMenu"> + <property name="visible">True</property> + <child> + <widget class="GtkImageMenuItem" id="prefItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Preferences</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_preferences_clicked"/> + <accelerator key="P" modifiers="GDK_CONTROL_MASK" signal="activate"/> + <child internal-child="image"> + <widget class="GtkImage" id="image1"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="stock">gtk-preferences</property> + <property name="icon_size">1</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="reloadItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">Re_load Portage</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_reload_clicked"/> + <child internal-child="image"> + <widget class="GtkImage" id="image2"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="stock">gtk-refresh</property> + <property name="icon_size">1</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkSeparatorMenuItem" id="separatormenuitem1"> + <property name="visible">True</property> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="closeItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">gtk-quit</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + <signal name="activate" handler="cb_close"/> + </widget> + </child> + </widget> + <widget class="GtkMenu" id="emergeMenu"> + <property name="visible">True</property> + <child> + <widget class="GtkImageMenuItem" id="emergeItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">E_merge</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_emerge_clicked"/> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image9"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property> + <property name="stock">gtk-add</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="unmergeItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Unmerge</property> + <property name="use_underline">True</property> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image10"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property> + <property name="stock">gtk-remove</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkMenuItem" id="updateItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">Update _World</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_update_clicked"/> + </widget> + </child> + <child> + <widget class="GtkMenuItem" id="showUpdatesItem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Show Updatable P_ackages</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_show_updates_clicked"/> + </widget> + </child> + <child> + <widget class="GtkCheckMenuItem" id="showInstalledItem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Show Only _Installed Packages</property> + <property name="use_underline">True</property> + <signal name="toggled" handler="cb_show_installed_toggled"/> + <accelerator key="i" modifiers="GDK_CONTROL_MASK" signal="activate"/> + </widget> + </child> + <child> + <widget class="GtkSeparatorMenuItem" id="separatormenuitem2"> + <property name="visible">True</property> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="syncItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Sync</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_sync_clicked"/> + <accelerator key="S" modifiers="GDK_CONTROL_MASK" signal="activate"/> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image11"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property> + <property name="stock">gtk-refresh</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="saveFlagsItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">Save _Flags</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_save_flags_clicked"/> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image12"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property> + <property name="stock">gtk-save</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkSeparatorMenuItem" id="separatormenuitem3"> + <property name="visible">True</property> + </widget> + </child> + <child> + <widget class="GtkCheckMenuItem" id="pauseItemMenu"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Emerge _Paused</property> + <property name="use_underline">True</property> + <accelerator key="Z" modifiers="GDK_CONTROL_MASK" signal="activate"/> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="killItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Kill Emerge</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_kill_clicked"/> + <accelerator key="K" modifiers="GDK_CONTROL_MASK" signal="activate"/> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image13"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="stock">gtk-stop</property> + <property name="icon_size">1</property> + </widget> + </child> + </widget> + </child> + </widget> + <widget class="GtkMenu" id="queuePopup"> + <property name="visible">True</property> + <child> + <widget class="GtkMenuItem" id="oneShotItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">Oneshot</property> + <signal name="activate" handler="cb_oneshot_clicked"/> + </widget> + </child> + </widget> + <widget class="GtkMenu" id="consolePopup"> + <property name="visible">True</property> + <child> + <widget class="GtkImageMenuItem" id="copyItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Copy</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_copy_clicked"/> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image8"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="stock">gtk-copy</property> + <property name="icon_size">1</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="killItemPopup"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Kill Emerge</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_kill_clicked"/> + <child internal-child="image"> + <widget class="GtkImage" id="image25"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="stock">gtk-stop</property> + <property name="icon_size">1</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkCheckMenuItem" id="pauseItemPopup"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Emerge _Paused</property> + <property name="use_underline">True</property> + </widget> + </child> + </widget> + <widget class="GtkMenu" id="helpMenu"> + <property name="visible">True</property> + <child> + <widget class="GtkImageMenuItem" id="aboutItem"> + <property name="visible">True</property> + <property name="label" translatable="yes">_About</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_about_clicked"/> + <child internal-child="image"> + <widget class="GtkImage" id="image31"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="yalign">0</property> + <property name="stock">gtk-about</property> + <property name="icon_size">1</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkImageMenuItem" id="pluginsItem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">_Plugins</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_plugins_clicked"/> + <child internal-child="image"> + <widget class="GtkImage" id="menu-item-image14"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="stock">gtk-connect</property> + </widget> + </child> + </widget> + </child> + <child> + <widget class="GtkMenuItem" id="logItem"> + <property name="visible">True</property> + <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> + <property name="label" translatable="yes">Show _Log</property> + <property name="use_underline">True</property> + <signal name="activate" handler="cb_show_log_clicked"/> + </widget> + </child> + </widget> + <widget class="GtkMenu" id="pluginMenu"> + <property name="visible">True</property> + </widget> <widget class="GtkMenu" id="systrayPopup"> <property name="visible">True</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> @@ -1870,18 +2150,17 @@ <property name="skip_pager_hint">True</property> <property name="urgency_hint">True</property> <property name="has_separator">False</property> - <property name="name">Portato</property> <property name="copyright" translatable="yes">This software is licensed under the terms of the GPLv2. Copyright (C) 2006-2007 René 'Necoro' Neumann <necoro@necoro.net></property> <property name="comments" translatable="yes">A Portage GUI</property> <property name="website">http://portato.necoro.net</property> <property name="authors">René 'Necoro' Neumann -uses code from: Daniel J. Popowich + uses code from: Daniel J. Popowich -Many thanks to the Porthole team which often inspired me or gave me hints. -(And sometimes I even copied files ^^ ;)) -</property> + Many thanks to the Porthole team which often inspired me or gave me hints. + (And sometimes I even copied files ^^ ;)) + </property> <property name="artists">p4r4d0x (inspired by wolfden)</property> <signal name="response" handler="close"/> <child internal-child="vbox"> |