1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 
3 /*
4  *  GThumb
5  *
6  *  Copyright (C) 2019 Free Software Foundation, Inc.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef GTH_SHORTCUT_H
23 #define GTH_SHORTCUT_H
24 
25 #include <gtk/gtk.h>
26 
27 G_BEGIN_DECLS
28 
29 #define GTH_SHORTCUT_CATEGORY_HIDDEN "hidden"
30 #define GTH_SHORTCUT_CATEGORY_GENERAL "general"
31 #define GTH_SHORTCUT_CATEGORY_UI "ui"
32 #define GTH_SHORTCUT_CATEGORY_NAVIGATION "file-navigation"
33 #define GTH_SHORTCUT_CATEGORY_FILE_MANAGER "file-manager"
34 #define GTH_SHORTCUT_CATEGORY_VIEWER "file-viewer"
35 
36 
37 typedef struct {
38 	char *id;
39 	char *display_name;
40 	int   sort_order;
41 } GthShortcutCategory;
42 
43 
44 typedef struct {
45 	char            *action_name;
46 	char            *description;
47 	int              context;
48 	char            *category;
49 	char            *default_accelerator;
50 	char            *accelerator;
51 	char            *label;
52 	guint            keyval;
53 	GdkModifierType  modifiers;
54 	GVariant        *action_parameter;
55 	char            *detailed_action;
56 } GthShortcut;
57 
58 
59 GthShortcut * gth_shortcut_new			(const char        *action_name,
60 						 GVariant          *param);
61 GthShortcut * gth_shortcut_dup			(const GthShortcut *shortcut);
62 void          gth_shortcut_free			(GthShortcut       *shortcut);
63 void          gth_shortcut_set_key		(GthShortcut       *shortcut,
64 						 guint              keyval,
65 						 GdkModifierType    modifiers);
66 void          gth_shortcut_set_accelerator	(GthShortcut       *shortcut,
67 						 const char        *name);
68 gboolean      gth_shortcut_customizable         (GthShortcut       *shortcut);
69 GthShortcut * gth_shortcut_array_find           (GPtrArray         *shortcuts_v,
70 						 int                context,
71 						 guint              keycode,
72 						 GdkModifierType    modifiers);
73 GthShortcut * gth_shortcut_array_find_by_accel  (GPtrArray         *shortcuts_v,
74 						 int                context,
75 						 const char        *accelerator);
76 GthShortcut * gth_shortcut_array_find_by_action (GPtrArray         *shortcuts_v,
77 						 const char        *detailed_action);
78 gboolean      gth_shortcut_valid                (guint              keycode,
79 						 GdkModifierType    modifiers);
80 gboolean      gth_shortcuts_write_to_file       (GPtrArray         *shortcuts_v,
81 						 GError           **error);
82 gboolean      gth_shortcuts_load_from_file      (GPtrArray         *shortcuts_v,
83 						 GHashTable        *shortcuts,
84 						 GError           **error);
85 
86 G_END_DECLS
87 
88 #endif /* GTH_SHORTCUT_H */
89