[Xfce4-commits] <xfce4-notes-plugin:master> Move Xfconf init/shutdown into Xnp.Application

Mike Massonnet noreply at xfce.org
Wed Dec 16 23:54:01 CET 2009


Updating branch refs/heads/master
         to b7fee03f4ea38270892f6b1e7bc951d1f8beec88 (commit)
       from 9baf62cfac88912c5a77c7227eaa4cb33af81e43 (commit)

commit b7fee03f4ea38270892f6b1e7bc951d1f8beec88
Author: Mike Massonnet <mmassonnet at gmail.com>
Date:   Wed Dec 16 23:49:12 2009 +0100

    Move Xfconf init/shutdown into Xnp.Application

 ChangeLog                           |   14 ++++++++++++++
 panel-plugin/application.vala       |    9 ++++++++-
 panel-plugin/main-panel-plugin.vala |   14 --------------
 panel-plugin/main-status-icon.vala  |   17 -----------------
 4 files changed, 22 insertions(+), 32 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 99589b3..187d62c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-12-16  Mike Massonnet <mmassonnet at xfce.org>
+
+Move Xfconf init/shutdown into Xnp.Application
+	* panel-plugin/application.vala:
+	  - Init Xfconf at construction.
+	  - Shutdown Xfconf at finalize.
+	* panel-plugin/main-panel-plugin.vala,
+	panel-plugin/main-status-icon.vala:
+	  - Drop Xfconf code.
+	* panel-plugin/main-status-icon.vala:
+	  - No need to call save_notes/windows_configuration at NotesPlugin
+	  finalize as it is done during the Application finalize.
+	  - No need to set notes to null (destroy it manually).
+
 2009-12-02  Mike Massonnet <mmassonnet at xfce.org>
 
 Add Unique support for xfce4-notes and the settings dialog
diff --git a/panel-plugin/application.vala b/panel-plugin/application.vala
index 38032ac..c0bee86 100644
--- a/panel-plugin/application.vala
+++ b/panel-plugin/application.vala
@@ -34,9 +34,15 @@ namespace Xnp {
 		}
 
 		public Application (string config_file) {
+			try {
+				Xfconf.init ();
+			}
+			catch (Xfconf.Error e) {
+				critical ("%s", e.message);
+			}
+
 			this.config_file = config_file;
 			xfconf_channel = new Xfconf.Channel.with_property_base ("xfce4-panel", "/plugins/notes");
-
 			string color = xfconf_channel.get_string ("/global/background-color", "#F2F1EF");
 			Xnp.Color.set_background (color);
 
@@ -67,6 +73,7 @@ namespace Xnp {
 			save_windows_configuration ();
 			save_notes ();
 			xfconf_channel.unref ();
+			Xfconf.shutdown ();
 		}
 
 		/*
diff --git a/panel-plugin/main-panel-plugin.vala b/panel-plugin/main-panel-plugin.vala
index ba83fc9..22644eb 100644
--- a/panel-plugin/main-panel-plugin.vala
+++ b/panel-plugin/main-panel-plugin.vala
@@ -18,7 +18,6 @@
  */
 
 using Config;
-using Xfconf;
 using Xfce;
 using Gtk;
 
@@ -34,12 +33,6 @@ public class NotesPlugin : GLib.Object {
 	private weak Xfce.PanelPlugin panel_plugin;
 	private Xnp.Application application;
 
-	~NotesPlugin () {
-		// Destroy application before calling Xfconf.shutdown()
-		application = null;
-		Xfconf.shutdown ();
-	}
-
 #if HAVE_LIBXFCE4PANEL47
 	public override void @construct () {
 		panel_plugin = this;
@@ -49,13 +42,6 @@ public class NotesPlugin : GLib.Object {
 #endif
 
 		Xfce.textdomain (Config.GETTEXT_PACKAGE, Config.PACKAGE_LOCALE_DIR);
-		try {
-			Xfconf.init ();
-		}
-		catch (Xfconf.Error e) {
-			warning ("%s", e.message);
-		}
-
 		application = new Xnp.Application (panel_plugin.save_location (true));
 
 #if HAVE_LIBXFCE4PANEL47
diff --git a/panel-plugin/main-status-icon.vala b/panel-plugin/main-status-icon.vala
index 0d975f7..2443a65 100644
--- a/panel-plugin/main-status-icon.vala
+++ b/panel-plugin/main-status-icon.vala
@@ -18,7 +18,6 @@
  */
 
 using Config;
-using Xfconf;
 using Xfce;
 using Gtk;
 
@@ -29,23 +28,8 @@ public class Notes : GLib.Object {
 	private Xnp.Application application;
 	private Gtk.Menu context_menu;
 
-	~NotesPlugin () {
-		application.save_windows_configuration ();
-		application.save_notes ();
-		// Destroy application before calling Xfconf.shutdown()
-		application = null;
-		Xfconf.shutdown ();
-	}
-
 	public Notes () {
 		Xfce.textdomain (Config.GETTEXT_PACKAGE, Config.PACKAGE_LOCALE_DIR);
-		try {
-			Xfconf.init ();
-		}
-		catch (Xfconf.Error e) {
-			warning ("%s", e.message);
-		}
-
 		var save_location = Xfce.Resource.save_location (Xfce.ResourceType.CONFIG, "xfce4/xfce4-notes.rc", true);
 		application = new Xnp.Application (save_location);
 
@@ -145,7 +129,6 @@ public class Notes : GLib.Object {
 		var notes = new Notes ();
 		Xfce.Autostart. at set ("xfce4-notes-autostart", "xfce4-notes", false);
 		Gtk.main ();
-		notes = null;
 		return 0;
 	}
 }



More information about the Xfce4-commits mailing list