[Xfce4-commits] <xfce4-notes-plugin:master> Properly quit on remove

Mike Massonnet noreply at xfce.org
Wed Dec 23 16:10:06 CET 2009


Updating branch refs/heads/master
         to 926b62ca4e2a1208198246a36053bf4bbc93fe6c (commit)
       from 7d379147dc8ea781d6ee20150ba56d7b9c75c96b (commit)

commit 926b62ca4e2a1208198246a36053bf4bbc93fe6c
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Wed Dec 23 16:07:13 2009 +0100

    Properly quit on remove

 ChangeLog                     |   11 +++++++++++
 lib/application.vala          |    6 +++++-
 src/main-panel-plugin-47.vala |   35 +++++++++++++----------------------
 3 files changed, 29 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6a1508c..f2f5cfe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2009-12-23  Mike Massonnet <mmassonnet at xfce.org>
 
+Properly quit on remove
+
+The panel plugin needs to call Gtk.main_quit() either on free or simpler on
+destroy otherwise the wrapper process will be around after removing the plugin
+from the panel.
+Drop the useless panel_plugin pointer.
+Change the call to warning() inside Xnp.Application to message() otherwise the
+panel will automatically drop the plugin.
+
+2009-12-23  Mike Massonnet <mmassonnet at xfce.org>
+
 Fix earlier commit with note.notify["name"]
 
 2009-12-23  Mike Massonnet <mmassonnet at xfce.org>
diff --git a/lib/application.vala b/lib/application.vala
index 828bda6..ca99845 100644
--- a/lib/application.vala
+++ b/lib/application.vala
@@ -75,6 +75,10 @@ namespace Xnp {
 			save_notes ();
 			xfconf_channel = null;
 			Xfconf.shutdown ();
+			foreach (var win in this.window_list) {
+				win.destroy ();
+				win = null;
+			}
 		}
 
 		/*
@@ -257,7 +261,7 @@ namespace Xnp {
 					window.show ();
 			}
 			catch (GLib.Error e) {
-				warning ("Unable to load window configuration from %s: %s", config_file, e.message);
+				message ("Unable to load window configuration from %s: %s", config_file, e.message);
 				window.show ();
 			}
 		}
diff --git a/src/main-panel-plugin-47.vala b/src/main-panel-plugin-47.vala
index 2503bd7..89fb778 100644
--- a/src/main-panel-plugin-47.vala
+++ b/src/main-panel-plugin-47.vala
@@ -26,56 +26,47 @@ public class NotesPlugin : Xfce.PanelPlugin {
 	private Gtk.Invisible invisible;
 	private Gtk.Button button;
 	private Xfce.PanelImage image;
-	private weak Xfce.PanelPlugin panel_plugin;
 	private Xnp.Application application;
 
 	public NotesPlugin () {
 		GLib.Object ();
-		debug ("constructor");
 	}
 
 	public override void @construct () {
-		panel_plugin = this;
-
 		Xfce.textdomain (Config.GETTEXT_PACKAGE, Config.PACKAGE_LOCALE_DIR);
-		application = new Xnp.Application (panel_plugin.save_location (true));
+		application = new Xnp.Application (save_location (true));
 
 		button = Xfce.panel_create_button ();
 		image = new Xfce.PanelImage.from_source ("xfce4-notes-plugin");
 		button.add (image);
 		button.clicked += () => { application.show_hide_notes (); };
 		button.show_all ();
-		panel_plugin.add (button);
-		panel_plugin.add_action_widget (button);
-		panel_plugin.set_tooltip_text (_("Notes"));
-		panel_plugin.menu_show_configure ();
-		panel_plugin.menu_show_about ();
+		add (button);
+		add_action_widget (button);
+		set_tooltip_text (_("Notes"));
+		menu_show_configure ();
+		menu_show_about ();
 
 		var mi = new Gtk.MenuItem.with_mnemonic (_("_Go"));
 		var menu = application.context_menu ();
 		mi.set_submenu (menu);
 		mi.show_all ();
-		panel_plugin.menu_insert_item (mi);
+		menu_insert_item (mi);
 
 		set_x_selection ();
 
-		panel_plugin.size_changed += (p, size) => {
+		size_changed += (p, size) => {
 			button.set_size_request (size, size);
 			return true;
 		};
-		panel_plugin.save += () => {
-			application.save_windows_configuration ();
-		};
-		panel_plugin.free_data += () => {
+		save += () => { application.save_windows_configuration (); };
+		free_data += () => {
 			application.save_windows_configuration ();
 			application.save_notes ();
 		};
-		panel_plugin.configure_plugin += () => {
-			application.open_settings_dialog ();
-		};
-		panel_plugin.about += () => {
-			application.open_about_dialog ();
-		};
+		configure_plugin += () => { application.open_settings_dialog (); };
+		about += () => { application.open_about_dialog (); };
+		destroy += () => { Gtk.main_quit (); };
 	}
 
 	/**



More information about the Xfce4-commits mailing list