[gnome-documents] view: move the item-activated handler to the window



commit 8f3d86702f37c16ab0ab33a0aabf1d43693e5772
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Jul 20 15:15:26 2011 -0400

    view: move the item-activated handler to the window
    
    This will allow to plug an embedded viewer from there.

 src/mainWindow.js |   10 ++++++++++
 src/view.js       |   10 ++++------
 2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 90a73bc..195aa17 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -116,6 +116,8 @@ MainWindow.prototype = {
         else
             this.view = new IconView.IconView(this);
 
+        this.view.connect('item-activated', Lang.bind(this, this._onViewItemActivated));
+
         this._viewBox.attach_next_to(this.view.widget, this._loadMore,
                                      Gtk.PositionType.TOP, 1, 1);
     },
@@ -134,6 +136,14 @@ MainWindow.prototype = {
         Main.application.quit();
     },
 
+    _onViewItemActivated: function(view, uri) {
+        try {
+            Gtk.show_uri(null, uri, Gtk.get_current_event_time());
+        } catch (e) {
+            log('Unable to open ' + uri + ': ' + e.toString());
+        }
+    },
+
     _onSearchEntryChanged: function() {
         if (this._searchTimeout != 0) {
             GLib.source_remove(this._searchTimeout);
diff --git a/src/view.js b/src/view.js
index d48c94d..80496e8 100644
--- a/src/view.js
+++ b/src/view.js
@@ -22,6 +22,7 @@
 const Gtk = imports.gi.Gtk;
 
 const Lang = imports.lang;
+const Signals = imports.signals;
 
 const Main = imports.main;
 const TrackerModel = imports.trackerModel;
@@ -55,10 +56,7 @@ View.prototype = {
         let iter = this.model.get_iter(path)[1];
         let uri = this.model.get_value(iter, TrackerModel.ModelColumns.URI);
 
-        try {
-            Gtk.show_uri(null, uri, Gtk.get_current_event_time());
-        } catch (e) {
-            log('Unable to open ' + uri + ': ' + e.toString());
-        }
+        this.emit('item-activated', uri);
     }
-}
+};
+Signals.addSignalMethods(View.prototype);



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