From fe6fa5a4ac78c2f45a92f84afd55faad7b7cbbdc Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 29 Apr 2009 22:36:46 +0200 Subject: '# On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: g-ed-it/gitAction.py # Use git-difftool instead of git-diff. - Force tool to be meld. - No special config in git have to set - meld become a prerequisite' --- g-ed-it/gitAction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/g-ed-it/gitAction.py b/g-ed-it/gitAction.py index afcc954..bf4670d 100644 --- a/g-ed-it/gitAction.py +++ b/g-ed-it/gitAction.py @@ -51,10 +51,10 @@ class GitAction (object): 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)) + subprocess.call(["git-difftool","--tool=meld","--no-prompt","--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)) + subprocess.call(["git-difftool","--tool=meld","--no-prompt",os.path.basename(fileUri)],stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri)) pass -- cgit From 634bf949864e0185e27538a52505252d2b61962b Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 30 Apr 2009 23:16:26 +0200 Subject: Fixing subprocess call --- g-ed-it/commitDialog.py | 10 +++++----- g-ed-it/gitAction.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/g-ed-it/commitDialog.py b/g-ed-it/commitDialog.py index 683e888..4144b8e 100644 --- a/g-ed-it/commitDialog.py +++ b/g-ed-it/commitDialog.py @@ -49,11 +49,11 @@ class CommitDialog (object): 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] +# 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) +# templateMsg = subprocess.Popen(["git-status","-s",self.fileName],stdout=subprocess.PIPE,cwd=self.cwd).communicate()[0] + self.commit_text_box.get_buffer().set_text("") self.commit_dialog.show() def on_cancel_button_clicked(self, close_button): @@ -63,9 +63,9 @@ class CommitDialog (object): commit_text_buffer = self.commit_text_box.get_buffer() 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) + subprocess.call('git-commit -m "'+commit_text+'" '+self.fileName,stdout=subprocess.PIPE,cwd=self.cwd, shell=True) else: - subprocess.call(["git-commit","-m'"+commit_text+"'"],stdout=subprocess.PIPE,cwd=self.cwd) + subprocess.call('git-commit -m "'+commit_text+'"',stdout=subprocess.PIPE,cwd=self.cwd, shell=True) commit_text_buffer.set_text("") self.commit_dialog.hide() self.plugin.fast_update_ui() diff --git a/g-ed-it/gitAction.py b/g-ed-it/gitAction.py index bf4670d..f25706c 100644 --- a/g-ed-it/gitAction.py +++ b/g-ed-it/gitAction.py @@ -45,16 +45,16 @@ class GitAction (object): 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)) + subprocess.call("git-add "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) self.plugin.fast_update_ui() pass def diff_head_index(self,launcher, fileUriMethod = None): if fileUriMethod : fileUri = fileUriMethod() - subprocess.call(["git-difftool","--tool=meld","--no-prompt","--cached",os.path.basename(fileUri)],stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri)) + subprocess.call("git-difftool --tool=meld --no-prompt --cached "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) pass def diff_index_wt(self, launcher, fileUriMethod = None): if fileUriMethod : fileUri = fileUriMethod() - subprocess.call(["git-difftool","--tool=meld","--no-prompt",os.path.basename(fileUri)],stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri)) + subprocess.call("git-difftool --tool=meld --no-prompt "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) pass -- cgit From b9ec0c418594803394bd16bc015e0c2970606e86 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 30 Apr 2009 23:19:08 +0200 Subject: Revert to git-diff. git-difftool is not yet present in the current version of git (Fedora). Use a git-difftool will be recommit when next git update. --- g-ed-it/gitAction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/g-ed-it/gitAction.py b/g-ed-it/gitAction.py index f25706c..47bd68e 100644 --- a/g-ed-it/gitAction.py +++ b/g-ed-it/gitAction.py @@ -51,10 +51,10 @@ class GitAction (object): def diff_head_index(self,launcher, fileUriMethod = None): if fileUriMethod : fileUri = fileUriMethod() - subprocess.call("git-difftool --tool=meld --no-prompt --cached "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) + subprocess.call("git-diff --cached "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) pass def diff_index_wt(self, launcher, fileUriMethod = None): if fileUriMethod : fileUri = fileUriMethod() - subprocess.call("git-difftool --tool=meld --no-prompt "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) + subprocess.call("git-diff "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) pass -- cgit From d74a31da487bcff192cbc99e238bc2c989dcc4d3 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Thu, 30 Apr 2009 23:43:51 +0200 Subject: Fix (and simplify) adding of the docBar. --- g-ed-it/docBar.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/g-ed-it/docBar.py b/g-ed-it/docBar.py index 9d019c1..e87a5c5 100644 --- a/g-ed-it/docBar.py +++ b/g-ed-it/docBar.py @@ -41,9 +41,6 @@ class DocBar (object): 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.docBar = gtk.HBox() @@ -67,23 +64,16 @@ class DocBar (object): self.docBar.pack_start(self.btn_add, False, False) self.docBar.pack_start(self.btn_commit, False, False) - self.vbox.pack_start(self.docBar, False, False) - self.vbox.pack_start(self.child) - - self.tab.add(self.vbox) + self.tab.pack_start(self.docBar, False, False) self.tab.show_all() self.update_ui() def deactivate(self): - self.tab.remove(self.vbox) - self.vbox.remove(self.child) - self.tab.add(self.child) + self.tab.remove(self.docBar) - self.doc = None - self.vbox = None - self.child = None + self.docBar = None self.tab = None def update_ui(self): -- cgit From bcbc657178824d2f88a1080d77a0d54eb8fc0534 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Sun, 3 May 2009 21:53:10 +0200 Subject: Add a commit text to the docBar. - If the commit text is empty, its content is used as commit message. - If not, the commit dialog box is shown. --- g-ed-it/docBar.py | 15 ++++++++++++--- g-ed-it/gitAction.py | 12 ++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/g-ed-it/docBar.py b/g-ed-it/docBar.py index e87a5c5..990c850 100644 --- a/g-ed-it/docBar.py +++ b/g-ed-it/docBar.py @@ -46,11 +46,13 @@ class DocBar (object): self.lbl_status = gtk.Label("État du fichier") + self.commit_text = gtk.Entry() + self.btn_add = gtk.Button("add") 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.gitAction.commit, window, self.tab.get_document().get_uri_for_display) + self.btn_commit.connect("clicked", self.gitAction.commit, window, self.tab.get_document().get_uri_for_display,self.get_and_clear_commitText) self.btn_diff_head_index = gtk.Button("diff HEAD/INDEX") self.btn_diff_head_index.connect("clicked", self.gitAction.diff_head_index, self.tab.get_document().get_uri_for_display) @@ -60,9 +62,10 @@ class DocBar (object): self.docBar.pack_start(self.btn_diff_head_index, False, False) self.docBar.pack_start(self.btn_diff_index_wt, False, False) - self.docBar.pack_start(self.lbl_status, True, False) - self.docBar.pack_start(self.btn_add, False, False) + self.docBar.pack_start(self.lbl_status, True, True) + self.docBar.pack_start(self.commit_text, True, True) self.docBar.pack_start(self.btn_commit, False, False) + self.docBar.pack_start(self.btn_add, False, False) self.tab.pack_start(self.docBar, False, False) @@ -70,6 +73,11 @@ class DocBar (object): self.update_ui() + def get_and_clear_commitText(self): + text = self.commit_text.get_text() + self.commit_text.set_text("") + return text + def deactivate(self): self.tab.remove(self.docBar) @@ -83,6 +91,7 @@ class DocBar (object): self.docBar.show() self.btn_add.set_sensitive(self.docHelper.index2WT!=None or not self.docHelper.isCached) self.btn_commit.set_sensitive(self.docHelper.HEAD2index!=None) + self.commit_text.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 <-" diff --git a/g-ed-it/gitAction.py b/g-ed-it/gitAction.py index 47bd68e..28460f8 100644 --- a/g-ed-it/gitAction.py +++ b/g-ed-it/gitAction.py @@ -33,14 +33,22 @@ class GitAction (object): self.plugin = plugin pass - def commit(self,launcher,window,fileUriMethod = None): + def commit(self,launcher,window,fileUriMethod = None, commitTextMethod = 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) + if commitTextMethod: + text = commitTextMethod() + if text != "": + subprocess.call('git-commit -m "'+text+'" '+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) + self.plugin.fast_update_ui() + else: + self.commitDialog.run(window,fileUri,allFile) + else: + self.commitDialog.run(window,fileUri,allFile) pass def add(self,launcher,fileUriMethod = None): -- cgit From 84f3c1a56d3de4b22688adcdb4773ed2a94a59b9 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Sun, 3 May 2009 22:07:17 +0200 Subject: Remove management of the docBar in the docHelper --- g-ed-it/docHelper.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/g-ed-it/docHelper.py b/g-ed-it/docHelper.py index dcd2c29..e44ab2f 100644 --- a/g-ed-it/docHelper.py +++ b/g-ed-it/docHelper.py @@ -29,9 +29,7 @@ class DocHelper (object): 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 @@ -39,11 +37,9 @@ class DocHelper (object): def deactivate(self): self.doc.disconnect(self.update_handler1) self.doc.disconnect(self.update_handler2) - self.docBar.deactivate() def update_ui(self): self.getDocState() - self.docBar.update_ui() def doc_changed(self,doc,arg1): self.getDocState() -- cgit From 37e613ff2b5b71228d158a3e8455d80f3b019622 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Sun, 3 May 2009 22:49:02 +0200 Subject: switch to an unique docBar --- g-ed-it/docBar.py | 73 +++++++++++++++++++++++++++++++++---------------- g-ed-it/docHelper.py | 9 ++++-- g-ed-it/windowHelper.py | 6 ++++ 3 files changed, 62 insertions(+), 26 deletions(-) diff --git a/g-ed-it/docBar.py b/g-ed-it/docBar.py index 990c850..a3d1712 100644 --- a/g-ed-it/docBar.py +++ b/g-ed-it/docBar.py @@ -22,6 +22,8 @@ import gedit import gtk import subprocess +import docHelper + import os import os.path @@ -37,28 +39,35 @@ class DocBar (object): 'X':'Unknown', 'B':'pairing Broken' }) - def __init__(self, tab, gitAction, window, docHelper): - self.tab = tab + def __init__(self, gitAction, window): self.gitAction = gitAction - self.docHelper = docHelper + self.window = window - self.docBar = gtk.HBox() + self.currentTab = None + self.create_docBar() + + self.swap_to_currentTab(window.get_active_tab()) + + self.window.connect("active-tab-changed",self.active_tab_changed) + self.window.connect("active-tab-state-changed",self.active_tab_state_changed) + def create_docBar(self): + self.docBar = gtk.HBox() self.lbl_status = gtk.Label("État du fichier") self.commit_text = gtk.Entry() self.btn_add = gtk.Button("add") - self.btn_add.connect("clicked", self.gitAction.add, self.tab.get_document().get_uri_for_display) + self.btn_add.connect("clicked", self.gitAction.add) self.btn_commit = gtk.Button("commit") - self.btn_commit.connect("clicked", self.gitAction.commit, window, self.tab.get_document().get_uri_for_display,self.get_and_clear_commitText) + self.btn_commit.connect("clicked", self.gitAction.commit, self.window,self.get_and_clear_commitText) self.btn_diff_head_index = gtk.Button("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_head_index.connect("clicked", self.gitAction.diff_head_index) self.btn_diff_index_wt = gtk.Button("diff INDEX/WT") - self.btn_diff_index_wt.connect("clicked", self.gitAction.diff_index_wt, self.tab.get_document().get_uri_for_display) + self.btn_diff_index_wt.connect("clicked", self.gitAction.diff_index_wt) self.docBar.pack_start(self.btn_diff_head_index, False, False) self.docBar.pack_start(self.btn_diff_index_wt, False, False) @@ -67,11 +76,22 @@ class DocBar (object): self.docBar.pack_start(self.btn_commit, False, False) self.docBar.pack_start(self.btn_add, False, False) - self.tab.pack_start(self.docBar, False, False) - - self.tab.show_all() + def active_tab_changed(self,window,tab): + print "tab_change" + self.swap_to_currentTab(tab) + + def active_tab_state_changed(self,window): + print "tab_state_changed" + self.update_docBar_ui() - self.update_ui() + def swap_to_currentTab(self, tab): + if self.currentTab: + self.currentTab.remove(self.docBar) + self.currentTab = tab + if self.currentTab: + self.currentTab.pack_start(self.docBar, False, False) + self.currentTab.show_all() + self.update_docBar_ui() def get_and_clear_commitText(self): text = self.commit_text.get_text() @@ -79,26 +99,31 @@ class DocBar (object): return text def deactivate(self): - self.tab.remove(self.docBar) + if self.currentTab: + self.currentTab.remove(self.docBar) self.docBar = None - self.tab = None + self.currentTab = None - def update_ui(self): - if not self.docHelper.inGitDir : + def update_docBar_ui(self): + if not self.currentTab: + return + _docHelper = self.currentTab.get_data(docHelper.DocHelper.KEY) + if not _docHelper or not _docHelper.inGitDir : self.docBar.hide() return + self.docBar.show() - self.btn_add.set_sensitive(self.docHelper.index2WT!=None or not self.docHelper.isCached) - self.btn_commit.set_sensitive(self.docHelper.HEAD2index!=None) - self.commit_text.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) + self.btn_add.set_sensitive(_docHelper.index2WT!=None or not _docHelper.isCached) + self.btn_commit.set_sensitive(_docHelper.HEAD2index!=None) + self.commit_text.set_sensitive(_docHelper.HEAD2index!=None) + self.btn_diff_head_index.set_sensitive(_docHelper.HEAD2index!=None) + self.btn_diff_index_wt.set_sensitive(_docHelper.index2WT!=None) text = "HEAD <-" - text = text + DocBar.code2status[self.docHelper.HEAD2index] + text = text + DocBar.code2status[_docHelper.HEAD2index] text = text + "-> INDEX <-" - if self.docHelper.isCached : - text = text + DocBar.code2status[self.docHelper.index2WT] + if _docHelper.isCached : + text = text + DocBar.code2status[_docHelper.index2WT] else: text = text + DocBar.code2status['A'] text = text + "-> WT" diff --git a/g-ed-it/docHelper.py b/g-ed-it/docHelper.py index e44ab2f..043be86 100644 --- a/g-ed-it/docHelper.py +++ b/g-ed-it/docHelper.py @@ -21,15 +21,19 @@ import os.path import subprocess -import docBar + class DocHelper (object): + KEY = "G-ED-IT_DOCHELPER_KEY" def __init__(self, tab, window, gitAction): self.doc = tab.get_document() self.gitAction = gitAction self.tab = tab + + self.tab.set_data(self.KEY,self) + self.getDocState() - + self.update_handler1 = self.doc.connect("saved",self.doc_changed) self.update_handler2 = self.doc.connect("loaded",self.doc_changed) pass @@ -37,6 +41,7 @@ class DocHelper (object): def deactivate(self): self.doc.disconnect(self.update_handler1) self.doc.disconnect(self.update_handler2) + self.tab.set_data(self.KEY,self) def update_ui(self): self.getDocState() diff --git a/g-ed-it/windowHelper.py b/g-ed-it/windowHelper.py index b45d911..4cf4d3c 100644 --- a/g-ed-it/windowHelper.py +++ b/g-ed-it/windowHelper.py @@ -29,6 +29,7 @@ import os import time import docHelper +import docBar ui_string = """ @@ -48,8 +49,11 @@ class WindowHelper: self.plugin = plugin self.gitAction = gitAction + self.docHelpers = {} self.create_all_docHelper() + + self.docBar = docBar.DocBar(self.gitAction,window) self.create_actionManager() # add menu @@ -63,6 +67,8 @@ class WindowHelper: self.manager.ensure_update() self.manager = None + self.docBar.deactivate() + self.window.disconnect(self.added_hid) self.window.disconnect(self.removed_hid) -- cgit From b720af68f07507c1149baeb5dfddb5057a29dcdc Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 4 May 2009 18:52:28 +0200 Subject: Solve unecessary call to update_ui() --- g-ed-it/docHelper.py | 11 ----------- g-ed-it/windowHelper.py | 2 -- 2 files changed, 13 deletions(-) diff --git a/g-ed-it/docHelper.py b/g-ed-it/docHelper.py index 043be86..cee5103 100644 --- a/g-ed-it/docHelper.py +++ b/g-ed-it/docHelper.py @@ -33,22 +33,11 @@ class DocHelper (object): self.tab.set_data(self.KEY,self) self.getDocState() - - 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) self.tab.set_data(self.KEY,self) - def update_ui(self): - self.getDocState() - - def doc_changed(self,doc,arg1): - self.getDocState() - def getDocState(self): uri = self.doc.get_uri_for_display() cwd = os.path.dirname(uri) diff --git a/g-ed-it/windowHelper.py b/g-ed-it/windowHelper.py index 4cf4d3c..68f417b 100644 --- a/g-ed-it/windowHelper.py +++ b/g-ed-it/windowHelper.py @@ -80,8 +80,6 @@ class WindowHelper: self.gitAction = None def update_ui(self): - for docHelper in self.docHelpers: - self.docHelpers[docHelper].update_ui() return def fast_update_ui(self): -- cgit From 445c9725f1198d1bcaeb640e85cba1b3175fbbd2 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 4 May 2009 18:53:45 +0200 Subject: Rewrite gitAction depending of modifications of the docBar --- g-ed-it/commitDialog.py | 2 -- g-ed-it/docBar.py | 15 +++++++++------ g-ed-it/gitAction.py | 32 +++++++++++++++----------------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/g-ed-it/commitDialog.py b/g-ed-it/commitDialog.py index 4144b8e..668a5c0 100644 --- a/g-ed-it/commitDialog.py +++ b/g-ed-it/commitDialog.py @@ -49,10 +49,8 @@ class CommitDialog (object): 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("") self.commit_dialog.show() diff --git a/g-ed-it/docBar.py b/g-ed-it/docBar.py index a3d1712..dcd40c3 100644 --- a/g-ed-it/docBar.py +++ b/g-ed-it/docBar.py @@ -58,16 +58,16 @@ class DocBar (object): self.commit_text = gtk.Entry() self.btn_add = gtk.Button("add") - self.btn_add.connect("clicked", self.gitAction.add) + self.btn_add.connect("clicked", self.gitAction.add, self.window) self.btn_commit = gtk.Button("commit") - self.btn_commit.connect("clicked", self.gitAction.commit, self.window,self.get_and_clear_commitText) + self.btn_commit.connect("clicked", self.gitAction.commit_current_file, self.window) self.btn_diff_head_index = gtk.Button("diff HEAD/INDEX") - self.btn_diff_head_index.connect("clicked", self.gitAction.diff_head_index) + self.btn_diff_head_index.connect("clicked", self.gitAction.diff_head_index, self.window) self.btn_diff_index_wt = gtk.Button("diff INDEX/WT") - self.btn_diff_index_wt.connect("clicked", self.gitAction.diff_index_wt) + self.btn_diff_index_wt.connect("clicked", self.gitAction.diff_index_wt, self.window) self.docBar.pack_start(self.btn_diff_head_index, False, False) self.docBar.pack_start(self.btn_diff_index_wt, False, False) @@ -109,10 +109,13 @@ class DocBar (object): if not self.currentTab: return _docHelper = self.currentTab.get_data(docHelper.DocHelper.KEY) - if not _docHelper or not _docHelper.inGitDir : + if not _docHelper : + self.docBar.hide() + return + _docHelper.getDocState() + if not _docHelper.inGitDir : self.docBar.hide() return - self.docBar.show() self.btn_add.set_sensitive(_docHelper.index2WT!=None or not _docHelper.isCached) self.btn_commit.set_sensitive(_docHelper.HEAD2index!=None) diff --git a/g-ed-it/gitAction.py b/g-ed-it/gitAction.py index 28460f8..1f48d51 100644 --- a/g-ed-it/gitAction.py +++ b/g-ed-it/gitAction.py @@ -33,36 +33,34 @@ class GitAction (object): self.plugin = plugin pass - def commit(self,launcher,window,fileUriMethod = None, commitTextMethod = None): - if fileUriMethod : - fileUri = fileUriMethod() - allFile = False - else: - fileUri = window.get_active_document().get_uri_for_display() - allFile = True + def commit(self, button, window): + fileUri = window.get_active_tab().get_document().get_uri_for_display() + self.commitDialog.run(window,fileUri,True) + + def commit_current_file(self, button, window, commitTextMethod = None): + fileUri = window.get_active_tab().get_document().get_uri_for_display() if commitTextMethod: text = commitTextMethod() if text != "": subprocess.call('git-commit -m "'+text+'" '+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) self.plugin.fast_update_ui() else: - self.commitDialog.run(window,fileUri,allFile) + self.commitDialog.run(window,fileUri,False) else: - self.commitDialog.run(window,fileUri,allFile) - pass + self.commitDialog.run(window,fileUri,False) - def add(self,launcher,fileUriMethod = None): - if fileUriMethod : fileUri = fileUriMethod() + def add(self, button, window): + fileUri = window.get_active_tab().get_document().get_uri_for_display() subprocess.call("git-add "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) - self.plugin.fast_update_ui() + window.emit("active-tab-state-changed") pass - def diff_head_index(self,launcher, fileUriMethod = None): - if fileUriMethod : fileUri = fileUriMethod() + def diff_head_index(self, button, window): + fileUri = window.get_active_tab().get_document().get_uri_for_display() subprocess.call("git-diff --cached "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) pass - def diff_index_wt(self, launcher, fileUriMethod = None): - if fileUriMethod : fileUri = fileUriMethod() + def diff_index_wt(self, button, window): + fileUri = window.get_active_tab().get_document().get_uri_for_display() subprocess.call("git-diff "+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) pass -- cgit From c0e1c23317d7f7c9cf8ddf86255e4a087027eb3e Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 4 May 2009 19:19:18 +0200 Subject: Fixing DocHelper.deactivate --- g-ed-it/docHelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/g-ed-it/docHelper.py b/g-ed-it/docHelper.py index cee5103..428344a 100644 --- a/g-ed-it/docHelper.py +++ b/g-ed-it/docHelper.py @@ -36,7 +36,7 @@ class DocHelper (object): pass def deactivate(self): - self.tab.set_data(self.KEY,self) + self.tab.set_data(self.KEY,None) def getDocState(self): uri = self.doc.get_uri_for_display() -- cgit From 5bc39fc9f68fe44a42f7fb4fd2a9845931337e49 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 4 May 2009 19:20:21 +0200 Subject: Adapt commit with docBar commit text to the new docBar --- g-ed-it/docBar.py | 5 ----- g-ed-it/gitAction.py | 14 ++++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/g-ed-it/docBar.py b/g-ed-it/docBar.py index dcd40c3..29d2027 100644 --- a/g-ed-it/docBar.py +++ b/g-ed-it/docBar.py @@ -93,11 +93,6 @@ class DocBar (object): self.currentTab.show_all() self.update_docBar_ui() - def get_and_clear_commitText(self): - text = self.commit_text.get_text() - self.commit_text.set_text("") - return text - def deactivate(self): if self.currentTab: self.currentTab.remove(self.docBar) diff --git a/g-ed-it/gitAction.py b/g-ed-it/gitAction.py index 1f48d51..fa51551 100644 --- a/g-ed-it/gitAction.py +++ b/g-ed-it/gitAction.py @@ -37,15 +37,13 @@ class GitAction (object): fileUri = window.get_active_tab().get_document().get_uri_for_display() self.commitDialog.run(window,fileUri,True) - def commit_current_file(self, button, window, commitTextMethod = None): + def commit_current_file(self, button, window): fileUri = window.get_active_tab().get_document().get_uri_for_display() - if commitTextMethod: - text = commitTextMethod() - if text != "": - subprocess.call('git-commit -m "'+text+'" '+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) - self.plugin.fast_update_ui() - else: - self.commitDialog.run(window,fileUri,False) + text = self.plugin.windowHelpers[window].docBar.commit_text.get_text() + self.plugin.windowHelpers[window].docBar.commit_text.set_text("") + if text != "": + subprocess.call('git-commit -m "'+text+'" '+os.path.basename(fileUri),stdout=subprocess.PIPE,cwd=os.path.dirname(fileUri), shell=True) + window.emit("active-tab-state-changed") else: self.commitDialog.run(window,fileUri,False) -- cgit