1 /* dzl-shortcut-chord.h
2  *
3  * Copyright (C) 2017 Christian Hergert <chergert@redhat.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef DZL_SHORTCUT_CHORD_H
20 #define DZL_SHORTCUT_CHORD_H
21 
22 #include <gtk/gtk.h>
23 
24 #include "dzl-version-macros.h"
25 
26 G_BEGIN_DECLS
27 
28 typedef enum
29 {
30   DZL_SHORTCUT_MATCH_NONE,
31   DZL_SHORTCUT_MATCH_EQUAL,
32   DZL_SHORTCUT_MATCH_PARTIAL
33 } DzlShortcutMatch;
34 
35 #define DZL_TYPE_SHORTCUT_CHORD       (dzl_shortcut_chord_get_type())
36 #define DZL_TYPE_SHORTCUT_CHORD_TABLE (dzl_shortcut_chord_table_get_type())
37 #define DZL_TYPE_SHORTCUT_MATCH       (dzl_shortcut_match_get_type())
38 
39 typedef struct _DzlShortcutChord      DzlShortcutChord;
40 typedef struct _DzlShortcutChordTable DzlShortcutChordTable;
41 
42 typedef void (*DzlShortcutChordTableForeach) (const DzlShortcutChord *chord,
43                                               gpointer                chord_data,
44                                               gpointer                user_data);
45 
46 DZL_AVAILABLE_IN_ALL
47 GType                   dzl_shortcut_chord_get_type            (void);
48 DZL_AVAILABLE_IN_ALL
49 DzlShortcutChord       *dzl_shortcut_chord_new_from_event      (const GdkEventKey            *event);
50 DZL_AVAILABLE_IN_ALL
51 DzlShortcutChord       *dzl_shortcut_chord_new_from_string     (const gchar                  *accelerator);
52 DZL_AVAILABLE_IN_ALL
53 gchar                  *dzl_shortcut_chord_to_string           (const DzlShortcutChord       *self);
54 DZL_AVAILABLE_IN_ALL
55 gchar                  *dzl_shortcut_chord_get_label           (const DzlShortcutChord       *self);
56 DZL_AVAILABLE_IN_ALL
57 guint                   dzl_shortcut_chord_get_length          (const DzlShortcutChord       *self);
58 DZL_AVAILABLE_IN_ALL
59 void                    dzl_shortcut_chord_get_nth_key         (const DzlShortcutChord       *self,
60                                                                 guint                         nth,
61                                                                 guint                        *keyval,
62                                                                 GdkModifierType              *modifier);
63 DZL_AVAILABLE_IN_ALL
64 gboolean                dzl_shortcut_chord_has_modifier        (const DzlShortcutChord       *self);
65 DZL_AVAILABLE_IN_ALL
66 gboolean                dzl_shortcut_chord_append_event        (DzlShortcutChord             *self,
67                                                                 const GdkEventKey            *event);
68 DZL_AVAILABLE_IN_ALL
69 DzlShortcutMatch        dzl_shortcut_chord_match               (const DzlShortcutChord       *self,
70                                                                 const DzlShortcutChord       *other);
71 DZL_AVAILABLE_IN_ALL
72 guint                   dzl_shortcut_chord_hash                (gconstpointer                 data);
73 DZL_AVAILABLE_IN_ALL
74 gboolean                dzl_shortcut_chord_equal               (gconstpointer                 data1,
75                                                                 gconstpointer                 data2);
76 DZL_AVAILABLE_IN_ALL
77 DzlShortcutChord       *dzl_shortcut_chord_copy                (const DzlShortcutChord       *self);
78 DZL_AVAILABLE_IN_ALL
79 void                    dzl_shortcut_chord_free                (DzlShortcutChord             *self);
80 DZL_AVAILABLE_IN_ALL
81 GType                   dzl_shortcut_chord_table_get_type      (void);
82 DZL_AVAILABLE_IN_ALL
83 DzlShortcutChordTable  *dzl_shortcut_chord_table_new           (void);
84 DZL_AVAILABLE_IN_ALL
85 void                    dzl_shortcut_chord_table_set_free_func (DzlShortcutChordTable        *self,
86                                                                 GDestroyNotify                notify);
87 DZL_AVAILABLE_IN_ALL
88 void                    dzl_shortcut_chord_table_free          (DzlShortcutChordTable        *self);
89 DZL_AVAILABLE_IN_ALL
90 void                    dzl_shortcut_chord_table_add           (DzlShortcutChordTable        *self,
91                                                                 const DzlShortcutChord       *chord,
92                                                                 gpointer                      data);
93 DZL_AVAILABLE_IN_ALL
94 gboolean                dzl_shortcut_chord_table_remove        (DzlShortcutChordTable        *self,
95                                                                 const DzlShortcutChord       *chord);
96 DZL_AVAILABLE_IN_ALL
97 gboolean                dzl_shortcut_chord_table_remove_data   (DzlShortcutChordTable        *self,
98                                                                 gpointer                      data);
99 DZL_AVAILABLE_IN_ALL
100 DzlShortcutMatch        dzl_shortcut_chord_table_lookup        (DzlShortcutChordTable        *self,
101                                                                 const DzlShortcutChord       *chord,
102                                                                 gpointer                     *data);
103 DZL_AVAILABLE_IN_ALL
104 const DzlShortcutChord *dzl_shortcut_chord_table_lookup_data   (DzlShortcutChordTable        *self,
105                                                                 gpointer                      data);
106 DZL_AVAILABLE_IN_ALL
107 guint                   dzl_shortcut_chord_table_size          (const DzlShortcutChordTable  *self);
108 DZL_AVAILABLE_IN_ALL
109 void                    dzl_shortcut_chord_table_foreach       (const DzlShortcutChordTable  *self,
110                                                                 DzlShortcutChordTableForeach  foreach_func,
111                                                                 gpointer                      foreach_data);
112 DZL_AVAILABLE_IN_ALL
113 void                    dzl_shortcut_chord_table_printf        (const DzlShortcutChordTable  *self);
114 DZL_AVAILABLE_IN_ALL
115 GType                   dzl_shortcut_match_get_type            (void);
116 
117 G_DEFINE_AUTOPTR_CLEANUP_FUNC (DzlShortcutChord, dzl_shortcut_chord_free)
118 
119 G_END_DECLS
120 
121 #endif /* DZL_SHORTCUT_CHORD_H */
122