[Goodies-commits] r7472 - in xfce4-notes-plugin/trunk: . panel-plugin
Mike Massonnet
mmassonnet at xfce.org
Sat Jun 6 15:18:48 CEST 2009
Author: mmassonnet
Date: 2009-06-06 13:18:48 +0000 (Sat, 06 Jun 2009)
New Revision: 7472
Modified:
xfce4-notes-plugin/trunk/ChangeLog
xfce4-notes-plugin/trunk/panel-plugin/application.vala
xfce4-notes-plugin/trunk/panel-plugin/note.vala
Log:
Verify window/notes names for a set of invalid characters
Modified: xfce4-notes-plugin/trunk/ChangeLog
===================================================================
--- xfce4-notes-plugin/trunk/ChangeLog 2009-06-06 12:26:58 UTC (rev 7471)
+++ xfce4-notes-plugin/trunk/ChangeLog 2009-06-06 13:18:48 UTC (rev 7472)
@@ -1,5 +1,13 @@
2009-06-06 Mike Massonnet <mmassonnet at xfce.org>
+Verify window/notes names for a set of invalid characters
+ * panel-plugin/application.vala:
+ - New method name_is_valid that verifies if the given name has
+ invalid characters in it.
+ - On window/notes rename, verify the name and revert appropriately.
+
+2009-06-06 Mike Massonnet <mmassonnet at xfce.org>
+
Sort window_list on window rename
* panel-plugin/application.vala:
- On rename_window sort the SList window_list.
Modified: xfce4-notes-plugin/trunk/panel-plugin/application.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/application.vala 2009-06-06 12:26:58 UTC (rev 7471)
+++ xfce4-notes-plugin/trunk/panel-plugin/application.vala 2009-06-06 13:18:48 UTC (rev 7472)
@@ -171,6 +171,10 @@
GLib.FileUtils.unlink (path);
};
window.note_renamed += (win, note, old_name) => {
+ if (!name_is_valid (note.name)) {
+ note.name = old_name;
+ return;
+ }
string old_path = "%s/%s/%s".printf (notes_path, win.name, old_name);
string new_path = "%s/%s/%s".printf (notes_path, win.name, note.name);
GLib.FileUtils.rename (old_path, new_path);
@@ -332,6 +336,9 @@
error_dialog.destroy ();
}
else {
+ if (!name_is_valid (name)) {
+ return;
+ }
string old_path = "%s/%s".printf (notes_path, window.name);
string new_path = "%s/%s".printf (notes_path, name);
window.name = name;
@@ -395,6 +402,23 @@
return false;
}
+ /**
+ * name_is_valid:
+ *
+ * Verify if the given name is valid for window and notes.
+ */
+ private bool name_is_valid (string name) {
+ bool res = GLib.Regex.match_simple ("^[^*|/\\:\"<>?]+$", name);
+ if (!res) {
+ var error_dialog = new Gtk.MessageDialog (null, 0,
+ Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, "The name \"%s\" is invalid.", name);
+ error_dialog.format_secondary_markup ("The invalid characters are restricted to: <tt>*|/\\:\"<>?</tt>");
+ error_dialog.run ();
+ error_dialog.destroy ();
+ }
+ return res;
+ }
+
}
}
Modified: xfce4-notes-plugin/trunk/panel-plugin/note.vala
===================================================================
--- xfce4-notes-plugin/trunk/panel-plugin/note.vala 2009-06-06 12:26:58 UTC (rev 7471)
+++ xfce4-notes-plugin/trunk/panel-plugin/note.vala 2009-06-06 13:18:48 UTC (rev 7472)
@@ -115,7 +115,7 @@
* Send save-data signal.
*/
private bool save_cb () {
- save_data ();
+ this.save_data ();
this.save_timeout = 0;
this._dirty = false;
return false;
More information about the Goodies-commits
mailing list