21
from xml.sax.saxutils import unescape
23
# define additional entities for the nav button unescape, needed
24
# because only '&', '<', and '>' are included by default
25
ESCAPE_ENTITIES = {"'":"'",
21
28
# FIXME: sucks, move elsewhere
22
29
in_replay_history_mode = False
24
31
class NavigationHistory(object):
26
Class to manage navigation history in the "Get Software" section (the
33
class to manage navigation history in the "Get Software" section (the
108
113
# first part is special and kept in remove_all
109
114
self.available_pane.navigation_bar.remove_all()
110
115
for part in self.parts[1:]:
111
self.available_pane.navigation_bar.add_with_id(part.label, part.callback, part.id, do_callback=False, animate=False)
116
self.available_pane.navigation_bar.add_with_id(unescape(part.label, ESCAPE_ENTITIES),
112
121
self.parts[-1].activate()
113
122
in_replay_history_mode = False
126
details.append("\n%s" % type(self))
128
if self.apps_category:
129
category_name = self.apps_category.name
130
details.append(" apps_category.name: %s" % category_name)
131
subcategory_name = ""
132
if self.apps_subcategory:
133
subcategory_name = self.apps_subcategory.name
134
details.append(" apps_subcategory.name: %s" % subcategory_name)
135
details.append(" current_app: %s" % self.current_app)
136
details.append(" apps_search_term: %s" % self.apps_search_term)
137
return '\n'.join(details)
115
139
class CategoryViewNavigationItem(NavigationItem):
117
141
navigation item that corresponds to the main category view
142
Note: all subclasses of NavigationItem are for debug use only and
143
can be collapsed to the NavigationItem class if desired
121
return "* CategoryViewNavigationItem"
123
146
class AppListNavigationItem(NavigationItem):
125
148
navigation item that corresponds to the application list for the
126
149
specified category
150
Note: all subclasses of NavigationItem are for debug use only and
151
can be collapsed to the NavigationItem class if desired
131
details.append("* AppListNavigationItem")
133
details.append(" apps_category.name: %s" % self.apps_category.name)
135
if (self.apps_subcategory):
136
details.append(" apps_subcategory.name: %s" % self.apps_category.name)
138
details.append(" apps_subcategory.name: none")
140
details.append(" apps_search_term: %s" % self.apps_search_term)
141
return ''.join(details)
143
154
class AppListSubcategoryNavigationItem(NavigationItem):
145
156
navigation item that corresponds to the application list for the
146
157
specified category and subcategory
158
Note: all subclasses of NavigationItem are for debug use only and
159
can be collapsed to the NavigationItem class if desired
151
details.append("* AppListSubcategoryNavigationItem")
153
details.append(" apps_category.name: %s" % self.apps_category.name)
155
if (self.apps_subcategory):
156
details.append(" apps_subcategory.name: %s" % self.apps_subcategory.name)
158
details.append(" apps_subcategory.name: none")
160
details.append(" apps_search_term: %s" % self.apps_search_term)
161
return ''.join(details)
163
162
class AppDetailsNavigationItem(NavigationItem):
165
164
navigation item that corresponds to the details view for the
166
165
specified application
166
Note: all subclasses of NavigationItem are for debug use only and
167
can be collapsed to the NavigationItem class if desired
170
details.append("* AppDetailsNavigationItem")
172
details.append(" apps_category.name: %s" % self.apps_category.name)
174
if (self.apps_subcategory):
175
details.append(" apps_subcategory.name: %s" % self.apps_category.name)
177
details.append(" apps_subcategory.name: none")
179
details.append(" current_app: %s" % self.current_app)
180
return ''.join(details)
182
# TODO: remove this class if not needed
183
170
class SearchNavigationItem(NavigationItem):
185
172
navigation item that corresponds to a search in progress
173
Note: all subclasses of NavigationItem are for debug use only and
174
can be collapsed to the NavigationItem class if desired