7037 GUI to cut last all but part of new Category Path
authorMichal Pryc <Michal.Pryc@Sun.Com>
Thu, 09 Apr 2009 21:23:22 +0100
changeset 1031 5c130cc07e44
parent 1030 2da88a296d1e
child 1032 ff3c6b09f430
7037 GUI to cut last all but part of new Category Path
src/gui/modules/cache.py
src/gui/modules/misc.py
src/packagemanager.py
src/updatemanager.py
--- a/src/gui/modules/cache.py	Thu Apr 09 13:14:37 2009 -0700
+++ b/src/gui/modules/cache.py	Thu Apr 09 21:23:22 2009 +0100
@@ -30,7 +30,7 @@
 import pkg.gui.enumerations as enumerations
 import pkg.gui.misc as gui_misc
 
-CACHE_VERSION=4
+CACHE_VERSION=5
 INDEX_HASH_LENGTH=41
 
 class CacheListStores:
--- a/src/gui/modules/misc.py	Thu Apr 09 13:14:37 2009 -0700
+++ b/src/gui/modules/misc.py	Thu Apr 09 21:23:22 2009 +0100
@@ -23,6 +23,11 @@
 # Use is subject to license terms.
 #
 
+SPECIAL_CATEGORIES = ["locale", "plugin"] # We should cut all, but last part of the
+                                          # new name scheme as part of fix for #7037.
+                                          # However we need to have an exception rule
+                                          # where we will cut all but three last parts.
+
 import os
 import sys
 try:
@@ -74,5 +79,33 @@
                         gnome.help_display('package-manager', link_id=id)
                 else:
                         gnome.help_display('package-manager')
-                        
 
+def get_pkg_name(pkg_name):
+        index = -1
+        try:
+                index = pkg_name.rindex("/")
+        except ValueError:
+                # Package Name without "/"
+                return pkg_name
+        pkg_name_bk = pkg_name
+        test_name = pkg_name[index:]
+        pkg_name = pkg_name[:index]
+        try:
+                index = pkg_name.rindex("/")
+        except ValueError:
+                # Package Name with only one "/"
+                return pkg_name_bk
+        if pkg_name[index:].strip("/") not in SPECIAL_CATEGORIES:
+                return test_name.strip("/")
+        else:
+                # The package name contains special category
+                converted_name = pkg_name[index:] + test_name
+                pkg_name = pkg_name[:index]
+                try:
+                        index = pkg_name.rindex("/")
+                except ValueError:
+                        # Only three parts "part1/special/part2"
+                        return pkg_name + converted_name
+                return pkg_name[index:].strip("/") + converted_name
+        return pkg_name_bk
+
--- a/src/packagemanager.py	Thu Apr 09 13:14:37 2009 -0700
+++ b/src/packagemanager.py	Thu Apr 09 21:23:22 2009 +0100
@@ -3156,6 +3156,7 @@
                         status_icon = None
                         category_icon = None
                         pkg_name = pkg.get_name()
+                        pkg_name = gui_misc.get_pkg_name(pkg_name)
                         pkg_stem = pkg.get_pkg_stem()
                         pkg_publisher = pkg.get_publisher()
                         pkg_state = enumerations.NOT_INSTALLED
--- a/src/updatemanager.py	Thu Apr 09 13:14:37 2009 -0700
+++ b/src/updatemanager.py	Thu Apr 09 21:23:22 2009 +0100
@@ -79,7 +79,7 @@
 UM_REBOOT,
 UM_LATEST_VER,
 UM_SIZE,
-UM_FMRI,
+UM_STEM,
 ) = range(8)
 
 #UPDATE STEPS
@@ -231,7 +231,7 @@
                         gtk.gdk.Pixbuf,           # UM_REBOOT
                         gobject.TYPE_STRING,      # UM_LATEST_VER
                         gobject.TYPE_STRING,      # UM_SIZE
-                        gobject.TYPE_STRING,      # UM_FMRI                        
+                        gobject.TYPE_STRING,      # UM_STEM                        
                         )
                 self.progress_stop_thread = False
                 self.initial_active = 0
@@ -676,7 +676,7 @@
                         gtk.gdk.Pixbuf,           # UM_REBOOT
                         gobject.TYPE_STRING,      # UM_LATEST_VER
                         gobject.TYPE_STRING,      # UM_SIZE
-                        gobject.TYPE_STRING,      # UM_FMRI                        
+                        gobject.TYPE_STRING,      # UM_STEM                        
                         )
 
                 image_obj = self.__get_image_obj_from_directory(self.__get_image_path())
@@ -708,10 +708,10 @@
                                 #        incState = _("Inc")
                                 #else:
                                 #        incState = "--"
-                                
+                                pkg_name = gui_misc.get_pkg_name(pkg.get_name())
                                 um_list.insert(count, [count, False, None,
-                                    pkg.get_name(), None, pkg.get_version(), None,
-                                    pkg.get_fmri()])
+                                    pkg_name, None, pkg.get_version(), None,
+                                    pkg.get_pkg_stem()])
                                 
                 if debug:
                         print _("count: %d") % count
@@ -869,7 +869,8 @@
                 '''This function is for handling package selection changes'''
                 model, itr = selection.get_selected()
                 if itr:                        
-                        fmri = model.get_value(itr, UM_NAME) 
+                        fmri = model.get_value(itr, UM_STEM)
+                        pkg_name =  model.get_value(itr, UM_NAME)
                         delta = time.time() - self.last_select_time
                         if delta < SELECTION_CHANGE_LIMIT:
                                 if self.selection_timer is not None:
@@ -887,28 +888,28 @@
                                 infobuffer.set_text("")
                                 textiter = infobuffer.get_end_iter()
                                 infobuffer.insert_with_tags_by_name(textiter,
-                                    "\n%s\n" % fmri, "bold")
+                                    "\n%s" % pkg_name, "bold")
                                 infobuffer.insert(textiter, self.details_cache[fmri])
                         else:
                                 infobuffer = self.w_um_textview.get_buffer()
                                 infobuffer.set_text(
-                                    _("\nFetching details for %s ...") % fmri)
+                                    _("\nFetching details for %s ...") % pkg_name)
                                 self.selection_timer = Timer(SELECTION_CHANGE_LIMIT,
                                     self.__show_package_info_thread,
-                                    args=(fmri, )).start()
+                                    args=(fmri, pkg_name )).start()
 
-        def __show_package_info_thread(self, fmri):
+        def __show_package_info_thread(self, fmri, pkg_name):
                 Thread(target = self.__show_package_info,
-                    args = (fmri, )).start()
+                    args = (fmri, pkg_name)).start()
 
-        def __show_package_info(self, fmri):
+        def __show_package_info(self, fmri, pkg_name):
                 details = self.__get_details_from_name(fmri)
                 if self.fmri_description == fmri and details != None:
                         infobuffer = self.w_um_textview.get_buffer()
                         infobuffer.set_text("")
                         textiter = infobuffer.get_end_iter()
                         infobuffer.insert_with_tags_by_name(textiter,
-                            "\n%s" % fmri, "bold")
+                            "\n%s" % pkg_name, "bold")
                         infobuffer.insert(textiter, details)
                 elif self.fmri_description == fmri and details == None:
                         infobuffer = self.w_um_textview.get_buffer()