1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
/*
xrus - keyboard switcher/indicator
Copyright (c) 1996 Alexander V. Lukyanov
This is free software with no warranty.
See COPYING for details.
*/
#include <config.h>
#if TK!=TK_NONE
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#if TK==TK_MOTIF
# include <Xm/Xm.h>
# include <Xm/RowColumn.h>
# include <Xm/PushB.h>
#elif TK==TK_XAW
# include <X11/Xaw/SmeBSB.h>
#endif
#include "altmap.h"
#include "xrus.h"
#include "keycomb.h"
#include "xalloca.h"
static
void altmap_CB(Widget w,XtPointer closure,XtPointer call_data)
{
ToLatKeys.Fire();
run_xmodmap((const char*)closure);
}
Widget CreateAltMapMenu(Widget parent,const char *altmap)
{
int altmap_count=0;
#if TK==TK_MOTIF
Widget menu_pane=XmCreatePulldownMenu(parent,"altmap_menu",NULL,0);
#endif
Widget button;
char *scan=alloca(strlen(altmap)+1);
char *file;
char button_name[32];
strcpy(scan,altmap);
for(;;)
{
/* ignore leading spaces */
while(*scan && isspace(*scan))
scan++;
if(!*scan)
break;
file=scan;
/* track down the end of file name */
while(*scan && !isspace(*scan))
scan++;
if(*scan)
*scan++=0;
/* add the item to the menu_pane */
sprintf(button_name,"altmap%d",altmap_count++);
#if TK==TK_MOTIF
button=XmCreatePushButton(menu_pane,button_name,NULL,0);
XtAddCallback(button,XmNactivateCallback,altmap_CB,strdup(file));
XtManageChild(button);
#elif TK==TK_XAW
button=XtVaCreateManagedWidget(button_name,smeBSBObjectClass,parent,NULL);
XtAddCallback(button,XtNcallback,altmap_CB,strdup(file));
#endif
}
#if TK==TK_MOTIF
if(altmap_count==0)
{
XtDestroyWidget(XtParent(menu_pane));
menu_pane=NULL;
}
return menu_pane;
#elif TK==TK_XAW
return NULL;
#endif
}
#endif /* !TK_NONE */
|