[gnome-music/wip/gtkmaster: 3/3] Add close button



commit a325e8d72b0a297e081611971c703e21b84eb424
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu May 30 18:59:42 2013 +0200

    Add close button

 src/toolbar.js |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/toolbar.js b/src/toolbar.js
index 1f54945..150c886 100644
--- a/src/toolbar.js
+++ b/src/toolbar.js
@@ -48,6 +48,7 @@ const Toolbar = new Lang.Class({
         this._stack_switcher = new Gtk.StackSwitcher ();
         this.set_custom_title (null);
         this._addBackButton();
+        this._addCloseButton();
     },
 
     set_stack: function(stack) {
@@ -79,6 +80,26 @@ const Toolbar = new Lang.Class({
                                                      label: _("Back") });
         this._backButton.connect('clicked', Lang.bind(this, this.setState))
         this.pack_start(this._backButton);
+    },
+
+    _closeButtonClicked: function () {
+        let event = new Gdk.Event(Gdk.EventType.DELETE);
+        event.any.window = this.get_parent().get_window();
+        event.any.send_event = 1;
+
+        Gtk.main_do_event(event);
+        event.free();
+    },
+
+    _addCloseButton: function() {
+        this._closeSeparator = new Gtk.Separator({ orientation: Gtk.Orientation.VERTICAL });
+        this.pack_end(this._closeSeparator);
+
+        let iconName = 'window-close-symbolic';
+        this._closeButton = new Gd.HeaderSimpleButton({ symbolic_icon_name: iconName,
+                                                        label: _("Close Window") });
+        this._closeButton.connect('clicked', Lang.bind(this, this._closeButtonClicked))
+        this.pack_end(this._closeButton);
     }
 });
 Signals.addSignalMethods(Toolbar.prototype);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]