Paging and other bugs in Sources.List

Moderators: Gully, peteru

Post Reply
prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Paging and other bugs in Sources.List

Post by prl » Wed Mar 01, 2017 12:34

I've been looking at pagination in Screens.About.AboutBase with the aim of getting rid of the ugly native key bindings.

The LEFT/RIGHT buttons are by default correctly bound to pageDown/pageUp in the native bindings for the screen's Renderer's eListbox instance.

The native key rebindings bind DOWN/UP to pageDown/pageUp in the eListbox.

I wanted to change that so that DOWN/UP were instead bound to the source's Sources.List.pageDown()/pageUp(). That can be done easily, simply by raising the ActionMap's priority (lowering the prio parameter value).

However, Sources.List.pageDown()/pageUp() don't actually do the function implied by their names. They simply move the selection point down and up by 10 entries, no matter what the displayed page length is (19 lines in the case of the About screens), and unlike the native pageDown/pageUp in eListbox, the "page"Up/Down in Sources.List wrap around when they are asked to "page" off the top or bottom, unlike the pagination operations on eListbox. The pageDown()/pageUp() wraparound is also implemented whether the class's self.enableWraparound is True or not.

The methods should really have the same pagination behaviour as eListbox, and implement it by having methods that are finally executed by pageUp/pageDown operations on the eListBox.

That would mean adding pageUp()/pageDown() methods to List converters like Converters.StringList.

A further bug in Converters.List is that it has two separate attributes for storing the "selectionEnabled" state: self.__selectionEnabled, which is initialised in __init__() and returned in the self.selectionEnabled property getter, and self.__selection_enabled which is updated in setSelectionEnabled() (which is the self.selectionEnabled property setter).

That means that the self.selectionEnabled property will always return False, no matter what the actual selectionEnabled state is.

There also seems to be some dead code in Converters.StringList. It implements getIndex()/setIndex() and the index property twice, the second of each overriding the first.

To test the pagination bugs in the Sources.List code, make the changes below in Screens.About.py. They leave the key bindings in place for DOWN/UP, LEFT/RIGHT and add ActionMap key bindings for CH+/- that call the List.pageDown/pageUp() methods. When the changes are in place and MENU>Information>Devices shows more than one page of information, the first press of CH+ on entering the screen appears too do nothing, the second press pages. Further presses of CH+ will eventually result in wraparound. The number needed is determined by the length of the list.

Code: Select all

diff --git a/lib/python/Screens/About.py b/lib/python/Screens/About.py
index 89c0276..f13760f 100644
--- a/lib/python/Screens/About.py
+++ b/lib/python/Screens/About.py
@@ -30,10 +30,12 @@ class AboutBase(Screen):
 		self.setBindings()
 
 		self["actions"] = ActionMap(
-			["SetupActions", "ColorActions"],
+			["SetupActions", "DirectionActions"],
 			{
 				"cancel": self.close,
 				"ok": self.close,
+				"chplus": self.pageUp,
+				"chminus": self.pageDown,
 			})
 
 	@staticmethod
@@ -82,6 +84,14 @@ class AboutBase(Screen):
 		l[AboutBase.ENT_HEADINFOLABEL:AboutBase.ENT_HEADINFO + 1] = label, info
 		return tuple(l)
 
+	def pageUp(self):
+		if "list" in self:
+			self["list"].pageUp()
+
+	def pageDown(self):
+		if "list" in self:
+			self["list"].pageDown()
+
 	def setBindings(self):
 		actionMap = eActionMap.getInstance()
 		actionMap.unbindNativeKey("ListboxActions", eListbox.moveUp)
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

IanSav
Uber Wizard
Posts: 16846
Joined: Tue May 29, 2007 15:00
Location: Melbourne, Australia

Re: Paging and other bugs in Sources.List

Post by IanSav » Wed Mar 01, 2017 16:05

Hi Prl,

I don't know what the coders were on when they wrote some of this code. I hope it made them feel good because the code they wrote in some places is real cr*p. :P

Regards,
Ian.

User avatar
peteru
Uber Wizard
Posts: 9741
Joined: Tue Jun 12, 2007 23:06
Location: Sydney, Australia
Contact:

Re: Paging and other bugs in Sources.List

Post by peteru » Thu Mar 02, 2017 02:15

If you run git blame/history you can find out who was responsible. Chances are that you can ask them directly in the OpenViX forums. :twisted:

"Beauty lies in the hands of the beer holder."
Blog.

prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Paging and other bugs in Sources.List

Post by prl » Tue Mar 07, 2017 16:41

Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

prl
Wizard God
Posts: 32709
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Paging and other bugs in Sources.List

Post by prl » Wed Mar 08, 2017 11:42

Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Post Reply

Return to “Developers Community”