[gnome-documents] Add Fullscreen and Quit menu items
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] Add Fullscreen and Quit menu items
- Date: Wed, 21 Dec 2011 16:57:16 +0000 (UTC)
commit be80461d62df4c8cba33fb6e0ec9b0697658cf0b
Author: Colin Walters <walters verbum org>
Date: Wed Nov 30 19:19:14 2011 -0500
Add Fullscreen and Quit menu items
src/application.js | 40 +++++++++++++++++++++++++++++++++++++---
src/mainWindow.js | 14 +++++++-------
2 files changed, 44 insertions(+), 10 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 36c2f1d..a6f6401 100644
--- a/src/application.js
+++ b/src/application.js
@@ -21,6 +21,7 @@
const Lang = imports.lang;
const Gettext = imports.gettext;
+const _ = imports.gettext.gettext;
const GtkClutter = imports.gi.GtkClutter;
const EvDoc = imports.gi.EvinceDocument;
@@ -56,6 +57,12 @@ function Application() {
Application.prototype = {
_init: function() {
+ Gettext.bindtextdomain('gnome-documents', Path.LOCALE_DIR);
+ Gettext.textdomain('gnome-documents');
+ GLib.set_prgname('gnome-documents');
+
+ Global.settings = new Gio.Settings({ schema: 'org.gnome.documents' });
+
// TODO: subclass Gtk.Application once we support GObject inheritance,
// see https://bugzilla.gnome.org/show_bug.cgi?id=663492
this.application = new Gtk.Application({
@@ -69,11 +76,39 @@ Application.prototype = {
function() {
this._mainWindow.window.present();
}));
+ this._actionGroup = new Gio.SimpleActionGroup();
+ this._menu = new Gio.Menu();
+ // this._viewAs = Gio.SimpleAction.new_stateful("view-as-list",
+ // GLib.VariantType.new("b"),
+ // Global.settings.get_value('list-view'));
+ // this._viewAs.connect('activate', Lang.bind(this, function () {
+ // Global.settings.set_boolean('list-view', this._viewAs.state);
+ // }));
+ // this._actionGroup.insert(this._viewAs);
+ this._fullscreen = false;
+ this._fullscreenAction = new Gio.SimpleAction({ name: 'fullscreen' });
+ this._fullscreenAction.connect('activate', Lang.bind(this, function() {
+ this._fullscreen = !this._fullscreen;
+ if (this._fullscreen)
+ this._mainWindow.window.fullscreen();
+ else
+ this._mainWindow.window.unfullscreen();
+ }));
+ this._actionGroup.insert(this._fullscreenAction);
+ this._menu.append(_('Fullscreen'), "app.fullscreen");
+
+ this._quitAction = new Gio.SimpleAction({ name: 'quit' });
+ this._quitAction.connect('activate', Lang.bind(this, function() {
+ this.application.release();
+ }));
+ this._actionGroup.insert(this._quitAction);
+ this._menu.append(_('Quit'), "app.quit");
+
+ this.application.set_action_group(this._actionGroup);
+ this.application.set_menu(this._menu);
},
_onStartup: function() {
- Gettext.bindtextdomain('gnome-documents', Path.LOCALE_DIR);
- Gettext.textdomain('gnome-documents');
String.prototype.format = Format.format;
GtkClutter.init(null, null);
@@ -81,7 +116,6 @@ Application.prototype = {
Tweener.init();
Global.application = this;
- Global.settings = new Gio.Settings({ schema: 'org.gnome.documents' });
Global.offsetController = new OffsetController.OffsetController();
Global.searchController = new Searchbar.SearchController();
Global.errorHandler = new Error.ErrorHandler();
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 069b608..46be9e3 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -39,18 +39,18 @@ const _ = imports.gettext.gettext;
const _CONFIGURE_ID_TIMEOUT = 100; // msecs
-function MainWindow() {
- this._init();
+function MainWindow(app) {
+ this._init(app);
}
MainWindow.prototype = {
- _init: function() {
+ _init: function(app) {
this._configureId = 0;
- this.window = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL,
- window_position: Gtk.WindowPosition.CENTER,
- hide_titlebar_when_maximized: true,
- title: _("Documents") });
+ this.window = new Gtk.ApplicationWindow({ application: app,
+ window_position: Gtk.WindowPosition.CENTER,
+ hide_titlebar_when_maximized: true,
+ title: _("Documents") });
this._clutterEmbed = new GtkClutter.Embed();
this.window.add(this._clutterEmbed);
this._clutterEmbed.show();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]