Commit 2901fc552e634240a857b2e028d87ce1b14666a5

Improved prev/next notification handling~

Commit diff

gmail-sentinel.py

 
6161
6262 self.popup.add_action("open", "Open", self.__open_link)
6363 if len(alist) > 1:
64 self.popup.add_action("previous", "Previous", self.__prev_msg)
65 self.popup.add_action("next", "Next", self.__next_msg)
66
67 def __prev_msg (self, notification, action):
68 """Updates the notification with the next available msg """
69 if self.counter == 0:
70 self.popup.set_timeout(self.timeout)
71 self.show()
72 else:
73 self.counter -= 1
64 self.popup.add_action("previous", "Previous", self.__change_msg)
65 self.popup.add_action("next", "Next", self.__change_msg)
66
67 def __change_msg (self, notification, action):
68 """Updates the notification with the next/previous available msg """
69 addend = {'previous' : -1, 'next' : 1}
70 next = self.counter + addend[action]
71 if next >= 0 and next < len(self.data):
72 self.counter = next
7473 self.popup.update(self.popup.get_property('summary'),
7574 self.__format_msg(self.data[self.counter]))
76 self.popup.set_timeout(self.timeout)
77 self.popup.show()
78
79 def __next_msg (self, notification, action):
80 """ """
81 if self.counter == len(self.data)-1:
82 self.popup.set_timeout(self.timeout)
83 self.show()
84 else:
85 self.counter += 1
86 self.popup.update(self.popup.get_property('summary'),
87 self.__format_msg(self.data[self.counter]))
88 self.popup.set_timeout(self.timeout)
89 self.popup.show()
75 self.popup.set_timeout(self.timeout)
76 self.popup.show()
9077
9178 def __format_msg (self, data):
9279 """Formats DATA using the class attribute template """
toggle raw diff