Added helpers for accelerators

This commit is contained in:
Pierre Pronchery 2009-11-15 19:17:04 +00:00
parent bb4d8abc8a
commit ded81a2d46
2 changed files with 27 additions and 0 deletions

View File

@ -20,5 +20,17 @@
/* Accel */
/* types */
typedef struct _DesktopAccel
{
GtkSignalFunc callback;
GdkModifierType modifier;
unsigned int accel;
} DesktopAccel;
/* functions */
void desktop_accel_create(DesktopAccel * accel, gpointer data,
GtkAccelGroup * group);
#endif /* !LIBDESKTOP_ACCEL_H */

View File

@ -19,3 +19,18 @@
/* Accel */
void desktop_accel_create(DesktopAccel * accel, gpointer data,
GtkAccelGroup * group)
{
size_t i;
GClosure * cc;
if(group == NULL)
return;
for(i = 0; accel[i].callback != NULL; i++)
{
cc = g_cclosure_new_swap(accel[i].callback, data, NULL);
gtk_accel_group_connect(group, accel[i].accel,
accel[i].modifier, GTK_ACCEL_VISIBLE, cc);
}
}