File: project_view.py

package info (click to toggle)
gnat-gps 18-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,716 kB
  • sloc: ada: 362,679; python: 31,031; xml: 9,597; makefile: 1,030; ansic: 917; sh: 264; java: 17
file content (21 lines) | stat: -rw-r--r-- 571 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# This script changes the label of the project view and set it to the current
# project file path. Upon a project changed, the title is properly updated.

from GPS import Project, MDI, Timeout, Hook


def update_project_view_title(t):
    new_name = Project.root().file().name()
    new_short_name = Project.root().name()
    view = MDI.get("Project View")

    if view is not None:
        view.rename(new_name, new_short_name)
        t.remove()


def on_project_changed(h):
    Timeout(100, update_project_view_title)


Hook("project_changed").add(on_project_changed)