gtkaccelgroup.h 8.5 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
2
 * Copyright (C) 1998, 2001 Tim Janik
Tim Janik's avatar
Tim Janik committed
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
Tim Janik's avatar
Tim Janik committed
6 7 8 9 10 11
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
12
 * Lesser General Public License for more details.
Tim Janik's avatar
Tim Janik committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
Tim Janik's avatar
Tim Janik committed
16
 */
17 18

/*
19
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
20 21
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
22
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 24
 */

Tim Janik's avatar
Tim Janik committed
25 26 27 28
#ifndef __GTK_ACCEL_GROUP_H__
#define __GTK_ACCEL_GROUP_H__


29 30 31 32
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif

Tim Janik's avatar
Tim Janik committed
33 34 35
#include <gdk/gdk.h>
#include <gtk/gtkenums.h>

36
G_BEGIN_DECLS
Tim Janik's avatar
Tim Janik committed
37 38


39
/* --- type macros --- */
40 41 42 43 44 45 46 47
#define GTK_TYPE_ACCEL_GROUP              (gtk_accel_group_get_type ())
#define GTK_ACCEL_GROUP(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ACCEL_GROUP, GtkAccelGroup))
#define GTK_ACCEL_GROUP_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))
#define GTK_IS_ACCEL_GROUP(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ACCEL_GROUP))
#define GTK_IS_ACCEL_GROUP_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ACCEL_GROUP))
#define GTK_ACCEL_GROUP_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ACCEL_GROUP, GtkAccelGroupClass))


48
/* --- accel flags --- */
49 50 51 52 53 54 55 56
/**
 * GtkAccelFlags:
 * @GTK_ACCEL_VISIBLE: Accelerator is visible
 * @GTK_ACCEL_LOCKED: Accelerator not removable
 * @GTK_ACCEL_MASK: Mask
 *
 * Accelerator flags used with gtk_accel_group_connect().
 */
57 58
typedef enum
{
59 60
  GTK_ACCEL_VISIBLE        = 1 << 0,
  GTK_ACCEL_LOCKED         = 1 << 1,
61 62
  GTK_ACCEL_MASK           = 0x07
} GtkAccelFlags;
Tim Janik's avatar
Tim Janik committed
63

64 65

/* --- typedefs & structures --- */
66 67 68 69 70
typedef struct _GtkAccelGroup	          GtkAccelGroup;
typedef struct _GtkAccelGroupClass        GtkAccelGroupClass;
typedef struct _GtkAccelGroupPrivate      GtkAccelGroupPrivate;
typedef struct _GtkAccelKey               GtkAccelKey;
typedef struct _GtkAccelGroupEntry        GtkAccelGroupEntry;
71 72 73 74
typedef gboolean (*GtkAccelGroupActivate) (GtkAccelGroup  *accel_group,
					   GObject        *acceleratable,
					   guint           keyval,
					   GdkModifierType modifier);
75

76 77 78 79
/**
 * GtkAccelGroupFindFunc:
 * @key: 
 * @closure: 
80
 * @data: (closure):
81 82 83
 * 
 * Since: 2.2
 */
84 85
typedef gboolean (*GtkAccelGroupFindFunc) (GtkAccelKey    *key,
					   GClosure       *closure,
86
					   gpointer        data);
87

88 89 90 91 92
/**
 * GtkAccelGroup:
 * 
 * An object representing and maintaining a group of accelerators.
 */
Tim Janik's avatar
Tim Janik committed
93 94
struct _GtkAccelGroup
{
95 96
  GObject               parent;
  GtkAccelGroupPrivate *priv;
Tim Janik's avatar
Tim Janik committed
97
};
98

99 100 101 102 103 104
/**
 * GtkAccelGroupClass:
 * @parent_class: The parent class.
 * @accel_changed: Signal emitted when an entry is added to or removed
 *    from the accel group.
 */
105 106 107 108
struct _GtkAccelGroupClass
{
  GObjectClass parent_class;

109 110
  /*< public >*/

111 112 113 114
  void	(*accel_changed)	(GtkAccelGroup	*accel_group,
				 guint           keyval,
				 GdkModifierType modifier,
				 GClosure       *accel_closure);
115 116 117

  /*< private >*/

118 119 120 121 122
  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
123
};
124

125 126 127 128 129 130
/**
 * GtkAccelKey:
 * @accel_key: The accelerator keyval
 * @accel_mods:The accelerator modifiers
 * @accel_flags: The accelerator flags
 */
131
struct _GtkAccelKey
Tim Janik's avatar
Tim Janik committed
132
{
133 134 135
  guint           accel_key;
  GdkModifierType accel_mods;
  guint           accel_flags : 16;
Tim Janik's avatar
Tim Janik committed
136 137 138
};


139
/* -- Accelerator Groups --- */
140
GDK_AVAILABLE_IN_ALL
Matthias Clasen's avatar
Matthias Clasen committed
141
GType          gtk_accel_group_get_type           (void) G_GNUC_CONST;
142
GDK_AVAILABLE_IN_ALL
143
GtkAccelGroup* gtk_accel_group_new	      	  (void);
144
GDK_AVAILABLE_IN_ALL
145
gboolean       gtk_accel_group_get_is_locked      (GtkAccelGroup  *accel_group);
146
GDK_AVAILABLE_IN_ALL
147 148
GdkModifierType 
               gtk_accel_group_get_modifier_mask  (GtkAccelGroup  *accel_group);
149
GDK_AVAILABLE_IN_ALL
150
void	       gtk_accel_group_lock		  (GtkAccelGroup  *accel_group);
151
GDK_AVAILABLE_IN_ALL
152
void	       gtk_accel_group_unlock		  (GtkAccelGroup  *accel_group);
153
GDK_AVAILABLE_IN_ALL
154 155 156 157 158
void	       gtk_accel_group_connect		  (GtkAccelGroup  *accel_group,
						   guint	   accel_key,
						   GdkModifierType accel_mods,
						   GtkAccelFlags   accel_flags,
						   GClosure	  *closure);
159
GDK_AVAILABLE_IN_ALL
160 161 162
void           gtk_accel_group_connect_by_path    (GtkAccelGroup  *accel_group,
						   const gchar	  *accel_path,
						   GClosure	  *closure);
163
GDK_AVAILABLE_IN_ALL
164 165
gboolean       gtk_accel_group_disconnect	  (GtkAccelGroup  *accel_group,
						   GClosure	  *closure);
166
GDK_AVAILABLE_IN_ALL
167 168 169
gboolean       gtk_accel_group_disconnect_key	  (GtkAccelGroup  *accel_group,
						   guint	   accel_key,
						   GdkModifierType accel_mods);
170
GDK_AVAILABLE_IN_ALL
171 172 173 174 175
gboolean       gtk_accel_group_activate           (GtkAccelGroup   *accel_group,
                                                   GQuark	   accel_quark,
                                                   GObject	  *acceleratable,
                                                   guint	   accel_key,
                                                   GdkModifierType accel_mods);
176 177 178 179


/* --- GtkActivatable glue --- */
void		_gtk_accel_group_attach		(GtkAccelGroup	*accel_group,
180
						 GObject	*object);
181
void		_gtk_accel_group_detach		(GtkAccelGroup	*accel_group,
182
						 GObject	*object);
183
GDK_AVAILABLE_IN_ALL
184
gboolean        gtk_accel_groups_activate      	(GObject	*object,
Tim Janik's avatar
Tim Janik committed
185
						 guint		 accel_key,
186
						 GdkModifierType accel_mods);
187
GDK_AVAILABLE_IN_ALL
188
GSList*	        gtk_accel_groups_from_object    (GObject	*object);
189
GDK_AVAILABLE_IN_ALL
190 191 192
GtkAccelKey*	gtk_accel_group_find		(GtkAccelGroup	      *accel_group,
						 GtkAccelGroupFindFunc find_func,
						 gpointer              data);
193
GDK_AVAILABLE_IN_ALL
194
GtkAccelGroup*	gtk_accel_group_from_accel_closure (GClosure    *closure);
Tim Janik's avatar
Tim Janik committed
195

196 197

/* --- Accelerators--- */
198
GDK_AVAILABLE_IN_ALL
199 200
gboolean gtk_accelerator_valid		      (guint	        keyval,
					       GdkModifierType  modifiers) G_GNUC_CONST;
201
GDK_AVAILABLE_IN_ALL
202 203 204
void	 gtk_accelerator_parse		      (const gchar     *accelerator,
					       guint	       *accelerator_key,
					       GdkModifierType *accelerator_mods);
205
GDK_AVAILABLE_IN_3_4
206 207 208 209
void gtk_accelerator_parse_with_keycode       (const gchar     *accelerator,
                                               guint           *accelerator_key,
                                               guint          **accelerator_codes,
                                               GdkModifierType *accelerator_mods);
210
GDK_AVAILABLE_IN_ALL
211 212
gchar*	 gtk_accelerator_name		      (guint	        accelerator_key,
					       GdkModifierType  accelerator_mods);
213
GDK_AVAILABLE_IN_3_4
214 215 216 217
gchar*	 gtk_accelerator_name_with_keycode    (GdkDisplay      *display,
                                               guint            accelerator_key,
                                               guint            keycode,
                                               GdkModifierType  accelerator_mods);
218
GDK_AVAILABLE_IN_ALL
219 220
gchar*   gtk_accelerator_get_label            (guint           accelerator_key,
                                               GdkModifierType accelerator_mods);
221
GDK_AVAILABLE_IN_3_4
222 223 224 225
gchar*   gtk_accelerator_get_label_with_keycode (GdkDisplay      *display,
                                                 guint            accelerator_key,
                                                 guint            keycode,
                                                 GdkModifierType  accelerator_mods);
226
GDK_AVAILABLE_IN_ALL
227
void	 gtk_accelerator_set_default_mod_mask (GdkModifierType  default_mod_mask);
228
GDK_AVAILABLE_IN_ALL
229 230
GdkModifierType
	 gtk_accelerator_get_default_mod_mask (void);
231

232
GDK_AVAILABLE_IN_ALL
233
GtkAccelGroupEntry*	gtk_accel_group_query	(GtkAccelGroup	*accel_group,
Tim Janik's avatar
Tim Janik committed
234
						 guint		 accel_key,
235
						 GdkModifierType accel_mods,
236
						 guint          *n_entries);
237

238 239 240 241 242 243 244
struct _GtkAccelGroupEntry
{
  GtkAccelKey  key;
  GClosure    *closure;
  GQuark       accel_path_quark;
};

245 246
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkAccelGroup, g_object_unref)

247
G_END_DECLS
Tim Janik's avatar
Tim Janik committed
248 249

#endif /* __GTK_ACCEL_GROUP_H__ */