add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / accelmap.cc
1 // -*- c++ -*-
2 /* $Id$ */
3
4 /* Copyright (C) 2002 The gtkmm Development Team
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #include <gtkmm/accelmap.h>
22 #include <gtk/gtkaccelmap.h>
23
24 namespace Gtk
25 {
26
27 namespace AccelMap
28 {
29
30 void add_entry(const std::string& accel_path, 
31                guint accel_key, 
32                Gdk::ModifierType accel_mods)
33 {
34     gtk_accel_map_add_entry(accel_path.c_str(), accel_key,
35                             (GdkModifierType)accel_mods);
36 }
37
38 bool change_entry(const std::string& accel_path, 
39                   guint accel_key, 
40                   Gdk::ModifierType accel_mods,
41                   bool replace)
42 {
43     return gtk_accel_map_change_entry(accel_path.c_str(), accel_key,
44                                       (GdkModifierType)accel_mods, replace);
45 }
46
47 void load(const std::string& filename)
48 {
49   gtk_accel_map_load(filename.c_str());
50 }
51
52 void save(const std::string& filename)
53 {
54   gtk_accel_map_save(filename.c_str());
55 }
56
57 void lock_path(const std::string& accel_path)
58 {
59   gtk_accel_map_lock_path(accel_path.c_str());
60 }
61
62 void unlock_path(const std::string& accel_path)
63 {
64   gtk_accel_map_unlock_path(accel_path.c_str());
65 }
66
67 bool lookup_entry(const Glib::ustring& accel_path, Gtk::AccelKey& key)
68 {
69   GtkAccelKey gkey = {GDK_VoidSymbol, GdkModifierType (0), 0};
70   const bool known = gtk_accel_map_lookup_entry(accel_path.c_str(), &gkey);
71
72   if(known)
73     key = AccelKey(gkey.accel_key, Gdk::ModifierType (gkey.accel_mods));
74   else
75     key = AccelKey(GDK_VoidSymbol, Gdk::ModifierType (0));
76
77   return known;
78 }
79
80 bool lookup_entry(const Glib::ustring& accel_path)
81 {
82   return gtk_accel_map_lookup_entry(accel_path.c_str(), 0 /* "optional", according to the C docs. */);
83 }
84
85 } // namespace AccelMap
86
87 } // namespace Gtk
88