my log
[synfig.git] / synfig-studio / trunk / 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 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include "keymapsettings.h"
32
33 #include <gtkmm/accelkey.h>
34 #include <gtkmm/accelmap.h>
35 #include <gtk/gtkaccelmap.h>
36
37 #endif
38
39 /* === U S I N G =========================================================== */
40
41 using namespace std;
42 //using namespace etl;
43 //using namespace synfig;
44 using namespace studio;
45
46 using namespace Gtk;
47 //using namespace Gtk::Menu_Helpers;
48
49 /* === M A C R O S ========================================================= */
50
51 /* === G L O B A L S ======================================================= */
52
53 /* === P R O C E D U R E S ================================================= */
54
55 /* === M E T H O D S ======================================================= */
56
57 /* === E N T R Y P O I N T ================================================= */
58
59 // KeyMapSettings Definitions
60 KeyMapSettings::KeyMapSettings()
61 {
62 }
63
64 KeyMapSettings::~KeyMapSettings()
65 {
66 }
67
68 bool KeyMapSettings::set_key(const char *path, guint key, Gdk::ModifierType mod, bool replace)
69 {
70         if(gtk_accel_map_lookup_entry(path,NULL))
71         {
72                 return AccelMap::change_entry(path,key,mod,replace);
73         }else
74         {
75                 AccelMap::add_entry(path,key,mod);
76                 return true;
77         }
78 }
79
80 bool KeyMapSettings::get_key(const char *path, AccelKey *key)
81 {
82         GtkAccelKey     ac;
83         if(gtk_accel_map_lookup_entry(path,&ac))
84         {
85                 *key = AccelKey(ac.accel_key,(Gdk::ModifierType)ac.accel_mods,string(path));
86                 return true;
87         }
88         
89         return false;
90 }
91
92 bool KeyMapSettings::load(const char *filename)
93 {
94         string n(filename);
95         n += ".skm";
96         
97         AccelMap::load(filename);
98         
99         return true;    
100 }
101
102 bool KeyMapSettings::save(const char *filename)
103 {
104         string n(filename);
105         n += ".skm";
106         
107         AccelMap::save(filename);
108         
109         return true;
110 }