Commit c586b0f
Custom icon files for themes
Changed files (4)
deletedlibbirdfont/Renderer/CarioDrawing.valamodifiedlibbirdfont/SearchPaths.valamodifiedlibbirdfont/Theme.valamodifiedlibbirdfont/Tool.vala
Diff
deleted file mode 100644@@ -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) {- }--}--}@@ -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; } @@ -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 ();+ } } }@@ -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))"); } }