Clone in a terminal:
Commit 0e66e5d
Johan Mattsson - 2013-03-02T17:39:48+00:00
0e66e5d33e519bdb28a5d881be884de5d23c6999johan.mattsson.m@gmail.com

delete backup files

Changed files (4)

Diff

diff --git a/configure b/configureindex 12feb19..2a2f87d 100755--- a/configure+++ b/configure@@ -85,7 +85,7 @@ parser.add_option("-c", "--cc", dest="cc", help="C compiler", metavar="CC") if not options.prefix: 	options.prefix = "/usr" if not options.dest:-	options.dest = "/"+	options.dest = "" if not options.cc: 	options.cc = "gcc" 	diff --git a/layout/delete_backup.png b/layout/delete_backup.pngnew file mode 100644index 0000000..e3ae819Binary files /dev/null and b/layout/delete_backup.png differdiff --git a/libbirdfont/FontDisplay.vala b/libbirdfont/FontDisplay.valaindex 534e2b3..47b49f0 100644--- a/libbirdfont/FontDisplay.vala+++ b/libbirdfont/FontDisplay.vala@@ -213,13 +213,13 @@ public abstract class FontDisplay : GLib.Object { 		f = get_file (d + "\\", name); 		if (likely (f.query_exists ())) return f; -		f = get_file ("/usr/local/share/birdfont/" + d + "/", name);+		f = get_file (@"$PREFIX/share/birdfont/" + d + "/", name); 		if (likely (f.query_exists ())) return f; -		f = get_file ("/usr/share/birdfont/" + d + "/", name);+		f = get_file ("/usr/local/share/birdfont/" + d + "/", name); 		if (likely (f.query_exists ())) return f; -		f = get_file (@"$PREFIX/share/birdfont/" + d + "/", name);+		f = get_file ("/usr/share/birdfont/" + d + "/", name); 		if (likely (f.query_exists ())) return f; 				 		warning (@"Did not find file $name in $d");diff --git a/libbirdfont/MenuTab.vala b/libbirdfont/MenuTab.valaindex 50f2f8f..429870c 100644--- a/libbirdfont/MenuTab.vala+++ b/libbirdfont/MenuTab.vala@@ -61,6 +61,11 @@ public class MenuTab : FontDisplay { 		add_html_callback ("help", (val) => { 			MainWindow.get_tool_tip ().show_text (val); 		});++		add_html_callback ("delete_backups", (val) => {+			delete_backups ();+			MainWindow.get_tab_bar ().select_tab_name ("Menu");+		});		 	} 	 	public static void set_suppress_event (bool e) {@@ -145,6 +150,21 @@ if (has_backup ()) { 		c.append ("</div>\n");		 	} +	if (get_backups ().length () > 0) {+		c.append ("""<div class="recent_font" """ + "onclick=\"call ('delete_backups:')\">");++		c.append ("<div class=\"one_line\">");+		c.append (_("Delete all"));+		c.append ("</div>");+		+		c.append ("<img src=\"");+		c.append (path_to_uri ((!) FontDisplay.find_layout_dir ().get_child ("delete_backup.png").get_path ()));+		c.append ("\" alt=\"\">");	+		c.append ("<br /><br />");++		c.append ("</div>\n");+	}+ 	c.append ("""</div>"""); } @@ -195,6 +215,7 @@ c.append (""" 		_("Recover"); 		_("Export SVG font and view the result"); 		_("Export SVG font and view the result");+		_("Delete all") #endif  		return c.str;@@ -204,6 +225,25 @@ c.append (""" 		return get_backups ().length () > 0; 	} +	public static void delete_backups () {+		FileEnumerator enumerator;+		FileInfo? file_info;+		string file_name;+		File backup_file;+		File dir = BirdFont.get_backup_directory ();++		try {+			enumerator = dir.enumerate_children (FileAttribute.STANDARD_NAME, 0);+			while ((file_info = enumerator.next_file ()) != null) {+				file_name = ((!) file_info).get_name ();+				backup_file = dir.get_child (file_name);+				backup_file.delete ();+			}+		} catch (Error e) {+			warning (e.message);+		}+	}+ 	public List<string> get_backups () { 		FileEnumerator enumerator; 		string file_name;

Contact

Email: johan.mattsson.m@gmail.com
Mastodon: typo.social/@birdfont
GitHub: johanmattssonm
LinkedIn: johan-mattsson-2ab324112