[PATCH] Deterministically sort categories on the hub.
Chris Lumens
clumens at redhat.com
Fri Jun 21 17:45:36 UTC 2013
We were just doing string comparisons, which were only the same across
languages because category names are marked with N_. Instead, give
categories a numeric value and sort on that.
I've preserved the current ordering on the hub with these new numbers.
---
pyanaconda/ui/gui/categories/__init__.py | 8 ++++++--
pyanaconda/ui/gui/categories/customization.py | 3 ++-
pyanaconda/ui/gui/categories/localization.py | 3 ++-
pyanaconda/ui/gui/categories/software.py | 3 ++-
pyanaconda/ui/gui/categories/storage.py | 3 ++-
pyanaconda/ui/gui/categories/user_settings.py | 5 +++--
pyanaconda/ui/gui/hubs/__init__.py | 2 +-
7 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/pyanaconda/ui/gui/categories/__init__.py b/pyanaconda/ui/gui/categories/__init__.py
index b5e5b4c..66bd5d4 100644
--- a/pyanaconda/ui/gui/categories/__init__.py
+++ b/pyanaconda/ui/gui/categories/__init__.py
@@ -1,6 +1,6 @@
# Base classes for spoke categories.
#
-# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011, 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
@@ -36,10 +36,14 @@ class SpokeCategory(object):
displayOnHub -- The Hub subclass to display this Category on. If
None, this Category will be skipped.
+ sortOrder -- A number indicating the order in which this Category
+ will be displayed. A lower number indicates display
+ higher up in the Hub.
title -- The title of this SpokeCategory, to be displayed above
the grid.
"""
displayOnHub = None
+ sortOrder = 1000
title = N_("DEFAULT TITLE")
def collect_categories(mask_paths):
@@ -49,5 +53,5 @@ def collect_categories(mask_paths):
categories = []
for mask, path in mask_paths:
categories.extend(collect(mask, path, lambda obj: getattr(obj, "displayOnHub", None) != None))
-
+
return categories
diff --git a/pyanaconda/ui/gui/categories/customization.py b/pyanaconda/ui/gui/categories/customization.py
index ebd1b51..be59dec 100644
--- a/pyanaconda/ui/gui/categories/customization.py
+++ b/pyanaconda/ui/gui/categories/customization.py
@@ -1,6 +1,6 @@
# Localization category classes
#
-# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011, 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
@@ -28,4 +28,5 @@ __all__ = ["CustomizationCategory"]
class CustomizationCategory(SpokeCategory):
displayOnHub = ProgressHub
+ sortOrder = 100
title = N_("CUSTOMIZATION")
diff --git a/pyanaconda/ui/gui/categories/localization.py b/pyanaconda/ui/gui/categories/localization.py
index 2e2f5a4..19a77ee 100644
--- a/pyanaconda/ui/gui/categories/localization.py
+++ b/pyanaconda/ui/gui/categories/localization.py
@@ -1,6 +1,6 @@
# Localization category classes
#
-# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011, 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
@@ -27,4 +27,5 @@ __all__ = ["LocalizationCategory"]
class LocalizationCategory(SpokeCategory):
displayOnHub = SummaryHub
+ sortOrder = 100
title = N_("LOCALIZATION")
diff --git a/pyanaconda/ui/gui/categories/software.py b/pyanaconda/ui/gui/categories/software.py
index 09f2fd7..843f736 100644
--- a/pyanaconda/ui/gui/categories/software.py
+++ b/pyanaconda/ui/gui/categories/software.py
@@ -1,6 +1,6 @@
# Software category classes
#
-# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011, 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
@@ -27,4 +27,5 @@ __all__ = ["SoftwareCategory"]
class SoftwareCategory(SpokeCategory):
displayOnHub = SummaryHub
+ sortOrder = 200
title = N_("SOFTWARE")
diff --git a/pyanaconda/ui/gui/categories/storage.py b/pyanaconda/ui/gui/categories/storage.py
index 696d7e2..bf24a0a 100644
--- a/pyanaconda/ui/gui/categories/storage.py
+++ b/pyanaconda/ui/gui/categories/storage.py
@@ -1,6 +1,6 @@
# Storage category classes
#
-# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011, 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
@@ -28,4 +28,5 @@ __all__ = ["StorageCategory"]
class StorageCategory(SpokeCategory):
displayOnHub = SummaryHub
+ sortOrder = 300
title = N_("STORAGE")
diff --git a/pyanaconda/ui/gui/categories/user_settings.py b/pyanaconda/ui/gui/categories/user_settings.py
index 6a64401..e025428 100644
--- a/pyanaconda/ui/gui/categories/user_settings.py
+++ b/pyanaconda/ui/gui/categories/user_settings.py
@@ -1,6 +1,6 @@
-# Localization category classes
+# User settings category classes
#
-# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011, 2013 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
@@ -28,4 +28,5 @@ __all__ = ["UserSettingsCategory"]
class UserSettingsCategory(SpokeCategory):
displayOnHub = ProgressHub
+ sortOrder = 200
title = N_("USER SETTINGS")
diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py
index 865fd80..4519e73 100644
--- a/pyanaconda/ui/gui/hubs/__init__.py
+++ b/pyanaconda/ui/gui/hubs/__init__.py
@@ -142,7 +142,7 @@ class Hub(GUIObject, common.Hub):
# Collect all the categories this hub displays, then collect all the
# spokes belonging to all those categories.
categories = sorted(filter(lambda c: c.displayOnHub == self.__class__, collect_categories(self.paths["categories"])),
- key=lambda c: c.title)
+ key=lambda c: c.sortOrder)
for c in categories:
ret[c] = collect_spokes(self.paths["spokes"], c.__name__)
--
1.8.1.2
More information about the anaconda-patches
mailing list