Example #1
0
// 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);
		}
	}
}
Example #2
0
// Cleanup a lister
void lister_cleanup(Lister *lister,BOOL bye)
{
	struct Node *node;

	// Send goodbye message?
	if (bye)
	{
		// Update our position
		if (!(environment->env->lister_options&LISTEROPTF_SNAPSHOT))
			PositionUpdate(lister,0);

		// Send goodbye message
		IPC_Goodbye(lister->ipc,&main_ipc,WINDOW_LISTER);
	}

	// Is lister iconified?
	if (lister->appicon)
	{
		// Remove AppIcon
		RemoveAppIcon(lister->appicon);

		// Free icon
		FreeDiskObjectCopy(lister->appicon_icon);
	}

	// If we still have a progress window, close it
	lister_progress_off(lister);

	// Showing a special buffer?
	if (lister->cur_buffer==lister->special_buffer)
	{
		// Return to normal
		lister->cur_buffer=lister->old_buffer;
	}

	// Remove buffer lock
	if (lister->cur_buffer)
	{
		// Get buffer list lock
		lock_listlock(&GUI->buffer_list,TRUE);

		// Unlock buffer
		buffer_clear_lock(lister->cur_buffer,1);

		// If buffer is empty or buffer count exceeds maximum, free it
		if (lister->cur_buffer->buf_TotalEntries[0]==0 ||
			GUI->buffer_count>environment->env->settings.max_buffer_count ||
			(environment->env->settings.dir_flags&DIRFLAGS_DISABLE_CACHING))
		{
			// Free buffer
			lister_free_buffer(lister->cur_buffer);
		}

		// Unlock buffer list
		unlock_listlock(&GUI->buffer_list);
	}

	// Free user data
	while ((node=lister->user_data_list.list.lh_Head)->ln_Succ)
	{
		Remove(node);
		FreeMemH(node);
	}

	// Free ports
	if (lister->app_port)
	{
		DOpusAppMessage *msg;
		while ((msg=(DOpusAppMessage *)GetMsg(lister->app_port)))
			ReplyAppMessage(msg);
		DeleteMsgPort(lister->app_port);
	}

	// Close font
	if (lister->font)
		CloseFont(lister->font);	

	// Free signals
	if (lister->abort_signal!=-1)
		FreeSignal(lister->abort_signal);
	if (lister->hot_name_bit!=-1)
		FreeSignal(lister->hot_name_bit);

	// Free timer stuff
	if (lister->timer_port)
	{
		// Close timers
		FreeTimer(lister->foo_timer);
		FreeTimer(lister->icon_drag_timer);
		FreeTimer(lister->busy_timer);
		FreeTimer(lister->edit_timer);
		FreeTimer(lister->scroll_timer);

		// Delete timer port
		DeleteMsgPort(lister->timer_port);
	}

	// Free regions
	if (lister->title_region) DisposeRegion(lister->title_region);
	if (lister->refresh_extra) DisposeRegion(lister->refresh_extra);

	// Free special buffer
	if (lister->special_buffer) buffer_free(lister->special_buffer);

	// Free reselection
	FreeReselect(&lister->reselect);

	// Free history
	Att_RemList(lister->path_history,0);

	// Free popup menu
	PopUpFreeHandle(lister->lister_tool_menu);

	// Free toolbar
	FreeToolBar(lister->toolbar_alloc);

	// Free IPC data
	IPC_Free(lister->ipc);

	// Free lister data
	lister_free(lister);

	// Decrement count
	--main_lister_count;
}