Merge lp:~laszlok/zeitgeist-datasources/trunk into lp:zeitgeist-datasources/0.8

Proposed by Laszlo Pandy
Status: Merged
Merged at revision: not available
Proposed branch: lp:~laszlok/zeitgeist-datasources/trunk
Merge into: lp:zeitgeist-datasources/0.8
Diff against target: 79 lines (+28/-22)
1 file modified
gedit/zeitgeist_plugin.py (+28/-22)
To merge this branch: bzr merge lp:~laszlok/zeitgeist-datasources/trunk
Reviewer Review Type Date Requested Status
Seif Lotfy Pending
Zeitgeist Framework Team Pending
Review via email: mp+17719@code.launchpad.net
To post a comment you must log in.
28. By Laszlo Pandy

OPEN and CLOSE events for rhythmbox.

29. By Laszlo Pandy

Catch 'eos' signal to determine if the user explicitly changed the song or not.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gedit/zeitgeist_plugin.py'
2--- gedit/zeitgeist_plugin.py 2009-11-25 22:24:13 +0000
3+++ gedit/zeitgeist_plugin.py 2010-01-20 07:05:24 +0000
4@@ -34,39 +34,46 @@
5 def __init__(self, plugin, window):
6 self._window = window
7 self._plugin = plugin
8- self.docs = self._window.get_documents()
9- self._handler = self._window.connect("tab-removed", self.TabRemovedHandler)
10- self._handler = self._window.connect("active-tab-changed", self.TabChangedHandler)
11- self._tabs = 0
12+ self._window.connect("tab-added", self.TabAddedHandler)
13+ self._window.connect("tab-removed", self.TabRemovedHandler)
14
15 def deactivate(self):
16- self._window.disconnect(self._handler)
17+ self._window.disconnect_by_func(self.TabAddedHandler)
18+ self._window.disconnect_by_func(self.TabRemovedHandler)
19 self._window = None
20 self._plugin = None
21- self._handler = None
22+
23+ def TabAddedHandler(self, window, tab):
24+ doc = tab.get_document()
25+ print "Zeitgeist: loaded new tab ", doc.get_uri()
26+
27+ """
28+ We don't send an OPEN_EVENT here because that will
29+ be done after the document's 'loaded' signal is emitted.
30+
31+ We do this because when if there are any empty tabs when
32+ the user opens a file, the new file will replace the empty
33+ tab, and the document's 'loaded' signal will fire, but no
34+ tab is added and therefore no 'tab-added' is fired.
35+ """
36+
37+ doc.connect("saved", self.SaveDocHandler)
38+ doc.connect("loaded", self.TabLoadedHandler)
39
40 def TabRemovedHandler(self, window, tab):
41 doc = tab.get_document()
42- print "tab removed", doc.get_uri()
43+ print "Zeitgeist: tab removed", doc.get_uri()
44+ doc.disconnect_by_func(self.SaveDocHandler)
45+ doc.disconnect_by_func(self.TabLoadedHandler)
46 self.SendToZeitgeist(doc, Interpretation.CLOSE_EVENT)
47- self.docs = self._window.get_documents()
48
49- def TabChangedHandler(self, window, tab):
50- doc = tab.get_document()
51- if self.docs.count(doc) == 0:
52- print "loaded new document ", doc.get_uri()
53- self.SendToZeitgeist(doc, Interpretation.OPEN_EVENT)
54- doc.connect("saved", self.SaveDocHandler)
55- else:
56- print "tab changed", doc.get_uri()
57- self.docs = self._window.get_documents()
58- print "***", self.docs
59+ def TabLoadedHandler(self, doc, data):
60+ print "Zeitgeist: tab loaded document", doc.get_uri()
61+ self.SendToZeitgeist(doc, Interpretation.OPEN_EVENT)
62
63 def SaveDocHandler(self, doc, data):
64- print "saved document", doc.get_uri()
65- self.docs = self._window.get_documents()
66+ print "Zeitgeist: saved document", doc.get_uri()
67 self.SendToZeitgeist(doc, Interpretation.SAVE_EVENT)
68- print "***", self.docs
69
70 def SendToZeitgeist(self, doc, event):
71 if doc.get_uri():
72@@ -93,7 +100,6 @@
73 self._instances = {}
74
75 def activate(self, window):
76- print window
77 self._instances[window] = ZeitgeistLogic(self, window)
78
79 def deactivate(self, window):

Subscribers

People subscribed via source and target branches