From 98f3ef2689de06e8ab8b46a91acfa7dd2056a3a6 Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Mon, 5 Mar 2012 12:19:59 +0100 Subject: Imported Upstream version 0.5.1 --- src/images/icon.vala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/images/icon.vala') diff --git a/src/images/icon.vala b/src/images/icon.vala index 81eb2d9..e942e7c 100644 --- a/src/images/icon.vala +++ b/src/images/icon.vala @@ -74,6 +74,24 @@ public class Icon : Image { return base.width(); } + ///////////////////////////////////////////////////////////////////// + /// 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. ///////////////////////////////////////////////////////////////////// -- cgit v1.2.3