* * olvwmtool_stubs.c - Notify and event callback function stubs. * This file was generated by `gxv' from `olvwmtool.G'. */ include include include include include include include include include include "olvwmtool_ui.h" * * Global object definitions. */ lvwmtool_main_objects *Olvwmtool_main; har *eventNames[] = "", "", "KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", "MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", "FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", "NoExpose", "VisibilityNotify", "CreateNotify", "DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest", "ReparentNotify", "ConfigureNotify", "ConfigureRequest", "GravityNotify", "ResizeRequest", "CirculateNotify", "CirculateRequest", "PropertyNotify", "SelectionClear", "SelectionRequest", "SelectionNotify", "ColormapNotify", "ClientMessage", "MappingNotify", "Startup", "Shutdown", ; define NEVENTS (sizeof(eventNames) / sizeof(char *)) define MAX_SOUNDS 2048 har *map[NEVENTS]; har *sounds[MAX_SOUNDS]; nt nsounds; nt current_event = -1; nt current_sound = -1; ifdef MAIN * * Instance XV_KEY_DATA key. An instance is a set of related * user interface objects. A pointer to an object's instance * is stored under this key in every object. This must be a * global variable. */ ttr_attribute INSTANCE; ain(int argc, char **argv) /* * Initialize XView. */ xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, NULL); INSTANCE = xv_unique_key(); /* * Initialize user interface components. * Do NOT edit the object initializations by hand. */ Olvwmtool_main = olvwmtool_main_objects_initialize(NULL, NULL); /* * Read in the sounds into the sounds list */ read_sounds(); /* * Read in the current mapping from events to sounds */ read_mapping(); /* * Turn control over to XView. */ xv_main_loop(Olvwmtool_main->main); exit(0); endif ompar(char **a1, char **a2) return strcasecmp(*a1, *a2); * * Read the sounds from the rplay config file and put them into the sounds list */ ead_sounds() FILE *fl = fopen("/usr/local/etc/rplay.conf", "r"); char buffer[200]; char *p; int i, n; if (fl == NULL) { perror("fopen"); exit(1); } n = 0; while (fgets(buffer, 200, fl) != NULL) { p = strrchr(buffer, '/'); p[strlen(p) - 1] = '\0'; sounds[n++] = strdup(p + 1); } qsort(sounds, n, sizeof(char *), compar); xv_set(Olvwmtool_main->sounds, XV_SHOW, FALSE, NULL); for (i = 0; i < n; i++) { xv_set(Olvwmtool_main->sounds, PANEL_LIST_INSERT, i, PANEL_LIST_STRING, i, sounds[i], NULL); } fclose(fl); xv_set(Olvwmtool_main->sounds, XV_SHOW, TRUE, NULL); nsounds = n; * * Read the current mapping of events to sounds into the map array. */ ead_mapping() FILE *fl = fopen(".olvwm-sounds", "r"); char buffer[200]; char *token; int i; if (fl == NULL) return; while (fgets(buffer, 200, fl) != NULL) { token = strtok(buffer, " \t:\r\n"); if (token == NULL) continue; for (i = 0; i < NEVENTS; i++) { if (strcmp(token, eventNames[i]) == 0) { token = strtok(NULL, " \t\r\n"); if (token == NULL) continue; map[i] = strdup(token); sprintf(buffer, "%s: %s", eventNames[i], map[i]); xv_set(Olvwmtool_main->events, PANEL_LIST_STRING, i, buffer, NULL); } } } fclose(fl); * * Notify callback function for `events'. */ nt vent_func(Panel_item item, char *string, Xv_opaque client_data, Panel_list_op op, Event *event, int row) olvwmtool_main_objects *ip = (olvwmtool_main_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); int i, j; switch (op) { case PANEL_LIST_OP_DESELECT: current_event = -1; break; case PANEL_LIST_OP_SELECT: current_event = row; if (current_sound != -1) { xv_set(ip->sounds, PANEL_LIST_SELECT, current_sound, FALSE, NULL); xv_set(ip->play, PANEL_INACTIVE, TRUE, NULL); xv_set(ip->stop, PANEL_INACTIVE, TRUE, NULL); current_sound = -1; } break; } /* gxv_start_connections DO NOT EDIT THIS SECTION */ /* gxv_end_connections */ return XV_OK; * * Notify callback function for `sounds'. */ nt ounds_func(Panel_item item, char *string, Xv_opaque client_data, Panel_list_op op, Event *event, int row) olvwmtool_main_objects *ip = (olvwmtool_main_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); char buffer[100]; switch (op) { case PANEL_LIST_OP_DESELECT: xv_set(ip->play, PANEL_INACTIVE, TRUE, NULL); xv_set(ip->stop, PANEL_INACTIVE, TRUE, NULL); current_sound = -1; if (current_event != -1) { map[current_event] = NULL; xv_set(ip->events, PANEL_LIST_STRING, current_event, eventNames[current_event], NULL); } break; case PANEL_LIST_OP_SELECT: current_sound = row; xv_set(ip->play, PANEL_INACTIVE, FALSE, NULL); xv_set(ip->stop, PANEL_INACTIVE, FALSE, NULL); if (current_event != -1) { map[current_event] = string; sprintf(buffer, "%s: %s", eventNames[current_event], string); xv_set(ip->events, PANEL_LIST_STRING, current_event, buffer, NULL); } break; } /* gxv_start_connections DO NOT EDIT THIS SECTION */ /* gxv_end_connections */ return XV_OK; * * Notify callback function for `apply'. */ oid pply(Panel_item item, Event *event) olvwmtool_main_objects *ip = (olvwmtool_main_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); FILE *fl = fopen(".olvwm-sounds", "w"); int i; for (i = 0; i < NEVENTS; i++) { if (map[i] != NULL) { fprintf(fl, "%s:\t%s\n", eventNames[i], map[i]); } } fclose(fl); /* gxv_start_connections DO NOT EDIT THIS SECTION */ /* gxv_end_connections */ tatic int rplay_fd; tatic int had_init = FALSE; * * Notify callback function for `play'. */ oid lay(Panel_item item, Event *event) olvwmtool_main_objects *ip = (olvwmtool_main_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); RPLAY *rp; if (!had_init) { rplay_fd = rplay_open("localhost"); had_init = TRUE; } rp = rplay_create(); rplay_set(rp, RPLAY_PLAY, (char *) xv_get(ip->sounds, PANEL_LIST_STRING, current_sound), NULL); rplay(rplay_fd, rp); rplay_destroy(rp); /* gxv_start_connections DO NOT EDIT THIS SECTION */ /* gxv_end_connections */ * * Notify callback function for `stop'. */ oid top(Panel_item item, Event *event) olvwmtool_main_objects *ip = (olvwmtool_main_objects *) xv_get(item, XV_KEY_DATA, INSTANCE); RPLAY *rp; if (!had_init) return; rp = rplay_create(); rplay_set(rp, RPLAY_STOP, (char *) xv_get(ip->sounds, PANEL_LIST_STRING, current_sound), NULL); rplay(rplay_fd, rp); rplay_destroy(rp); /* gxv_start_connections DO NOT EDIT THIS SECTION */ /* gxv_end_connections */