[Xfce4-commits] <xfmpc:master> status-icon: Make an option to "close into notification area"

Mike Massonnet noreply at xfce.org
Sat Aug 13 10:54:04 CEST 2011


Updating branch refs/heads/master
         to 98a81b44fb1073e4abf4273454da5fcaae6faff3 (commit)
       from 24132cf3d9ca3e4a83e9337b096fc13bb128d7bb (commit)

commit 98a81b44fb1073e4abf4273454da5fcaae6faff3
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Sun Jul 31 20:18:22 2011 +0200

    status-icon: Make an option to "close into notification area"
    
    When closing the window, instead of quitting the application hide
    it instead and let it be possible to show it again by clicking the
    status icon.

 src/main-window.vala        |   11 ++++++++++-
 src/preferences-dialog.vala |   12 +++++++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/main-window.vala b/src/main-window.vala
index 1b3136b..bf719a6 100644
--- a/src/main-window.vala
+++ b/src/main-window.vala
@@ -186,7 +186,11 @@ namespace Xfmpc {
 		private bool cb_window_closed (Gdk.Event event) {
 			close_window ();
 
-			return false;
+			/* Return true in case the window should not be destroyed,
+			 * and there is currently one case when this should be done:
+			 * the user choosed to "close into notification area," that
+			 * is when the status icon is visible. */
+			return this.status_icon.visible;
 		}
 
 		private void action_close () {
@@ -197,6 +201,11 @@ namespace Xfmpc {
 			int posx, posy;
 			int width, height;
 
+			if (this.status_icon.visible) {
+				this.hide ();
+				return;
+			}
+
 			get_position (out posx, out posy);
 			get_size (out width, out height);
 
diff --git a/src/preferences-dialog.vala b/src/preferences-dialog.vala
index 4d3bd74..73ae343 100644
--- a/src/preferences-dialog.vala
+++ b/src/preferences-dialog.vala
@@ -29,6 +29,7 @@ namespace Xfmpc {
 		private Gtk.Entry entry_host;
 		private Gtk.Entry entry_passwd;
 		private Gtk.SpinButton entry_port;
+		private Gtk.CheckButton show_status_icon;
 		private Gtk.CheckButton show_statusbar;
 		private Gtk.ComboBox combo_format;
 		private Gtk.Entry entry_custom;
@@ -111,9 +112,14 @@ namespace Xfmpc {
 			notebook.append_page (vbox, label);
 
 			vbox2 = new Gtk.VBox (false, 6);
-			frame = Xfce.gtk_frame_box_new_with_content (_("Statusbar"), vbox2);
+			frame = Xfce.gtk_frame_box_new_with_content (_("General"), vbox2);
 			vbox.pack_start (frame, false, false, 0);
 
+			this.show_status_icon = new Gtk.CheckButton.with_mnemonic (_("Close window into notification area"));
+			this.show_status_icon.set_active (this.preferences.show_status_icon);
+			this.show_status_icon.toggled.connect (cb_show_status_icon_toggled);
+			vbox2.pack_start (this.show_status_icon, false, false, 0);
+
 			this.show_statusbar = new Gtk.CheckButton.with_mnemonic (_("Show _stastusbar"));
 			this.show_statusbar.set_active (this.preferences.show_statusbar);
 			this.show_statusbar.toggled.connect (cb_show_statusbar_toggled);
@@ -242,6 +248,10 @@ namespace Xfmpc {
 			mpdclient.connect ();
 		}
 
+		private void cb_show_status_icon_toggled () {
+			this.preferences.show_status_icon = this.show_status_icon.get_active ();
+		}
+
 		private void cb_show_statusbar_toggled () {
 			this.preferences.show_statusbar = this.show_statusbar.get_active ();
 		}


More information about the Xfce4-commits mailing list