/* get_high_name brings up a dialog that prompts the player to enter his/her name. The name is stored in buf. */ void get_high_name(char *buf) { XEvent event; register int j, finished; /* register unsigned long utimer, usecond; */ XMapRaised(display, dialogwindow); XMapRaised(display, dialogstringwindow); XMapRaised(display, dialogbuttonwindow); XFlush(display); dtext[0] = '\0'; finished = 0; while(!finished) { XNextEvent(display, &event); switch(event.type) { case ConfigureNotify: case Expose: case MapNotify: display_dialog(event.xany.window); break; case ButtonPress: if(event.xbutton.window == dialogbuttonwindow) { XFillRectangle(display, dialogbuttonwindow, ctable[CBLUE].smallgc, 0, 0, 50, 30); display_dialog(dialogbuttonwindow); finished = 1; } break; case KeyPress: finished = dialog_key(&event.xkey); break; } } /* check to see if there are non-blank characters in the name. If there aren't any, the user is shy, so return "Anonymous" */ for(j=0, finished=0; dtext[j] != '\0'; j++) { if(dtext[j] != ' ') finished = 1; } if(!finished) strncpy(dtext,"Anonymous",20); strncpy(buf, dtext, 20); /* unmap the dialog */ XUnmapWindow(display, dialogstringwindow); XUnmapWindow(display, dialogbuttonwindow); XUnmapWindow(display, dialogwindow); XFlush(display); }
/* dialog_key processes keypresses from the dialog */ int dialog_key(XKeyEvent *event) { int length, l; char buf[MAXNAMELENGTH]; KeySym keysym; XComposeStatus composestatus; length = XLookupString(event, buf, MAXNAMELENGTH, &keysym, &composestatus); buf[1] = '\0'; l = strlen(dtext); /* check for printable character */ if((keysym >= ' ') && (keysym <= '~') && (length > 0)) { if((l + strlen(buf)) < MAXNAMELENGTH) { strcat(dtext, buf); display_dialog(dialogstringwindow); } } else { switch(keysym) { /* delete key */ case XK_BackSpace: case XK_Delete: if(l >= 1) { XClearWindow(display, dialogstringwindow); l--; dtext[l] = '\0'; display_dialog(dialogstringwindow); XFlush(display); } break; /* return is as good as hitting ok */ case '\n': case XK_Return: case XK_KP_Enter: XFillRectangle(display, dialogbuttonwindow, ctable[CBLUE].smallgc, 0, 0, 50, 30); display_dialog(dialogbuttonwindow); return(1); default: break; } } return(0); }
static gboolean display_request (DBusGMethodInvocation *context, DBusGProxy *device, guint pin, guint entered, gpointer user_data) { g_warning ("Not implemented, please file a bug at how this happened"); return FALSE; #if 0 DBusGProxy *adapter = user_data; char *name, *text; name = get_name_for_display (device); if (name == NULL) return FALSE; text = g_strdup_printf("%d", pin); display_dialog(adapter, device, address, name, text, entered, context); g_free(text); if (notification_supports_actions () == FALSE) { g_free (name); present_notification_dialogs (); return TRUE; } /* translators: this is a popup telling you a particular device * has asked for pairing */ line = g_strdup_printf(_("Pairing request for '%s'"), name); g_free(name); show_notification(_("Bluetooth device"), line, _("Enter PIN"), 0, G_CALLBACK(notification_closed)); g_free(line); return TRUE; #endif }