void ScriptDlg(FontView *fv,CharView *cv) { GRect pos; static GWindow gw; GWindowAttrs wattrs; GGadgetCreateData gcd[12], boxes[5], *barray[4][8], *hvarray[4][2]; #if !defined(_NO_FFSCRIPT) && !defined(_NO_PYTHON) GGadgetCreateData *rarray[4]; #endif GTextInfo label[12]; struct sd_data sd; FontView *list; int i,l; memset(&sd,0,sizeof(sd)); sd.fv = fv; sd.sc = cv==NULL ? NULL : cv->b.sc; sd.layer = cv==NULL ? ly_fore : CVLayer((CharViewBase *) cv); sd.oldh = pos.height = GDrawPointsToPixels(NULL,SD_Height); if ( gw==NULL ) { memset(&wattrs,0,sizeof(wattrs)); wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_restrict|wam_isdlg; wattrs.event_masks = ~(1<<et_charup); wattrs.restrict_input_to_me = 1; wattrs.undercursor = 1; wattrs.cursor = ct_pointer; wattrs.utf8_window_title = _("Execute Script"); wattrs.is_dlg = true; pos.x = pos.y = 0; pos.width = GDrawPointsToPixels(NULL,GGadgetScale(SD_Width)); gw = GDrawCreateTopWindow(NULL,&pos,sd_e_h,&sd,&wattrs); memset(&boxes,0,sizeof(boxes)); memset(&gcd,0,sizeof(gcd)); memset(&label,0,sizeof(label)); i = l = 0; gcd[i].gd.pos.x = 10; gcd[i].gd.pos.y = 10; gcd[i].gd.pos.width = SD_Width-20; gcd[i].gd.pos.height = SD_Height-54; gcd[i].gd.flags = gg_visible | gg_enabled | gg_textarea_wrap; gcd[i].gd.cid = CID_Script; gcd[i++].creator = GTextAreaCreate; hvarray[l][0] = &gcd[i-1]; hvarray[l++][1] = NULL; #if !defined(_NO_FFSCRIPT) && !defined(_NO_PYTHON) gcd[i-1].gd.pos.height -= 24; gcd[i].gd.pos.x = 10; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y+gcd[i-1].gd.pos.height+1; gcd[i].gd.flags = gg_visible | gg_enabled | gg_cb_on; gcd[i].gd.cid = CID_Python; label[i].text = (unichar_t *) _("_Python"); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.label = &label[i]; gcd[i].gd.handle_controlevent = SD_LangChanged; gcd[i++].creator = GRadioCreate; rarray[0] = &gcd[i-1]; gcd[i].gd.pos.x = 70; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y; gcd[i].gd.flags = gg_visible | gg_enabled; /* disabled if cv!=NULL later */ gcd[i].gd.cid = CID_FF; label[i].text = (unichar_t *) _("_FF"); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.label = &label[i]; gcd[i].gd.handle_controlevent = SD_LangChanged; gcd[i++].creator = GRadioCreate; rarray[1] = &gcd[i-1]; rarray[2] = GCD_Glue; rarray[3] = NULL; boxes[2].gd.flags = gg_enabled | gg_visible; boxes[2].gd.u.boxelements = rarray; boxes[2].creator = GHBoxCreate; hvarray[l][0] = &boxes[2]; hvarray[l++][1] = NULL; #endif barray[0][0] = barray[1][0] = barray[0][6] = barray[1][6] = GCD_Glue; barray[0][2] = barray[1][2] = barray[0][4] = barray[1][4] = GCD_Glue; barray[0][1] = barray[0][5] = GCD_RowSpan; barray[0][7] = barray[1][7] = barray[2][0] = NULL; gcd[i].gd.pos.x = 25-3; gcd[i].gd.pos.y = SD_Height-32-3; gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_default; label[i].text = (unichar_t *) _("_OK"); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.mnemonic = 'O'; gcd[i].gd.label = &label[i]; gcd[i].gd.handle_controlevent = SD_OK; gcd[i].gd.cid = CID_OK; gcd[i++].creator = GButtonCreate; barray[1][1] = &gcd[i-1]; gcd[i].gd.pos.x = -25; gcd[i].gd.pos.y = SD_Height-32; gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_cancel; label[i].text = (unichar_t *) _("_Cancel"); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.label = &label[i]; gcd[i].gd.mnemonic = 'C'; gcd[i].gd.handle_controlevent = SD_Cancel; gcd[i].gd.cid = CID_Cancel; gcd[i++].creator = GButtonCreate; barray[1][5] = &gcd[i-1]; gcd[i].gd.pos.x = (SD_Width-GIntGetResource(_NUM_Buttonsize)*100/GIntGetResource(_NUM_ScaleFactor))/2; gcd[i].gd.pos.y = SD_Height-40; gcd[i].gd.flags = gg_visible | gg_enabled; label[i].text = (unichar_t *) _("C_all..."); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.label = &label[i]; gcd[i].gd.mnemonic = 'a'; gcd[i].gd.handle_controlevent = SD_Call; gcd[i].gd.cid = CID_Call; gcd[i++].creator = GButtonCreate; barray[0][3] = &gcd[i-1]; #if !defined(_NO_FFSCRIPT) gcd[i].gd.pos.width = gcd[i].gd.pos.height = 5; gcd[i].gd.flags = gg_visible | gg_enabled; gcd[i++].creator = GSpacerCreate; barray[1][3] = &gcd[i-1]; #else barray[1][3] = GCD_RowSpan; #endif barray[3][0] = NULL; boxes[3].gd.flags = gg_enabled | gg_visible; boxes[3].gd.u.boxelements = barray[0]; boxes[3].creator = GHVBoxCreate; hvarray[l][0] = &boxes[3]; hvarray[l++][1] = NULL; hvarray[l][0] = NULL; boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2; boxes[0].gd.flags = gg_enabled | gg_visible; boxes[0].gd.u.boxelements = hvarray[0]; boxes[0].creator = GHVGroupCreate; GGadgetsCreate(gw,boxes); if ( boxes[2].ret!=NULL ) GHVBoxSetExpandableCol(boxes[2].ret,gb_expandglue); GHVBoxSetExpandableCol(boxes[3].ret,gb_expandgluesame); GHVBoxSetExpandableRow(boxes[0].ret,0); GHVBoxFitWindow(boxes[0].ret); } #if !defined(_NO_FFSCRIPT) && !defined(_NO_PYTHON) GGadgetSetEnabled(GWidgetGetControl(gw,CID_FF),cv==NULL); #endif sd.gw = gw; GDrawSetUserData(gw,&sd); GWidgetIndicateFocusGadget(GWidgetGetControl(gw,CID_Script)); #if !defined(_NO_FFSCRIPT) && !defined(_NO_PYTHON) _SD_LangChanged(&sd); #endif GDrawSetVisible(gw,true); while ( !sd.done ) GDrawProcessOneEvent(NULL); GDrawSetVisible(gw,false); /* Selection may be out of date, force a refresh */ for ( list = fv_list; list!=NULL; list=(FontView *) list->b.next ) GDrawRequestExpose(list->v,NULL,false); GDrawSync(NULL); GDrawProcessPendingEvents(NULL); GDrawSetUserData(gw,NULL); }
static void FilterDlg(void) { static struct col_init cols[] = { { me_string, NULL, NULL, NULL, N_("Name") }, { me_string, NULL, NULL, NULL, N_("Filter") } }; static int inited = false; static struct matrixinit mi = { 2, cols, 0, NULL, NULL, filter_candelete, NULL, NULL, NULL, NULL }; struct matrix_data *md; int k, cnt, i, ptwidth; GGadgetCreateData gcd[3], boxes[3], *varray[7], *harray[7]; GTextInfo label[3]; GRect pos; GWindow gw; GWindowAttrs wattrs; struct filter_d d; if ( !inited ) { inited = true; cols[0].title = _(cols[0].title); cols[1].title = _(cols[1].title); } for ( k=0; k<2; ++k ) { cnt = 0; for ( i=0; def_font_filters[i].name!=NULL; ++i ) { if ( *(char *) def_font_filters[i].name != '-' ) { if ( k ) { md[2*cnt].u.md_str = copy(_(def_font_filters[i].name)); md[2*cnt].frozen = true; md[2*cnt+1].u.md_str = copy(def_font_filters[i].filter); md[2*cnt+1].frozen = true; } ++cnt; } } if ( user_font_filters!=NULL ) { for ( i=0; user_font_filters[i].name!=NULL; ++i ) { if ( *(char *) user_font_filters[i].name != '-' ) { if ( k ) { md[2*cnt].u.md_str = copy(user_font_filters[i].name); md[2*cnt].frozen = false; md[2*cnt+1].u.md_str = copy(user_font_filters[i].filter); md[2*cnt+1].frozen = false; } ++cnt; } } } if ( !k ) md = calloc(2*cnt,sizeof(struct matrix_data)); } mi.initial_row_cnt = cnt; mi.matrix_data = md; memset(&d,'\0',sizeof(d)); memset(&wattrs,0,sizeof(wattrs)); wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_restrict|wam_isdlg; wattrs.event_masks = ~(1<<et_charup); wattrs.restrict_input_to_me = 1; wattrs.is_dlg = true; wattrs.undercursor = 1; wattrs.cursor = ct_pointer; wattrs.utf8_window_title = _("Edit Font Filters"); pos.x = pos.y = 0; ptwidth = 2*GIntGetResource(_NUM_Buttonsize)+GGadgetScale(60); pos.width =GDrawPointsToPixels(NULL,ptwidth); pos.height = GDrawPointsToPixels(NULL,90); gw = GDrawCreateTopWindow(NULL,&pos,filter_e_h,&d,&wattrs); memset(&label,0,sizeof(label)); memset(&gcd,0,sizeof(gcd)); memset(&boxes,0,sizeof(boxes)); gcd[0].gd.pos.x = 10; gcd[0].gd.pos.y = 6; gcd[0].gd.pos.width = 300; gcd[0].gd.pos.height = 200; gcd[0].gd.flags = gg_visible | gg_enabled; gcd[0].creator = GMatrixEditCreate; gcd[0].gd.u.matrix = &mi; varray[0] = &gcd[0]; varray[1] = NULL; gcd[1].gd.pos.x = 20-3; gcd[1].gd.pos.y = 90-35-3; gcd[1].gd.pos.width = -1; gcd[1].gd.pos.height = 0; gcd[1].gd.flags = gg_visible | gg_enabled | gg_but_default; label[1].text = (unichar_t *) _("_OK"); label[1].text_is_1byte = true; label[1].text_in_resource = true; gcd[1].gd.label = &label[1]; gcd[1].gd.handle_controlevent = Filter_OK; gcd[1].creator = GButtonCreate; harray[0] = GCD_Glue; harray[1] = &gcd[1]; harray[2] = GCD_Glue; gcd[2].gd.pos.x = -20; gcd[2].gd.pos.y = 90-35; gcd[2].gd.pos.width = -1; gcd[2].gd.pos.height = 0; gcd[2].gd.flags = gg_visible | gg_enabled | gg_but_cancel; label[2].text = (unichar_t *) _("_Cancel"); label[2].text_is_1byte = true; label[2].text_in_resource = true; gcd[2].gd.label = &label[2]; gcd[2].gd.handle_controlevent = Filter_Cancel; gcd[2].creator = GButtonCreate; harray[3] = GCD_Glue; harray[4] = &gcd[2]; harray[5] = GCD_Glue; harray[6] = NULL; varray[2] = &boxes[2]; varray[3] = NULL; varray[4] = NULL; boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2; boxes[0].gd.flags = gg_enabled|gg_visible; boxes[0].gd.u.boxelements = varray; boxes[0].creator = GHVGroupCreate; boxes[2].gd.flags = gg_enabled|gg_visible; boxes[2].gd.u.boxelements = harray; boxes[2].creator = GHBoxCreate; GGadgetsCreate(gw,boxes); GHVBoxSetExpandableRow(boxes[0].ret,0); GHVBoxSetExpandableCol(boxes[2].ret,gb_expandgluesame); GHVBoxFitWindow(boxes[0].ret); GMatrixEditSetNewText(gcd[0].ret,S_("Filter|New")); d.gme = gcd[0].ret; GDrawSetVisible(gw,true); while ( !d.done ) GDrawProcessOneEvent(NULL); GDrawDestroyWindow(gw); for ( i=0; i<cnt; ++i ) { free(md[2*i].u.md_str); free(md[2*i+1].u.md_str); } free(md); }
unichar_t *FVOpenFont(char *title, const char *defaultfile, int mult) { GRect pos; int i, filter, renamei; GWindow gw; GWindowAttrs wattrs; GGadgetCreateData gcd[11], boxes[5], *varray[9], *harray1[7], *harray2[4], *harray3[9]; GTextInfo label[10]; struct gfc_data d; int bs = GIntGetResource(_NUM_Buttonsize), bsbigger, totwid, spacing; GGadget *tf; unichar_t *temp; char **nlnames; GTextInfo *namelistnames, **filts; int cnt; memset(&d,'\0',sizeof(d)); memset(&wattrs,0,sizeof(wattrs)); wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict; wattrs.event_masks = ~(1<<et_charup); wattrs.restrict_input_to_me = 1; wattrs.is_dlg = true; wattrs.undercursor = 1; wattrs.cursor = ct_pointer; wattrs.utf8_window_title = title; pos.x = pos.y = 0; totwid = GGadgetScale(295); bsbigger = 4*bs+4*14>totwid; totwid = bsbigger?4*bs+4*12:totwid; spacing = (totwid-4*bs-2*12)/3; pos.width = GDrawPointsToPixels(NULL,totwid); pos.height = GDrawPointsToPixels(NULL,247); gw = GDrawCreateTopWindow(NULL,&pos,e_h,&d,&wattrs); memset(&label,0,sizeof(label)); memset(&gcd,0,sizeof(gcd)); memset(&boxes,0,sizeof(boxes)); i=0; gcd[i].gd.pos.x = 12; gcd[i].gd.pos.y = 6; gcd[i].gd.pos.width = totwid*100/GIntGetResource(_NUM_ScaleFactor)-24; gcd[i].gd.pos.height = 180; gcd[i].gd.flags = gg_visible | gg_enabled; if ( RecentFiles[0]!=NULL ) gcd[i].gd.flags = gg_visible | gg_enabled | gg_file_pulldown; if ( mult ) gcd[i].gd.flags |= gg_file_multiple; varray[0] = &gcd[i]; varray[1] = NULL; gcd[i++].creator = GFileChooserCreate; label[i].text = (unichar_t *) _("Filter:"); label[i].text_is_1byte = true; gcd[i].gd.label = &label[i]; gcd[i].gd.pos.x = 8; gcd[i].gd.pos.y = 188+6; gcd[i].gd.flags = gg_visible | gg_enabled | gg_utf8_popup; gcd[i].gd.popup_msg = (unichar_t *) _("Display files of this type" ); harray1[0] = GCD_Glue; harray1[1] = &gcd[i]; gcd[i++].creator = GLabelCreate; gcd[i].gd.pos.x = 0; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y-6; gcd[i].gd.flags = gg_visible | gg_enabled | gg_utf8_popup; gcd[i].gd.popup_msg = (unichar_t *) _("Display files of this type"); gcd[i].gd.handle_controlevent = GFD_FilterSelected; harray1[2] = &gcd[i]; harray1[3] = GCD_Glue; harray1[4] = GCD_Glue; harray1[5] = GCD_Glue; harray1[6] = NULL; gcd[i++].creator = GListButtonCreate; boxes[2].gd.flags = gg_visible | gg_enabled; boxes[2].gd.u.boxelements = harray1; boxes[2].creator = GHBoxCreate; varray[2] = &boxes[2]; varray[3] = NULL; label[i].text = (unichar_t *) _("Force glyph names to:"); label[i].text_is_1byte = true; gcd[i].gd.label = &label[i]; gcd[i].gd.pos.x = 8; gcd[i].gd.pos.y = 188+6; gcd[i].gd.flags = gg_visible | gg_enabled | gg_utf8_popup; gcd[i].gd.popup_msg = (unichar_t *) _("In the saved font, force all glyph names to match those in the specified namelist"); harray2[0] = &gcd[i]; gcd[i++].creator = GLabelCreate; renamei = i; gcd[i].gd.pos.x = 0; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y-6; gcd[i].gd.flags = gg_visible | gg_enabled | gg_utf8_popup; gcd[i].gd.popup_msg = (unichar_t *) _("In the saved font, force all glyph names to match those in the specified namelist"); gcd[i].creator = GListButtonCreate; nlnames = AllNamelistNames(); for ( cnt=0; nlnames[cnt]!=NULL; ++cnt); namelistnames = calloc(cnt+3,sizeof(GTextInfo)); namelistnames[0].text = (unichar_t *) _("No Rename"); namelistnames[0].text_is_1byte = true; if ( force_names_when_opening==NULL ) { namelistnames[0].selected = true; gcd[i].gd.label = &namelistnames[0]; } namelistnames[1].line = true; for ( cnt=0; nlnames[cnt]!=NULL; ++cnt) { namelistnames[cnt+2].text = (unichar_t *) nlnames[cnt]; namelistnames[cnt+2].text_is_1byte = true; if ( force_names_when_opening!=NULL && strcmp(_(force_names_when_opening->title),nlnames[cnt])==0 ) { namelistnames[cnt+2].selected = true; gcd[i].gd.label = &namelistnames[cnt+2]; } } harray2[1] = &gcd[i]; harray2[2] = GCD_Glue; harray2[3] = NULL; gcd[i++].gd.u.list = namelistnames; boxes[3].gd.flags = gg_visible | gg_enabled; boxes[3].gd.u.boxelements = harray2; boxes[3].creator = GHBoxCreate; varray[4] = &boxes[3]; varray[5] = NULL; gcd[i].gd.pos.x = 12; gcd[i].gd.pos.y = 216-3; gcd[i].gd.pos.width = -1; gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_default; label[i].text = (unichar_t *) _("_OK"); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.mnemonic = 'O'; gcd[i].gd.label = &label[i]; gcd[i].gd.handle_controlevent = GFD_Ok; harray3[0] = GCD_Glue; harray3[1] = &gcd[i]; gcd[i++].creator = GButtonCreate; gcd[i].gd.pos.x = -(spacing+bs)*100/GIntGetResource(_NUM_ScaleFactor)-12; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y+3; gcd[i].gd.pos.width = -1; gcd[i].gd.flags = gg_visible | gg_enabled; label[i].text = (unichar_t *) S_("Font|_New"); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.mnemonic = 'N'; gcd[i].gd.label = &label[i]; gcd[i].gd.handle_controlevent = GFD_New; harray3[2] = GCD_Glue; harray3[3] = &gcd[i]; gcd[i++].creator = GButtonCreate; filter = i; gcd[i].gd.pos.x = (spacing+bs)*100/GIntGetResource(_NUM_ScaleFactor)+12; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y; gcd[i].gd.pos.width = -1; gcd[i].gd.flags = /* gg_visible |*/ gg_enabled; label[i].text = (unichar_t *) _("_Filter"); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.mnemonic = 'F'; gcd[i].gd.label = &label[i]; gcd[i].gd.handle_controlevent = GFileChooserFilterEh; harray3[4] = &gcd[i]; gcd[i++].creator = GButtonCreate; gcd[i].gd.pos.x = -12; gcd[i].gd.pos.y = gcd[i-1].gd.pos.y; gcd[i].gd.pos.width = -1; gcd[i].gd.flags = gg_visible | gg_enabled | gg_but_cancel; label[i].text = (unichar_t *) _("_Cancel"); label[i].text_is_1byte = true; label[i].text_in_resource = true; gcd[i].gd.label = &label[i]; gcd[i].gd.mnemonic = 'C'; gcd[i].gd.handle_controlevent = GFD_Cancel; harray3[5] = GCD_Glue; harray3[6] = &gcd[i]; harray3[7] = GCD_Glue; harray3[8] = NULL; gcd[i++].creator = GButtonCreate; boxes[4].gd.flags = gg_visible | gg_enabled; boxes[4].gd.u.boxelements = harray3; boxes[4].creator = GHBoxCreate; varray[6] = &boxes[4]; varray[7] = NULL; varray[8] = NULL; boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2; boxes[0].gd.flags = gg_visible | gg_enabled; boxes[0].gd.u.boxelements = varray; boxes[0].creator = GHVGroupCreate; gcd[i].gd.pos.x = 2; gcd[i].gd.pos.y = 2; gcd[i].gd.pos.width = pos.width-4; gcd[i].gd.pos.height = pos.height-4; gcd[i].gd.flags = gg_enabled | gg_visible | gg_pos_in_pixels; gcd[i++].creator = GGroupCreate; GGadgetsCreate(gw,boxes); d.gfc = gcd[0].ret; d.rename = gcd[renamei].ret; filts = StandardFilters(); GGadgetSetList(harray1[2]->ret,filts,true); GHVBoxSetExpandableRow(boxes[0].ret,0); GHVBoxSetExpandableCol(boxes[2].ret,gb_expandglue); GHVBoxSetExpandableCol(boxes[3].ret,gb_expandglue); GHVBoxSetExpandableCol(boxes[4].ret,gb_expandgluesame); GHVBoxFitWindow(boxes[0].ret); free(namelistnames); GGadgetSetUserData(gcd[filter].ret,gcd[0].ret); GFileChooserConnectButtons(gcd[0].ret,harray3[1]->ret,gcd[filter].ret); temp = utf82u_copy(filts[default_font_filter_index]->userdata); GFileChooserSetFilterText(gcd[0].ret,temp); free(temp); GFileChooserGetChildren(gcd[0].ret,NULL, NULL, &tf); if ( RecentFiles[0]!=NULL ) { GGadgetSetList(tf,GTextInfoFromChars(RecentFiles,RECENT_MAX),false); } GGadgetSetTitle8(gcd[0].ret,defaultfile); GWidgetHidePalettes(); GDrawSetVisible(gw,true); while ( !d.done ) GDrawProcessOneEvent(NULL); GDrawDestroyWindow(gw); GDrawProcessPendingEvents(NULL); /* Give the window a chance to vanish... */ GDrawSync(NULL); GDrawProcessPendingEvents(NULL); /* Give the window a chance to vanish... */ free( d.lastpopupfontname ); GTextInfoArrayFree(filts); for ( cnt=0; nlnames[cnt]!=NULL; ++cnt) { free(nlnames[cnt]); } free(nlnames); return(d.ret); }
static uint32_t * GWidgetOpenFileWPath (const uint32_t *title, const uint32_t *defaultfile, const uint32_t *initial_filter, char **mimetypes, GFileChooserFilterType filter, char **path) { GRect pos; GWindow gw; GWindowAttrs wattrs; GGadgetCreateData gcd[7], boxes[3], *varray[5], *harray[8]; GTextInfo label[4]; struct gfc_data d; int bs = GIntGetResource (_NUM_Buttonsize), bsbigger, totwid; GProgressPauseTimer (); memset (&wattrs, 0, sizeof (wattrs)); wattrs.mask = wam_events | wam_cursor | wam_wtitle | wam_undercursor | wam_restrict | wam_isdlg; wattrs.event_masks = ~(1 << et_charup); wattrs.restrict_input_to_me = 1; wattrs.undercursor = 1; wattrs.is_dlg = 1; wattrs.cursor = ct_pointer; wattrs.window_title = (uint32_t *) title; pos.x = pos.y = 0; totwid = GGadgetScale (223); bsbigger = 3 * bs + 4 * 14 > totwid; totwid = bsbigger ? 3 * bs + 4 * 12 : totwid; pos.width = GDrawPointsToPixels (NULL, totwid); pos.height = GDrawPointsToPixels (NULL, 223); gw = GDrawCreateTopWindow (NULL, &pos, e_h, &d, &wattrs); memset (&label, 0, sizeof (label)); memset (&gcd, 0, sizeof (gcd)); memset (&boxes, 0, sizeof (boxes)); gcd[0].gd.pos.x = 12; gcd[0].gd.pos.y = 6; gcd[0].gd.pos.width = 223 - 24; gcd[0].gd.pos.height = 180; gcd[0].gd.flags = gg_visible | gg_enabled; gcd[0].creator = GFileChooserCreate; varray[0] = &gcd[0]; varray[1] = NULL; gcd[1].gd.pos.x = 12; gcd[1].gd.pos.y = 192 - 3; gcd[1].gd.pos.width = -1; gcd[1].gd.flags = gg_visible | gg_enabled | gg_but_default; label[1].text = (uint32_t *) _("_OK"); label[1].text_is_1byte = true; label[1].text_has_mnemonic = true; gcd[1].gd.label = &label[1]; gcd[1].gd.handle_controlevent = GFD_Ok; gcd[1].creator = GButtonCreate; harray[0] = GCD_Glue; harray[1] = &gcd[1]; gcd[2].gd.pos.x = (totwid - bs) * 100 / GIntGetResource (_NUM_ScaleFactor) / 2; gcd[2].gd.pos.y = gcd[1].gd.pos.y + 3; gcd[2].gd.pos.width = -1; gcd[2].gd.flags = gg_visible | gg_enabled; label[2].text = (uint32_t *) _("_Filter"); label[2].text_is_1byte = true; label[2].text_has_mnemonic = true; gcd[2].gd.label = &label[2]; gcd[2].gd.handle_controlevent = GFileChooserFilterEh; gcd[2].creator = GButtonCreate; harray[2] = GCD_Glue; harray[3] = &gcd[2]; gcd[3].gd.pos.x = -gcd[1].gd.pos.x; gcd[3].gd.pos.y = gcd[2].gd.pos.y; gcd[3].gd.pos.width = -1; gcd[3].gd.flags = gg_visible | gg_enabled | gg_but_cancel; label[3].text = (uint32_t *) _("_Cancel"); label[3].text_is_1byte = true; label[3].text_has_mnemonic = true; gcd[3].gd.label = &label[3]; gcd[3].gd.handle_controlevent = GFD_Cancel; gcd[3].creator = GButtonCreate; harray[4] = GCD_Glue; harray[5] = &gcd[3]; harray[6] = GCD_Glue; harray[7] = NULL; boxes[2].gd.flags = gg_visible | gg_enabled; boxes[2].gd.u.boxelements = harray; boxes[2].creator = GHBoxCreate; varray[2] = &boxes[2]; varray[3] = NULL; varray[4] = NULL; boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2; boxes[0].gd.flags = gg_visible | gg_enabled; boxes[0].gd.u.boxelements = varray; boxes[0].creator = GHVGroupCreate; gcd[4].gd.pos.x = 2; gcd[4].gd.pos.y = 2; gcd[4].gd.pos.width = pos.width - 4; gcd[4].gd.pos.height = pos.height - 4; gcd[4].gd.flags = gg_enabled | gg_visible | gg_pos_in_pixels; gcd[4].creator = GGroupCreate; GGadgetsCreate (gw, boxes); GGadgetSetUserData (gcd[2].ret, gcd[0].ret); GHVBoxSetExpandableRow (boxes[0].ret, 0); GHVBoxSetExpandableCol (boxes[2].ret, gb_expandgluesame); GHVBoxFitWindow (boxes[0].ret); GFileChooserConnectButtons (gcd[0].ret, gcd[1].ret, gcd[2].ret); GFileChooserSetFilterText (gcd[0].ret, initial_filter); GFileChooserSetFilterFunc (gcd[0].ret, filter); GFileChooserSetMimetypes (gcd[0].ret, mimetypes); GFileChooserSetPaths (gcd[0].ret, path); GGadgetSetTitle (gcd[0].ret, defaultfile); memset (&d, '\0', sizeof (d)); d.gfc = gcd[0].ret; GDrawSetVisible (gw, true); while (!d.done) GDrawProcessOneEvent (NULL); GDrawDestroyWindow (gw); GDrawProcessPendingEvents (NULL); /* Give the window a chance to vanish... */ GDrawSync (NULL); GDrawProcessPendingEvents (NULL); /* Give the window a chance to vanish... */ GProgressResumeTimer (); return (d.ret); }