/usr/share/doc/xviewg/examples/seln_svc/simple_seln.c is in xview-examples 3.2p1.4-28.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /*
* simple_seln.c -- print the primary selection by pressing the panel
* button. The selection may have originated from any window or
* application on the server.
*/
#include <stdio.h>
#include <xview/xview.h>
#include <xview/panel.h>
#include <xview/server.h>
#include <xview/seln.h>
Xv_Server server;
main(argc, argv)
char *argv[];
{
Frame frame;
Panel panel;
void exit();
int print_seln();
xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL);
frame = (Frame) xv_create(NULL, FRAME,
FRAME_LABEL, argv[0],
NULL);
panel = (Panel)xv_create(frame, PANEL,
WIN_WIDTH, WIN_EXTEND_TO_EDGE,
NULL);
(void) xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Quit",
PANEL_NOTIFY_PROC, exit,
NULL);
(void) xv_create(panel, PANEL_BUTTON,
PANEL_LABEL_STRING, "Print Selection",
PANEL_NOTIFY_PROC, print_seln,
NULL);
window_fit(panel);
window_fit(frame);
server = (Xv_Server)xv_get(xv_get(frame, XV_SCREEN), SCREEN_SERVER);
xv_main_loop(frame);
}
/*
* Get the selection using selection_ask(). Note that if the
* selection is bigger than about 2K, the whole selection will
* not be gotten with one call, thus this method of getting
* the selection may not be sufficient for all situations.
*/
int
print_seln(item, event)
Panel_item item;
Event *event;
{
Seln_holder holder;
Seln_request *response;
char text[BUFSIZ];
/* get the holder of the primary selection */
holder = selection_inquire(server, SELN_PRIMARY);
response = selection_ask(server, &holder,
SELN_REQ_CONTENTS_ASCII, NULL,
NULL);
strcpy(text, response->data + sizeof (SELN_REQ_CONTENTS_ASCII));
printf("---selection---\n%s\n---end seln---\n", text);
return XV_OK;
}
|