diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-07-24 19:58:27 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2017-07-24 19:58:27 +0200 |
commit | 309d161f6d464fcea2de200bb3cb5a7cb784b6d3 (patch) | |
tree | a0d5ea02bfb3765191f2596aa8a7404f6b3a819c /src/images | |
parent | 45a3d7f0e2783d9898f017772583d31c1c9e0f03 (diff) |
New upstream version 0.7.1upstream/0.7.1
Diffstat (limited to 'src/images')
-rw-r--r-- | src/images/icon.vala | 63 | ||||
-rw-r--r-- | src/images/image.vala | 2 | ||||
-rw-r--r-- | src/images/renderedText.vala | 2 | ||||
-rw-r--r-- | src/images/themedIcon.vala | 2 |
4 files changed, 26 insertions, 43 deletions
diff --git a/src/images/icon.vala b/src/images/icon.vala index 176e187..7933e81 100644 --- a/src/images/icon.vala +++ b/src/images/icon.vala @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011-2016 by Simon Schneegans +// Copyright (c) 2011-2017 by Simon Schneegans // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -75,60 +75,43 @@ public class Icon : Image { } ///////////////////////////////////////////////////////////////////// - /// Returns the icon name for a given GLib.Icon. - ///////////////////////////////////////////////////////////////////// - - public static string get_icon_name(GLib.Icon? icon) { - if (icon != null) { - var icon_names = icon.to_string().split(" "); - - foreach (var icon_name in icon_names) { - if (Gtk.IconTheme.get_default().has_icon(icon_name)) { - return icon_name; - } - } - } - - return ""; - } - - ///////////////////////////////////////////////////////////////////// /// Returns the filename for a given system icon. ///////////////////////////////////////////////////////////////////// public static string get_icon_file(string icon_name, int size) { - string result = ""; - if (icon_name.contains("/")) { var file = GLib.File.new_for_path(icon_name); - if(file.query_exists()) + if(file.query_exists()) { return icon_name; - - warning("Icon \"" + icon_name + "\" not found! Using default icon..."); + } } - var icon_theme = Gtk.IconTheme.get_default(); var file = icon_theme.lookup_icon(icon_name, size, 0); - if (file != null) result = file.get_filename(); - - if (result == "") { - warning("Icon \"" + icon_name + "\" not found! Using default icon..."); - - string[] default_icons = {"application-default-icon", "stock_unknown"}; - foreach (var icon in default_icons) { - file = icon_theme.lookup_icon(icon, size, 0); - if (file != null) { - result = file.get_filename(); - break; - } + if (file != null) { + return file.get_filename(); + } + + try { + file = icon_theme.lookup_by_gicon(GLib.Icon.new_for_string(icon_name), size, 0); + if (file != null) { + return file.get_filename(); } + } catch(GLib.Error e) {} + + warning("Icon \"" + icon_name + "\" not found! Using default icon..."); - if (result == "") - warning("No default icon found! Will be ugly..."); + string[] default_icons = {"image-missing", "application-default-icon"}; + foreach (var icon in default_icons) { + file = icon_theme.lookup_icon(icon, size, 0); + if (file != null) { + return file.get_filename(); + } } - return result; + warning("No default icon found! Will be ugly..."); + + return ""; } } diff --git a/src/images/image.vala b/src/images/image.vala index 840a8ad..9a00f45 100644 --- a/src/images/image.vala +++ b/src/images/image.vala @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011-2016 by Simon Schneegans +// Copyright (c) 2011-2017 by Simon Schneegans // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/images/renderedText.vala b/src/images/renderedText.vala index f00c8b5..cae6ee3 100644 --- a/src/images/renderedText.vala +++ b/src/images/renderedText.vala @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011-2016 by Simon Schneegans +// Copyright (c) 2011-2017 by Simon Schneegans // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/src/images/themedIcon.vala b/src/images/themedIcon.vala index 9dd9609..6ab5741 100644 --- a/src/images/themedIcon.vala +++ b/src/images/themedIcon.vala @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// Copyright (c) 2011-2016 by Simon Schneegans +// Copyright (c) 2011-2017 by Simon Schneegans // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by |