[sushi/wip/cosimoc/no-clutter: 27/66] mainWindow: make a GtkWindow subclass
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sushi/wip/cosimoc/no-clutter: 27/66] mainWindow: make a GtkWindow subclass
- Date: Sat, 8 Jun 2019 18:42:25 +0000 (UTC)
commit 55ba519a7be2f55c376c42e55b0297d8a1566270
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 | 100 +++++++++++++++++++++--------------------------
2 files changed, 46 insertions(+), 56 deletions(-)
---
diff --git a/src/js/ui/application.js b/src/js/ui/application.js
index c54e440..0594326 100644
--- a/src/js/ui/application.js
+++ b/src/js/ui/application.js
@@ -73,7 +73,7 @@ var 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 9a39d10..78a67cf 100644
--- a/src/js/ui/mainWindow.js
+++ b/src/js/ui/mainWindow.js
@@ -42,55 +42,46 @@ const Utils = imports.ui.utils;
var 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,
- // don't support maximize and minimize
+ // don't support maximize and minimize
decoration_layout: "menu:close" });
- 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);
},
/**************************************************************************
@@ -102,9 +93,9 @@ var 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() {
@@ -135,9 +126,9 @@ var 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;
},
@@ -153,8 +144,8 @@ var 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;
@@ -188,9 +179,8 @@ var 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) {
@@ -313,7 +303,7 @@ var MainWindow = new Lang.Class({
if (this._renderer.clear)
this._renderer.clear();
- this._gtkWindow.destroy();
+ this.destroy();
},
/**************************************************************************
@@ -321,13 +311,13 @@ var 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) {
@@ -336,11 +326,11 @@ var 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() {
@@ -355,10 +345,10 @@ var 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]