forked from reox/FreeCAD_gitproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InitGui.py
63 lines (50 loc) · 1.43 KB
/
InitGui.py
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
54
55
56
57
58
59
60
61
62
63
# (c) Sebastian Bachmann <[email protected]>, 2017
class GitProjectWorkbench (Workbench):
"""
Git Project Workbench
"""
MenuText = "git project"
ToolTip = "git project workbench"
Icon = '''
/* XPM */
static char * git_xpm[] = {
"16 16 2 1",
" c None",
"! c #F05033",
" !! ",
" !!!! ",
" !!!! ",
" !! !!!! ",
" !!!! !!!! ",
" !!!!! !!!! ",
" !!!!!!! !!!! ",
"!!!!!!!! ! !!!!",
"!!!!!!!! ! !!!!",
" !!!!!!! !!!!!! ",
" !!!!! !!!!! ",
" !!!! !!!! ",
" !!!! !!! ",
" !!!!!! ",
" !!!! ",
" !! "};
'''
def __init__(self):
# Monkey patch the save function, so we can hook it
z = Gui.SendMsgToActiveView
from GitWrapper import commitchanges
def hookedSaveFunction(*args, **kwargs):
res = z(*args, **kwargs)
# We like to hook after the save was done
if "Save" in args:
Msg("save pressed\n")
commitchanges()
return res
Gui.SendMsgToActiveView = hookedSaveFunction
def Initialize(self):
import GitWrapper
cmds = ["GitProject_CommandCommit", "GitProject_CommandTag", "GitProject_CommandCreate"]
self.appendToolbar("git project", cmds)
self.appendMenu("git project", cmds)
def GetClassName(self):
return "Gui::PythonWorkbench"
Gui.addWorkbench(GitProjectWorkbench())