summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-06-10 12:38:31 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2014-06-10 14:39:28 -0400
commitd59d26b89a875d226e8d7405d75c17c331fc6a0a (patch)
tree5eeee798eb68549dbf70da5a43c8f8a2acc0e0cd /gtk2_ardour/utils.cc
parenteca6c9f998feb70c606577f33446c907e0749c73 (diff)
change ::get_icon_path() and ::get_icon() to accept an "icon set" name to provide ability to use different sets of icons; use when creating MouseCursors
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc44
1 files changed, 37 insertions, 7 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index a04e37f9e5..3919a756cb 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -655,22 +655,52 @@ get_xpm (std::string name)
}
std::string
-get_icon_path (const char* cname)
+get_icon_path (const char* cname, string icon_set)
{
+ std::string data_file_path;
string name = cname;
name += X_(".png");
Searchpath spath(ARDOUR::ardour_data_search_path());
+
+ if (!icon_set.empty() && icon_set != "default") {
+ string subdir = Glib::build_filename ("icons", icon_set);
+ spath.add_subdirectory_to_paths (subdir);
+
+ find_file_in_search_path (spath, name, data_file_path);
+ }
+
+ if (data_file_path.empty()) {
+
+ if (!icon_set.empty() && icon_set != "default") {
+ warning << string_compose (_("icon \"%1\" not found for icon set \"%2\", fallback to default"), cname, icon_set) << endmsg;
+ }
+
+ Searchpath def (ARDOUR::ardour_data_search_path());
+ def.add_subdirectory_to_paths ("icons");
+
+ if (!find_file_in_search_path (def, name, data_file_path)) {
+ fatal << string_compose (_("cannot find icon image for %1 using %2"), name, spath.to_string()) << endmsg;
+ /*NOTREACHED*/
+ }
+ }
- spath.add_subdirectory_to_paths("icons");
-
- std::string data_file_path;
+ return data_file_path;
+}
- if (!find_file_in_search_path (spath, name, data_file_path)) {
- fatal << string_compose (_("cannot find icon image for %1 using %2"), name, spath.to_string()) << endmsg;
+Glib::RefPtr<Gdk::Pixbuf>
+get_icon (const char* cname, string icon_set)
+{
+ Glib::RefPtr<Gdk::Pixbuf> img;
+ try {
+ img = Gdk::Pixbuf::create_from_file (get_icon_path (cname, icon_set));
+ } catch (const Gdk::PixbufError &e) {
+ cerr << "Caught PixbufError: " << e.what() << endl;
+ } catch (...) {
+ error << string_compose (_("Caught exception while loading icon named %1"), cname) << endmsg;
}
- return data_file_path;
+ return img;
}
Glib::RefPtr<Gdk::Pixbuf>