1 /* dzl-shortcut-manager.c
2  *
3  * Copyright (C) 2016 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_MANAGER_H
20 #define DZL_SHORTCUT_MANAGER_H
21 
22 #include <gtk/gtk.h>
23 
24 #include "dzl-version-macros.h"
25 
26 #include "dzl-shortcut-phase.h"
27 #include "dzl-shortcut-theme.h"
28 #include "dzl-shortcuts-window.h"
29 
30 G_BEGIN_DECLS
31 
32 #define DZL_TYPE_SHORTCUT_MANAGER (dzl_shortcut_manager_get_type())
33 
34 DZL_AVAILABLE_IN_ALL
35 G_DECLARE_DERIVABLE_TYPE (DzlShortcutManager, dzl_shortcut_manager, DZL, SHORTCUT_MANAGER, GObject)
36 
37 /**
38  * DzlShortcutEntry:
39  * @command: the command identifier
40  * @phase: the phase for activation, or 0 for the default
41  * @default_accel: the default accelerator for the command, if any
42  * @section: the section for the shortcuts window
43  * @group: the group for the shortcuts window
44  * @title: the title for the shortcuts window
45  * @subtitle: the subtitle for the shortcuts window, if any
46  *
47  * The #DzlShortcutEntry structure can be used to bulk register shortcuts
48  * for a particular widget. It can also do the necessary hooks of registering
49  * commands that can be changed using the keytheme components.
50  */
51 typedef struct
52 {
53   const gchar      *command;
54   DzlShortcutPhase  phase;
55   const gchar      *default_accel;
56   const gchar      *section;
57   const gchar      *group;
58   const gchar      *title;
59   const gchar      *subtitle;
60 } DzlShortcutEntry;
61 
62 struct _DzlShortcutManagerClass
63 {
64   GObjectClass parent_instance;
65 
66   gpointer _reserved1;
67   gpointer _reserved2;
68   gpointer _reserved3;
69   gpointer _reserved4;
70   gpointer _reserved5;
71   gpointer _reserved6;
72   gpointer _reserved7;
73   gpointer _reserved8;
74 };
75 
76 DZL_AVAILABLE_IN_ALL
77 DzlShortcutManager *dzl_shortcut_manager_get_default             (void);
78 DZL_AVAILABLE_IN_ALL
79 void                dzl_shortcut_manager_queue_reload            (DzlShortcutManager     *self);
80 DZL_AVAILABLE_IN_ALL
81 void                dzl_shortcut_manager_reload                  (DzlShortcutManager     *self,
82                                                                   GCancellable           *cancellable);
83 DZL_AVAILABLE_IN_ALL
84 void                dzl_shortcut_manager_append_search_path      (DzlShortcutManager     *self,
85                                                                   const gchar            *directory);
86 DZL_AVAILABLE_IN_ALL
87 void                dzl_shortcut_manager_prepend_search_path     (DzlShortcutManager     *self,
88                                                                   const gchar            *directory);
89 DZL_AVAILABLE_IN_ALL
90 void                dzl_shortcut_manager_remove_search_path      (DzlShortcutManager     *self,
91                                                                   const gchar            *directory);
92 DZL_AVAILABLE_IN_ALL
93 DzlShortcutTheme   *dzl_shortcut_manager_get_theme               (DzlShortcutManager     *self);
94 DZL_AVAILABLE_IN_ALL
95 void                dzl_shortcut_manager_set_theme               (DzlShortcutManager     *self,
96                                                                   DzlShortcutTheme       *theme);
97 DZL_AVAILABLE_IN_ALL
98 const gchar        *dzl_shortcut_manager_get_theme_name          (DzlShortcutManager     *self);
99 DZL_AVAILABLE_IN_ALL
100 void                dzl_shortcut_manager_set_theme_name          (DzlShortcutManager     *self,
101                                                                   const gchar            *theme_name);
102 DZL_AVAILABLE_IN_ALL
103 DzlShortcutTheme   *dzl_shortcut_manager_get_theme_by_name       (DzlShortcutManager     *self,
104                                                                   const gchar            *theme_name);
105 DZL_AVAILABLE_IN_ALL
106 gboolean            dzl_shortcut_manager_handle_event            (DzlShortcutManager     *self,
107                                                                   const GdkEventKey      *event,
108                                                                   GtkWidget              *toplevel);
109 DZL_AVAILABLE_IN_ALL
110 const gchar        *dzl_shortcut_manager_get_user_dir            (DzlShortcutManager     *self);
111 DZL_AVAILABLE_IN_ALL
112 void                dzl_shortcut_manager_set_user_dir            (DzlShortcutManager     *self,
113                                                                   const gchar            *user_dir);
114 DZL_AVAILABLE_IN_ALL
115 void                dzl_shortcut_manager_add_action              (DzlShortcutManager     *self,
116                                                                   const gchar            *detailed_action_name,
117                                                                   const gchar            *section,
118                                                                   const gchar            *group,
119                                                                   const gchar            *title,
120                                                                   const gchar            *subtitle);
121 DZL_AVAILABLE_IN_ALL
122 void                dzl_shortcut_manager_add_command             (DzlShortcutManager     *self,
123                                                                   const gchar            *command,
124                                                                   const gchar            *section,
125                                                                   const gchar            *group,
126                                                                   const gchar            *title,
127                                                                   const gchar            *subtitle);
128 DZL_AVAILABLE_IN_ALL
129 void                dzl_shortcut_manager_add_shortcut_entries    (DzlShortcutManager     *self,
130                                                                   const DzlShortcutEntry *shortcuts,
131                                                                   guint                   n_shortcuts,
132                                                                   const gchar            *translation_domain);
133 DZL_AVAILABLE_IN_ALL
134 void                dzl_shortcut_manager_add_shortcuts_to_window (DzlShortcutManager     *self,
135                                                                   DzlShortcutsWindow     *window);
136 
137 G_END_DECLS
138 
139 #endif /* DZL_SHORTCUT_MANAGER_H */
140