summaryrefslogtreecommitdiffstats
path: root/g-ed-it
diff options
context:
space:
mode:
authorMatthieu Gautier <mgautier@fedoraproject.org>2009-04-05 23:03:35 +0200
committerMatthieu Gautier <mgautier@fedoraproject.org>2009-04-05 23:03:35 +0200
commit958e374655d4920b648b43ee0f6f03921b678495 (patch)
tree5778b98830c3bf01457e9f0becac6ecd1af7971e /g-ed-it
parentbec3ba59a76c90e3364e6dd2abe794ebb8441d97 (diff)
downloadg-ed-it-958e374655d4920b648b43ee0f6f03921b678495.zip
g-ed-it-958e374655d4920b648b43ee0f6f03921b678495.tar.gz
g-ed-it-958e374655d4920b648b43ee0f6f03921b678495.tar.xz
Refactoring code.
* Create windowHelper * Create gitAction.py to handle all (almost) git actions * Split docBar into docHelper and docBar * Fix a bug when gedit is launch with the '&' * Change g-ed-it.glade in git_windows.glade Signed-off-by: Matthieu Gautier <mgautier@fedoraproject.org>
Diffstat (limited to 'g-ed-it')
-rw-r--r--g-ed-it/__init__.py17
-rw-r--r--g-ed-it/commitDialog.py44
-rw-r--r--g-ed-it/docBar.py152
-rw-r--r--g-ed-it/docHelper.py60
-rw-r--r--g-ed-it/g_ed_it.py115
-rw-r--r--g-ed-it/gitAction.py43
-rw-r--r--g-ed-it/git_windows.glade (renamed from g-ed-it/g-ed-it.glade)0
-rw-r--r--g-ed-it/menuManager.py33
-rw-r--r--g-ed-it/windowHelper.py113
9 files changed, 283 insertions, 294 deletions
diff --git a/g-ed-it/__init__.py b/g-ed-it/__init__.py
index 870eb32..1b23b98 100644
--- a/g-ed-it/__init__.py
+++ b/g-ed-it/__init__.py
@@ -3,18 +3,25 @@ import gedit
import os
import os.path
-import g_ed_it
+import windowHelper
+import gitAction
class G_ed_it(gedit.Plugin):
def __init__(self):
gedit.Plugin.__init__(self)
- self.instances = {}
+ self.windowHelpers = {}
+ self.gitAction = gitAction.GitAction(self)
def activate(self, window):
- self.instances[window] = g_ed_it.G_ed_itHelper(self, window)
+ self.windowHelpers[window] = windowHelper.WindowHelper(self, window, self.gitAction)
def deactivate(self, window):
- self.instances[window].deactivate()
+ self.windowHelpers[window].deactivate()
def update_ui(self, window):
- self.instances[window].update_ui()
+ self.windowHelpers[window].update_ui()
+
+ def fast_update_ui(self):
+ for windowHelper in self.windowHelpers :
+ self.windowHelpers[windowHelper].fast_update_ui()
+
diff --git a/g-ed-it/commitDialog.py b/g-ed-it/commitDialog.py
index bd1906a..0bc2007 100644
--- a/g-ed-it/commitDialog.py
+++ b/g-ed-it/commitDialog.py
@@ -2,21 +2,21 @@
#-*- coding:utf-8 -*-
import os
+import time
import subprocess
class CommitDialog (object):
- def __init__(self,window,glade_xml):
- self.window = window
+ def __init__(self,glade_xml,plugin):
self.glade_xml = glade_xml
self.load_dialog()
+ self.plugin = plugin
pass
def load_dialog(self):
self.commit_dialog = self.glade_xml.get_widget("commit_dialog")
self.commit_dialog.hide()
- self.commit_dialog.set_transient_for(self.window)
- self.commit_dialog.connect("delete_event", self.commit_dialog.hide_on_delete)
+ self.commit_dialog.connect("delete_event", self.on_cancel_button_clicked)
self.commit_button = self.glade_xml.get_widget("commit_button")
self.commit_button.connect("clicked", self.on_commit_button_clicked)
@@ -27,33 +27,33 @@ class CommitDialog (object):
self.commit_text_box = self.glade_xml.get_widget("commit_text")
self.commit_text_box.connect("insert-at-cursor", self.on_commit_text_changed)
+ def run(self,window,fileURI, allFile):
+ self.commit_dialog.set_transient_for(window)
+ self.cwd = os.path.dirname(fileURI)
+ if allFile:
+ self.fileName = None
+ templateMsg = subprocess.Popen(["git-status","-s"],stdout=subprocess.PIPE,cwd=self.cwd).communicate()[0]
+ else:
+ self.fileName = os.path.basename(fileURI)
+ templateMsg = subprocess.Popen(["git-status","-s",self.fileName],stdout=subprocess.PIPE,cwd=self.cwd).communicate()[0]
+ self.commit_text_box.get_buffer().set_text(templateMsg)
+ self.commit_dialog.show()
+
def on_cancel_button_clicked(self, close_button):
self.commit_dialog.hide()
def on_commit_button_clicked(self, close_button):
commit_text_buffer = self.commit_text_box.get_buffer()
- subprocess.call(["git-commit","-m'"+commit_text_buffer.get_text(commit_text_buffer.get_start_iter(),commit_text_buffer.get_end_iter())+"'"],cwd=self.cwd)
- if self.call_obj :
- self.call_obj.getDocState()
- print "callback"
+ commit_text = commit_text_buffer.get_text(commit_text_buffer.get_start_iter(),commit_text_buffer.get_end_iter())
+ if self.fileName :
+ subprocess.call(["git-commit","-m'"+commit_text+"'", self.fileName],stdout=subprocess.PIPE,cwd=self.cwd)
+ else:
+ subprocess.call(["git-commit","-m'"+commit_text+"'"],stdout=subprocess.PIPE,cwd=self.cwd)
commit_text_buffer.set_text("")
self.commit_dialog.hide()
+ self.plugin.fast_update_ui()
pass
def on_commit_text_changed(self, commit_text_entry):
pass
-
- def show(self,fileName=None, call_obj=None):
- self.fileName = fileName
- self.call_obj = call_obj
- if self.fileName:
- self.cwd = os.path.dirname(fileName)
- templateMsg = subprocess.Popen(["git-status","-s",os.path.basename(fileName)],stdout=subprocess.PIPE,cwd=self.cwd).communicate()[0]
- else:
- self.cwd = os.path.dirname(self.window.get_active_document().get_uri_for_display())
- templateMsg = subprocess.Popen(["git-status","-s"],stdout=subprocess.PIPE,cwd=self.cwd).communicate()[0]
- self.commit_text_box.get_buffer().set_text(templateMsg)
- self.commit_dialog.show()
- print "dialog shown"
-
diff --git a/g-ed-it/docBar.py b/g-ed-it/docBar.py
index e7deb24..f92b804 100644
--- a/g-ed-it/docBar.py
+++ b/g-ed-it/docBar.py
@@ -3,41 +3,46 @@
import gedit
import gtk
-
import subprocess
import os
import os.path
class DocBar (object):
-
- def __init__(self, tab, commitDialog):
+ code2status = dict({None:'Identical',
+ 'A':'Added',
+ 'C':'Copied',
+ 'D':'Deleted',
+ 'M':'Modified',
+ 'R':'Renamed',
+ 'T':'Type changed',
+ 'U':'Unmerged',
+ 'X':'Unknown',
+ 'B':'pairing Broken'
+ })
+ def __init__(self, tab, gitAction, window, docHelper):
self.tab = tab
+ self.gitAction = gitAction
+ self.docHelper = docHelper
self.child = self.tab.get_children()[0]
self.tab.remove(self.child)
self.vbox = gtk.VBox()
- self.commitDialog = commitDialog
-
- self.doc = self.tab.get_document()
- self.update_handler1 = self.doc.connect("saved",self.doc_changed)
- self.update_handler2 = self.doc.connect("loaded",self.doc_changed)
-
self.docBar = gtk.HBox()
self.lbl_status = gtk.Label("√Čtat du fichier")
self.btn_add = gtk.Button("add")
- self.btn_add.connect("clicked", self.add_file)
+ self.btn_add.connect("clicked", self.gitAction.add, self.tab.get_document().get_uri_for_display)
self.btn_commit = gtk.Button("commit")
- self.btn_commit.connect("clicked", self.commit_file)
+ self.btn_commit.connect("clicked", self.gitAction.commit, window, self.tab.get_document().get_uri_for_display)
self.btn_diff_head_index = gtk.Button("diff HEAD/INDEX")
- self.btn_diff_head_index.connect("clicked", self.diff_head_index)
+ self.btn_diff_head_index.connect("clicked", self.gitAction.diff_head_index, self.tab.get_document().get_uri_for_display)
self.btn_diff_index_wt = gtk.Button("diff INDEX/WT")
- self.btn_diff_index_wt.connect("clicked", self.diff_index_wt)
+ self.btn_diff_index_wt.connect("clicked", self.gitAction.diff_index_wt, self.tab.get_document().get_uri_for_display)
self.docBar.pack_start(self.btn_diff_head_index, False, False)
self.docBar.pack_start(self.btn_diff_index_wt, False, False)
@@ -52,124 +57,33 @@ class DocBar (object):
self.tab.show_all()
- self.getDocState()
+ self.update_ui()
def deactivate(self):
self.tab.remove(self.vbox)
self.vbox.remove(self.child)
self.tab.add(self.child)
- self.doc.disconnect(self.update_handler1)
- self.doc.disconnect(self.update_handler2)
-
self.doc = None
self.vbox = None
self.child = None
self.tab = None
- def getDocState(self):
- uri = self.doc.get_uri_for_display()
- cwd = os.path.dirname(uri)
- bname = os.path.basename(uri)
-
- self.inGitDir = False
- self.iscached = False
- self.HEAD2index = None
- self.index2WT = None
-
- if not self.doc.is_untitled():
- subPro = subprocess.Popen(["git-ls-files",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=cwd)
- statusStr = subPro.communicate()[0]
- if subPro.returncode == 0 :
- self.inGitDir = True
- if statusStr != "":
- self.iscached = True
- statusStr = subprocess.Popen(["git-diff","--cached","--name-status",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=cwd).communicate()[0]
- if statusStr != "":
- status = statusStr[:-1].split()[0]
- self.HEAD2index = status
- statusStr = subprocess.Popen(["git-diff","--name-status",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=cwd).communicate()[0]
- if statusStr != "":
- status = statusStr[:-1].split()[0]
- self.index2WT = status
- self.setDocInfo()
- pass
-
- def setDocInfo(self):
- if not self.inGitDir :
+ def update_ui(self):
+ if not self.docHelper.inGitDir :
self.docBar.hide()
return
self.docBar.show()
- self.btn_add.set_sensitive(self.index2WT!=None)
- self.btn_commit.set_sensitive(self.HEAD2index!=None)
- self.btn_diff_head_index.set_sensitive(self.HEAD2index!=None)
- self.btn_diff_index_wt.set_sensitive(self.index2WT!=None)
- if not self.iscached :
- self.lbl_status.set_label("Not cached")
- self.btn_add.set_sensitive(True)
+ self.btn_add.set_sensitive(self.docHelper.index2WT!=None or not self.docHelper.isCached)
+ self.btn_commit.set_sensitive(self.docHelper.HEAD2index!=None)
+ self.btn_diff_head_index.set_sensitive(self.docHelper.HEAD2index!=None)
+ self.btn_diff_index_wt.set_sensitive(self.docHelper.index2WT!=None)
+ text = "HEAD <-"
+ text = text + DocBar.code2status[self.docHelper.HEAD2index]
+ text = text + "-> INDEX <-"
+ if self.docHelper.isCached :
+ text = text + DocBar.code2status[self.docHelper.index2WT]
else:
- text = "HEAD -- "
- if self.HEAD2index == "A":
- text = text + "Added"
- elif self.HEAD2index == "C":
- text = text + "Copied"
- elif self.HEAD2index == "D":
- text = text + "Deleted"
- elif self.HEAD2index == "M":
- text = text + "Modified"
- elif self.HEAD2index == "R":
- text = text + "Renamed"
- elif self.HEAD2index == "T":
- text = text + "Type changed"
- elif self.HEAD2index == "U":
- text = text + "Unmerged"
- elif self.HEAD2index == "X":
- text = text + "Unknown"
- elif self.HEAD2index == "B":
- text = text + "pairing Broken"
- text = text + " --> INDEX -- "
- if self.index2WT == "A":
- text = text + "Added"
- elif self.index2WT == "C":
- text = text + "Copied"
- elif self.index2WT == "D":
- text = text + "Deleted"
- elif self.index2WT == "M":
- text = text + "Modified"
- elif self.index2WT == "R":
- text = text + "Renamed"
- elif self.index2WT == "T":
- text = text + "Type changed"
- elif self.index2WT == "U":
- text = text + "Unmerged"
- elif self.index2WT == "X":
- text = text + "Unknown"
- elif self.index2WT == "B":
- text = text + "pairing Broken"
- text = text + " --> WT"
- self.lbl_status.set_label(text)
- pass
-
- def doc_changed(self,doc,arg1):
- self.getDocState()
-
- def add_file(self,button):
- uri = self.doc.get_uri_for_display()
- subprocess.call(["git-add",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=os.path.dirname(uri))
- self.getDocState()
- pass
-
- def commit_file(self,button):
- uri = self.doc.get_uri_for_display()
- self.commitDialog.show(uri,self)
- pass
-
- def diff_head_index(self,button):
- uri = self.doc.get_uri_for_display()
- subprocess.call(["git-diff","--cached",os.path.basename(uri)],cwd=os.path.dirname(uri))
- pass
-
- def diff_index_wt(self,button):
- uri = self.doc.get_uri_for_display()
- subprocess.call(["git-diff",os.path.basename(uri)],cwd=os.path.dirname(uri))
- pass
+ text = text + DocBar.code2status['A']
+ text = text + "-> WT"
+ self.lbl_status.set_label(text)
diff --git a/g-ed-it/docHelper.py b/g-ed-it/docHelper.py
new file mode 100644
index 0000000..45be438
--- /dev/null
+++ b/g-ed-it/docHelper.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+
+import os.path
+import subprocess
+
+import docBar
+
+class DocHelper (object):
+ def __init__(self, tab, window, gitAction):
+ self.doc = tab.get_document()
+ self.gitAction = gitAction
+ self.tab = tab
+ self.getDocState()
+
+ self.docBar = docBar.DocBar(tab,self.gitAction, window, self)
+
+ self.update_handler1 = self.doc.connect("saved",self.doc_changed)
+ self.update_handler2 = self.doc.connect("loaded",self.doc_changed)
+ pass
+
+ def deactivate(self):
+ self.doc.disconnect(self.update_handler1)
+ self.doc.disconnect(self.update_handler2)
+
+ def update_ui(self):
+ self.getDocState()
+ self.docBar.update_ui()
+
+ def doc_changed(self,doc,arg1):
+ self.getDocState()
+
+ def getDocState(self):
+ uri = self.doc.get_uri_for_display()
+ cwd = os.path.dirname(uri)
+ bname = os.path.basename(uri)
+
+ self.inGitDir = False
+ self.isCached = False
+ self.HEAD2index = None
+ self.index2WT = None
+
+ if not self.doc.is_untitled():
+ subPro = subprocess.Popen(["git-ls-files",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=cwd)
+ statusStr = subPro.communicate()[0]
+ if subPro.returncode == 0 :
+ self.inGitDir = True
+ if statusStr != "":
+ self.isCached = True
+ statusStr = subprocess.Popen(["git-diff","--cached","--name-status",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=cwd).communicate()[0]
+ if statusStr != "":
+ status = statusStr[:-1].split()[0]
+ self.HEAD2index = status
+ statusStr = subprocess.Popen(["git-diff","--name-status",os.path.basename(uri)],stdout=subprocess.PIPE,cwd=cwd).communicate()[0]
+ if statusStr != "":
+ status = statusStr[:-1].split()[0]
+ self.index2WT = status
+ pass
+
+
diff --git a/g-ed-it/g_ed_it.py b/g-ed-it/g_ed_it.py
deleted file mode 100644
index cda8154..0000000
--- a/g-ed-it/g_ed_it.py
+++ /dev/null
@@ -1,115 +0,0 @@
-import gedit
-
-import gtk
-import gtk.glade
-
-import gobject
-
-import os
-import time
-
-import menuManager
-import commitDialog
-import docBar
-
-GLADE_FILE = os.path.join(os.path.dirname(__file__), "g-ed-it.glade")
-
-class G_ed_itHelper:
- G_ED_IT_VIEW_DATA_KEY = "G-ed-itPluginTabData"
- G_ED_IT_WINDOW_DATA_KEY = "G-ed-itPluginWindowData"
-
- def __init__(self, plugin, window):
- self.window = window
- self.plugin = plugin
-
- self.createActionManager()
- self.glade_xml = gtk.glade.XML(GLADE_FILE)
-
- self.menuManager = menuManager.MenuManager(self.window)
-
- self.commitDialog = commitDialog.CommitDialog(self.window,self.glade_xml)
-
- self.setCallBack()
-
-
-
- # I hardly even know how this works, but it gets our encoding.
- try: self.encoding = gedit.encoding_get_current()
- except: self.encoding = gedit.gedit_encoding_get_current()
-
- def deactivate(self):
- self.menuManager.deactivate()
- self.manager.remove_action_group(self.action_group)
-
- handlers = self.window.get_data(self.G_ED_IT_WINDOW_DATA_KEY)
- for handler in handlers:
- self.window.disconnect(handler)
- self.window.set_data(self.G_ED_IT_WINDOW_DATA_KEY, None)
-
- for view in self.window.get_views():
- view.get_data(self.G_ED_IT_VIEW_DATA_KEY).deactivate()
-
- self.window = None
- self.plugin = None
-
- def update_ui(self):
- return
-
- def action_commit(self, window):
- self.commitDialog.show()
- pass
-
- def action_add(self, window):
- pass
-
- def createActionManager(self):
- self.manager = self.window.get_ui_manager()
-
-
- self.action_group = gtk.ActionGroup("GitPluginActions")
-
- self.git_menu_action = gtk.Action(name="GitMenu",
- label="Git",
- tooltip="Manage git",
- stock_id=None)
- self.commit_action = gtk.Action(name="Commit",
- label="Commit",
- tooltip="Commit current state",
- stock_id=gtk.STOCK_GO_UP)
- self.add_action = gtk.Action(name="Add",
- label="Add to index",
- tooltip="",
- stock_id=gtk.STOCK_ADD)
-
- self.commit_action.connect("activate", self.action_commit)
- self.add_action.connect("activate", self.action_add)
-
- self.action_group.add_action(self.git_menu_action)
- self.action_group.add_action(self.commit_action)
- self.action_group.add_action(self.add_action)
-
- # Add the action group.
- self.manager.insert_action_group(self.action_group, -1)
- pass
-
- def setCallBack(self):
- for view in self.window.get_views():
- tab = view
- while (tab.__class__ != gedit.Tab):
- tab = tab.get_parent()
- self.createDocBar(tab)
-
- added_hid = self.window.connect("tab-added",
- lambda w, t: self.createDocBar(t))
- removed_hid = self.window.connect("tab-removed",
- lambda w, t: self.removeDocBar(t))
- self.window.set_data(self.G_ED_IT_WINDOW_DATA_KEY, (added_hid, removed_hid))
- pass
-
- def createDocBar(self, tab):
- docBar_ = docBar.DocBar(tab,self.commitDialog)
- tab.get_view().set_data(self.G_ED_IT_VIEW_DATA_KEY, docBar_)
-
- def removeDocBar(self, tab):
- tab.get_view().get_data(self.G_ED_IT_VIEW_DATA_KEY).deactivate()
- tab.get_view().set_data(self.G_ED_IT_VIEW_DATA_KEY, None)
diff --git a/g-ed-it/gitAction.py b/g-ed-it/gitAction.py
new file mode 100644
index 0000000..e07eb97
--- /dev/null
+++ b/g-ed-it/gitAction.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+#-*- coding:utf-8 -*-
+
+import os.path
+import gtk
+import subprocess
+
+import commitDialog
+
+GLADE_FILE = os.path.join(os.path.dirname(__file__), "git_windows.glade")
+
+class GitAction (object):
+ def __init__(self,plugin):
+ self.glade_xml = gtk.glade.XML(GLADE_FILE)
+ self.commitDialog = commitDialog.CommitDialog(self.glade_xml,plugin)
+ self.plugin = plugin
+ pass
+
+ def commit(self,launcher,window,fileUriMethod = None):
+ if fileUriMethod :
+ fileUri = fileUriMethod()
+ allFile = False
+ else:
+ fileUri = window.get_active_document().get_uri_for_display()
+ allFile = True
+ self.commitDialog.run(window,fileUri,allFile)
+ pass
+
+ def add(self,launcher,fileUriMethod = None):
+ if fileUriMethod : fileUri = fileUriMethod()
+ subprocess.call(["git-add",os.path.basename(fileUri)],stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri))
+ self.plugin.fast_update_ui()
+ pass
+
+ def diff_head_index(self,launcher, fileUriMethod = None):
+ if fileUriMethod : fileUri = fileUriMethod()
+ subprocess.call(["git-diff","--cached",os.path.basename(fileUri)],stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri))
+ pass
+
+ def diff_index_wt(self, launcher, fileUriMethod = None):
+ if fileUriMethod : fileUri = fileUriMethod()
+ subprocess.call(["git-diff",os.path.basename(fileUri)],stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri))
+ pass
diff --git a/g-ed-it/g-ed-it.glade b/g-ed-it/git_windows.glade
index e550a5f..e550a5f 100644
--- a/g-ed-it/g-ed-it.glade
+++ b/g-ed-it/git_windows.glade
diff --git a/g-ed-it/menuManager.py b/g-ed-it/menuManager.py
deleted file mode 100644
index 70c4b38..0000000
--- a/g-ed-it/menuManager.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python
-#-*- coding:utf-8 -*-
-
-ui_string = """<ui>
- <menubar name="MenuBar">
- <placeholder name="ExtraMenu_1">
- <menu action="GitMenu">
- <menuitem action="Commit"/>
- <menuitem action="Add"/>
- </menu>
- </placeholder>
- </menubar>
-</ui>
-"""
-
-class MenuManager (object):
-
- def __init__(self, window):
- self.window = window
- self.ui_id = None
- self.insert_menu_item(window)
-
- def insert_menu_item(self, window):
- self.manager = self.window.get_ui_manager()
- self.ui_id = self.manager.add_ui_from_string(ui_string)
-
- def deactivate(self):
- self.manager.remove_ui(self.ui_id)
- self.manager.ensure_update()
-
- self.window = None
-
-
diff --git a/g-ed-it/windowHelper.py b/g-ed-it/windowHelper.py
new file mode 100644
index 0000000..9391b8f
--- /dev/null
+++ b/g-ed-it/windowHelper.py
@@ -0,0 +1,113 @@
+import gedit
+
+import gtk
+import gtk.glade
+
+import gobject
+
+import os
+import time
+
+import docHelper
+
+ui_string = """<ui>
+ <menubar name="MenuBar">
+ <placeholder name="ExtraMenu_1">
+ <menu action="GitMenu">
+ <menuitem action="Commit"/>
+ <menuitem action="Add"/>
+ </menu>
+ </placeholder>
+ </menubar>
+</ui>
+"""
+
+class WindowHelper:
+ def __init__(self, plugin, window, gitAction):
+ self.window = window
+ self.plugin = plugin
+ self.gitAction = gitAction
+
+ self.docHelpers = {}
+ self.create_all_docHelper()
+
+ self.create_actionManager()
+ # add menu
+ self.ui_id = self.manager.add_ui_from_string(ui_string)
+ self.set_call_back()
+
+
+ def deactivate(self):
+ self.manager.remove_ui(self.ui_id)
+ self.manager.remove_action_group(self.action_group)
+ self.manager.ensure_update()
+ self.manager = None
+
+ self.window.disconnect(self.added_hid)
+ self.window.disconnect(self.removed_hid)
+
+ for docHelper in self.docHelpers:
+ self.docHelpers[docHelper].deactivate()
+
+ self.window = None
+ self.plugin = None
+ self.gitAction = None
+
+ def update_ui(self):
+ for docHelper in self.docHelpers:
+ self.docHelpers[docHelper].update_ui()
+ return
+
+ def fast_update_ui(self):
+ self.docHelpers[self.window.get_active_document()].update_ui()
+
+ def create_actionManager(self):
+ self.manager = self.window.get_ui_manager()
+ self.action_group = gtk.ActionGroup("GitPluginActions")
+
+ self.git_menu_action = gtk.Action(name="GitMenu",
+ label="Git",
+ tooltip="Manage git",
+ stock_id=None)
+ self.commit_action = gtk.Action(name="Commit",
+ label="Commit",
+ tooltip="Commit current state",
+ stock_id=gtk.STOCK_GO_UP)
+ self.add_action = gtk.Action(name="Add",
+ label="Add to index",
+ tooltip="",
+ stock_id=gtk.STOCK_ADD)
+
+ self.commit_action.connect("activate", self.gitAction.commit, self.window)
+ self.add_action.connect("activate", self.gitAction.add)
+
+ self.action_group.add_action(self.git_menu_action)
+ self.action_group.add_action(self.commit_action)
+ self.action_group.add_action(self.add_action)
+
+ # Add the action group.
+ self.manager.insert_action_group(self.action_group, -1)
+ pass
+
+
+ def create_all_docHelper(self):
+ for view in self.window.get_views():
+ tab = view
+ while (tab.__class__ != gedit.Tab):
+ tab = tab.get_parent()
+ self.docHelpers[tab.get_document()] = docHelper.DocHelper(tab,self.window,self.gitAction)
+ pass
+
+ def set_call_back(self):
+ self.added_hid = self.window.connect("tab-added",self.on_tab_added)
+ self.removed_hid = self.window.connect("tab-removed",self.on_tab_removed)
+ pass
+
+ def on_tab_added(self,window,tab):
+ self.docHelpers[tab.get_document()] = docHelper.DocHelper(tab,self.window,self.gitAction)
+ pass
+
+ def on_tab_removed(self,window,tab):
+ self.docHelpers.pop(tab.get_document()).deactivate()
+ pass
+