← Back to team overview

elementaryart team mailing list archive

[Merge] lp:~victored/granite/decorated-window-hide-on-close into lp:granite

 

Victor Eduardo has proposed merging lp:~victored/granite/decorated-window-hide-on-close into lp:granite.

Requested reviews:
  elementary Pantheon team (elementary-pantheon)

For more details, see:
https://code.launchpad.net/~victored/granite/decorated-window-hide-on-close/+merge/106544

Is hide_on_close okay or should I pick a more intuitive name for this property?
-- 
https://code.launchpad.net/~victored/granite/decorated-window-hide-on-close/+merge/106544
Your team elementaryart (old) is subscribed to branch lp:granite.
=== modified file 'lib/Widgets/DecoratedWindow.vala'
--- lib/Widgets/DecoratedWindow.vala	2012-05-18 17:13:53 +0000
+++ lib/Widgets/DecoratedWindow.vala	2012-05-20 20:53:18 +0000
@@ -81,6 +81,15 @@
             }
         }
 
+        /**
+         * Whether to hide or destroy the window when the close button is clicked.
+         * By default, the window is destroyed. You can change that by changing this
+         * property to 'true'.
+         *
+         * Default: false;
+         */
+        public bool hide_on_close { get; set; default = false; }
+
         protected Gtk.Box box { get; private set; }
         protected Gtk.Window draw_ref { get; private set; }
         protected Gdk.Pixbuf close_img;
@@ -193,10 +202,15 @@
         }
 
         private bool on_button_press (Gdk.EventButton e) {
-                if (coords_over_close_button (e.x, e.y))
-                    this.destroy ();
-                else
+                if (coords_over_close_button (e.x, e.y)) {
+                    if (hide_on_close)
+                        this.hide ();
+                    else
+                        this.destroy ();
+                }
+                else {
                     this.begin_move_drag ((int)e.button, (int)e.x_root, (int)e.y_root, e.time);
+                }
 
                 return true;
         }