summaryrefslogtreecommitdiff
path: root/src/images
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2017-07-25 06:51:21 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2017-07-25 06:51:21 +0200
commit3b49907c8b012b0a62d6e264f62bf03b13e68a51 (patch)
treee9acc532002ca7a52810325eee1f16d6d17f9d27 /src/images
parent394ad3b32f9f79775bcac4c6cc2a4dfa74586800 (diff)
parent334f925d5866faaf6ed36a4269d14bcc7aa86a76 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'src/images')
-rw-r--r--src/images/icon.vala63
-rw-r--r--src/images/image.vala2
-rw-r--r--src/images/renderedText.vala2
-rw-r--r--src/images/themedIcon.vala2
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