blob: 6b27b48d1c9dcf76f89a392f4cca621857e1f1e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import os
from gi.repository import GLib, Gtk
_manager = None
def get_recent_python_script_manager(xbel = None):
"""Provide the manager for the recently run Python scripts."""
global _manager
# As a first panel creation is forced by the Chrysalide core to register
# its final GType, xbel is not defined at the first call of this function.
# Thus relying on the definition of xbel is a better filter than relying
# on the existence of _manager.
#
# In that special initial case, result is None
if not(xbel is None):
assert(_manager is None)
_manager = Gtk.RecentManager(filename=xbel)
return _manager
def remember_python_script(filename):
"""Register a Python script into the recents list."""
uri = GLib.filename_to_uri(filename)
recent_data = Gtk.RecentData()
recent_data.app_name = 'Chrysalide Python plugin'
recent_data.app_exec = 'chrysalide'
recent_data.display_name = os.path.basename(filename)
recent_data.description = 'Python script run inside Chrysalide'
recent_data.mime_type = 'text/x-python'
manager = get_recent_python_script_manager()
manager.add_full(uri, recent_data)
def forget_python_script(filename):
"""Unregister a Python script from the recents list."""
uri = GLib.filename_to_uri(filename)
manager = get_recent_python_script_manager()
manager.remove_item(uri)
|