1 | /* |
2 | * Copyright © 2018 Benjamin Otte |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2.1 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. |
16 | * |
17 | * Authors: Benjamin Otte <otte@gnome.org> |
18 | */ |
19 | |
20 | #ifndef __GTK_SHORTCUT_ACTION_H__ |
21 | #define __GTK_SHORTCUT_ACTION_H__ |
22 | |
23 | #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) |
24 | #error "Only <gtk/gtk.h> can be included directly." |
25 | #endif |
26 | |
27 | #include <gtk/gtktypes.h> |
28 | |
29 | G_BEGIN_DECLS |
30 | |
31 | #define GTK_TYPE_SHORTCUT_ACTION (gtk_shortcut_action_get_type ()) |
32 | |
33 | /** |
34 | * GtkShortcutFunc: |
35 | * @widget: The widget passed to the activation |
36 | * @args: (nullable): The arguments passed to the activation |
37 | * @user_data: (nullable): The user data provided when activating the action |
38 | * |
39 | * Prototype for shortcuts based on user callbacks. |
40 | * |
41 | * Returns: %TRUE if the action was successful. |
42 | */ |
43 | typedef gboolean (* GtkShortcutFunc) (GtkWidget *widget, |
44 | GVariant *args, |
45 | gpointer user_data); |
46 | |
47 | /** |
48 | * GtkShortcutActionFlags: |
49 | * @GTK_SHORTCUT_ACTION_EXCLUSIVE: The action is the only |
50 | * action that can be activated. If this flag is not set, |
51 | * a future activation may select a different action. |
52 | * |
53 | * List of flags that can be passed to action activation. |
54 | * |
55 | * More flags may be added in the future. |
56 | **/ |
57 | typedef enum { |
58 | GTK_SHORTCUT_ACTION_EXCLUSIVE = 1 << 0 |
59 | } GtkShortcutActionFlags; |
60 | |
61 | GDK_AVAILABLE_IN_ALL |
62 | GDK_DECLARE_INTERNAL_TYPE (GtkShortcutAction, gtk_shortcut_action, GTK, SHORTCUT_ACTION, GObject) |
63 | |
64 | GDK_AVAILABLE_IN_ALL |
65 | char * gtk_shortcut_action_to_string (GtkShortcutAction *self); |
66 | GDK_AVAILABLE_IN_ALL |
67 | GtkShortcutAction * gtk_shortcut_action_parse_string (const char * string); |
68 | |
69 | GDK_AVAILABLE_IN_ALL |
70 | void gtk_shortcut_action_print (GtkShortcutAction *self, |
71 | GString *string); |
72 | GDK_AVAILABLE_IN_ALL |
73 | gboolean gtk_shortcut_action_activate (GtkShortcutAction *self, |
74 | GtkShortcutActionFlags flags, |
75 | GtkWidget *widget, |
76 | GVariant *args); |
77 | |
78 | #define GTK_TYPE_NOTHING_ACTION (gtk_nothing_action_get_type()) |
79 | |
80 | /** |
81 | * GtkNothingAction: |
82 | * |
83 | * A `GtkShortcutAction` that does nothing. |
84 | */ |
85 | GDK_AVAILABLE_IN_ALL |
86 | GDK_DECLARE_INTERNAL_TYPE (GtkNothingAction, gtk_nothing_action, GTK, NOTHING_ACTION, GtkShortcutAction) |
87 | |
88 | GDK_AVAILABLE_IN_ALL |
89 | GtkShortcutAction * gtk_nothing_action_get (void); |
90 | |
91 | #define GTK_TYPE_CALLBACK_ACTION (gtk_callback_action_get_type()) |
92 | |
93 | /** |
94 | * GtkCallbackAction: |
95 | * |
96 | * A `GtkShortcutAction` that invokes a callback. |
97 | */ |
98 | GDK_AVAILABLE_IN_ALL |
99 | GDK_DECLARE_INTERNAL_TYPE (GtkCallbackAction, gtk_callback_action, GTK, CALLBACK_ACTION, GtkShortcutAction) |
100 | |
101 | GDK_AVAILABLE_IN_ALL |
102 | GtkShortcutAction * gtk_callback_action_new (GtkShortcutFunc callback, |
103 | gpointer data, |
104 | GDestroyNotify destroy); |
105 | |
106 | #define GTK_TYPE_MNEMONIC_ACTION (gtk_mnemonic_action_get_type()) |
107 | |
108 | /** |
109 | * GtkMnemonicAction: |
110 | * |
111 | * A `GtkShortcutAction` that calls gtk_widget_mnemonic_activate(). |
112 | */ |
113 | GDK_AVAILABLE_IN_ALL |
114 | GDK_DECLARE_INTERNAL_TYPE (GtkMnemonicAction, gtk_mnemonic_action, GTK, MNEMONIC_ACTION, GtkShortcutAction) |
115 | |
116 | GDK_AVAILABLE_IN_ALL |
117 | GtkShortcutAction * gtk_mnemonic_action_get (void); |
118 | |
119 | #define GTK_TYPE_ACTIVATE_ACTION (gtk_activate_action_get_type()) |
120 | |
121 | /** |
122 | * GtkActivateAction: |
123 | * |
124 | * A `GtkShortcutAction` that calls gtk_widget_activate(). |
125 | */ |
126 | GDK_AVAILABLE_IN_ALL |
127 | GDK_DECLARE_INTERNAL_TYPE (GtkActivateAction, gtk_activate_action, GTK, ACTIVATE_ACTION, GtkShortcutAction) |
128 | |
129 | GDK_AVAILABLE_IN_ALL |
130 | GtkShortcutAction * gtk_activate_action_get (void); |
131 | |
132 | #define GTK_TYPE_SIGNAL_ACTION (gtk_signal_action_get_type()) |
133 | |
134 | /** |
135 | * GtkSignalAction: |
136 | * |
137 | * A `GtkShortcut`Action that emits a signal. |
138 | * |
139 | * Signals that are used in this way are referred to as keybinding signals, |
140 | * and they are expected to be defined with the %G_SIGNAL_ACTION flag. |
141 | */ |
142 | GDK_AVAILABLE_IN_ALL |
143 | GDK_DECLARE_INTERNAL_TYPE (GtkSignalAction, gtk_signal_action, GTK, SIGNAL_ACTION, GtkShortcutAction) |
144 | |
145 | GDK_AVAILABLE_IN_ALL |
146 | GtkShortcutAction * gtk_signal_action_new (const char *signal_name); |
147 | GDK_AVAILABLE_IN_ALL |
148 | const char * gtk_signal_action_get_signal_name (GtkSignalAction *self); |
149 | |
150 | #define GTK_TYPE_NAMED_ACTION (gtk_named_action_get_type()) |
151 | |
152 | /** |
153 | * GtkNamedAction: |
154 | * |
155 | * A `GtkShortcutAction` that activates an action by name. |
156 | */ |
157 | GDK_AVAILABLE_IN_ALL |
158 | GDK_DECLARE_INTERNAL_TYPE (GtkNamedAction, gtk_named_action, GTK, NAMED_ACTION, GtkShortcutAction) |
159 | |
160 | GDK_AVAILABLE_IN_ALL |
161 | GtkShortcutAction * gtk_named_action_new (const char *name); |
162 | GDK_AVAILABLE_IN_ALL |
163 | const char * gtk_named_action_get_action_name (GtkNamedAction *self); |
164 | |
165 | G_END_DECLS |
166 | |
167 | #endif /* __GTK_SHORTCUT_ACTION_H__ */ |
168 | |