// Display a buffer in a lister // Called from LISTER PROCESS void lister_show_buffer(Lister *lister,DirBuffer *buffer,int show,BOOL active) { // Different to current buffer? if (lister->cur_buffer!=buffer) { // End a direct edit lister_end_edit(lister,0); // Clear lock pointer in current buffer buffer_clear_lock(lister->cur_buffer,0); // Free icons backdrop_free_list(lister->backdrop_info); // Store new buffer pointer lister->cur_buffer=buffer; buffer->buf_CurrentLister=lister; // Remove buffer and add to head of list Remove(&buffer->node); AddHead(&GUI->buffer_list.list,&buffer->node); // See if buffer needs to be resorted lister_resort(lister,0); // Clear save status flag lister->flags&=~LISTERF_SAVE_STATUS; // Does new buffer have a custom handler? if (lister->cur_buffer->buf_CustomHandler[0] && active) { // Send active message buffer_active(lister->cur_buffer,0); } // Add to history list lister_add_history(lister); } // Initialise path field if (show && lister_valid_window(lister)) { // Is volume present? if (!lister->cur_buffer->buf_CustomHandler[0] && VolumePresent(buffer)) { BPTR lock; struct FileInfoBlock __aligned fib; // Lock path if (lock=Lock(buffer->buf_Path,ACCESS_READ)) { // Store full path NameFromLock(lock,buffer->buf_ExpandedPath,512); AddPart(buffer->buf_ExpandedPath,"",512); // Examine object Examine(lock,&fib); UnLock(lock); // Save object name if (fib.fib_FileName[0]) strcpy(buffer->buf_ObjectName,fib.fib_FileName); else { if (buffer->flags&DWF_ROOT) { char *ptr; stccpy(buffer->buf_ObjectName,buffer->buf_ExpandedPath,GUI->def_filename_length-1); if (ptr=strchr(buffer->buf_ObjectName,':')) *ptr=0; } else stccpy(buffer->buf_ObjectName,FilePart(buffer->buf_ExpandedPath),GUI->def_filename_length-1); } } // Failed to lock else strcpy(buffer->buf_ExpandedPath,buffer->buf_Path); // Update disk name and size lister_update_name(lister); } // No, refresh disk name from buffer else lister_show_name(lister); // Not showing icons? if (!(lister->flags&LISTERF_VIEW_ICONS) || lister->flags&LISTERF_ICON_ACTION) { // Update path field lister_update_pathfield(lister); // Refresh window lister_refresh_display(lister,REFRESHF_SLIDERS|REFRESHF_STATUS|REFRESHF_CLEAR_ICONS); // Show selection information select_show_info(lister,1); } } }
// Fix menu ghosting for a lister void lister_fix_menus(Lister *lister,BOOL sel_only) { struct MenuItem *item; struct Menu *menu; BOOL busy=0,icon=0,action=0,sel=0; short a; // Get menu pointer if (!lister_valid_window(lister) || !(menu=lister->window->MenuStrip)) return; // Clear menu strip ClearMenuStrip(lister->window); // Get flags if (lister->flags&LISTERF_LOCK) busy=1; if (lister->flags&LISTERF_VIEW_ICONS) icon=1; if (lister->flags&LISTERF_ICON_ACTION) action=1; // In icon mode? if (icon) { BackdropObject *icon; // Lock icon list lock_listlock(&lister->backdrop_info->objects,FALSE); // Go through list for (icon=(BackdropObject *)lister->backdrop_info->objects.list.lh_Head; icon->node.ln_Succ; icon=(BackdropObject *)icon->node.ln_Succ) { // Something selected? if (icon->state) { // Set flag and break sel=1; break; } } // Unlock icon list unlock_listlock(&lister->backdrop_info->objects); } /* // Text mode else { // Anything selected? if (lister->cur_buffer->buf_SelectedFiles[0]>0 || lister->cur_buffer->buf_SelectedDirs[0]>0) sel=1; } */ // Not just doing things dependant on selected icon? if (!sel_only) { // Show as name (set) if ((item=find_menu_item(menu,MENU_LISTER_VIEW_NAME))) { set_item(item,!icon); } // Show as icon (set) if ((item=find_menu_item(menu,MENU_LISTER_VIEW_ICON))) { set_item(item,icon && !action); } // Icon action (set) if ((item=find_menu_item(menu,MENU_LISTER_ICON_ACTION))) { set_item(item,icon && action); } // Show all if ((item=find_menu_item(menu,MENU_LISTER_SHOW_ALL))) { set_item(item,icon && lister->flags&LISTERF_SHOW_ALL); } // Close (disabled when busy) if ((item=find_menu_item(menu,MENU_LISTER_CLOSE))) { off_item(item,busy); } // Lister states (disabled when busy, or in icon - not action - mode) for (a=MENU_LISTER_SOURCE;a<=MENU_LISTER_OFF;a++) { // Find item if ((item=find_menu_item(menu,a))) { off_item(item,busy || (icon && !action)); } } // Edit (disabled when busy or in icon mode) if ((item=find_menu_item(menu,MENU_EDIT_LISTER))) { off_item(item,busy || icon); } // New drawer (disabled when busy) if ((item=find_menu_item(menu,MENU_ICON_MAKEDIR))) { off_item(item,busy); } // Snapshot (disabled when busy) if ((item=find_menu_item(menu,MENU_ICON_SNAPSHOT))) { off_item(item,busy); } // Select all (disabled when busy) if ((item=find_menu_item(menu,MENU_ICON_SELECT_ALL))) { off_item(item,busy); } // Clean up (disabled when busy or not in icon mode) if ((item=find_menu_item(menu,MENU_ICON_CLEANUP))) { off_item(item,busy || !icon); } // Open parent (disabled when there's no parent) if ((item=find_menu_item(menu,MENU_OPEN_PARENT))) { BOOL dis=0; // Does path end in a colon? if (lister->cur_buffer->buf_Path[strlen(lister->cur_buffer->buf_Path)-1]==':') dis=1; // Do disable off_item(item,dis); } } // Open icon (disabled when busy or nothing selected) if ((item=find_menu_item(menu,MENU_ICON_OPEN))) { off_item(item,busy || !sel); } // Information (disabled when busy or nothing selected) if ((item=find_menu_item(menu,MENU_ICON_INFO))) { off_item(item,busy || !sel); } // Snapshot icon (disabled when nothing selected) if ((item=find_menu_item(menu,MENU_ICON_SNAPSHOT_ICON))) { off_item(item,!sel); } // Unsnapshot (disabled when busy or nothing selected) if ((item=find_menu_item(menu,MENU_ICON_UNSNAPSHOT))) { off_item(item,busy || !sel); } // Leave out (disabled when busy or nothing selected in icon mode) if ((item=find_menu_item(menu,MENU_ICON_LEAVE_OUT))) { off_item(item,busy || (!sel && icon)); } // Rename (disabled when busy or nothing selected in icon mode) if ((item=find_menu_item(menu,MENU_ICON_RENAME))) { off_item(item,busy || (!sel && icon)); } // Delete (disabled when busy or nothing selected in icon mode) if ((item=find_menu_item(menu,MENU_ICON_DELETE))) { off_item(item,busy || (!sel && icon)); } // Reset menu strip ResetMenuStrip(lister->window,menu); }