The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Custom icon files for themes

These changes was commited to the Birdfont repository Mon, 16 Mar 2015 08:26:56 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 16 Mar 2015 08:26:56 +0000 (09:26 +0100)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 16 Mar 2015 09:20:32 +0000 (10:20 +0100)
commit c586b0fbcd517cc0ff40ec3a4ad380b2fd0cc145
tree 0da0534ca7b67a9798e120b195fb99e9469115c1
parent 562584155ff1ea606068a5d6eb0b0e1f7542ee15
Custom icon files for themes

libbirdfont/Renderer/CarioDrawing.vala [deleted ]
libbirdfont/SearchPaths.vala
libbirdfont/Theme.vala
libbirdfont/Tool.vala
--- a/libbirdfont/Renderer/CarioDrawing.vala +++ /dev/null @@ -1,35 +1,1 @@ - /* - 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) { - } - - } - - }
--- a/libbirdfont/SearchPaths.vala +++ b/libbirdfont/SearchPaths.vala @@ -20,6 +20,16 @@ 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 @@ 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; }
--- a/libbirdfont/Theme.vala +++ b/libbirdfont/Theme.vala @@ -84,7 +84,7 @@ } 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> (); @@ -374,8 +374,29 @@ }); 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 (); } } }
--- a/libbirdfont/Tool.vala +++ b/libbirdfont/Tool.vala @@ -184,14 +184,16 @@ 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))"); } }