[gnome-music] add window.js and fix application.js, main.js
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] add window.js and fix application.js, main.js
- Date: Mon, 1 Apr 2013 22:30:16 +0000 (UTC)
commit 4862352cacb799cfd8bd6dd833cfaf103a14d5d2
Author: Eslam Mostafa <cseslam gmail com>
Date: Mon Apr 1 19:40:43 2013 +0200
add window.js and fix application.js, main.js
Signed-off-by: Seif Lotfy <seif lotfy com>
src/Makefile.am | 1 +
src/application.js | 78 ++++-------------------------------------
src/main.js | 6 +++-
src/window.js | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 111 insertions(+), 71 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 695ef5c..b209773 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,6 +12,7 @@ dist_js_DATA = \
grilo.js \
query.js \
widgets.js \
+ window.js \
main.js \
package.js \
searchbar.js \
diff --git a/src/application.js b/src/application.js
index cc4c72b..f9e324e 100644
--- a/src/application.js
+++ b/src/application.js
@@ -18,7 +18,6 @@
*
*/
-
const Lang = imports.lang;
const Gtk = imports.gi.Gtk;
const Gdk = imports.gi.Gdk;
@@ -26,9 +25,7 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gd = imports.gi.Gd;
-const Toolbar = imports.toolbar;
-const Views = imports.view;
-const Player = imports.player;
+const Window = imports.window;
const Gettext = imports.gettext;
const _ = imports.gettext.gettext;
@@ -56,62 +53,6 @@ const Application = new Lang.Class({
GLib.set_application_name(_("Music"));
},
- _buildApp: function() {
- this._window = new Gtk.ApplicationWindow({
- application: this,
- title: _("Music"),
- window_position: Gtk.WindowPosition.CENTER,
- hide_titlebar_when_maximized: true
- });
-
-
- this._window.set_size_request (800, 600)
- this.vbox = new Gtk.Box({
- orientation: Gtk.Orientation.VERTICAL,
- spacing: 0
- });
-
- this.player = new Player.Player();
-
- this.views = [];
-
- this.toolbar = new Toolbar.Toolbar();
- this._stack = new Gd.Stack({
- visible: true
- });
-
- this._window.set_default_size(640, 400);
- this.vbox.pack_start(this.toolbar, false, false, 0);
- this.vbox.pack_start(this._stack, true, true, 0);
- this.vbox.pack_start(this.player.eventbox, false, false, 0);
- this._window.add(this.vbox);
-
- this.views[0] = new Views.Albums(this.toolbar);
- this.views[1] = new Views.Artists(this.toolbar);
- this.views[2] = new Views.Songs(this.toolbar);
- this.views[3] = new Views.Playlists(this.toolbar);
-
- for (let i in this.views) {
- this._stack.add_titled(
- this.views[i],
- this.views[i].title,
- this.views[i].title
- );
- }
-
- //this._stack.connect("notify::visible-child", this._onNotifyMode);
-
- this.views[0].populate();
- this.toolbar.set_stack(this._stack);
- this.toolbar.show();
- this.player.eventbox.show_all();
- this.vbox.show();
- },
-
- _onNotifyMode: function(stack, param) {
- stack.get_visible_child().populate();
- },
-
_buildAppMenu: function() {
var builder,
menu;
@@ -123,18 +64,15 @@ const Application = new Lang.Class({
this.set_app_menu(menu);
},
- _toggleView: function(btn, i) {
- this._stack.set_visible_child(this.views[i])
- },
+ vfunc_startup: function() {
+ Gtk.init(null);
+ this.parent();
+ this._window = new Window.MainWindow(this);
+ this._buildAppMenu();
+ },
+
vfunc_activate: function() {
this._window.present();
},
-
- vfunc_startup: function() {
- this.parent();
- Gtk.init(null);
- this._buildApp();
- this._buildAppMenu();
- }
});
diff --git a/src/main.js b/src/main.js
index 6196be2..ed27969 100644
--- a/src/main.js
+++ b/src/main.js
@@ -23,4 +23,8 @@ const GIRepository = imports.gi.GIRepository;
const App = imports.application;
let app = new App.Application();
-app.run(ARGV);
+//app.run(ARGV);
+
+function main(argv) {
+ return app.run(argv);
+}
diff --git a/src/window.js b/src/window.js
new file mode 100644
index 0000000..24ecee5
--- /dev/null
+++ b/src/window.js
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013 Eslam Mostafa.
+ *
+ * Gnome Music is free software; you can Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * Gnome Music is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with Gnome Music; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author: Eslam Mostafa <cseslam gmail com>
+ *
+ */
+
+const Lang = imports.lang;
+const Gtk = imports.gi.Gtk;
+const Gd = imports.gi.Gd;
+const GLib = imports.gi.GLib;
+
+const Gettext = imports.gettext;
+const _ = imports.gettext.gettext;
+
+const Toolbar = imports.toolbar;
+const Views = imports.view;
+const Player = imports.player;
+
+const MainWindow = new Lang.Class({
+ Name: "MainWindow",
+ Extends: Gtk.ApplicationWindow,
+
+ _init: function (app) {
+ this.parent({
+ application: app,
+ title: _('Music'),
+ window_position: Gtk.WindowPosition.CENTER,
+ hide_titlebar_when_maximized: true
+ });
+
+ this.set_default_size(640, 400);
+ this._setupView();
+ },
+
+ _setupView: function () {
+ this._box = new Gtk.Box({
+ orientation: Gtk.Orientation.VERTICAL,
+ spacing: 0
+ });
+ this.views = [];
+ this.player = new Player.Player();
+
+ this.toolbar = new Toolbar.Toolbar();
+ this._stack = new Gd.Stack({
+ visible: true
+ });
+
+ this._box.pack_start(this.toolbar, false, false, 0);
+ this._box.pack_start(this._stack, true, true, 0);
+ this._box.pack_start(this.player.eventbox, false, false, 0);
+ this.add(this._box);
+
+ this.views[0] = new Views.Albums(this.toolbar);
+ this.views[1] = new Views.Artists(this.toolbar);
+ this.views[2] = new Views.Songs(this.toolbar);
+ this.views[3] = new Views.Playlists(this.toolbar);
+
+ for (let i in this.views) {
+ this._stack.add_titled(
+ this.views[i],
+ this.views[i].title,
+ this.views[i].title
+ );
+ }
+
+ //this._stack.connect("notify::visible-child", this._onNotifyMode);
+
+ this.views[0].populate();
+ this.toolbar.set_stack(this._stack);
+ this.toolbar.show();
+ this.player.eventbox.show_all();
+ this._box.show();
+ this.show();
+ },
+
+ _onNotifyMode: function(stack, param) {
+ stack.get_visible_child().populate();
+ },
+
+ _toggleView: function(btn, i) {
+ this._stack.set_visible_child(this.views[i])
+ },
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]