[Xfce4-commits] <xfce4-notes-plugin:master> Keep order of notes (bug #5534)

Mike Massonnet mmassonnet at xfce.org
Fri Aug 21 22:54:02 CEST 2009


Updating branch refs/heads/master
         to 5b258ff8c7348a38bf6f63ef5a8969c5939deb8b (commit)
       from fcfe6ce6da97a909a9ff7accadd6133797a013b6 (commit)

commit 5b258ff8c7348a38bf6f63ef5a8969c5939deb8b
Author: Mike Massonnet <mmassonnet at xfce.org>
Date:   Fri Aug 21 22:51:04 2009 +0200

    Keep order of notes (bug #5534)

 ChangeLog                     |   13 +++++++++++++
 panel-plugin/application.vala |    5 +++++
 panel-plugin/window.vala      |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 18a552c..91709f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-08-21  Mike Massonnet <mmassonnet at xfce.org>
+
+Keep order of notes (bug #5534)
+	* panel-plugin/application.vala:
+	  - Store tabs order in configuration file for each window with new
+	  XnpWindow method get_note_names().
+	  - Load tabs order and place them correctly in notebook with new
+	  XnpWindow method move_note().
+	* panel-plugin/window.vala:
+	  - Two new public methods get_note_names() that returns the name of
+	  the notes in a string array, and move_note() that reorders a note
+	  find by its name in the notebook.
+
 2009-08-08  Mike Massonnet <mmassonnet at xfce.org>
 
 Rework default window visibility (bug #4055)
diff --git a/panel-plugin/application.vala b/panel-plugin/application.vala
index fa832f6..cc25f2f 100644
--- a/panel-plugin/application.vala
+++ b/panel-plugin/application.vala
@@ -227,6 +227,7 @@ namespace Xnp {
 				int winy = keyfile.get_integer (window.name, "PosY");
 				int width = keyfile.get_integer (window.name, "Width");
 				int height = keyfile.get_integer (window.name, "Height");
+				string[] tabs_order = keyfile.get_string_list (window.name, "TabsOrder");
 				int last_page = keyfile.get_integer (window.name, "LastTab");
 				bool above = keyfile.get_boolean (window.name, "Above");
 				bool sticky = keyfile.get_boolean (window.name, "Sticky");
@@ -235,6 +236,8 @@ namespace Xnp {
 
 				window.move (winx, winy);
 				window.resize (width, height);
+				for (int i = 0; i < tabs_order.length; i++)
+					window.move_note (tabs_order[i], i);
 				window.set_current_page (last_page);
 				window.above = above;
 				window.sticky = sticky;
@@ -259,6 +262,7 @@ namespace Xnp {
 				foreach (var win in this.window_list) {
 					int winx, winy, width, height;
 					win.get_geometry (out winx, out winy, out width, out height);
+					string[] tabs_order = win.get_note_names ();
 					int last_page = win.get_current_page ();
 					int transparency = (int)((1 - win.opacity) * 100);
 					bool visible = (bool)(win.get_flags () & Gtk.WidgetFlags.VISIBLE);
@@ -267,6 +271,7 @@ namespace Xnp {
 					keyfile.set_integer (win.name, "PosY", winy);
 					keyfile.set_integer (win.name, "Width", width);
 					keyfile.set_integer (win.name, "Height", height);
+					keyfile.set_string_list (win.name, "TabsOrder", tabs_order);
 					keyfile.set_integer (win.name, "LastTab", last_page);
 					keyfile.set_boolean (win.name, "Above", win.above);
 					keyfile.set_boolean (win.name, "Sticky", win.sticky);
diff --git a/panel-plugin/window.vala b/panel-plugin/window.vala
index 0c2c049..e9a003f 100644
--- a/panel-plugin/window.vala
+++ b/panel-plugin/window.vala
@@ -935,6 +935,39 @@ namespace Xnp {
 		}
 
 		/**
+		 * move_note:
+		 *
+		 * Moves the note named @note_name to position @page.
+		 */
+		public void move_note (string note_name, int page) {
+			int n_pages = this.notebook.get_n_pages ();
+			for (int p = 0; p < n_pages; p++) {
+				var note = (Xnp.Note)this.notebook.get_nth_page (p);
+				if (note.name == note_name) {
+					this.notebook.reorder_child (note, page);
+					update_navigation_sensitivity (page);
+					break;
+				}
+			}
+		}
+
+		/**
+		 * get_note_names:
+		 *
+		 * Returns a string list of the note names in the order they are currently displayed
+		 * in the notebook.
+		 */
+		public string[] get_note_names () {
+			string[] note_names = null;
+			int n_pages = this.notebook.get_n_pages ();
+			for (int p = 0; p < n_pages; p++) {
+				var note = (Xnp.Note)this.notebook.get_nth_page (p);
+				note_names += note.name;
+			}
+			return note_names;
+		}
+
+		/**
 		 * delete_current_note:
 		 *
 		 * Delete the current note.



More information about the Xfce4-commits mailing list