Improve Email Experience: Make Gnome Evolution Focus Topmost Item in Mail List
Email clients are an essential tool for modern communication, and Gnome Evolution is one such client that offers a wide range of features for managing emails, calendars, and contacts. One common issue that users face is that the mail list does not always bring the last-viewed or the newest email into focus. In this article, we will discuss how to make Gnome Evolution focus on the topmost item in the mail list, ensuring a more seamless and focused email experience.
Understanding the Problem
When you are viewing a list of emails in Gnome Evolution, and you click on an email to read it, the mail list does not automatically bring the next email into focus when you go back to the mail list view. This can be frustrating, especially if you are trying to quickly go through a long list of emails. The same issue arises when a new email arrives; Gnome Evolution does not automatically bring the newest email into focus.
Making Gnome Evolution Focus on the Topmost Item
To make Gnome Evolution focus on the topmost item in the mail list, you can use a simple script that uses the Gnome Evolution API. The script listens for the "mail-view-read" signal, which is emitted when you read an email, and then scrolls the mail list to the topmost item.
The Script
Here's the script that you can use to make Gnome Evolution focus on the topmost item in the mail list:
#!/usr/bin/env python
import gi
gi.require\_version('Evolution', '3.0')
from gi.repository import Evolution, GObject
class FocusTopmostItem(GObject.GObject):
def __init__(self):
super().__init__()
self.mail\_view = None
self.mail\_list = None
@GObject.Signal
def topmost\_item\_focused(self):
pass
def on\_mail\_view\_realize(self, mail\_view):
self.mail\_view = mail\_view
self.mail\_list = self.mail\_view.get\_view()
self.mail\_list.connect('row-activated', self.on\_row\_activated)
def on\_row\_activated(self, mail\_list, path, column):
self.topmost\_item\_focused.emit()
GObject.type\_register(FocusTopmostItem)
GObject.signal\_new('topmost\_item\_focused',
FocusTopmostItem,
GObject.SignalFlags.RUN\_FIRST,
None, ())
if __name__ == '__main__':
focus\_topmost\_item = FocusTopmostItem()
focus\_topmost\_item.connect('topmost\_item\_focused', lambda *args: focus\_topmost\_item.mail\_list.scroll\_to\_row(0))
gtk.main()
To use this script, save it as a Python file (for example, focus\_topmost\_item.py), and then run it using the following command:
python3 focus\_topmost\_item.pyMaking Gnome Evolution Focus on the Newest Email
To make Gnome Evolution focus on the newest email, you can use a similar script that listens for the "mail-received" signal, which is emitted when a new email arrives. The script then scrolls the mail list to the newest email.
The Script
Here's the script that you can use to make Gnome Evolution focus on the newest email:
#!/usr/bin/env python
import gi
gi.require\_version('Evolution', '3.0')
from gi.repository import Evolution, GObject
class FocusNewestEmail(GObject.GObject):
def __init__(self):
super().__init__()
self.mail\_list = None
@GObject.Signal
def newest\_email\_focused(self):
pass
def on\_mail\_list\_row\_added(self, mail\_list, path, iter):
self.newest\_email\_focused.emit()
GObject.type\_register(FocusNewestEmail)
GObject.signal\_new('newest\_email\_focused',
FocusNewestEmail,
GObject.SignalFlags.RUN\_FIRST,
None, ())
if __name__ == '__main__':
focus\_newest\_email = FocusNewestEmail()
focus\_newest\_email.connect('newest\_email\_focused', lambda *args: focus\_newest\_email.mail\_list.scroll\_to\_row(len(focus\_newest\_email.mail\_list.get\_model()) - 1))
mail\_list = focus\_newest\_email.mail\_list = evolution\_data\_server.get\_default\_mail\_list()
mail\_list.connect('row-added', focus\_newest\_email.on\_mail\_list\_row\_added)
To use this script, save it as a Python file (for example, focus\_newest\_email.py), and then run it using the following command:
python3 focus\_newest\_email.pyBy making Gnome Evolution focus on the topmost item in the mail list, you can ensure a more focused email experience. The scripts provided in this article can help you achieve this, and they can be easily customized to meet your specific needs. Additionally, by making Gnome Evolution focus on the newest email, you can ensure that you never miss an important message.
References
- Gnome Evolution API: https://developer.gnome.org/evolution-data-server/stable/
- GObject Introspection: https://lazka.github.io/pgi-docs/
- Python GTK+ 3 Tutorial: https://python-gtk-3-tutorial.readthedocs.io/en/latest/