| 1 | /* Copyright (C) 1998-2002 The gtkmm Development Team |
| 2 | * |
| 3 | * This library is free software; you can redistribute it and/or |
| 4 | * modify it under the terms of the GNU Lesser General Public |
| 5 | * License as published by the Free Software Foundation; either |
| 6 | * version 2.1 of the License, or (at your option) any later version. |
| 7 | * |
| 8 | * This library is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public |
| 14 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include <gtkmm/accelkey.h> |
| 18 | #include <gtkmm/accelgroup.h> |
| 19 | |
| 20 | namespace Gtk |
| 21 | { |
| 22 | |
| 23 | AccelKey::AccelKey() |
| 24 | : key_(GDK_KEY_VoidSymbol), |
| 25 | mod_((Gdk::ModifierType)0) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | AccelKey::AccelKey(guint accel_key, Gdk::ModifierType accel_mods, |
| 30 | const Glib::ustring& accel_path) |
| 31 | : key_(accel_key), |
| 32 | mod_(accel_mods), |
| 33 | path_(accel_path) |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | AccelKey::AccelKey(const Glib::ustring& accelerator, const Glib::ustring& accel_path) |
| 38 | : path_(accel_path) |
| 39 | { |
| 40 | //Get the key and mod by parsing the accelerator string: |
| 41 | AccelGroup::parse (accelerator, key_, mod_); |
| 42 | } |
| 43 | |
| 44 | AccelKey::AccelKey(const AccelKey& src) |
| 45 | { |
| 46 | key_ = src.key_; |
| 47 | mod_ = src.mod_; |
| 48 | path_ = src.path_; |
| 49 | } |
| 50 | |
| 51 | AccelKey& AccelKey::operator=(const AccelKey& src) |
| 52 | { |
| 53 | key_ = src.key_; |
| 54 | mod_ = src.mod_; |
| 55 | path_ = src.path_; |
| 56 | |
| 57 | return *this; |
| 58 | } |
| 59 | |
| 60 | guint AccelKey::get_key() const |
| 61 | { |
| 62 | return key_; |
| 63 | } |
| 64 | |
| 65 | Gdk::ModifierType AccelKey::get_mod() const |
| 66 | { |
| 67 | return mod_; |
| 68 | } |
| 69 | |
| 70 | Glib::ustring AccelKey::get_path() const |
| 71 | { |
| 72 | return path_; |
| 73 | } |
| 74 | |
| 75 | bool AccelKey::is_null() const |
| 76 | { |
| 77 | return ( (key_ == GDK_KEY_VoidSymbol) || !(get_key() > 0) ); //both seem to be invalid. |
| 78 | } |
| 79 | |
| 80 | Glib::ustring AccelKey::get_abbrev() const |
| 81 | { |
| 82 | return AccelGroup::name (key_, mod_); |
| 83 | } |
| 84 | |
| 85 | } // namespace |