[gnome-documents/menu: 1/2] Added a menu (open, print) to the Preview Toolbar
- From: Anna Zacchi <annazacchi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/menu: 1/2] Added a menu (open, print) to the Preview Toolbar
- Date: Wed, 18 Jul 2012 18:46:14 +0000 (UTC)
commit f51aeedf211e275f9bbda5149e5337ca259234ed
Author: Anna Zacchi <annazacchi src gnome org>
Date: Tue Jul 17 22:16:12 2012 +0200
Added a menu (open, print) to the Preview Toolbar
src/application.js | 35 +++++++++++++++++++++-------
src/global.js | 9 ++++++-
src/lib/gd-main-toolbar.c | 26 +++++++++++++++++++++
src/lib/gd-main-toolbar.h | 3 ++
src/mainToolbar.js | 54 ++++++++++++++++++++++++++++++++++++++++++++-
5 files changed, 116 insertions(+), 11 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 3202f7b..422f0f3 100644
--- a/src/application.js
+++ b/src/application.js
@@ -42,6 +42,7 @@ const GDataMiner = imports.gDataMiner;
const Global = imports.global;
const Main = imports.main;
const MainWindow = imports.mainWindow;
+const MainToolbar = imports.mainToolbar;
const Manager = imports.manager;
const Notifications = imports.notifications;
const Path = imports.path;
@@ -82,12 +83,12 @@ const Application = new Lang.Class({
},
_initMenus: function() {
- let quitAction = new Gio.SimpleAction({ name: 'quit' });
- quitAction.connect('activate', Lang.bind(this,
- function() {
- this._mainWindow.window.destroy();
- }));
- this.application.add_action(quitAction);
+ let quitAction = new Gio.SimpleAction({ name: 'quit' });
+ quitAction.connect('activate', Lang.bind(this,
+ function() {
+ this._mainWindow.window.destroy();
+ }));
+ this.application.add_action(quitAction);
let aboutAction = new Gio.SimpleAction({ name: 'about' });
aboutAction.connect('activate', Lang.bind(this,
@@ -129,7 +130,7 @@ const Application = new Lang.Class({
}));
this.application.add_action(viewAsAction);
- let menu = new Gio.Menu();
+ let menu = new Gio.Menu();
let viewAs = new Gio.Menu();
viewAs.append(_("Grid"), 'app.view-as::icon');
@@ -143,7 +144,23 @@ const Application = new Lang.Class({
menu.append(_("About Documents"), 'app.about');
menu.append(_("Quit"), 'app.quit');
- this.application.set_app_menu(menu);
+ this.application.set_app_menu(menu);
+
+
+ //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' });
+ openAction.connect('activate', Lang.bind(this,
+ function() {
+ MainToolbar.filePrint();
+ }));
+ this.application.add_action(openAction);
},
_refreshMinerNow: function(miner) {
@@ -238,5 +255,5 @@ const Application = new Lang.Class({
app.activate();
return 0;
- }
+ },
});
diff --git a/src/global.js b/src/global.js
index abb90e2..3690609 100644
--- a/src/global.js
+++ b/src/global.js
@@ -25,6 +25,10 @@ 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;
@@ -45,6 +49,7 @@ let selectionController = null;
let settings = null;
let sourceManager = null;
let trackerController = null;
+let screen = null;
function initSearch() {
sourceManager = new Sources.SourceManager();
@@ -58,4 +63,6 @@ function initSearch() {
offsetController = new OffsetController.OffsetController();
queryBuilder = new Query.QueryBuilder();
connectionQueue = new TrackerController.TrackerConnectionQueue();
-}
+};
+
+
diff --git a/src/lib/gd-main-toolbar.c b/src/lib/gd-main-toolbar.c
index f6d132c..349bf79 100644
--- a/src/lib/gd-main-toolbar.c
+++ b/src/lib/gd-main-toolbar.c
@@ -291,3 +291,29 @@ gd_main_toolbar_add_button (GdMainToolbar *self,
return button;
}
+
+/**
+ * gd_main_toolbar_add_menu:
+ * @self:
+ * @pack_start:
+ *
+ * Returns: (transfer none):
+ */
+GtkWidget *
+gd_main_toolbar_add_menu (GdMainToolbar *self,
+ gboolean pack_start)
+{
+ GtkWidget *menuButton;
+
+ menuButton = gtk_menu_button_new ();
+
+ if (pack_start)
+ gtk_container_add (GTK_CONTAINER (self->priv->left_grid), menuButton);
+ else
+ gtk_container_add (GTK_CONTAINER (self->priv->right_grid), menuButton);
+
+ gtk_widget_show_all (menuButton);
+
+ return menuButton;
+}
+
diff --git a/src/lib/gd-main-toolbar.h b/src/lib/gd-main-toolbar.h
index 5244d5e..6506394 100644
--- a/src/lib/gd-main-toolbar.h
+++ b/src/lib/gd-main-toolbar.h
@@ -81,6 +81,9 @@ GtkWidget * gd_main_toolbar_add_button (GdMainToolbar *self,
const gchar *label,
gboolean pack_start);
+GtkWidget * gd_main_toolbar_add_menu (GdMainToolbar *self,
+ gboolean pack_start);
+
G_END_DECLS
#endif /* __GD_MAIN_TOOLBAR_H__ */
diff --git a/src/mainToolbar.js b/src/mainToolbar.js
index 7c9139c..4288b86 100644
--- a/src/mainToolbar.js
+++ b/src/mainToolbar.js
@@ -38,6 +38,9 @@ const Searchbar = imports.searchbar;
const Tweener = imports.util.tweener;
const WindowMode = imports.windowMode;
+const EvView = imports.gi.EvinceView;//for printing
+const Notifications = imports.notifications;//for printing
+
const MainToolbar = new Lang.Class({
Name: 'MainToolbar',
@@ -231,6 +234,7 @@ const MainToolbar = new Lang.Class({
},
_populateForPreview: function(model) {
+ //back button, on the left of the toolbar
let iconName =
(this.widget.get_direction() == Gtk.TextDirection.RTL) ?
'go-next-symbolic' : 'go-previous-symbolic';
@@ -241,6 +245,15 @@ const MainToolbar = new Lang.Class({
function() {
Global.modeController.setWindowMode(WindowMode.WindowMode.OVERVIEW);
}));
+
+ //menu button, on the right of the toolbar (false)
+ this._menuButton =
+ this.widget.add_menu( false );
+ this._initMenus();
+ let menu = new Gtk.Menu.new_from_model(this.menuModel);
+ menu.show();
+ this._menuButton.set_menu( menu );
+ Global.screen = this.widget.get_screen();
},
_populateForOverview: function() {
@@ -306,7 +319,16 @@ const MainToolbar = new Lang.Class({
}));
this._setToolbarTitle();
- }
+ },
+
+ _initMenus: function() {
+ this.menuModel = new Gio.Menu();
+
+ let menuItemOpen = Gio.MenuItem.new(_("Open"), 'app.open');
+ let menuItemPrint = Gio.MenuItem.new(_("Print"), 'app.print');
+ this.menuModel.append_item(menuItemOpen);
+ this.menuModel.append_item(menuItemPrint);
+ },
});
const PreviewToolbar = new Lang.Class({
@@ -359,3 +381,33 @@ 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, evDoc, error) {
+ if (!evDoc) {
+ // TODO: handle error here!
+ return;
+ }
+
+ let printOp = EvView.PrintOperation.new(evDoc);
+ let printNotification = new Notifications.PrintNotification(printOp, doc);
+
+ let toplevel = this.widget.get_toplevel();
+ printOp.run(toplevel);
+ }));
+};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]