2 from PyQt4
import QtCore
, QtGui
3 from PyQt4
.QtCore
import SIGNAL
4 from PyQt4
.QtGui
import QDialog
5 from Window
import Ui_Window
6 from CommandDialog
import Ui_CommandDialog
7 from CommitBrowser
import Ui_CommitBrowser
8 from BranchDialog
import Ui_BranchDialog
9 from CreateBranchDialog
import Ui_CreateBranchDialog
11 from syntax
import GitSyntaxHighlighter
13 class GitView (Ui_Window
, QtGui
.QMainWindow
):
14 '''The main ugit interface.'''
15 def __init__ (self
, parent
=None):
16 QtGui
.QMainWindow
.__init
__ (self
, parent
)
17 Ui_Window
.__init
__ (self
)
19 self
.display_splitter
.setSizes ([ 300, 400 ])
20 GitSyntaxHighlighter (self
.displayText
.document())
22 class GitCommandDialog (Ui_CommandDialog
, QtGui
.QDialog
):
23 '''A simple dialog to display command output.'''
24 def __init__ (self
, parent
=None, output
=None):
25 QtGui
.QDialog
.__init
__ (self
, parent
)
26 Ui_CommandDialog
.__init
__ (self
)
28 if output
: self
.set_command (output
)
30 def set_command (self
, output
):
31 self
.commandText
.setText (output
)
33 class GitBranchDialog (Ui_BranchDialog
, QtGui
.QDialog
):
34 '''A dialog to display available branches.'''
35 def __init__ (self
, parent
=None, branches
=None):
36 QtGui
.QDialog
.__init
__ (self
, parent
)
37 Ui_BranchDialog
.__init
__ (self
)
40 if branches
: self
.addBranches (branches
)
46 def addBranches (self
, branches
):
47 for branch
in branches
:
48 self
.branches
.append (branch
)
49 self
.comboBox
.addItem (branch
)
51 def getSelectedBranch (self
):
53 if self
.exec_() == QDialog
.Accepted
:
54 return self
.branches
[ self
.comboBox
.currentIndex() ]
58 class GitCommitBrowser (Ui_CommitBrowser
, QtGui
.QDialog
):
59 '''A dialog to display commits in for selection.'''
60 def __init__ (self
, parent
=None):
61 QtGui
.QDialog
.__init
__ (self
, parent
)
62 Ui_CommitBrowser
.__init
__ (self
)
64 # Make the list widget slighty larger
65 self
.splitter
.setSizes ([ 50, 200 ])
66 GitSyntaxHighlighter (self
.commitText
.document())
68 class GitCreateBranchDialog (Ui_CreateBranchDialog
, QtGui
.QDialog
):
69 '''A dialog for creating or updating branches.'''
70 def __init__ (self
, parent
=None):
71 QtGui
.QDialog
.__init
__ (self
, parent
)
72 Ui_CreateBranchDialog
.__init
__ (self
)