[gnome-documents] application: move menu action callbacks to Application class
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] application: move menu action callbacks to Application class
- Date: Thu, 19 Jul 2012 01:52:44 +0000 (UTC)
commit d70f0bd9afcd3d4130d0ec5823bd3cba5e5da477
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Jul 18 21:48:57 2012 -0400
application: move menu action callbacks to Application class
Instead of using static methods and leaking global state.
src/application.js | 25 ++++++++++++++-----------
src/global.js | 8 --------
src/mainToolbar.js | 30 ------------------------------
3 files changed, 14 insertions(+), 49 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index b76f7b8..3141fe0 100644
--- a/src/application.js
+++ b/src/application.js
@@ -131,21 +131,24 @@ const Application = new Lang.Class({
this.application.add_accelerator('<Primary>q', 'app.quit', null);
this.application.add_accelerator('F11', 'app.fullscreen', null);
- //setting actions for other menus in topBar
- let saveAction = new Gio.SimpleAction({ name: 'open' });
- saveAction.connect('activate', Lang.bind(this,
- function() {
- MainToolbar.fileOpen();
- }));
- this.application.add_action(saveAction);
-
- let openAction = new Gio.SimpleAction({ name: 'print' });
+ // actions for other toolbar menus
+ let openAction = new Gio.SimpleAction({ name: 'open-current' });
openAction.connect('activate', Lang.bind(this,
- function() {
- MainToolbar.filePrint();
+ function() {
+ let doc = Global.documentManager.getActiveItem();
+ if (doc)
+ doc.open(this._mainWindow.window.get_screen(), Gtk.get_current_event_time());
}));
this.application.add_action(openAction);
+ let printAction = new Gio.SimpleAction({ name: 'print-current' });
+ printAction.connect('activate', Lang.bind(this,
+ function() {
+ let doc = Global.documentManager.getActiveItem();;
+ if (doc)
+ doc.print(this._mainWindow.window);
+ }));
+ this.application.add_action(printAction);
},
_initAppMenu: function() {
diff --git a/src/global.js b/src/global.js
index e72e2cd..58810a2 100644
--- a/src/global.js
+++ b/src/global.js
@@ -25,10 +25,6 @@ const Query = imports.query;
const Searchbar = imports.searchbar;
const Sources = imports.sources;
const TrackerController = imports.trackerController;
-const EvView = imports.gi.EvinceView;//for printing
-const Notifications = imports.notifications;//for printing
-const Lang = imports.lang;//for printing
-const Gtk = imports.gi.Gtk;//for opening
let application = null;
let collectionManager = null;
@@ -48,8 +44,6 @@ let selectionController = null;
let settings = null;
let sourceManager = null;
let trackerController = null;
-let screen = null;
-let menuWidget = null;
function initSearch() {
sourceManager = new Sources.SourceManager();
@@ -64,5 +58,3 @@ function initSearch() {
queryBuilder = new Query.QueryBuilder();
connectionQueue = new TrackerController.TrackerConnectionQueue();
};
-
-
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index d3c0b8c..f2c73f8 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -371,33 +371,3 @@ const OverviewToolbar = new Lang.Class({
this.searchbar.show();
}
});
-
-function fileOpen(screen) {
- print ("No fileOpen here. This is temp.");
- let doc = Global.documentManager.getActiveItem();
- //let doc = documentManager.getActiveItem();
- doc.open(Global.screen, Gtk.get_current_event_time());
-
-};
-
-/**
- * Prints the current document
- */
-function filePrint() {
- print ("No filePrint here. This is temp.");
- let doc = Global.documentManager.getActiveItem();
- //let doc = documentManager.getActiveItem();
- doc.load(null, Lang.bind(this,
- function(doc, docModel, error) {
- if (error) {
- // TODO: handle error here!
- return;
- }
-
- let printOp = EvView.PrintOperation.new(docModel.get_document());
- let printNotification = new Notifications.PrintNotification(printOp, doc);
-
- let toplevel = Global.menuWidget.get_toplevel();
- printOp.run(toplevel);
- }));
-};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]