Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_04 / synfig-studio / src / gtkmm / keymapsettings.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file keymapsettings.cpp
3 **      \brief Contains Info for Key Map settings
4 **
5 **      $Id: keymapsettings.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "keymapsettings.h"
33
34 #include <gtkmm/accelkey.h>
35 #include <gtkmm/accelmap.h>
36 #include <gtk/gtkaccelmap.h>
37
38 #endif
39
40 /* === U S I N G =========================================================== */
41
42 using namespace std;
43 //using namespace etl;
44 //using namespace synfig;
45 using namespace studio;
46
47 using namespace Gtk;
48 //using namespace Gtk::Menu_Helpers;
49
50 /* === M A C R O S ========================================================= */
51
52 /* === G L O B A L S ======================================================= */
53
54 /* === P R O C E D U R E S ================================================= */
55
56 /* === M E T H O D S ======================================================= */
57
58 /* === E N T R Y P O I N T ================================================= */
59
60 // KeyMapSettings Definitions
61 KeyMapSettings::KeyMapSettings()
62 {
63 }
64
65 KeyMapSettings::~KeyMapSettings()
66 {
67 }
68
69 bool KeyMapSettings::set_key(const char *path, guint key, Gdk::ModifierType mod, bool replace)
70 {
71         if(gtk_accel_map_lookup_entry(path,NULL))
72         {
73                 return AccelMap::change_entry(path,key,mod,replace);
74         }else
75         {
76                 AccelMap::add_entry(path,key,mod);
77                 return true;
78         }
79 }
80
81 bool KeyMapSettings::get_key(const char *path, AccelKey *key)
82 {
83         GtkAccelKey     ac;
84         if(gtk_accel_map_lookup_entry(path,&ac))
85         {
86                 *key = AccelKey(ac.accel_key,(Gdk::ModifierType)ac.accel_mods,string(path));
87                 return true;
88         }
89         
90         return false;
91 }
92
93 bool KeyMapSettings::load(const char *filename)
94 {
95         string n(filename);
96         n += ".skm";
97         
98         AccelMap::load(filename);
99         
100         return true;    
101 }
102
103 bool KeyMapSettings::save(const char *filename)
104 {
105         string n(filename);
106         n += ".skm";
107         
108         AccelMap::save(filename);
109         
110         return true;
111 }