summaryrefslogtreecommitdiff
path: root/gtk2_ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-09-10 15:03:30 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-09-10 15:03:30 +0000
commit68e943265edf04e63a8e8b8f62bab20f99d9c637 (patch)
treeff8941a59662fc0c4622944b65f7b2d5e3bdd0c3 /gtk2_ardour/utils.cc
parente4372df05b7d74a6b80dbbf4b6c00cc2b31c4723 (diff)
merge from 2.0-ongoing @ 3581
git-svn-id: svn://localhost/ardour2/branches/3.0@3711 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/utils.cc')
-rw-r--r--gtk2_ardour/utils.cc101
1 files changed, 62 insertions, 39 deletions
diff --git a/gtk2_ardour/utils.cc b/gtk2_ardour/utils.cc
index a52969268a..9008f8b8cd 100644
--- a/gtk2_ardour/utils.cc
+++ b/gtk2_ardour/utils.cc
@@ -36,6 +36,7 @@
#include <gtkmm2ext/utils.h>
#include <ardour/configuration.h>
+#include <ardour/configuration.h>
#include <ardour/filesystem_paths.h>
@@ -469,39 +470,10 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
it does allow.
*/
- int fakekey = GDK_VoidSymbol;
- int ret = false;
-
- switch (ev->keyval) {
- case GDK_Tab:
- case GDK_ISO_Left_Tab:
- fakekey = GDK_nabla;
- break;
-
- case GDK_Up:
- fakekey = GDK_uparrow;
- break;
-
- case GDK_Down:
- fakekey = GDK_downarrow;
- break;
-
- case GDK_Right:
- fakekey = GDK_rightarrow;
- break;
-
- case GDK_Left:
- fakekey = GDK_leftarrow;
- break;
-
- default:
- break;
- }
+ uint32_t fakekey = ev->keyval;
- if (fakekey != GDK_VoidSymbol) {
- ret = gtk_accel_groups_activate(G_OBJECT(win), fakekey, GdkModifierType(ev->state));
-
- if (ret) {
+ if (possibly_translate_keyval_to_make_legal_accelerator (fakekey)) {
+ if (gtk_accel_groups_activate(G_OBJECT(win), fakekey, GdkModifierType(ev->state))) {
return true;
}
@@ -590,18 +562,30 @@ key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev)
Glib::RefPtr<Gdk::Pixbuf>
get_xpm (std::string name)
{
- SearchPath spath(ARDOUR::ardour_search_path());
- spath += ARDOUR::system_data_search_path();
+ if (!xpm_map[name]) {
- spath.add_subdirectory_to_paths("pixmaps");
+ SearchPath spath(ARDOUR::ardour_search_path());
+ spath += ARDOUR::system_data_search_path();
+
+ spath.add_subdirectory_to_paths("pixmaps");
+
+ sys::path data_file_path;
+
+ if (!find_file_in_search_path (spath, name, data_file_path)) {
+ fatal << string_compose (_("cannot find XPM file for %1"), name) << endmsg;
+ /*NOTREACHED*/
+ }
- sys::path data_file_path;
+ try {
+ xpm_map[name] = Gdk::Pixbuf::create_from_file (data_file_path.to_string());
+ }
- if(!find_file_in_search_path (spath, name, data_file_path)) {
- fatal << string_compose (_("cannot find XPM file for %1"), name) << endmsg;
+ catch(const Glib::Error& e) {
+ warning << "Caught Glib::Error: " << e.what() << endmsg;
+ }
}
- return Gdk::Pixbuf::create_from_file (data_file_path.to_string());
+ return xpm_map[name];
}
Glib::RefPtr<Gdk::Pixbuf>
@@ -738,3 +722,42 @@ reset_dpi ()
DPIReset();//Emit Signal
}
+bool
+possibly_translate_keyval_to_make_legal_accelerator (uint32_t& keyval)
+{
+ int fakekey = GDK_VoidSymbol;
+
+ switch (keyval) {
+ case GDK_Tab:
+ case GDK_ISO_Left_Tab:
+ fakekey = GDK_nabla;
+ break;
+
+ case GDK_Up:
+ fakekey = GDK_uparrow;
+ break;
+
+ case GDK_Down:
+ fakekey = GDK_downarrow;
+ break;
+
+ case GDK_Right:
+ fakekey = GDK_rightarrow;
+ break;
+
+ case GDK_Left:
+ fakekey = GDK_leftarrow;
+ break;
+
+ default:
+ break;
+ }
+
+ if (fakekey != GDK_VoidSymbol) {
+ keyval = fakekey;
+ return true;
+ }
+
+ return false;
+}
+