[sushi/wip/cosimoc/no-clutter: 46/67] mainWindow: make a GtkWindow subclass
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi/wip/cosimoc/no-clutter: 46/67] mainWindow: make a GtkWindow subclass
- Date: Mon, 30 Apr 2018 15:17:30 +0000 (UTC)
commit 4ccec147ea5b616cba66a4f9bae47f02d3d06f31
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Sun Apr 2 17:35:51 2017 -0700
mainWindow: make a GtkWindow subclass
src/js/ui/application.js | 2 +-
src/js/ui/mainWindow.js | 98 ++++++++++++++++++++-------------------------
2 files changed, 45 insertions(+), 55 deletions(-)
---
diff --git a/src/js/ui/application.js b/src/js/ui/application.js
index 42bcc3c..0c54749 100644
--- a/src/js/ui/application.js
+++ b/src/js/ui/application.js
@@ -73,7 +73,7 @@ const Application = new Lang.Class({
_createMainWindow : function() {
this._mainWindow =
- new MainWindow.MainWindow({ application: this });
+ new MainWindow.MainWindow(this);
},
_defineStyleAndThemes : function() {
diff --git a/src/js/ui/mainWindow.js b/src/js/ui/mainWindow.js
index 7dde23f..175ed68 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -42,53 +42,44 @@ const Utils = imports.ui.utils;
const MainWindow = new Lang.Class({
Name: 'MainWindow',
+ Extends: Gtk.Window,
- _init : function(args) {
- args = args || {};
-
+ _init : function(application) {
this._isFullScreen = false;
this._pendingRenderer = null;
this._renderer = null;
this._texture = null;
this._toolbar = null;
this._toolbarId = 0;
+ this.file = null;
this._mimeHandler = new MimeHandler.MimeHandler();
- this._application = args.application;
- this._createGtkWindow();
-
- this.file = null;
- },
+ this.parent({ type: Gtk.WindowType.TOPLEVEL,
+ skipPagerHint: true,
+ skipTaskbarHint: true,
+ windowPosition: Gtk.WindowPosition.CENTER,
+ gravity: Gdk.Gravity.CENTER,
+ application: application });
- _createGtkWindow : function() {
- this._gtkWindow = new Gtk.Window({ type: Gtk.WindowType.TOPLEVEL,
- skipPagerHint: true,
- skipTaskbarHint: true,
- windowPosition: Gtk.WindowPosition.CENTER,
- gravity: Gdk.Gravity.CENTER,
- application: this._application });
this._titlebar = new Gtk.HeaderBar({ show_close_button: true });
- this._gtkWindow.set_titlebar(this._titlebar);
-
- let screen = Gdk.Screen.get_default();
- this._gtkWindow.set_visual(screen.get_rgba_visual());
-
- this._gtkWindow.connect('button-press-event',
- Lang.bind(this, this._onButtonPressEvent));
- this._gtkWindow.connect('delete-event',
- Lang.bind(this, this._onDeleteEvent));
- this._gtkWindow.connect('key-press-event',
- Lang.bind(this, this._onKeyPressEvent));
- this._gtkWindow.connect('motion-notify-event',
- Lang.bind(this, this._onMotionNotifyEvent));
- this._gtkWindow.connect('realize',
- Lang.bind(this, this._onRealize));
- this._gtkWindow.connect('size-allocate',
- Lang.bind(this, this._onSizeAllocate));
+ this.set_titlebar(this._titlebar);
+
+ this.connect('button-press-event',
+ Lang.bind(this, this._onButtonPressEvent));
+ this.connect('delete-event',
+ Lang.bind(this, this._onDeleteEvent));
+ this.connect('key-press-event',
+ Lang.bind(this, this._onKeyPressEvent));
+ this.connect('motion-notify-event',
+ Lang.bind(this, this._onMotionNotifyEvent));
+ this.connect('realize',
+ Lang.bind(this, this._onRealize));
+ this.connect('size-allocate',
+ Lang.bind(this, this._onSizeAllocate));
this._embed = new Gtk.Overlay();
- this._gtkWindow.add(this._embed);
+ this.add(this._embed);
},
/**************************************************************************
@@ -100,9 +91,9 @@ const MainWindow = new Lang.Class({
_onRealize: function() {
// don't support maximize and minimize
- this._gtkWindow.get_window().set_functions(Gdk.WMFunction.MOVE |
- Gdk.WMFunction.RESIZE |
- Gdk.WMFunction.CLOSE);
+ this.get_window().set_functions(Gdk.WMFunction.MOVE |
+ Gdk.WMFunction.RESIZE |
+ Gdk.WMFunction.CLOSE);
},
_onSizeAllocate: function() {
@@ -133,9 +124,9 @@ const MainWindow = new Lang.Class({
let [, rootX, rootY] = event.get_root_coords();
let [, button] = event.get_button();
- this._gtkWindow.begin_move_drag(button,
- rootX, rootY,
- event.get_time());
+ this.begin_move_drag(button,
+ rootX, rootY,
+ event.get_time());
return false;
},
@@ -151,8 +142,8 @@ const MainWindow = new Lang.Class({
*********************** texture allocation *******************************
**************************************************************************/
_getTextureSize : function() {
- let screenSize = [ this._gtkWindow.get_window().get_width(),
- this._gtkWindow.get_window().get_height() ];
+ let screenSize = [ this.get_window().get_width(),
+ this.get_window().get_height() ];
let availableWidth = this._isFullScreen ? screenSize[0] : Constants.VIEW_MAX_W;
let availableHeight = this._isFullScreen ? screenSize[1] : Constants.VIEW_MAX_H;
@@ -186,9 +177,8 @@ const MainWindow = new Lang.Class({
this._lastWindowSize = windowSize;
- if (!this._isFullScreen) {
- this._gtkWindow.resize(windowSize[0], windowSize[1]);
- }
+ if (!this._isFullScreen)
+ this.resize(windowSize[0], windowSize[1]);
},
_createRenderer : function(file) {
@@ -311,7 +301,7 @@ const MainWindow = new Lang.Class({
if (this._renderer.clear)
this._renderer.clear();
- this._gtkWindow.destroy();
+ this.destroy();
},
/**************************************************************************
@@ -319,13 +309,13 @@ const MainWindow = new Lang.Class({
**************************************************************************/
setParent : function(xid) {
this._parent = Sushi.create_foreign_window(xid);
- this._gtkWindow.realize();
+ this.realize();
if (this._parent)
- this._gtkWindow.get_window().set_transient_for(this._parent);
- this._gtkWindow.show_all();
+ this.get_window().set_transient_for(this._parent);
+ this.show_all();
- if (this._gtkWindow.get_window().move_to_current_desktop)
- this._gtkWindow.get_window().move_to_current_desktop();
+ if (this.get_window().move_to_current_desktop)
+ this.get_window().move_to_current_desktop();
},
setFile : function(file) {
@@ -334,11 +324,11 @@ const MainWindow = new Lang.Class({
this._createTexture();
this._createToolbar();
- this._gtkWindow.show_all();
+ this.show_all();
},
setTitle : function(label) {
- this._gtkWindow.set_title(label);
+ this.set_title(label);
},
refreshSize : function() {
@@ -353,10 +343,10 @@ const MainWindow = new Lang.Class({
if (this._isFullScreen) {
this._isFullScreen = false;
- this._gtkWindow.unfullscreen();
+ this.unfullscreen();
} else {
this._isFullScreen = true;
- this._gtkWindow.fullscreen();
+ this.fullscreen();
}
return this._isFullScreen;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]