// Read program groups (icon list must be locked) void backdrop_read_groups(BackdropInfo *info) { BPTR lock; struct FileInfoBlock __aligned fib; struct AnchorPath *anchor; short error; // Allocate anchor if (!(anchor=AllocVec(sizeof(struct AnchorPath)+256,MEMF_CLEAR))) return; // Initialise anchor anchor->ap_Strlen=256; // Search for icons error=MatchFirst("dopus5:groups/#?.info",anchor); // Continue while there's files while (!error) { char *ptr; // Strip .info suffix if (ptr=sufcmp(anchor->ap_Buf,".info")) *ptr=0; // See if directory exists to go with it if (lock=Lock(anchor->ap_Buf,ACCESS_READ)) { // Examine file Examine(lock,&fib); UnLock(lock); // Is it a directory? if (fib.fib_DirEntryType>0) { BackdropObject *object; struct List *search; // Lock icon list lock_listlock(&info->objects,FALSE); // See if group already exists search=&info->objects.list; while (object=(BackdropObject *)FindNameI(search,fib.fib_FileName)) { // Is it a group? if (object->type==BDO_GROUP) break; // Continue search search=(struct List *)object; } // Unlock icon list unlock_listlock(&info->objects); // Didn't have it already? if (!object) { // Create a new icon for this if (object=backdrop_leftout_new(info,anchor->ap_Buf,0,0)) { // Change type to group object->type=BDO_GROUP; // Get icon backdrop_get_icon(info,object,GETICON_CD); } } } } // Get next entry error=MatchNext(anchor); } // Clean up MatchEnd(anchor); FreeVec(anchor); }
// Initialise backdrop info void backdrop_init_info( BackdropInfo *info, struct Window *window, short no_icons) { // Backdrop window pointer info->window=window; // Initialise size info->size.MinX=window->BorderLeft+info->left_border; info->size.MinY=window->BorderTop+info->top_border; info->size.MaxX=window->Width-window->BorderRight-info->right_border-1; info->size.MaxY=window->Height-window->BorderBottom-info->bottom_border-1; // Not re-initialising? if (no_icons!=-1) { BackdropObject *icon; // Clone rastport info->rp=*window->RPort; // Get font backdrop_get_font(info); // If not backdrop window, add scroll bars if (!(window->Flags&WFLG_BACKDROP)) { // Create scroll bars if (AddScrollBars(window,&info->boopsi_list,GUI->draw_info,SCROLL_VERT|SCROLL_HORIZ|SCROLL_NOIDCMP)) { // Get scrollers info->vert_scroller=FindBOOPSIGadget(&info->boopsi_list,GAD_VERT_SCROLLER); info->horiz_scroller=FindBOOPSIGadget(&info->boopsi_list,GAD_HORIZ_SCROLLER); // Add to window AddGList(window,info->vert_scroller,-1,-1,0); RefreshGList(info->vert_scroller,window,0,-1); } } // Get clip region info->clip_region=NewRegion(); info->temp_region=NewRegion(); // Allocate notification port if (info->notify_port=CreateMsgPort()) { // Add notify request info->notify_req=AddNotifyRequest(DN_WRITE_ICON,0,info->notify_port); } // Lock icon list lock_listlock(&info->objects,0); // Remap existing icons for (icon=(BackdropObject *)info->objects.list.lh_Head; icon->node.ln_Succ; icon=(BackdropObject *)icon->node.ln_Succ) { // Remap the icon if (RemapIcon(icon->icon,info->window->WScreen,0)) { // Had icon never been remapped before? if (!(icon->flags&BDOF_REMAPPED)) { // Get new object size, etc backdrop_get_icon(info,icon,GETICON_KEEP|GETICON_POS_ONLY|GETICON_SAVE_POS|GETICON_REMAP); // Get new masks backdrop_get_masks(icon); } } // Set flag to say we've been remapped icon->flags|=BDOF_REMAPPED; } // Unlock icon list unlock_listlock(&info->objects); } // Install clip if (info->clip_region) backdrop_install_clip(info); }
// Got a notify message from PutDiskObject() BOOL backdrop_check_notify( BackdropInfo *info, DOpusNotify *notify, Lister *lister) { char *name_buf; BOOL disk=0,ret=0; struct List *search; BackdropObject *object; if (!(name_buf=AllocVec(256,0))) return 0; // Disk icon? if (notify->dn_Name[strlen(notify->dn_Name)-1]==':') { char *ptr; // Get volume name if ((ptr=strchr(notify->dn_Name,':'))) { stccpy(name_buf,notify->dn_Name,ptr-notify->dn_Name+1); disk=1; } } // Otherwise copy name and clear it else { // Get name pointer char *name=FilePart(notify->dn_Name); // Copy name strcpy(name_buf,name); *name=0; // Strip trailing '/' if (*(name-1)=='/') *(name-1)=0; } // Is this a lister? if (lister) { short len; BOOL ok=0; // Match length len=strlen(notify->dn_Name); // See if strings match if (strnicmp(lister->cur_buffer->buf_Path,notify->dn_Name,len)==0) { // Check termination if (lister->cur_buffer->buf_Path[len]=='\0') ok=1; // / can terminate too else if (lister->cur_buffer->buf_Path[len]=='/' && lister->cur_buffer->buf_Path[len+1]=='\0') ok=1; } // Didn't match? if (!ok) { // Free message ReplyFreeMsg(notify); FreeVec(name_buf); return 0; } } // Lock backdrop list lock_listlock(&info->objects,1); // See if there's an icon of this name search=&info->objects.list; while ((object=(BackdropObject *)FindNameI(search,name_buf))) { // Disk? if (object->type==BDO_DISK && disk) { // Matched break; } // Valid object? else if (object->type!=BDO_APP_ICON && object->type!=BDO_BAD_DISK && object->path) { char *path=0; BPTR lock; // If no lister, get full path of object if (!lister && (path=AllocVec(512,0))) { // Lock path if ((lock=Lock(object->path,ACCESS_READ))) { // Get full path DevNameFromLockDopus(lock,path,512); UnLock(lock); } // Failed else strcpy(path,object->path); } // Objects in same directory? if (lister || stricmp(notify->dn_Name,(path)?path:object->path)==0) { // Free path if (path) FreeVec(path); // Matched break; } // Free path if (path) FreeVec(path); } // If this is a lister, there could only be one if (lister) { object=0; break; } // Keep searching from this object search=(struct List *)object; } // Got object? if (object) { ULONG old_image1=0,old_image2=0,new_image1,new_image2,old_flags=0,new_flags; BOOL redraw=0; struct DiskObject *old; // Save old icon old=object->icon; object->icon=0; // Not deleted? if (!notify->dn_Flags) { // Get image checksums old_image1=IconCheckSum(old,0); old_image2=IconCheckSum(old,1); old_flags=GetIconFlags(old); // Get new icon backdrop_get_icon(info,object,GETICON_CD|GETICON_NO_POS|GETICON_FAIL); } // No icon now? if (!object->icon) { // Replace old icon object->icon=old; // Erase old object backdrop_erase_icon(info,object,BDSF_RECALC); // Is object a disk? if (object->type==BDO_DISK) { // Signal to refresh drives IPC_Command(info->ipc,MAINCMD_REFRESH_DRIVES,0,0,0,0); } // Remove object from list backdrop_remove_object(info,object); } // Ok to keep going else { // Get image checksums new_image1=IconCheckSum(object->icon,0); new_image2=IconCheckSum(object->icon,1); new_flags=GetIconFlags(object->icon); // Mask out uninteresting flag bits old_flags&=ICONF_BORDER_OFF|ICONF_BORDER_ON|ICONF_NO_LABEL; new_flags&=ICONF_BORDER_OFF|ICONF_BORDER_ON|ICONF_NO_LABEL; // Need to redraw? if (old_image1!=new_image1 || old_image2!=new_image2 || old_flags!=new_flags) { // Erase old object backdrop_erase_icon(info,object,0); redraw=1; } // Free old icon if (old) { // Free icon remapping RemapIcon(old,(info->window)?info->window->WScreen:0,1); // Free icon FreeCachedDiskObject(old); } // Fix new icon size backdrop_get_icon(info,object,GETICON_POS_ONLY|GETICON_SAVE_POS|GETICON_KEEP); // Need to get masks? if (!backdrop_icon_border(object)) { // Get masks for this icon backdrop_get_masks(object); } // Show new icon if (redraw) backdrop_render_object(info,object,BRENDERF_CLIP); } ret=1; } // Otherwise, got lister? else if (lister) { // Tell lister to get icons IPC_Command(lister->ipc,LISTER_GET_ICONS,0,0,0,0); ret=1; } // Or, on the desktop? else if (info->flags&BDIF_MAIN_DESKTOP) { BPTR lock1,lock2; // Lock the desktop folder and the changed directory if ((lock1=Lock(environment->env->desktop_location,ACCESS_READ)) && (lock2=Lock(notify->dn_Name,ACCESS_READ))) { // Same directory? if (SameLock(lock1,lock2)==LOCK_SAME) { // Update the desktop folder misc_startup("dopus_desktop_update",MENU_UPDATE_DESKTOP,GUI->window,0,TRUE); } // Unlock second lock UnLock(lock2); } // Unlock first lock UnLock(lock1); } // Unlock list unlock_listlock(&info->objects); // Free message ReplyFreeMsg(notify); FreeVec(name_buf); return ret; }