Added helpers for accelerators
This commit is contained in:
parent
bb4d8abc8a
commit
ded81a2d46
|
@ -20,5 +20,17 @@
|
||||||
|
|
||||||
|
|
||||||
/* Accel */
|
/* 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 */
|
#endif /* !LIBDESKTOP_ACCEL_H */
|
||||||
|
|
15
src/accel.c
15
src/accel.c
|
@ -19,3 +19,18 @@
|
||||||
|
|
||||||
|
|
||||||
/* Accel */
|
/* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user