[gedit-plugins] synctex: Update evince_dbus.py to new DBUS interface of Evince.



commit f79edae9119c319ac0d8f67d9c93a8f304424550
Author: José Aliste <jaliste src gnome org>
Date:   Fri Mar 25 10:12:08 2011 -0400

    synctex: Update evince_dbus.py to new DBUS interface of Evince.

 plugins/synctex/synctex/evince_dbus.py |   12 ++++++------
 plugins/synctex/synctex/synctex.py     |   25 ++++++++++++-------------
 2 files changed, 18 insertions(+), 19 deletions(-)
---
diff --git a/plugins/synctex/synctex/evince_dbus.py b/plugins/synctex/synctex/evince_dbus.py
index 63aa0b3..20c4264 100755
--- a/plugins/synctex/synctex/evince_dbus.py
+++ b/plugins/synctex/synctex/evince_dbus.py
@@ -114,25 +114,25 @@ class EvinceWindowProxy:
         self.window = None
         self.status = CLOSED
 
-    def on_sync_source(self, input_file, source_link):
+    def on_sync_source(self, input_file, source_link, timestamp):
         if self.source_handler is not None:
-            self.source_handler(input_file, source_link)
+            self.source_handler(input_file, source_link, timestamp)
 
-    def SyncView(self, input_file, data):
+    def SyncView(self, input_file, data, time):
         if self.status == CLOSED:
             if self.spawn:
-                self._tmp_syncview = [input_file, data];
+                self._tmp_syncview = [input_file, data, time];
                 self._handler = self._syncview_handler
                 self._get_dbus_name(True)
         else:
-            self.window.SyncView(input_file, data, dbus_interface = "org.gnome.evince.Window")
+            self.window.SyncView(input_file, data, time,  dbus_interface = "org.gnome.evince.Window")
 
     def _syncview_handler(self, window_list):
         self.handle_get_window_list_reply(window_list)
 
         if self.status == CLOSED: 
             return False
-        self.window.SyncView(self._tmp_syncview[0],self._tmp_syncview[1], dbus_interface="org.gnome.evince.Window")
+        self.window.SyncView(self._tmp_syncview[0],self._tmp_syncview[1], self._tmp_syncview[2], dbus_interface="org.gnome.evince.Window")
         del self._tmp_syncview
         self._handler = None
         return True
diff --git a/plugins/synctex/synctex/synctex.py b/plugins/synctex/synctex/synctex.py
index a7b605c..c00414a 100644
--- a/plugins/synctex/synctex/synctex.py
+++ b/plugins/synctex/synctex/synctex.py
@@ -105,7 +105,7 @@ class SynctexViewHelper:
         modifier_mask = Gtk.accelerator_get_default_mod_mask()
         event_state = event.state & modifier_mask
         if event.button == 1 and event_state == Gdk.ModifierType.CONTROL_MASK:
-            self.sync_view()
+            self.sync_view(event.time)
 
     def on_saved_or_loaded(self, doc, data):
         self.update_location()
@@ -173,23 +173,23 @@ class SynctexViewHelper:
                                  self.last_iters[0], self.last_iters[1])
         self.last_iters = None
 
-    def goto_line (self, line):
+    def goto_line (self, line, time):
         self._doc.goto_line(line) 
         self._view.scroll_to_cursor()
         self._window.set_active_tab(self._tab)
         self._highlight()
-        self._window.present()
+        self._window.present_with_time (time)
 
     def goto_line_after_load(self, a, line):
         self.goto_line(line)
         self._doc.disconnect(self._goto_handler)
 
-    def sync_view(self):
+    def sync_view(self, time):
         if self.active:
             cursor_iter =  self._doc.get_iter_at_mark(self._doc.get_insert())
             line = cursor_iter.get_line() + 1
             col = cursor_iter.get_line_offset()
-            self.window_proxy.SyncView(self.gfile.get_path(), (line, col))
+            self.window_proxy.SyncView(self.gfile.get_path(), (line, col), time)
 
     def update_active(self):
         # Activate the plugin only if the doc is a LaTeX file.
@@ -296,8 +296,7 @@ class SynctexWindowHelper:
         self._ui_id = manager.add_ui_from_string(ui_str)
 
     def forward_search_cb(self, action, what):
-        print self, action, what
-        self._window.get_active_view().get_data(VIEW_DATA_KEY).sync_view()
+        self._window.get_active_view().get_data(VIEW_DATA_KEY).sync_view(Gtk.get_current_event_time())
 
 class SynctexPlugin(GObject.Object, Gedit.WindowActivatable):
     __gtype_name__ = "SynctexPlugin"
@@ -320,9 +319,9 @@ class SynctexPlugin(GObject.Object, Gedit.WindowActivatable):
         window.get_data(WINDOW_DATA_KEY).deactivate()
         window.set_data(WINDOW_DATA_KEY, None)
 
-    def source_view_handler(self, out_gfile, input_file, source_link):
-        uri_input = out_gfile.get_parent().get_child(str(input_file)).get_uri()
-        
+    def source_view_handler(self, out_gfile, input_file, source_link, time):
+        uri_input = input_file
+
         if uri_input not in SynctexPlugin.view_dict:
             window = SynctexPlugin._proxy_dict[out_gfile.get_uri()][2]
             tab = window.create_tab_from_uri(uri_input,
@@ -330,9 +329,9 @@ class SynctexPlugin(GObject.Object, Gedit.WindowActivatable):
             helper =  tab.get_view().get_data(VIEW_DATA_KEY)
             helper._goto_handler = tab.get_document().connect_object("loaded", 
                                                 SynctexViewHelper.goto_line_after_load, 
-                                                helper, source_link[0] - 1) 
+                                                helper, source_link[0] - 1, time)
         else:
-            SynctexPlugin.view_dict[uri_input].goto_line(source_link[0] - 1)
+            SynctexPlugin.view_dict[uri_input].goto_line(source_link[0] - 1, time)
 
     def ref_evince_proxy(self, gfile, window):
         uri = gfile.get_uri()
@@ -340,7 +339,7 @@ class SynctexPlugin(GObject.Object, Gedit.WindowActivatable):
         if uri not in SynctexPlugin._proxy_dict:
             proxy = EvinceWindowProxy (uri, True, _logger)
             SynctexPlugin._proxy_dict[uri] = [1, proxy, window]
-            proxy.set_source_handler (lambda i, s: self.source_view_handler(Gio.file_new_for_uri(uri), i, s))
+            proxy.set_source_handler (lambda i, s, time: self.source_view_handler(Gio.file_new_for_uri(uri), i, s, time))
         else:
             SynctexPlugin._proxy_dict[uri][0]+=1
             proxy = SynctexPlugin._proxy_dict[uri][1]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]