Clone in a terminal:
Commit c586b0f
Johan Mattsson - 2015-03-16T09:20:32+00:00
c586b0fbcd517cc0ff40ec3a4ad380b2fd0cc145johan.mattsson.m@gmail.com

Custom icon files for themes

Changed files (4)

Diff

diff --git a/libbirdfont/Renderer/CarioDrawing.vala b/libbirdfont/Renderer/CarioDrawing.valadeleted file mode 100644index 0835d4d..0000000--- a/libbirdfont/Renderer/CarioDrawing.vala+++ /dev/null@@ -1,34 +0,0 @@-/*-    Copyright (C) 2014 Johan Mattsson--    This library is free software; you can redistribute it and/or modify -    it under the terms of the GNU Lesser General Public License as -    published by the Free Software Foundation; either version 3 of the -    License, or (at your option) any later version.--    This library is distributed in the hope that it will be useful, but -    WITHOUT ANY WARRANTY; without even the implied warranty of -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -    Lesser General Public License for more details.-*/--using Cairo;--namespace BirdFont {--public class CairoDrawing {-	-	public static Context? drawing_context;-	-	public static void new_path (double xa, double ya) {	-	}--	public static void curve_to (double xb, double yb, double xc, double yc, double xd, double yd) {-	}--	public static void close_path (double x, double y) {-	}--}--}diff --git a/libbirdfont/SearchPaths.vala b/libbirdfont/SearchPaths.valaindex 8cdaf41..b81c7b5 100644--- a/libbirdfont/SearchPaths.vala+++ b/libbirdfont/SearchPaths.vala@@ -20,6 +20,16 @@ public class SearchPaths { 	private static string resources_folder = ""; 	 	public static File find_file (string? dir, string name) {+		File f = search_file (dir, name);++		if (!f.query_exists ()) {+			warning (@"Did not find file $name");+		}+		+		return f;+	}+	+	public static File search_file (string? dir, string name) { 		File f; 		string d = (dir == null) ? "" : (!) dir; 		string resources;@@ -82,9 +92,7 @@ public class SearchPaths {  		f = get_file (@"/usr/share/birdfont/" + d + "/", name); 		if (likely (f.query_exists ())) return f;-								-		warning (@"Did not find file $name in $d (resources: $resources)");-			+ 		return f;		 	} 		diff --git a/libbirdfont/Theme.vala b/libbirdfont/Theme.valaindex ed98627..a4ca82f 100644--- a/libbirdfont/Theme.vala+++ b/libbirdfont/Theme.vala@@ -84,7 +84,7 @@ public class Theme : GLib.Object { 	} 	 	public static void set_default_colors () {-		current_theme = "";+		current_theme = "default.theme"; // FIXME: only on test 		 		color_list = new Gee.ArrayList<string> (); 		colors = new Gee.HashMap<string, Color> ();@@ -375,6 +375,27 @@ public class Theme : GLib.Object { 		 		TabContent.show_text_input (listener);		 	}+	+	public static string get_icon_file () {+		string icons;+		File f;++		return_val_if_fail (!is_null (current_theme), "icons.bf".dup ());+		return_val_if_fail (current_theme != "", "icons.bf".dup ());+		+		if (current_theme == "default.theme" || current_theme == "high_contrast.theme") {+			return "icons.bf".dup ();+		}+		+		icons = current_theme.replace (".theme", ".bf");+		f = SearchPaths.search_file (null, icons);+		+		if (f.query_exists ()) {+			return icons;+		}+		+		return "icons.bf".dup ();+	} }  }diff --git a/libbirdfont/Tool.vala b/libbirdfont/Tool.valaindex b6cc769..1d6d599 100644--- a/libbirdfont/Tool.vala+++ b/libbirdfont/Tool.vala@@ -184,14 +184,16 @@ public class Tool : Widget { 	 	public void set_icon (string name) { 		bool found;+		string icon_file; 		+		icon_file = Theme.get_icon_file (); 		icon_font = new Text ((!) name);-		found = icon_font.load_font ("icons.bf");+		found = icon_font.load_font (icon_file); 		icon_font.use_cache (false); 		icon_font.set_font_size (35); 		 		if (!found) {-			warning ("Icon font for toolbox was not found.");+			warning (@"Icon font for toolbox was not found. ($(icon_file))"); 		} 	} 	

Contact

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