Exemplo n.º 1
0
// Handle some appstuff
BOOL buttons_app_message(Buttons *buttons,DOpusAppMessage *msg)
{
	short col,row;
	Cfg_Button *button;
	Cfg_Function *function;
	struct ArgArray *arg_array;
	IPCData *ipc;

	// Lock process list
	lock_listlock(&GUI->process_list,FALSE);

	// See if button editor is running
	ipc=IPC_FindProc(&GUI->process_list,NAME_BUTTON_EDITOR_RUN,FALSE,0);

	// Unlock process list
	unlock_listlock(&GUI->process_list);

	// Editor running?
	if (ipc)
	{
		// Send button
		if (buttons_edit_bank(buttons,-1,-1,0,(struct AppMessage *)msg,0))
		{
			// Message was swallowed
			return 1;
		}
	}

	// Lock bank
	GetSemaphore(&buttons->bank->lock,SEMF_SHARED,0);

	// Get button and function we dropped on
	col=msg->da_Msg.am_MouseX;
	row=msg->da_Msg.am_MouseY;
	if (!(button=button_from_point(buttons,&col,&row)) ||
		!(function=button_valid(button,button->current)))
	{
		FreeSemaphore(&buttons->bank->lock);
		return 0;
	}

	// Get arg array
	if ((arg_array=AppArgArray(msg,AAF_ALLOW_DIRS)))
	{
		BPTR lock;
		char pathname[256];

		// Get pathname of first file
		DevNameFromLockDopus(msg->da_Msg.am_ArgList[0].wa_Lock,pathname,256);

		// Need source directory; if no name, get parent
		if ((!msg->da_Msg.am_ArgList[0].wa_Name ||
			!*msg->da_Msg.am_ArgList[0].wa_Name) &&
			(lock=ParentDir(msg->da_Msg.am_ArgList[0].wa_Lock)))
		{
			// Get pathname of parent
			DevNameFromLockDopus(lock,pathname,256);
			UnLock(lock);
		}

		// Launch function
		function_launch(
			FUNCTION_RUN_FUNCTION_EXTERNAL,
			function,
			0,
			0,
			0,0,
			pathname,0,
			arg_array,0,
			buttons);
	}

	// Unlock button lock
	FreeSemaphore(&buttons->bank->lock);

	return 0;
}
Exemplo n.º 2
0
// Load a new bank into open buttons window
void buttons_new_bank(Buttons *buttons,short func,Cfg_ButtonBank *use_bank)
{
	Cfg_ButtonBank *bank;
	IPCData *ipc;

	// Check for change
	if (!buttons_check_change(buttons,1)) return;

	// Save old bank pointer
	bank=buttons->bank;

	// New?
	if (func==MENU_TOOLBAR_BUTTONS_NEW)
	{
		// Create new button bank
		if (!(buttons->bank=NewButtonBank(1,1)))
		{
			// Restore old pointer
			buttons->bank=bank;
			return;
		}

		// Free old bank
		CloseButtonBank(bank);
	}

	// Load?
	else
	if (func==MENU_OPEN_BUTTONS_LOCAL)
	{
		// Open button bank
		if (!(buttons_load(buttons,GUI->screen_pointer,0)))
			return;
	}

	// Defaults
	else
	if (func==MENU_TOOLBAR_RESET_DEFAULTS)
	{
		// Open button bank
		if (!(buttons_load(buttons,GUI->screen_pointer,"dopus5:buttons/toolbar_default")))
			return;
	}

	// Restore
	else
	if (func==MENU_TOOLBAR_RESTORE)
	{
		// Copy backup bank
		if (!(buttons->bank=CopyButtonBank(buttons->backup)))
		{
			// Restore old pointer
			buttons->bank=bank;
			return;
		}

		// Free old bank
		CloseButtonBank(bank);
	}

	// Last saved
	else
	if (buttons->last_saved[0])
	{
		// Open button bank
		if (!(buttons_load(buttons,GUI->screen_pointer,buttons->last_saved)))
			return;
	}

	// Lock process list
	lock_listlock(&GUI->process_list,FALSE);

	// Find editor
	if ((ipc=IPC_FindProc(&GUI->process_list,NAME_BUTTON_EDITOR_RUN,0,0)))
	{
		// Set flag in bank
		buttons->bank->window.flags|=BTNWF_TOOLBAR;

		// Tell editor to change bank pointer
		IPC_Command(
			buttons->editor,
			BUTTONEDIT_CHANGE_BANK,
			(ULONG)bank,
			buttons->bank,
			0,
			REPLY_NO_PORT);
	}

	// Unlock the process list
	unlock_listlock(&GUI->process_list);

	// Signal for re-open
	IPC_Command(buttons->ipc,BUTTONEDIT_REOPEN,0,0,0,0);

	// Clear change flag
	buttons->flags&=~BUTTONF_CHANGED;
}
Exemplo n.º 3
0
// Show help on something
void help_show_help(char *thing,char *file)
{
    IPCData *ipc;
    char *copy,*ptr,helpbuf[256];
    CommandList *cmd;

    // Valid thing?
    if (!thing || !*thing) return;

    // Can't do help if we don't have the amigaguide.library
    if (!AmigaGuideBase)
    {
        // Flash error and return
        DisplayBeep(GUI->screen_pointer);
        return;
    }

    // Is the node name a command?
    ptr=thing;
    if (!file && (cmd=function_find_internal(&ptr,0)))
    {
        // Is this an external module that has help available?
        if (cmd->flags&FUNCF_EXTERNAL_FUNCTION &&
                cmd->help_name)
        {
            // Build full path to help file
            strcpy(helpbuf,"dopus5:help/");
            AddPart(helpbuf,FilePart(cmd->help_name),256);

            // Use this file for help
            file=helpbuf;
        }
    }

    // Lock process list
    lock_listlock(&GUI->process_list,FALSE);

    // Is help process running?
    if (!(ipc=IPC_FindProc(&GUI->process_list,"dopus_help",0,0)))
    {
        // Unlock process list
        unlock_listlock(&GUI->process_list);

        // Launch help process
        if (!(IPC_Launch(
                    &GUI->process_list,
                    &ipc,
                    "dopus_help",
                    (ULONG)&help_proc,
                    STACK_DEFAULT,
                    0,
                    (struct Library *)DOSBase)))
        {
            // Couldn't launch it
            return;
        }

        // Lock process list
        lock_listlock(&GUI->process_list,FALSE);
    }

    // No file given?
    if (!file || !*file) file="dopus5:Help/dopus5.guide";

    // Copy thing
    if (ipc && (copy=AllocVec(strlen(thing)+1+strlen(file)+1,0)))
    {
        // Copy thing and file string
        strcpy(copy,thing);
        strcpy(copy+strlen(copy)+1,file);

        // Send help command
        IPC_Command(ipc,HELPCMD_LINK,0,0,copy,0);
    }

    // Unlock process list
    unlock_listlock(&GUI->process_list);
}
Exemplo n.º 4
0
// Open the button editor (called from a sub-process)
void buttons_edit(
	IPCData *my_ipc,
	buttons_edit_packet *packet)
{
	ButtonsStartup startup;
	struct Library *ConfigOpusBase;
	IPCData *ipc;
	long ret,command;
	Buttons *buttons=0;
	Cfg_Button *send_button=0;
	struct AppMessage *send_msg=0;
	short button_col=-1,button_row=-1;
	short can_start=1;

	// Get packet data
	if (packet)
	{
		buttons=packet->buttons;
		send_button=packet->edit;
		button_col=packet->col;
		button_row=packet->row;
		can_start=packet->can_start;
		send_msg=packet->appmsg;
	}

	// Lock process list
	lock_listlock(&GUI->process_list,FALSE);

	// Get edit command
	command=(button_col==-2)?BUTTONEDIT_RE_EDIT_ME:BUTTONEDIT_EDIT_ME;

	// See if button editor is running
	if (ipc=IPC_FindProc(&GUI->process_list,NAME_BUTTON_EDITOR_RUN,FALSE,0))
	{
		BOOL front=1;

		// Button bank supplied?
		if (buttons)
		{
			// Does the bank not already have the editor?
			if (!buttons->editor)
			{
				// Tell editor to edit the toolbar bank
				IPC_Command(
					ipc,
					command,
					(ULONG)buttons->bank,
					buttons->ipc,
					0,
					0);

				// Set flag for pending edit request
				buttons->flags|=BUTTONF_EDIT_REQUEST;
				front=0;
			}

			// Button to send?
			if (send_button)
			{
				Point *pos;

				// Allocate position
				if (pos=AllocVec(sizeof(Point),MEMF_CLEAR))
				{
					// Convert coordinates to window relative
					pos->x=button_col-buttons->window->LeftEdge;
					pos->y=button_row-buttons->window->TopEdge;

					// Send command
					IPC_Command(
						ipc,
						BUTTONEDIT_BUTTON_TO_BANK,
						0,
						send_button,
						pos,
						0);
					send_button=0;
				}
				front=0;
			}

			// Message to send?
			if (send_msg)
			{
				// Send it on
				IPC_Command(
					ipc,
					CFG_APPMESSAGE_PASS,
					(ULONG)buttons->bank,
					send_msg,
					0,
					0);
				send_msg=0;
			}

			// Button to edit?
			if (button_col>-1)
			{
				// Send edit command
				IPC_Command(
					ipc,
					BUTTONEDIT_EDIT_BUTTON,
					button_col,
					(APTR)button_row,
					0,
					0);
				front=0;
			}
		}

		// Bring editor to front
		if (front) IPC_Command(ipc,IPC_ACTIVATE,0,0,0,0);
	}

	// Unlock the process list
	unlock_listlock(&GUI->process_list);

	// Free button if we have one
	if (send_button) FreeButton(send_button);

	// Free message if we have one
	if (send_msg) ReplyAppMessage((DOpusAppMessage *)send_msg);

	// If editor was already running, or we can't start it if not, return
	if (ipc || !can_start) return;

	// Change our name
	my_ipc->proc->pr_Task.tc_Node.ln_Name=NAME_BUTTON_EDITOR_RUN;

	// Set flag
	GUI->flags|=GUIF_BUTTON_EDITOR;

	// Open configuration library
	if (!(ConfigOpusBase=OpenModule(config_name)))
		return;

	// Bank supplied?
	if (buttons)
	{
		// Fill out startup packet
		startup.bank=buttons->bank;
		startup.ipc=buttons->ipc;

		// Button supplied?
		if (button_col>-1)
		{
			// Set flag
			startup.flag=1;

			// Pass button
			startup.button=(button_col<<16)|button_row;
		}
		else startup.flag=0;

		// Set pending edit request
		buttons->flags|=BUTTONF_EDIT_REQUEST;
	}
	else startup.bank=0;

	// Configure buttons
	ret=Config_Buttons(
		&startup,
		my_ipc,
		&main_ipc,
		GUI->screen_pointer,
		(ULONG)&GUI->command_list.list);

	// Change our name back
	my_ipc->proc->pr_Task.tc_Node.ln_Name=NAME_BUTTON_EDITOR;

	// Clear flag
	GUI->flags&=~GUIF_BUTTON_EDITOR;

	// Permit now we've cleaned up
	Permit();

	// Close library
	CloseLibrary(ConfigOpusBase);

	// Lock buttons list
	lock_listlock(&GUI->buttons_list,FALSE);

	// Go through button banks
	for (ipc=(IPCData *)GUI->buttons_list.list.lh_Head;
		ipc->node.mln_Succ;
		ipc=(IPCData *)ipc->node.mln_Succ)
	{
		// Get buttons pointer
		Buttons *buttons=IPCDATA(ipc);

		// Toolbar buttons?
		if (buttons->flags&BUTTONF_TOOLBAR)
		{
			// Hide bank
			IPC_Command(ipc,IPC_HIDE,0,0,0,REPLY_NO_PORT);

			// Need to save?
			if (ret&CONFIG_SAVE)
				IPC_Command(ipc,BUTTONS_SAVE,0,0,0,REPLY_NO_PORT);

			// Use?
			if (ret)
			{
				// Send change
				send_main_reset_cmd(CONFIG_CHANGE_LIST_TOOLBAR,0,buttons->bank);

				// Steal bank pointer
				IPC_Command(ipc,BUTTONEDIT_NEW_BANK,1,0,0,REPLY_NO_PORT);
			}

			// Close bank
			IPC_Command(ipc,IPC_QUIT,0,0,0,0);
		}

		// Ok?
		else
		if (ret)
		{
			// Save?
			if (ret&CONFIG_SAVE)
			{
				// Buttons been changed?
				if (buttons->flags&BUTTONF_CHANGED)
				{
					// Tell bank to save itself
					IPC_Command(ipc,BUTTONS_SAVE,0,0,0,REPLY_NO_PORT);
				}
			}

			// Clear 'new' flag
			buttons->flags&=~BUTTONF_NEW_BANK;
		}
	}

	// Unlock buttons list
	unlock_listlock(&GUI->buttons_list);
}