static void WarnMenuCopy(GWindow gw,struct gmenuitem *mi,GEvent *e) { GDrawGrabSelection(gw,sn_clipboard); GDrawAddSelectionType(gw,sn_clipboard,"UTF8_STRING",&errdata,1, sizeof(char), genutf8data,noop); GDrawAddSelectionType(gw,sn_clipboard,"STRING",&errdata,1, sizeof(char), genutf8data,noop); }
static void SendNextArg(struct argsstruct *args) { int i; char *msg; static GTimer *timeout; if ( timeout!=NULL ) { GDrawCancelTimer(timeout); timeout = NULL; } for ( i=args->next; i<args->argc; ++i ) { if ( *args->argv[i]!='-' || strcmp(args->argv[i],"-quit")==0 || strcmp(args->argv[i],"--quit")==0 || strcmp(args->argv[i],"-new")==0 || strcmp(args->argv[i],"--new")==0 ) break; } if ( i>=args->argc ) { if ( args->any ) exit(0); /* Sent everything */ msg = "-open"; } else msg = args->argv[i]; args->next = i+1; args->any = true; GDrawGrabSelection(splashw,sn_user1); GDrawAddSelectionType(splashw,sn_user1,"STRING", copy(msg),strlen(msg),1, NULL,NULL); /* If we just sent the other fontforge a request to die, it will never*/ /* take the selection back. So we should just die quietly */ /* But we can't die instantly, or it will never get our death threat */ /* (it won't have a chance to ask us for the selection if we're dead)*/ timeout = GDrawRequestTimer(splashw,1000,0,NULL); }
static int warningsv_e_h(GWindow gw, GEvent *event) { int i; extern GBox _ggadget_Default_Box; if (( event->type==et_mouseup || event->type==et_mousedown ) && (event->u.mouse.button>=4 && event->u.mouse.button<=7) ) { return( GGadgetDispatchEvent(errdata.vsb,event)); } switch ( event->type ) { case et_expose: /*GDrawFillRect(gw,&event->u.expose.rect,GDrawGetDefaultBackground(NULL));*/ GDrawSetFont(gw,errdata.font); for ( i=0; i<errdata.linecnt && i+errdata.offtop<errdata.cnt; ++i ) { int xs, xe; int s_l = errdata.start_l, s_c = errdata.start_c, e_l = errdata.end_l, e_c = errdata.end_c; GRect r; if ( s_l>e_l ) { s_l = e_l; s_c = e_c; e_l = errdata.start_l; e_c = errdata.start_c; } if ( GDrawHasCairo(gw)&gc_pango ) GDrawLayoutInit(gw,errdata.errlines[i+errdata.offtop],-1,NULL); if ( i+errdata.offtop >= s_l && i+errdata.offtop <= e_l ) { if ( i+errdata.offtop > s_l ) xs = 0; else if ( GDrawHasCairo(gw)&gc_pango ) { GRect pos; GDrawLayoutIndexToPos(gw,s_c,&pos); xs = pos.x+3; } else xs = GDrawGetText8Width(gw,errdata.errlines[i+errdata.offtop],s_c,NULL); if ( i+errdata.offtop < e_l ) xe = 3000; else if ( GDrawHasCairo(gw)&gc_pango ) { GRect pos; GDrawLayoutIndexToPos(gw,s_c,&pos); xe = pos.x+pos.width+3; } else xe = GDrawGetText8Width(gw,errdata.errlines[i+errdata.offtop],e_c,NULL); r.x = xs+3; r.width = xe-xs; r.y = i*errdata.fh; r.height = errdata.fh; GDrawFillRect(gw,&r,ACTIVE_BORDER); } if ( GDrawHasCairo(gw)&gc_pango ) GDrawLayoutDraw(gw,3,i*errdata.fh+errdata.as,MAIN_FOREGROUND); else GDrawDrawBiText8(gw,3,i*errdata.fh+errdata.as,errdata.errlines[i+errdata.offtop],-1,NULL,MAIN_FOREGROUND); } break; case et_char: return( ErrChar(event)); break; case et_mousedown: if ( event->u.mouse.button==3 ) { warnpopupmenu[1].ti.disabled = errdata.start_l == -1; warnpopupmenu[3].ti.disabled = errdata.cnt == 0; GMenuCreatePopupMenu(gw,event, warnpopupmenu); } else { if ( errdata.down ) return( true ); MouseToPos(event,&errdata.start_l,&errdata.start_c); errdata.down = true; } case et_mousemove: case et_mouseup: if ( !errdata.down ) return( true ); MouseToPos(event,&errdata.end_l,&errdata.end_c); GDrawRequestExpose(gw,NULL,false); if ( event->type==et_mouseup ) { errdata.down = false; if ( errdata.start_l == errdata.end_l && errdata.start_c == errdata.end_c ) { errdata.start_l = errdata.end_l = -1; } else { GDrawGrabSelection(gw,sn_primary); GDrawAddSelectionType(gw,sn_primary,"UTF8_STRING",&errdata,1, sizeof(char), genutf8data,noop); GDrawAddSelectionType(gw,sn_primary,"STRING",&errdata,1, sizeof(char), genutf8data,noop); } } break; case et_selclear: errdata.start_l = errdata.end_l = -1; GDrawRequestExpose(gw,NULL,false); break; case et_timer: break; case et_focus: break; } return( true ); }
static int splash_e_h(GWindow gw, GEvent *event) { static int splash_cnt; GRect old; int i, y, x; static char *foolishness[] = { /* GT: These strings are for fun. If they are offensive or incomprehensible */ /* GT: simply translate them as something dull like: "FontForge" */ /* GT: This is a spoof of political slogans, designed to point out how foolish they are */ N_("A free press discriminates\nagainst the illiterate."), N_("A free press discriminates\nagainst the illiterate."), /* GT: This is a pun on the old latin drinking song "Gaudeamus igature!" */ N_("Gaudeamus Ligature!"), N_("Gaudeamus Ligature!"), /* GT: Spoof on the bible */ N_("In the beginning was the letter..."), /* GT: Some wit at MIT came up with this ("ontology recapitulates phylogony" is the original) */ N_("fontology recapitulates file-ogeny") }; switch ( event->type ) { case et_create: GDrawGrabSelection(gw,sn_user1); break; case et_expose: GDrawPushClip(gw,&event->u.expose.rect,&old); GDrawDrawImage(gw,&splashimage,NULL,0,0); GDrawSetFont(gw,splash_font); y = splashimage.u.image->height + as + fh/2; for ( i=1; i<linecnt; ++i ) { if ( is>=lines[i-1]+1 && is<lines[i] ) { x = 8+GDrawDrawText(gw,8,y,lines[i-1]+1,is-lines[i-1]-1,0x000000); GDrawSetFont(gw,splash_italic); GDrawDrawText(gw,x,y,is,lines[i]-is,0x000000); } else if ( ie>=lines[i-1]+1 && ie<lines[i] ) { x = 8+GDrawDrawText(gw,8,y,lines[i-1]+1,ie-lines[i-1]-1,0x000000); GDrawSetFont(gw,splash_font); GDrawDrawText(gw,x,y,ie,lines[i]-ie,0x000000); } else GDrawDrawText(gw,8,y,lines[i-1]+1,lines[i]-lines[i-1]-1,0x000000); y += fh; } GDrawPopClip(gw,&old); break; case et_map: splash_cnt = 0; break; case et_timer: if ( event->u.timer.timer==autosave_timer ) { DoAutoSaves(); } else if ( event->u.timer.timer==splasht ) { if ( ++splash_cnt==1 ) GDrawResize(gw,splashimage.u.image->width,splashimage.u.image->height-30); else if ( splash_cnt==2 ) GDrawResize(gw,splashimage.u.image->width,splashimage.u.image->height); else if ( splash_cnt>=7 ) { GGadgetEndPopup(); GDrawSetVisible(gw,false); GDrawCancelTimer(splasht); splasht = NULL; } } else { DoDelayedEvents(event); } break; case et_char: case et_mousedown: case et_close: GGadgetEndPopup(); GDrawSetVisible(gw,false); break; case et_mousemove: GGadgetPreparePopup8(gw,_(foolishness[rand()%(sizeof(foolishness)/sizeof(foolishness[0]))]) ); break; case et_selclear: /* If this happens, it means someone wants to send us a message with a*/ /* filename to open. So we need to ask for it, process it, and then */ /* take the selection back again */ if ( event->u.selclear.sel == sn_user1 ) { int len; char *arg; arg = GDrawRequestSelection(splashw,sn_user1,"STRING",&len); if ( arg==NULL ) return( true ); if ( strcmp(arg,"-new")==0 || strcmp(arg,"--new")==0 ) FontNew(); else if ( strcmp(arg,"-open")==0 || strcmp(arg,"--open")==0 ) _FVMenuOpen(NULL); else if ( strcmp(arg,"-quit")==0 || strcmp(arg,"--quit")==0 ) MenuExit(NULL,NULL,NULL); else ViewPostScriptFont(arg,0); free(arg); GDrawGrabSelection(splashw,sn_user1); } break; case et_destroy: IError("Who killed the splash screen?"); break; } return( true ); }