Esempio n. 1
0
// Save from button editor
void buttons_edit_defaults(ULONG id)
{
	IPCData *ipc;

	// 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);

		// Is this the bank being edited, and is it a toolbar?
		if (buttons->editor && buttons->flags&BUTTONF_TOOLBAR)
		{
			// Send command to button bank
			IPC_Command(buttons->ipc,id,0,0,0,0);
			break;
		}
	}

	// Unlock buttons list
	unlock_listlock(&GUI->buttons_list);
}
Esempio n. 2
0
// Save from button editor
void buttons_edit_save(ULONG id)
{
	IPCData *ipc;

	// 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);

		// Is this the bank being edited?
		if (buttons->editor)
		{
			// Send command to button bank
			IPC_Command(
				buttons->ipc,
				(id==BUTTONEDIT_MENU_SAVE)?BUTTONS_SAVE:BUTTONS_SAVEAS,
				0,
				0,
				0,
				0);
			break;
		}
	}

	// Unlock buttons list
	unlock_listlock(&GUI->buttons_list);
}
Esempio n. 3
0
// Update size for a backdrop
void backdrop_update_size(BackdropInfo *info)
{
	// Check new size
	backdrop_check_size(info);

	// Set flag to say we have a new size
	info->flags|=BDIF_NEW_SIZE;

	// Centered pattern?
	if (info->window->WLayer->BackFill!=LAYERS_BACKFILL &&
		GUI->pattern &&
		GUI->pattern[(info->flags&BDIF_MAIN_DESKTOP)?WBP_ROOT:WBP_DRAWER].flags&PATF_CENTER)
	{
		// Signal full refresh
		IPC_Command(info->ipc,LISTER_BACKFILL_CHANGE,1,0,0,0);
	}

	// Smart-refresh?
	else
	if (info->window->WLayer->Flags&LAYERSMART)
	{
		// Refresh objects immediately
		backdrop_show_objects(info,BDSF_REFRESH_DONE|BDSF_RECALC);
		info->flags&=~BDIF_NEW_SIZE;
	}
}
Esempio n. 4
0
// Handles key press in edit mode
void buttons_edit_key(Buttons *buttons,USHORT code,USHORT qual)
{
	// Look at key
	switch (code)
	{
		// Cursor to move
		case CURSORLEFT:
		case CURSORRIGHT:
		case CURSORUP:
		case CURSORDOWN:

			// Is the editor running?
			if (buttons->editor)
			{
				// Send key to the editor
				IPC_Command(
					buttons->editor,
					BUTTONEDIT_PROCESS_KEY,
					code,
					(APTR)qual,
					0,
					0);
			}
			break;

		// Enter edits
		case 0x44:

			// Is the editor running?
			if (buttons->editor)
			{
				// Send edit command
				IPC_Command(
					buttons->editor,
					BUTTONEDIT_EDIT_BUTTON,
					buttons->editor_sel_col,
					(APTR)buttons->editor_sel_row,
					0,
					0);
			}
			break;
	}
}
Esempio n. 5
0
// Someone pressed the help key
void help_get_help(short x,short y,unsigned short qual)
{
    struct Window *window=0;
    struct Layer *layer;
    IPCData *ipc=0;

    // Lock screen layer
    LockLayerInfo(&GUI->screen_pointer->LayerInfo);

    // Find which layer the mouse is over
    if ((layer=WhichLayer(&GUI->screen_pointer->LayerInfo,x,y)))
    {
        // Get window pointer
        window=layer->Window;

        // Get window ID
        if (GetWindowID(window)!=WINDOW_UNKNOWN)
        {
            // Forbid to get port
            Forbid();

            // Get port
            if (!(ipc=(IPCData *)GetWindowAppPort(window)))
                Permit();
        }
    }

    // Unlock layer
    UnlockLayerInfo(&GUI->screen_pointer->LayerInfo);

    // Got a port?
    if (ipc)
    {
        ULONG coords;

        // Convert coordinates to window-relative
        x-=window->LeftEdge;
        y-=window->TopEdge;

        // Pack into longword
        coords=((unsigned short)x<<16)|(unsigned short)y;

        // Send help command
        IPC_Command(ipc,IPC_HELP,qual,(APTR)coords,0,0);

        // Enable multitasking now that message has been sent
        Permit();
    }

    // Otherwise, show generic help
    else help_show_help(HELP_MAIN,0);
}
Esempio n. 6
0
void UseIPC(void)		/* ROM patch: executing IPC command */
{
	if((Ptr)gPC-(Ptr)theROM-2==IPC_CMD_ADDR)
	{	if(IPC_Command()) rts();
		else table[code=0x40e7]();
	}
	else
	{	exception=4;
		extraFlag=true;
		nInst2=nInst;
		nInst=0;
	}
}
Esempio n. 7
0
// Send reset command to main process
void send_main_reset_cmd(ULONG flags1,ULONG flags2,APTR data)
{
	ULONG *flags;

	// Allocate flags
	if ((flags=AllocVec(sizeof(ULONG)*2,0)))
	{
		// Fill out flags
		flags[0]=flags1;
		flags[1]=flags2;

		// Send command
		IPC_Command(&main_ipc,MAINCMD_RESET,0,data,flags,0);
	}
}
Esempio n. 8
0
// Signal with pattern update
void display_update_pattern(short which,short valid)
{
	// Main pattern changed?
	if (which==PATTERN_MAIN)
	{
		// Send refresh command
		IPC_Command(&main_ipc,LISTER_BACKFILL_CHANGE,valid,0,0,REPLY_NO_PORT);
	}

	// Redraw listers and groups if they need it
	else
	if (which==PATTERN_LISTER)
	{
		IPC_ListCommand(&GUI->lister_list,LISTER_BACKFILL_CHANGE,valid,0,TRUE);
		IPC_ListCommand(&GUI->group_list,LISTER_BACKFILL_CHANGE,valid,0,TRUE);
	}
}
short LIBFUNC L_Config_Filetypes(
	REG(a0, struct Screen *screen),
	REG(a1, IPCData *ipc),
	REG(a2, IPCData *owner_ipc),
	REG(d0, ULONG command_list),
	REG(a3, char *name))
{
	config_filetypes_data *data;
	IPCMessage *quit_msg=0;
	short undo_flag=0,pending_quit=0;
	short ret=0,fontsize;
	struct IBox pos;
	ConfigWindow dims;

	// Allocate data and memory handle
	if (!(data=AllocVec(sizeof(config_filetypes_data),MEMF_CLEAR)) ||
		!(data->memory=NewMemHandle(4096,256,MEMF_CLEAR)))
		return 0;

	// Save pointers
	data->ipc=ipc;
	data->owner_ipc=owner_ipc;
	data->command_list=command_list;

	// Initialise data
	NewList(&data->list_list);
	InitListLock(&data->proc_list,0);

	// Fill in new window
	data->newwin.parent=screen;
	data->newwin.dims=&dims;
	data->newwin.title=GetString(locale,MSG_FILETYPES_TITLE);
	data->newwin.locale=locale;
	data->newwin.flags=WINDOW_SCREEN_PARENT|WINDOW_VISITOR|WINDOW_REQ_FILL|WINDOW_AUTO_KEYS|WINDOW_SIZE_BOTTOM;

	// Get default size
	dims=_config_filetypes_window;

	// Get saved position
	if (LoadPos("dopus/windows/filetypes",&pos,&fontsize))
	{
		dims.char_dim.Width=0;
		dims.char_dim.Height=0;
		dims.fine_dim.Width=pos.Width;
		dims.fine_dim.Height=pos.Height;
	}
		
	// Open window and add objects
	if (!(data->window=OpenConfigWindow(&data->newwin)) ||
		!(data->objlist=AddObjectList(data->window,_config_filetypes_objects)))
	{
		CloseConfigWindow(data->window);
		FreeMemHandle(data->memory);
		FreeVec(data);
		return 0;
	}

	// Set minimum size
	SetConfigWindowLimits(data->window,&_config_filetypes_window,0);

	// Read filetype list
	SetWindowBusy(data->window);
	filetype_read_list(data->memory,&data->list_list);

	// Build display list
	filetype_build_list(data);
	ClearWindowBusy(data->window);

	// Name to edit?
	if (name) filetype_edit_name(data,name);

	// Event loop
	FOREVER
	{
		struct IntuiMessage *msg;
		IPCMessage *imsg;
		int quit_flag=0;

		// Any IPC messages?
		while ((imsg=(IPCMessage *)GetMsg(ipc->command_port)))
		{
			// Look at command
			switch (imsg->command)
			{
				// Quit
				case IPC_QUIT:
					quit_flag=1;
					quit_msg=imsg;
					imsg=0;
					data->change=0;
					break;


				// Activate
				case IPC_ACTIVATE:
					if (data->window)
					{
						// Bring window to front
						WindowToFront(data->window);
						ActivateWindow(data->window);

						// Edit name supplied?
						if (imsg->data) filetype_edit_name(data,(char *)imsg->data);
					}
					break;


				// Process saying goodbye
				case IPC_GOODBYE:
					{
						FiletypeNode *node;

						// Handle goodbye
						if ((node=(FiletypeNode *)IPC_GetGoodbye(imsg)))
						{
							// Node no longer has an editor
							node->editor=0;
						}

						// All process gone and pending quit?
						if (pending_quit && (IsListEmpty(&data->proc_list.list)))
						{
							quit_flag=1;
							pending_quit=2;
						}
					}
					break;


				// Got a filetype back from the editor
				case FILETYPEEDIT_RETURN:
					if (filetype_receive_edit(
						data,
						(Cfg_Filetype *)imsg->flags,
						(FiletypeNode *)imsg->data))
					{
						data->change=1;
						imsg->command=1;
					}
					else imsg->command=0;
					break;
			}

			// Reply message
			IPC_Reply(imsg);

			// Check quit flag
			if (quit_flag) break;
		}

		// Intuimessages
		if (data->window)
		{
			while ((msg=GetWindowMsg(data->window->UserPort)))
			{
				struct IntuiMessage msg_copy;
				UWORD id;

				// Copy message and reply
				msg_copy=*msg;
				ReplyWindowMsg(msg);

				if (pending_quit) continue;

				// Look at message
				switch (msg_copy.Class)
				{
					// Close window
					case IDCMP_CLOSEWINDOW:
						quit_flag=1;
						undo_flag=1;
						break;


					// Gadget
					case IDCMP_GADGETUP:

						id=((struct Gadget *)msg_copy.IAddress)->GadgetID;
						switch (id)
						{
							// Cancel
							case GAD_FILETYPES_CANCEL:
								undo_flag=1;

							// Use
							case GAD_FILETYPES_USE:
								quit_flag=1;
								break;


							// Filetype selected
							case GAD_FILETYPES_LIST:
								{
									Att_Node *node;

									// Enable buttons
									filetype_able_buttons(data,FALSE);

									// Get selection
									if (!(node=Att_FindNode(data->filetype_list,msg_copy.Code)))
										break;

									// Double-click?
									if (node==data->sel_filetype &&
										DoubleClick(
											data->seconds,data->micros,
											msg_copy.Seconds,msg_copy.Micros))
									{
										// Launch editor for this filetype
										filetype_edit(data,(FiletypeNode *)data->sel_filetype->data,0);
									}

									// New selection
									else
									{
										data->sel_filetype=node;
										data->seconds=msg_copy.Seconds;
										data->micros=msg_copy.Micros;
									}
								}
								break;


							// Add a new filetype
							case GAD_FILETYPES_DUPLICATE:
								if (!data->sel_filetype) break;
							case GAD_FILETYPES_ADD:
								{
									Cfg_FiletypeList *list;
									Cfg_Filetype *type=0;

									// Allocate a new filetype list
									if ((list=AllocMemH(data->memory,sizeof(Cfg_FiletypeList))))
									{
										// Initialise list
										NewList(&list->filetype_list);

										// Copy existing filetype?
										if ((((struct Gadget *)msg_copy.IAddress)->GadgetID==
											GAD_FILETYPES_DUPLICATE))
										{
											// Copy filetype
											type=CopyFiletype(
												((FiletypeNode *)data->sel_filetype->data)->type,
												data->memory);
										}

										// Allocate a new filetype
										else if ((type=NewFiletype(data->memory)))
										{
											// Initialise name
											strcpy(type->type.name,GetString(locale,MSG_UNTITLED));
										}

										// Get a filetype?
										if (type)
										{
											// Add filetype list to main list
											AddTail(&data->list_list,&list->node);

											// Add filetype to list
											AddTail(&list->filetype_list,&type->node);

											// Set list pointer
											type->list=list;
											list->flags=FTLISTF_CHANGED;
										}

										// Failed
										else FreeMemH(list);
									}

									// Got new filetype?
									if (type)
									{
										Att_Node *node;

										// Remove existing list
										SetGadgetChoices(
											data->objlist,
											GAD_FILETYPES_LIST,
											(APTR)~0);

										// Add entry for this filetype
										node=filetype_add_entry(data,type);

										// Handle new nodes
										filetype_new_node(data,node);
									}
								}
								break;


							// Edit filetype
							case GAD_FILETYPES_EDIT:

								// Valid selection?
								if (data->sel_filetype)
								{
									// Launch editor for this filetype
									filetype_edit(data,(FiletypeNode *)data->sel_filetype->data,0);
								}
								break;


							// Remove/Store
							case GAD_FILETYPES_REMOVE:
							case GAD_FILETYPES_STORE:

								// Valid selection?
								if (data->sel_filetype)
								{
									short ret;

									// Remove filetype
									if ((ret=
										filetype_remove(
											data,
											data->sel_filetype,
											(id==GAD_FILETYPES_STORE)))==1)
									{
										data->change=1;
										data->sel_filetype=0;
									}

									// Quit?
									else if (ret==-1)
									{
										quit_flag=1;
									}
								}
								break;
						}
						break;


					// Key press
					case IDCMP_RAWKEY:

						// Help?
						if (msg_copy.Code==0x5f &&
							!(msg_copy.Qualifier&VALID_QUALIFIERS))
						{
							// Set busy pointer
							SetWindowBusy(data->window);

							// Send help command
							IPC_Command(data->owner_ipc,IPC_HELP,(1<<31),"File Types",0,REPLY_NO_PORT);

							// Clear busy pointer
							ClearWindowBusy(data->window);
						}
						break;
				}

				// Check quit flag
				if (quit_flag) break;
			}
		}

		// Check quit flag
		if (quit_flag)
		{
			if (!pending_quit)
			{
				SetWindowBusy(data->window);
				if (!(IPC_ListQuit(&data->proc_list,0,!undo_flag,FALSE)))
					pending_quit=2;
				else
					pending_quit=1;
			}
		}

		// Set to break?
		if (pending_quit==2)
		{
			// Save filetypes?
			if (data->change && !undo_flag)
			{
				if (!(ret=filetype_save(data)))
				{
					// Abort save/quit
					ClearWindowBusy(data->window);
					pending_quit=0;
					continue;
				}
			}
			break;
		}

		// Wait for an event
		Wait(1<<ipc->command_port->mp_SigBit|
			((data->window)?1<<data->window->UserPort->mp_SigBit:0));
	}

	// Save window position
	if (data->window)
	{
		struct IBox pos;
		pos.Left=data->window->LeftEdge;
		pos.Top=data->window->TopEdge;
		pos.Width=data->window->Width-data->window->BorderLeft-data->window->BorderRight;
		pos.Height=data->window->Height-data->window->BorderTop-data->window->BorderBottom;
		SavePos("dopus/windows/filetypes",(struct IBox *)&pos,data->window->RPort->TxHeight);
	}

	// Close up
	CloseConfigWindow(data->window);

	// Free data
	Att_RemList(data->filetype_list,REMLIST_FREEDATA);
	FreeMemHandle(data->memory);
	FreeVec(data);

	// Reply quit message
	IPC_Reply(quit_msg);
	return ret;
}
Esempio n. 10
0
Cfg_Filetype *LIBFUNC L_EditFiletype(
	REG(a0, Cfg_Filetype *type),
	REG(a1, struct Window *window),
	REG(a2, IPCData *ipc),
	REG(a3, IPCData *dopus_ipc),
	REG(d0, ULONG flags))
{
	filetype_ed_data *data;
	IPCData *editor;
	IPCMessage *imsg;
	Cfg_Filetype *ret_type=0;

	// Valid filetype?
	if (!type) return 0;

	// Allocate data for the editor, copy filetype
	if (!(data=AllocVec(sizeof(filetype_ed_data),MEMF_CLEAR)) ||
		!(data->type=CopyFiletype(type,0)))
	{
		FreeVec(data);
		return 0;
	}

	// Fill out data
	data->owner_ipc=ipc;
	data->action_lookup=filetype_action_lookup;

	// Supply libraries
	/*data->func_startup.dopus_base=DOpusBase;
	data->func_startup.dos_base=(struct Library *)DOSBase;
	data->func_startup.int_base=(struct Library *)IntuitionBase;
	data->func_startup.util_base=(struct Library *)UtilityBase;
	data->func_startup.cx_base=CxBase;
	data->func_startup.wb_base=WorkbenchBase;
	data->func_startup.gfx_base=(struct Library *)GfxBase;
	data->func_startup.asl_base=AslBase;
	data->func_startup.layers_base=LayersBase;*/

	// Supply locale
	data->func_startup.locale=locale;

	// Supply gui data pointers
	data->new_win.parent=window;
	data->new_win.dims=&_filetype_editor_window;
	data->new_win.locale=locale;
	data->obj_def=_filetype_editor_objects;

	// Supply data pointers for function editor
	data->func_startup.win_def=&_function_editor_window;
	data->func_startup.obj_def=_function_editor_objects;
	data->func_startup.func_labels=_function_type_labels;
	data->func_startup.flag_list=_funced_flaglist;
	data->func_startup.func_list=IPC_Command(dopus_ipc,MAINCMD_GET_LIST,0,0,0,REPLY_NO_PORT);
	data->func_startup.flags=FUNCEDF_NO_KEY;
	data->func_startup.main_owner=ipc;

	// Supply data pointers for the fileclass editor
	data->class_win=&_fileclass_editor_window;
	data->class_obj=_fileclass_editor_objects;
	data->class_lookup=fileclass_match_lookup;
	data->class_strings=matchtype_labels;

	// Open class editor automatically?
	if (flags&EFTF_EDIT_CLASS) data->edit_flag=1;

	// Launch editor
	if (!(IPC_Launch(
		0,
		&editor,
		"dopus_filetype_editor",
		(ULONG)IPC_NATIVE(FiletypeEditor),
		STACK_DEFAULT,
		(ULONG)data,
		(struct Library *)DOSBase)) || !editor)
	{
		// Failed; free data
		FreeFiletype(data->type);
		FreeVec(data);
		return 0;
	}

	// Event loop
	FOREVER
	{
		BOOL quit=0;

		// IPC messages
		while ((imsg=(IPCMessage *)GetMsg(ipc->command_port)))
		{
			// Filetype returned?
			if (imsg->command==FILETYPEEDIT_RETURN)
			{
				// Copy the filetype
				ret_type=CopyFiletype((Cfg_Filetype *)imsg->flags,0);
			}

			// Said goodbye?
			else
			if (imsg->command==IPC_GOODBYE && imsg->data==editor)
				quit=1;

			// Abort?
			else
			if (imsg->command==IPC_QUIT)
			{
				// Send abort message
				IPC_Quit(editor,imsg->flags,TRUE);
			}

			// Activate?
			else
			if (imsg->command==IPC_ACTIVATE)
			{
				// Send message
				IPC_Command(editor,IPC_ACTIVATE,imsg->flags,imsg->data,0,0);
			}

			// Identify?
			else
			if (imsg->command==IPC_IDENTIFY)
			{
				// Pass to DOpus
				IPC_Command(dopus_ipc,IPC_IDENTIFY,imsg->flags,imsg->data,0,REPLY_NO_PORT);
			}

			// Reply to message
			IPC_Reply(imsg);
		}

		// Check quit flag
		if (quit) break;

		// Wait for message
		WaitPort(ipc->command_port);
	}

	// Return new filetype (if any)
	return ret_type;
}
Esempio n. 11
0
void desktop_delete(IPCData *ipc,BackdropInfo *info,BackdropObject *only_one)
{
	short groupcount=0,filecount=0,assigncount=0,othercount=0,dircount=0;
	BackdropObject *object=0;
	Att_List *list;
	Att_Node *node;
	char buf[100];

	// Create list
	if (!(list=Att_NewList(LISTF_POOL)))
		return;

	// Lock backdrop list
	lock_listlock(&info->objects,0);

	// Go through backdrop list
	while ((object=backdrop_next_object(info,object,only_one)))
	{
		// Group?
		if (object->type==BDO_GROUP) ++groupcount;

		// Assign?
		else
		if (object->flags&BDOF_ASSIGN) ++assigncount;

		// Group object?
		else
		if (object->type==BDO_LEFT_OUT && info->flags&BDIF_GROUP) ++filecount;

		// Desktop object?
		else
		if (object->type==BDO_LEFT_OUT && object->flags&BDOF_DESKTOP_FOLDER)
		{
			++othercount;
			if (object->icon->do_Type==WBDRAWER) ++dircount;
		}

		// Something else
		else continue;

		// Add to list
		Att_NewNode(list,0,(ULONG)object,0);
	}

	// Unlock backdrop list
	unlock_listlock(&info->objects);

	// Nothing to delete?
	if (IsListEmpty((struct List *)list))
	{
		Att_RemList(list,0);
		return;
	}

	// Build message; start with query
	strcpy(info->buffer,GetString(&locale,MSG_DESKTOP_REALLY_DELETE));

	// Any groups?
	if (groupcount>0)
	{
		lsprintf(buf,GetString(&locale,MSG_DESKTOP_DELETE_GROUPS),groupcount);
		strcat(info->buffer,buf);
	}

	// Or assigns?
	else
	if (assigncount>0)
	{
		lsprintf(buf,GetString(&locale,MSG_DESKTOP_DELETE_ASSIGNS),assigncount);
		strcat(info->buffer,buf);
	}

	// Any group files?
	else
	if (filecount>0)
	{
		// Add file count
		lsprintf(buf,GetString(&locale,MSG_DESKTOP_DELETE_GROUP_OBJECTS),filecount);
		strcat(info->buffer,buf);
	}

	// Desktop objects?
	if (othercount>0)
	{
		BOOL cr=0;

		// Add CR?
		if (groupcount>0 || assigncount>0 || filecount>0) cr=1;

		// Add files
		if (othercount>dircount)
		{
			lsprintf(buf,GetString(&locale,MSG_DESKTOP_DELETE_DESKTOP_FILES),othercount-dircount);
			if (cr) strcat(info->buffer,"\n");
			strcat(info->buffer,buf);
			cr=1;
		}

		// Add dirs
		if (dircount>0)
		{
			lsprintf(buf,GetString(&locale,MSG_DESKTOP_DELETE_DESKTOP_DIRS),dircount);
			if (cr) strcat(info->buffer,"\n");
			strcat(info->buffer,buf);
		}
	}
			
	// Add question mark
	strcat(info->buffer,"?");

	// Display requester
	if (!(super_request_args(
		GUI->screen_pointer,
		info->buffer,
		SRF_IPC|SRF_SCREEN_PARENT,
		ipc,
		GetString(&locale,MSG_DELETE),
		GetString(&locale,MSG_CANCEL),0)))
	{
		Att_RemList(list,0);
		return;
	}

	// Check owner for refresh
	if (info->lister)
		IPC_Command(info->lister->ipc,LISTER_CHECK_REFRESH,0,0,0,REPLY_NO_PORT);

	// Group objects?
	if (info->flags&BDIF_GROUP)
	{
		// Send command to group
		IPC_Command(info->ipc,GROUP_DELETE,0,only_one,0,0);
	}

	// Otherwise
	else
	{
		// Go through the list
		for (node=(Att_Node *)list->list.lh_Head;
			node->node.ln_Succ;
			node=(Att_Node *)node->node.ln_Succ)
		{
			// Lock backdrop list
			lock_listlock(&info->objects,1);

			// Get object
			if ((object=find_backdrop_object(info,(BackdropObject *)node->data)))
			{
				// Group?
				if (object->type==BDO_GROUP)
				{
					// Delete this group
					backdrop_delete_group(info,object);
				}

				// Assign?
				else
				if (object->flags&BDOF_ASSIGN)
				{
					// Copy name, strip trailing colon
					strcpy(info->buffer+2,object->name);
					info->buffer[strlen(info->buffer+2)+1]=0;

					// Delete assign
					if (AssignLock(info->buffer+2,0))
					{
						// Erase object
						backdrop_erase_icon(info,object,0);

						// Remove object
						backdrop_remove_object(info,object);
					}
				}
			}

			// Unlock backdrop list
			unlock_listlock(&info->objects);
		}
	}

	// Free list
	Att_RemList(list,0);

	// Recalc backdrop objects
	backdrop_calc_virtual(info);

	// Delete other things?
	if (othercount>0)
	{
		// Run delete function
		icon_function(info,0,0,def_function_delete_quiet,0);
	}
}
Esempio n. 12
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);
}
Esempio n. 13
0
int LIBFUNC L_Module_Entry(
	REG(a0, char *argstring),
	REG(a1, struct Screen *screen),
	REG(a2, IPCData *ipc),
	REG(a3, IPCData *main_ipc),
	REG(d0, ULONG mod_id),
	REG(d1, EXT_FUNC(func_callback)))
{
	DOpusCallbackInfo info, *infoptr = &info;
	char filename[300];
	FuncArgs *args;

	// Get callbacks
    info.dc_Count=DOPUS_HOOK_COUNT;
    info.dc_RexxCommand=0;
    info.dc_FileRequest=0;
    info.dc_GetThemes=0;
    info.dc_UnlockSource=0;
    IPC_Command(main_ipc,HOOKCMD_GET_CALLBACKS,0,&info,0,REPLY_NO_PORT);

	// Must be able to send rexx commands and show file requester
	if (!info.dc_RexxCommand || !info.dc_FileRequest) return 0;

	// See if filename is supplied
	filename[0]=0;
	if ((args=ParseArgs(func_templates[mod_id],argstring)) && args->FA_Arguments[0])
	{
		strcpy(filename,(char *)args->FA_Arguments[0]);
		if (!strchr(filename,'/') && !strchr(filename,':'))
		{
			lsprintf(filename,"D5THEMES:%s",(IPTR)args->FA_Arguments[0]);
		}	
		if (mod_id!=CONVERTTHEME && (strlen(filename)<7 || stricmp(filename+strlen(filename)-6,".theme")!=0))
			strcat(filename,".theme");
	}

	// No filename?
	if (!*filename && (mod_id==LOADTHEME || mod_id==CONVERTTHEME))
	{
		FunctionEntry *entry;

		// Get first entries
		if ((entry=(FunctionEntry *)func_callback(EXTCMD_GET_ENTRY,IPCDATA(ipc),0)))
		{
			struct endentry_packet packet;

			// Build filename
			func_callback(EXTCMD_GET_SOURCE,IPCDATA(ipc),filename);
			AddPart(filename,entry->name,256);

			// Fill out packet to end entry
			packet.entry=entry;
			packet.deselect=1;
			func_callback(EXTCMD_END_ENTRY,IPCDATA(ipc),&packet);
		}
	}

	// Unlock source lister
	if (info.dc_UnlockSource)
		DC_CALL1(infoptr, dc_UnlockSource, DC_REGA0, IPCDATA(ipc));
		//DC_UnlockSource(infoptr, IPCDATA(ipc));
		//info.dc_UnlockSource(IPCDATA(ipc));
	
	// Save theme?
	if (mod_id==SAVETHEME || mod_id==BUILDTHEME)
	{
		char buf[256];

		// Get themes path
		if (info.dc_GetThemes)
			DC_CALL1(infoptr, dc_GetThemes, DC_REGA0, buf);
			//DC_GetThemes(infoptr,buf);
			//info.dc_GetThemes(buf);
		else
			strcpy(buf,"D5THEMES:");

		// Get filename
		if (filename[0] ||
			DC_CALL6(infoptr, dc_FileRequest,
				DC_REGA0, (struct Window *)screen,
				DC_REGA1, GetString(locale,(mod_id==SAVETHEME)?MSG_SAVE_THEME_MSG:MSG_BUILD_THEME_MSG),
				DC_REGA2, buf,
				DC_REGA3, filename,
				DC_REGD0, (1<<30)|(1<<31)|FRF_DOSAVEMODE,
				DC_REGD1, 0))
			//DC_FileRequest(infoptr,
			//info.dc_FileRequest(
			/*	(struct Window *)screen,
				GetString(locale,(mod_id==SAVETHEME)?MSG_SAVE_THEME_MSG:MSG_BUILD_THEME_MSG),
				buf,
				filename,
				(1<<30)|(1<<31)|FRF_DOSAVEMODE,0))*/
		{
			long res;
			char *ptr;

			// Check .theme suffix
			if (strlen(filename)<7 || stricmp(filename+strlen(filename)-6,".theme")!=0)
				strcat(filename,".theme");

			// Remove spaces
			for (ptr=FilePart(filename);*ptr;ptr++)
				if (*ptr==' ') *ptr='_';

			// Save theme
			if ((res=save_theme(screen,&info,filename,(mod_id==BUILDTHEME)?TRUE:FALSE)))
			{
				// Build error
				lsprintf(filename,GetString(locale,MSG_SAVE_ERROR),res);

				// Show error
				AsyncRequestTags(
					ipc,
					REQTYPE_SIMPLE,
					0,
					0,
					0,
					AR_Screen,(IPTR)screen,
					AR_Message,(IPTR)filename,
					AR_Button,(IPTR)GetString(locale,MSG_OK),
					TAG_END);
			}
		}
	}

	// Load theme
	else
	if (mod_id==LOADTHEME)
	{
		ULONG apply_flags=0;

		// Flags supplied?
		if (args)
		{
			short num;
			for (num=0;num<4;num++)
			{
				if (args->FA_Arguments[num+1])
					apply_flags|=1<<num;
			}
		}

		// No name supplied?
		if (!filename[0])
		{
			BPTR lock;
			Att_List *list;
			Att_Node *node;
			char *apply_switches[5];
			char temp[20];
			char path[256];
			long err;

			// Get old apply flags
			if (!apply_flags && (GetVar("dopus/taf",temp,16,GVF_GLOBAL_ONLY))>0)
				apply_flags=atoi(temp);

			// Initial theme path
			strcpy(path,"D5THEMES:");
			if ((lock=Lock(path,ACCESS_READ)))
			{
				NameFromLock(lock,path,256);
				UnLock(lock);
			}
			
			// Get list of themes
			while ((list=theme_build_list(path)))
			{
				// Switches for what to apply
				apply_switches[0]=GetString(locale,MSG_THEME_APPLY_PALETTE);
				apply_switches[1]=GetString(locale,MSG_THEME_APPLY_FONTS);
				apply_switches[2]=GetString(locale,MSG_THEME_APPLY_PICTURES);
				apply_switches[3]=GetString(locale,MSG_THEME_APPLY_SOUNDS);
				apply_switches[4]=0;

				// Show selection list
				strcpy(filename,path);
				if ((err=SelectionList(
							list,
							0,
							screen,
							GetString(locale,MSG_LOAD_THEME_MSG),
							-1,
							SLF_DIR_FIELD|SLF_USE_INITIAL|SLF_SWITCHES|SLF_RETURN_PATH,
							filename,
							GetString(locale,MSG_OK),
							GetString(locale,MSG_CANCEL),
							apply_switches,
							&apply_flags))>-1)
				{
					// Name selected?
					if ((node=Att_FindNode(list,err)))
					{
						char *ptr;
						for (ptr=node->node.ln_Name;*ptr;ptr++)
							if (*ptr==' ') *ptr='_';
						lsprintf(filename,"D5THEMES:%s.theme",(IPTR)node->node.ln_Name);
					}
					else
						filename[0]=0;

					// Save apply flags
					lsprintf(temp,"%ld",apply_flags);
					SetEnv("dopus/taf",temp,TRUE);
				}
				else
				if (err!=-1 && filename[0]!=0 && filename[strlen(filename)-1]=='/') filename[0]=0;

				// Free list
				Att_RemList(list,0);

				// Break out?
				if (err!=-1) break;

				// Empty path returns to default
				if (!filename[0])
				{
					// Get themes path
					if (info.dc_GetThemes)
						DC_CALL1(infoptr, dc_GetThemes,	DC_REGA0, filename);
						//DC_GetThemes(infoptr,filename);
						//info.dc_GetThemes(filename);
					else 
						strcpy(filename,"DOpus5:Themes/");
					
				}

				// Re-open with new path
				strcpy(path,filename);

				// Assign D5THEMES to the new directory
				if ((lock=Lock(filename,ACCESS_READ)) &&
					!(AssignLock("D5THEMES",lock)))
					UnLock(lock);
			}
		}

		// File to load?
		if (filename[0])
		{
			short num;
			char apply[20],*ptr,command[400],port[40];

			// Build apply flags
			for (num=0,ptr=apply;num<APPLY_LAST;num++)
			{
				if (apply_flags&(1<<num))
					*(ptr++)=apply_lookup[num];
			}
			*ptr=0;

			// Get ARexx port name
			DC_CALL1(infoptr, dc_GetPort, DC_REGA0, port);
			//DC_GetPort(infoptr,port);
			//info.dc_GetPort(port);

			// Build ARexx command to send to DOpus
			lsprintf(command,"%s %s %s",(IPTR)filename,(IPTR)port,(IPTR)apply);
			DC_CALL4(infoptr, dc_SendCommand,
				DC_REGA0, 0,
				DC_REGA1, command,
				DC_REGA2, 0,
				DC_REGD0, COMMANDF_RUN_SCRIPT);
			//DC_SendCommand(infoptr,0,command,0,COMMANDF_RUN_SCRIPT);
			//info.dc_SendCommand(0,command,0,COMMANDF_RUN_SCRIPT);
		}
	}

	// Convert theme
	else
	if (mod_id==CONVERTTHEME)
	{
		// Get filename
		if (filename[0] ||
			DC_CALL6(infoptr, dc_FileRequest,
				DC_REGA0, (struct Window *)screen,
				DC_REGA1, GetString(locale,MSG_CONVERT_THEME_MSG),
				DC_REGA2, 0,
				DC_REGA3, filename,
				DC_REGD0, (1<<30)|(1<<31)|(1<<29)|FRF_DOPATTERNS,
				DC_REGD1, "#?.theme"))
			//DC_FileRequest(infoptr,
			//info.dc_FileRequest(
				/*(struct Window *)screen,
				GetString(locale,MSG_CONVERT_THEME_MSG),
				0,
				filename,
				(1<<30)|(1<<31)|(1<<29)|FRF_DOPATTERNS,
				"#?.theme"))*/
		{
			char dest[256],buf[256],*ptr;

			dest[0]=0;
			if ((args=ParseArgs(func_templates[mod_id],argstring)) && args->FA_Arguments[1])
			{
				strcpy(dest,(char *)args->FA_Arguments[1]);
				if (!strchr(dest,'/') && !strchr(dest,':'))
				{	
					lsprintf(dest,"D5THEMES:%s",(IPTR)args->FA_Arguments[0]);
				}	
			}

			// Ask for path?
			if (!dest[0])
			{
				// Get themes path
				if (info.dc_GetThemes)
					DC_CALL1(infoptr, dc_GetThemes,	DC_REGA0, buf);
					//DC_GetThemes(infoptr,buf);
					//info.dc_GetThemes(buf);
				else
					strcpy(buf,"D5THEMES:");
			}	

			// Get save filename
			if (dest[0] ||
				DC_CALL6(infoptr, dc_FileRequest,
					DC_REGA0, (struct Window *)screen,
					DC_REGA1, GetString(locale,MSG_SAVE_THEME_MSG),
					DC_REGA2, buf,
					DC_REGA3, dest,
					DC_REGD0, (1<<30)|(1<<31)|FRF_DOSAVEMODE,
					DC_REGD1, 0))
				//(DC_FileRequest(infoptr,
				//(info.dc_FileRequest(
				/*	(struct Window *)screen,
					GetString(locale,MSG_SAVE_THEME_MSG),
					buf,
					dest,
					(1<<30)|(1<<31)|FRF_DOSAVEMODE,0)))*/
			{
				short res;

				// Check .theme suffix
				if (strlen(dest)<7 || stricmp(dest+strlen(dest)-6,".theme")!=0)
					strcat(dest,".theme");

				// Remove spaces
				for (ptr=FilePart(dest);*ptr;ptr++)
					if (*ptr==' ') *ptr='_';

				// Convert the file
				if ((res=convert_theme(&info,filename,dest)))
				{
					// Build error
					lsprintf(filename,GetString(locale,MSG_SAVE_ERROR),res);

					// Show error
					AsyncRequestTags(
						ipc,
						REQTYPE_SIMPLE,
						0,
						0,
						0,
						AR_Screen,(IPTR)screen,
						AR_Message,(IPTR)filename,
						AR_Button,(IPTR)GetString(locale,MSG_OK),
						TAG_END);
				}
			}
		}
	}

	DisposeArgs(args);
	return 1;
}
Esempio n. 14
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;
}
Esempio n. 15
0
// Change volume name of a disk in buffers
void notify_disk_name_change(
	BackdropInfo *info,
	char *device,
	char *new_volume)
{
	IPCData *ipc;
	Lister *lister;
	DirBuffer *buffer;
	char *ptr;

	// Get list lock
	lock_listlock(&GUI->buffer_list,FALSE);

	// Go through all buffers
	for (buffer=(DirBuffer *)GUI->buffer_list.list.lh_Head;
		buffer->node.ln_Succ;
		buffer=(DirBuffer *)buffer->node.ln_Succ)
	{
		// Correct disk?
		if (strnicmp(device,buffer->buf_Path,strlen(device))==0)
		{
			// Change volume name
			strcpy(buffer->buf_VolumeLabel,new_volume);

			// Get new full path
			strcpy(buffer->buf_ExpandedPath,new_volume);
			if ((ptr=strchr(buffer->buf_Path,':')))
				strcat(buffer->buf_ExpandedPath,ptr);

			// Is buffer currently displayed in a lister?
			if (buffer->buf_CurrentLister)
			{
				// Refresh path
				IPC_Command(buffer->buf_CurrentLister->ipc,LISTER_REFRESH_PATH,0,0,0,0);
			}
		}
	}

	// Free list lock
	unlock_listlock(&GUI->buffer_list);

	// Lock lister list
	lock_listlock(&GUI->lister_list,FALSE);

	// Go through listers
	for (ipc=(IPCData *)GUI->lister_list.list.lh_Head;
		ipc->node.mln_Succ;
		ipc=(IPCData *)ipc->node.mln_Succ)
	{
		// Get lister pointer
		lister=(Lister *)IPCDATA(ipc);

		// Is lister a device list?
		if (lister->cur_buffer->more_flags&DWF_DEVICE_LIST)
		{
			// Check it's not our current backdrop
			if (lister->backdrop_info!=info)
			{
				devname_change *change;

				// Allocate data structure
				if ((change=AllocVec(sizeof(devname_change),MEMF_CLEAR)))
				{
					// Fill it out
					strcpy(change->old_name,device);
					strcpy(change->new_name,new_volume);

					// Signal it to update the name of the device
					IPC_Command(
						ipc,
						LISTER_UPDATE_DEVICE,
						0,
						0,
						change,
						0);
				}
			}
		}		
	}

	// Unlock lister list
	unlock_listlock(&GUI->lister_list);

	// Have to update main window?
	if (info!=GUI->backdrop)
	{
		devname_change change;

		// Fill in change packet
		strcpy(change.old_name,device);
		strcpy(change.new_name,new_volume);

		// Update name
		backdrop_update_disk(GUI->backdrop,&change,TRUE);
	}
}
Esempio n. 16
0
int LIBFUNC L_Module_Entry(
	REG(a0, struct List *files),
	REG(a1, struct Screen *screen),
	REG(a2, IPCData *ipc),
	REG(a3, IPCData *main_ipc),
	REG(d0, ULONG mod_id),
	REG(d1, ULONG mod_data))
{
	config_path_data *data;
	short success=1;

	// Allocate data
	if (!(data=AllocVec(sizeof(config_path_data),MEMF_CLEAR)) ||
		!(data->path_list=Att_NewList(0)))
	{
		FreeVec(data);
		return 0;
	}

	// Store data pointers
	data->paths=files;
	data->ipc=ipc;
	data->main_ipc=main_ipc;
	data->memory=(APTR)mod_id;
	data->def_format=(ListFormat *)mod_data;

	// AppPort
	data->appport=CreateMsgPort();

	// Open commodities library
	/*data->cxbase=OpenLibrary("commodities.library",0);
	#ifdef __amigaos4__
	ICommodities=(struct CommoditiesIFace *)GetInterface(data->cxbase,"main",1,NULL); 
	#endif	*/
	
	// Build path list
	config_paths_build_list(data);

	// Open window
	if (!(config_paths_open(data,screen)))
		return 0;

	// Event loop
	FOREVER
	{
		IPCMessage *imsg;
		struct IntuiMessage *msg;
		int quit_flag=0;

		// IPC messages?
		while ((imsg=(IPCMessage *)GetMsg(ipc->command_port)))
		{
			// Quit?
			if (imsg->command==IPC_QUIT)
			{
				quit_flag=1;
				success=0;
			}

			// Hide?
			else if (imsg->command==IPC_HIDE)
			{
				RemoveAppWindow(data->appwindow);
				data->appwindow=0;
				CloseConfigWindow(data->window);	
				data->window=0;
			}

			// Show?
			else if (imsg->command==IPC_SHOW)
			{
				if (!(config_paths_open(data,imsg->data)))
				{
					quit_flag=1;
					success=0;
				}
			}

			// Activate
			else if (imsg->command==IPC_ACTIVATE)
			{
				if (data->window)
				{
					WindowToFront(data->window);
					ActivateWindow(data->window);
				}
			}

			// Reply
			IPC_Reply(imsg);
		}

		// Any messages to the window?
		if (data->window)
		{
			while ((msg=GetWindowMsg(data->window->UserPort)))
			{
				struct IntuiMessage msg_copy;
				UWORD gadgetid;

				// Copy message and reply
				msg_copy=*msg;
				ReplyWindowMsg(msg);

				// Look at message
				switch (msg_copy.Class)
				{
					// Close window
					case IDCMP_CLOSEWINDOW:
						quit_flag=1;
						success=0;
						break;


					// Gadget
					case IDCMP_GADGETUP:
					case IDCMP_GADGETDOWN:

						// Get GadgetID
						gadgetid=((struct Gadget *)msg_copy.IAddress)->GadgetID;

						// Look at gadget
						switch (gadgetid)
						{
							// Cancel
							case GAD_PATHFORMAT_CANCEL:
								success=0;

							// Use
							case GAD_PATHFORMAT_SAVE:
								quit_flag=1;
								break;


							// Add an entry
							case GAD_PATHFORMAT_ADD:
								config_paths_add(data,TRUE);
								break;


							// Change path name
							case GAD_PATHFORMAT_PATH:
								config_paths_change(data);
								break;


							// Select an entry
							case GAD_PATHFORMAT_PATHS:
								{
									Att_Node *node;

									// Find selected entry
									node=Att_FindNode(data->path_list,msg_copy.Code);

									// Double-click?
									if (DoubleClick(data->seconds,data->micros,msg_copy.Seconds,msg_copy.Micros) &&
										node==data->path_sel)
									{
										// Edit it	
										config_paths_edit(data);
										break;
									}

									// Store double-click time
									data->seconds=msg_copy.Seconds;
									data->micros=msg_copy.Micros;

									// Not already selected?
									if (node!=data->path_sel)
									{
										// Select it
										config_paths_select(data,node,FALSE);
									}
								}
								break;


							// Key
							case GAD_PATHFORMAT_KEY:
								config_paths_get_key(data);
								break;


							// Open new lister
							case GAD_PATHFORMAT_NEW_LISTER:

								// Valid selection?
								if (data->path_sel)
								{
									position_rec *pos=(position_rec *)data->path_sel->data;

									// Open new lister?
									if (msg_copy.Code)
									{
										// Set flag
										pos->flags|=POSITIONF_OPEN_NEW;
	
										// Clear type flags
										pos->flags&=~(POSITIONF_ICON|POSITIONF_ICON_ACTION);

										// Icon action?
										if (msg_copy.Code==MODE_ACTION)
											pos->flags|=POSITIONF_ICON|POSITIONF_ICON_ACTION;

										// Icon?
										else
										if (msg_copy.Code==MODE_ICON)
											pos->flags|=POSITIONF_ICON;
									}

									// No lister
									else pos->flags&=~POSITIONF_OPEN_NEW;
								}
								break;


							// Remove
							case GAD_PATHFORMAT_REMOVE:
								config_paths_remove(data,TRUE);
								break;


							// Edit
							case GAD_PATHFORMAT_EDIT:
								config_paths_edit(data);
								break;
						}
						break;


					// Key press
					case IDCMP_RAWKEY:

						// Help?
						if (msg_copy.Code==0x5f &&
							!(msg_copy.Qualifier&VALID_QUALIFIERS))
						{
							// Valid main IPC?
							if (main_ipc)
							{
								// Set busy pointer
								SetWindowBusy(data->window);

								// Send help request
								IPC_Command(main_ipc,IPC_HELP,(1<<31),"Paths",0,(struct MsgPort *)-1);

								// Clear busy pointer
								ClearWindowBusy(data->window);
							}
						}
						break;
				}

				// Check quit flag
				if (quit_flag) break;
			}
		}

		// Check quit flag
		if (quit_flag) break;

		// App messages?
		if (data->appport)
		{
			struct AppMessage *msg;

			// Get messages
			while ((msg=(struct AppMessage *)GetMsg(data->appport)))
			{
				// Get first argument
				if (msg->am_NumArgs>0)
				{
					// Is it a directory?
					if (!msg->am_ArgList[0].wa_Name || !*msg->am_ArgList[0].wa_Name)
					{
						char buf[256];

						// Expand path name	
						if (NameFromLock(msg->am_ArgList[0].wa_Lock,buf,256))
						{
							Att_Node *node;

							// Fix trailing /
							AddPart(buf,"",256);

							// Check it's not already in the list
							if (!(node=(Att_Node *)FindNameI((struct List *)data->path_list,buf)))
							{
								// Add a new entry
								config_paths_add(data,FALSE);

								// Copy path to path field
								SetGadgetValue(data->objlist,GAD_PATHFORMAT_PATH,(ULONG)buf);

								// Accept the new path
								config_paths_change(data);
							}

							// It is, select this entry
							else config_paths_select(data,node,FALSE);
						}
					}
				}

				// Reply message
				ReplyMsg((struct Message *)msg);
			}
		}

		// Wait for input
		Wait(
			((data->window)?(1<<data->window->UserPort->mp_SigBit):0)|
			((data->appport)?(1<<data->appport->mp_SigBit):0)|
			1<<ipc->command_port->mp_SigBit);
	}

	// Free stuff
	config_paths_cleanup(data);
	return success;
}
Esempio n. 17
0
void FiletypeEditor(void)
{
	filetype_ed_data *data=0;
	IPCData *ipc;
	short success=0,pending_quit=0;
	BOOL change_flag=0;

	// Do startup
	if (!(ipc=Local_IPC_ProcStartup((ULONG *)&data, (APTR)&_filetypeed_init)))
		return;

	// Create App stuff
	if ((data->app_port=CreateMsgPort()))
	{
		data->app_window=AddAppWindowA(0,0,data->window,data->app_port,0);
	}

	// Get icon image
	if (data->type->icon_path)
	{
#ifdef USE_DRAWICONSTATE
		{
			char *path_copy;
			data->icon_image=NULL;
			if ((path_copy=AllocMemH(0,strlen(data->type->icon_path)+1)))
			{
				// icon_path is guaranteed to have a .info at the end
				stccpy(path_copy,data->type->icon_path,strlen(data->type->icon_path)-4);
				data->icon_image=GetCachedDiskObject(path_copy,0);
				FreeMemH(path_copy);
			}
		}
#else
		data->icon_image=OpenImage(data->type->icon_path,0);
#endif
		// Show icon image
		filetypeed_show_icon(data);
	}

	// Launch class editor immediately?
	if (data->edit_flag) filetypeed_edit_definition(data);

	// Message loop
	FOREVER
	{
		IPCMessage *msg;
		struct IntuiMessage *imsg;
		short break_flag=0;

		// Check drag
		if (config_drag_check(&data->drag))
		{
			// End drag
			filetypeed_end_drag(data,0);
		}

		// Task message?
		while ((msg=(IPCMessage *)GetMsg(ipc->command_port)))
		{
			switch (msg->command)
			{
				// Close message?
				case IPC_QUIT:
					if (!pending_quit)
					{
						success=msg->flags;
						break_flag=1;
					}
					break;


				// Activate
				case IPC_ACTIVATE:
					if (data->window)
					{
						WindowToFront(data->window);
						ActivateWindow(data->window);
					}
					break;


				// Editor saying goodbye
				case IPC_GOODBYE:
					{
						ULONG which;

						// What's just gone?
						which=IPC_GetGoodbye(msg);

						// Class editor?
						if (which==(ULONG)-1) data->class_editor=0;

						// Icon menu editor?
						else
						if (which>15)
						{
							Att_Node *node;

							// Go through icon list
							for (node=(Att_Node *)data->icon_list->list.lh_Head;
								node->node.ln_Succ;
								node=(Att_Node *)node->node.ln_Succ)
							{
								// Match function
								if (((func_node *)node->data)->func==(Cfg_Function *)which)
								{
									// Clear editor pointer
									((func_node *)node->data)->editor=0;

									// Check for invalid function
									if (filetypeed_check_iconmenu(data,node,FALSE))
										change_flag=1;
									break;
								}
							}
						}

						// Normal filetype editor
						else data->editor[which]=0;
					}
					break;


				// Editor returning a function
				case FUNCTIONEDIT_RETURN:
					{
						short ret;

						if ((ret=filetypeed_receive_edit(
							data,
							(FunctionReturn *)msg->data)))
						{
							change_flag=1;
							filetypeed_update_actions(data);
							if (ret==2) filetypeed_update_iconmenu(data);
						}
					}
					break;


				// Class editor returning
				case CLASSEDIT_RETURN:
					filetypeed_receive_class(data,(Cfg_Filetype *)msg->data);
					change_flag=1;
					break;


				// Get a copy of a button
				case BUTTONEDIT_CLIP_BUTTON:

					// Handle this button
					if (filetypeed_get_button(data,(Cfg_Button *)msg->data,(Point *)msg->data_free))
						change_flag=1;
					break;
			}

			// Reply the message
			IPC_Reply(msg);
		}

		// Intuimessage
		if (data->window)
		{
			while ((imsg=GetWindowMsg(data->window->UserPort)))
			{
				struct IntuiMessage msg_copy;
				struct Gadget *gadget;
				struct TagItem *tags;

				// Copy message
				msg_copy=*imsg;

				// Don't reply to IDCMPUPDATE messages just yet
				if (imsg->Class!=IDCMP_IDCMPUPDATE)
				{
					ReplyWindowMsg(imsg);
					imsg=0;
				}

				// Get gadget and tag pointers
				gadget=(struct Gadget *)msg_copy.IAddress;
				tags=(struct TagItem *)gadget;

				// Look at message
				switch (msg_copy.Class)
				{
					// Close window
					case IDCMP_CLOSEWINDOW:
						if (!pending_quit) break_flag=1;
						break;


					// Gadget
					case IDCMP_GADGETUP:
						switch (gadget->GadgetID)
						{
							// Use
							case GAD_FILETYPEED_USE:
								success=1;

							// Cancel
							case GAD_FILETYPEED_CANCEL:
								if (!pending_quit) break_flag=1;
								break;


							// Select a function
							case GAD_FILETYPEED_ACTION_LIST:
								{
									Att_Node *node;

									// Get selected node
									if (!(node=Att_FindNode(data->action_list,msg_copy.Code)))
										break;

									// Enable edit action button
									DisableObject(data->objlist,GAD_FILETYPES_EDIT_ACTION,FALSE);

									// Double-click?
									if (!(DoubleClick(data->last_sec,data->last_mic,msg_copy.Seconds,msg_copy.Micros)) ||
										node!=data->last_sel)
									{
										data->last_sec=msg_copy.Seconds;
										data->last_mic=msg_copy.Micros;
										data->last_sel=node;
										data->last_icon=0;
										break;
									}
								}

								// Fall through

							case GAD_FILETYPES_EDIT_ACTION:

								// No current selection?
								if (!data->last_sel) break;

								// Is editor already up for this action?	
								if (data->editor[data->last_sel->data])
									IPC_Command(data->editor[data->last_sel->data],IPC_ACTIVATE,0,0,0,0);

								// Need to launch editor
								else filetypeed_edit_action(data,data->last_sel->data,data->last_sel->node.ln_Name);
								break;


							// Delete action
							case GAD_FILETYPES_DEL_ACTION:

								// No current selection?
								if (!data->last_sel) break;

								// Is editor up for this action?	
								if (data->editor[data->last_sel->data])
									IPC_Command(data->editor[data->last_sel->data],IPC_QUIT,0,0,0,0);

								// Delete it
								if (filetypeed_del_action(data,data->last_sel->data))
									change_flag=1;
								break;


							// Edit filetype definition
							case GAD_FILETYPEED_EDIT_CLASS:

								// Is class editor already up for this action?	
								if (data->class_editor)
									IPC_Command(data->class_editor,IPC_ACTIVATE,0,0,0,0);

								// Need to launch editor
								else filetypeed_edit_definition(data);
								break;


							// Select icon
							case GAD_FILETYPEED_SELECT_ICON:
								if (filetypeed_pick_icon(data))
									change_flag=1;
								break;


							// Add to icon menu
							case GAD_FILETYPES_ADD_ICON_MENU:
								filetypeed_add_iconmenu(data);
								break;


							// Select an icon menu
							case GAD_FILETYPES_ICON_MENU:
								{
									Att_Node *last=data->last_icon;

									// Handle selection
									if (!(filetypeed_sel_icon(data,msg_copy.Code))) break;

									// Double-click?
									if (data->last_icon!=last ||
										!(DoubleClick(
											data->last_sec,
											data->last_mic,
											msg_copy.Seconds,
											msg_copy.Micros)))
									{
										data->last_sec=msg_copy.Seconds;
										data->last_mic=msg_copy.Micros;
										data->last_sel=0;
										break;
									}
								}

								// Fall through

							case GAD_FILETYPES_EDIT_ICON_MENU:

								// No current selection?
								if (!data->last_icon) break;

								// Edit it
								filetypeed_edit_iconmenu(data,data->last_icon);
								break;


							// Delete from icon menu
							case GAD_FILETYPES_DEL_ICON_MENU:

								// No current selection?
								if (!data->last_icon) break;

								// Delete function
								if (filetypeed_check_iconmenu(data,data->last_icon,TRUE))
									change_flag=1;
								break;
						}
						break;


					// BOOPSI message
					case IDCMP_IDCMPUPDATE:
						{
							short item;

							// Icon list?
							if (GetTagData(GA_ID,0,tags)!=GAD_FILETYPES_ICON_MENU) break;

							// Get item
							if ((item=GetTagData(DLV_DragNotify,-1,tags))!=-1)
							{
								// Handle selection
								filetypeed_sel_icon(data,item);

								// Start the drag
								config_drag_start(&data->drag,data->icon_list,item,tags,TRUE);
							}
						}
						break;


					// Ticks
					case IDCMP_INTUITICKS:
						++data->drag.tick_count;
						break;


					// Mouse move
					case IDCMP_MOUSEMOVE:

						// Handle drag move
						config_drag_move(&data->drag);
						break;


					// Mouse buttons
					case IDCMP_MOUSEBUTTONS:

						// Valid drag info?
						if (data->drag.drag)
						{
							short ok=-1;

							// Dropped ok?
							if (msg_copy.Code==SELECTUP)
							{
								// Remember last position
								data->drag.drag_x=data->window->WScreen->MouseX;
								data->drag.drag_y=data->window->WScreen->MouseY;
								ok=1;
							}

							// Aborted
							else
							if (msg_copy.Code==MENUDOWN) ok=0;

							// End drag?
							if (ok!=-1 && filetypeed_end_drag(data,ok)) change_flag=1;
						}
						break;


					// Key press
					case IDCMP_RAWKEY:

						// Help?
						if (msg_copy.Code==0x5f &&
							!(msg_copy.Qualifier&VALID_QUALIFIERS))
						{
							// Set busy pointer
							SetWindowBusy(data->window);

							// Send help command
							IPC_Command(data->func_startup.main_owner,IPC_HELP,(1<<31),"File Type Editor",0,REPLY_NO_PORT);

							// Clear busy pointer
							ClearWindowBusy(data->window);
						}
						break;
				}

				// Reply to outstanding messages
				if (imsg) ReplyWindowMsg(imsg);
			}

			// Check break flag
			if (break_flag || pending_quit)
			{
				// See if all the editors are gone
				if (IsListEmpty(&data->proc_list.list))
					break;

				// Send quit?
				if (break_flag)
				{
					IPC_ListQuit(&data->proc_list,0,success,FALSE);
					SetWindowBusy(data->window);
				}
				pending_quit=1;
			}
		}

		// AppMessage
		if (data->app_window)
		{
			struct AppMessage *msg;

			while ((msg=(struct AppMessage *)GetMsg(data->app_port)))
			{
				// Got an argument?
				if (msg->am_NumArgs>0)
				{
					char name[256];
					short len;
					APTR image;

					// Get full name
					NameFromLock(msg->am_ArgList[0].wa_Lock,name,256);
					if (msg->am_ArgList[0].wa_Name &&
						*msg->am_ArgList[0].wa_Name)
						AddPart(name,msg->am_ArgList[0].wa_Name,256);

					// Add .info
					if ((len=strlen(name))<6 ||
						stricmp(name+len-5,".info")!=0) strcat(name,".info");

					// Try to get image
#ifdef USE_DRAWICONSTATE
					{
						char *path_copy;
						image=NULL;
						if ((path_copy=AllocMemH(0,strlen(name)+1)))
						{
							// icon_path is guaranteed to have a .info at the end
							stccpy(path_copy,name,strlen(name)-4);
							image=GetCachedDiskObject(path_copy,0);
							FreeMemH(path_copy);
						}
					}
#else
					image=OpenImage(name,0);
#endif

					if (image)
					{
						// Store path
						FreeMemH(data->type->icon_path);
						if ((data->type->icon_path=AllocMemH(0,strlen(name)+1)))
							strcpy(data->type->icon_path,name);

						// Free existing image
#ifdef USE_DRAWICONSTATE
						FreeCachedDiskObject(data->icon_image);
#else
						CloseImage(data->icon_image);
#endif
						data->icon_image=image;

						// Show new image
						filetypeed_show_icon(data);
						change_flag=1;
					}
				}

				// Reply message
				ReplyMsg((struct Message *)msg);
			}
		}

		Wait(1<<ipc->command_port->mp_SigBit|
			1<<data->drag.timer->port->mp_SigBit|
			((data->window)?(1<<data->window->UserPort->mp_SigBit):0)|
			((data->app_window)?(1<<data->app_port->mp_SigBit):0));
	}

	// End any drag in progress
	filetypeed_end_drag(data,0);

	// Need to send button back?
	if (success==1 && change_flag)
	{
		if (IPC_Command(
			data->owner_ipc,
			FILETYPEEDIT_RETURN,
			(ULONG)data->type,
			data->node,
			0,
			REPLY_NO_PORT))
		{
			data->node=0;
		}
	}

	// Free edit filetype
	FreeFiletype(data->type);

	// Remove AppWindow
	RemoveAppWindow(data->app_window);

	// Close window
	CloseConfigWindow(data->window);

	// Close app port
	if (data->app_port)
	{
		struct Message *msg;
		while ((msg=GetMsg(data->app_port)))
			ReplyMsg(msg);
		DeleteMsgPort(data->app_port);
	}

	// Say goodbye
	IPC_Goodbye(ipc,data->owner_ipc,(success==-1)?0:(ULONG)data->node);

	// Free icon image
#ifdef USE_DRAWICONSTATE
	FreeCachedDiskObject(data->icon_image);
#else
	CloseImage(data->icon_image);
#endif

	// Close timer
	FreeTimer(data->drag.timer);

	// Free data
	IPC_Free(ipc);
	Att_RemList(data->action_list,0);
	Att_RemList(data->icon_list,REMLIST_FREEDATA);
	FreeVec(data);
}
Esempio n. 18
0
// Open a group
void backdrop_open_group(BackdropInfo *info,BackdropObject *object,BOOL activate)
{
	GroupData *group;
	IPCData *ipc=0;

	// Valid object?
	if (!object || !object->icon || object->icon->do_Type!=WBDRAWER) return;

	// See if it's already open
	lock_listlock(&GUI->group_list,0);
	if (group=backdrop_find_group(object))
	{
		// Send activate message
		if (activate) IPC_Command(group->ipc,IPC_ACTIVATE,0,0,0,0);
	}
	unlock_listlock(&GUI->group_list);

	// If it was open, return
	if (group) return;

	// Allocate group packet
	if (!(group=AllocVec(sizeof(GroupData),MEMF_CLEAR)))
		return;

	// Fill in group packet
	group->screen=info->window->WScreen;
	if (object->icon->do_DrawerData)
		group->dimensions=*((struct IBox *)&object->icon->do_DrawerData->dd_NewWindow.LeftEdge);
	else
	{
		group->dimensions.Left=20;
		group->dimensions.Top=20;
		group->dimensions.Width=200;
		group->dimensions.Height=150;
	}
	strcpy(group->name,object->name);
	group->object=object;

	// Initialise popup menu
	if (group->popup=PopUpNewHandle(0,0,&locale))
	{
		// Add items
		PopUpNewItem(group->popup,MSG_ICON_SNAPSHOT_MENU,MENU_ICON_SNAPSHOT_WINDOW,0);
		PopUpNewItem(group->popup,MSG_ICON_CLEANUP,MENU_ICON_CLEANUP,0);
	}

	// Launch process
	IPC_Launch(
		&GUI->group_list,
		&ipc,
		"dopus_group",
		(ULONG)backdrop_group_handler,
		STACK_DEFAULT,
		(ULONG)group,(struct Library *)DOSBase);

	// Failed?
	if (!ipc)
	{
		// Free
		PopUpFreeHandle(group->popup);
		FreeVec(group);
	}
}
Esempio n. 19
0
// Read an environment
BOOL environment_open(Cfg_Environment *env,char *name,BOOL first,APTR prog)
{
	struct OpenEnvironmentData *opendata;
	BOOL success;
	short progress=1;

	// Free volatile memory
	ClearMemHandle(env->volatile_memory);

	// Initialise open structure
	if (!(opendata=AllocMemH(env->volatile_memory,sizeof(struct OpenEnvironmentData))))
		return 0;
	opendata->memory=env->desktop_memory;
	opendata->volatile_memory=env->volatile_memory;
	opendata->flags=OEDF_ALL;


	// Initialise progress
	SetProgressWindowTags(prog,PW_FileCount,14,PW_FileNum,1,TAG_END);


	// Read environment
	if ((success=OpenEnvironment((name)?name:env->path,opendata)))
	{
		// Check stack setting and increase if too low
		if (opendata->env.default_stack < STACK_DEFAULT)
			opendata->env.default_stack = STACK_DEFAULT;

		// Copy things back to the environment
		CopyMem((char *)&opendata->env,(char *)env->env,sizeof(CFG_ENVR));
		strcpy(env->toolbar_path,opendata->toolbar_path);
		strcpy(env->menu_path,opendata->menu_path);
		strcpy(env->user_menu_path,opendata->user_menu_path);
		strcpy(env->scripts_path,opendata->scripts_path);
		strcpy(env->hotkeys_path,opendata->hotkeys_path);
		
		// Get maximum filename length
		// we have to do this before the listers are opened
		GUI->def_filename_length=environment->env->settings.max_filename;
		if (GUI->def_filename_length<FILENAME_LEN)
			GUI->def_filename_length=FILENAME_LEN;
		else
		if (GUI->def_filename_length>107)
			GUI->def_filename_length=107;
	}

	// Successful?
	if (success || first)
	{
		ButtonBankNode *button;
		OpenListerNode *lister;

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Store new environment path
		if (name) strcpy(env->path,name);

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Get new toolbar
		FreeToolBar(GUI->toolbar);
		GUI->toolbar=OpenToolBar(0,env->toolbar_path);

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Free lister menu, get new one
		CloseButtonBank(GUI->lister_menu);
		if ((GUI->lister_menu=OpenButtonBank(env->menu_path)))
		{
			// Check if it needs conversion
			if (!(GUI->lister_menu->window.flags&BTNWF_FIX_MENU))
			{
				// Convert it to new format
				ConvertStartMenu(GUI->lister_menu);
				GUI->lister_menu->window.flags|=BTNWF_FIX_MENU;
			}
		}

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Free user menu, get new one
		CloseButtonBank(GUI->user_menu);
		GUI->user_menu=OpenButtonBank(env->user_menu_path);

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Free scripts, get new set
		CloseButtonBank(GUI->scripts);
		GUI->scripts=OpenButtonBank(env->scripts_path);

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Free hotkeys, get new ones
		send_main_reset_cmd(CONFIG_CHANGE_HOTKEYS,0,0);

		// Go through buttons to open
		for (button=(ButtonBankNode *)opendata->buttons.mlh_Head;
			button->node.ln_Succ;)
		{
			ButtonBankNode *next=(ButtonBankNode *)button->node.ln_Succ;
			Buttons *but;

			// Create button bank from this node
			if ((but=buttons_new(button->node.ln_Name,0,&button->pos,0,button->flags|BUTTONF_FAIL)))
			{
				// Set icon position
				but->icon_pos_x=button->icon_pos_x;
				but->icon_pos_y=button->icon_pos_y;
			}

			// Free this node, get next
			Remove((struct Node *)button);
			FreeMemH(button->node.ln_Name);
			FreeMemH(button);
			button=next;
		}

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Go through StartMenus to open
		for (button=(ButtonBankNode *)opendata->startmenus.mlh_Head;
			button->node.ln_Succ;)
		{
			ButtonBankNode *next=(ButtonBankNode *)button->node.ln_Succ;

			// Create new start menu
			start_new(button->node.ln_Name,0,0,button->pos.Left,button->pos.Top);

			// Free this node, get next
			Remove((struct Node *)button);
			FreeMemH(button->node.ln_Name);
			FreeMemH(button);
			button=next;
		}

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Go through listers to open
		for (lister=(OpenListerNode *)opendata->listers.mlh_Head;
			lister->node.ln_Succ;)
		{
			OpenListerNode *next=(OpenListerNode *)lister->node.ln_Succ;

			// Create lister from this node
			if (lister->lister)
				lister_new((Cfg_Lister *)lister->lister);

			// Free this node, get next
			Remove((struct Node *)lister);
			FreeMemH(lister);
			lister=next;
		}

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Free existing desktop list
		env_free_desktop(&env->desktop);

		// Copy new desktop into list
		if (!(IsListEmpty((struct List *)&opendata->desktop)))
		{
			env->desktop=opendata->desktop;
			env->desktop.mlh_TailPred->mln_Succ=(struct MinNode *)&env->desktop.mlh_Tail;
			env->desktop.mlh_Head->mln_Pred=(struct MinNode *)&env->desktop.mlh_Head;
		}

		// Free existing path list
		env_free_desktop(&env->path_list);

		// Copy new pathlist into list
		if (!(IsListEmpty((struct List *)&opendata->pathlist)))
		{
			env->path_list=opendata->pathlist;
			env->path_list.mlh_TailPred->mln_Succ=(struct MinNode *)&env->path_list.mlh_Tail;
			env->path_list.mlh_Head->mln_Pred=(struct MinNode *)&env->path_list.mlh_Head;
		}

		// Free existing sound list
		env_free_desktop(&env->sound_list);

		// Copy new sound list into list
		if (!(IsListEmpty((struct List *)&opendata->soundlist)))
		{
			env->sound_list=opendata->soundlist;
			env->sound_list.mlh_TailPred->mln_Succ=(struct MinNode *)&env->sound_list.mlh_Tail;
			env->sound_list.mlh_Head->mln_Pred=(struct MinNode *)&env->sound_list.mlh_Head;
		}

		// Bump progress
		main_bump_progress(prog,progress++,0);

		// Update priority
		IPC_Command(&main_ipc,
			IPC_PRIORITY,
			env->env->settings.pri_main[1],
			(APTR)env->env->settings.pri_main[0],
			0,0);

		// Fix lister priorities
		lister_fix_priority(0);

		// Bump progress
		main_bump_progress(prog,progress++,0);
	}

	// Failed, free temp lists
	else
	{
		env_free_desktop(&opendata->desktop);
		env_free_desktop(&opendata->pathlist);
		env_free_desktop(&opendata->soundlist);
		env_free_desktop(&opendata->startmenus);
		env_free_desktop(&opendata->buttons);
		env_free_desktop(&opendata->listers);
	}

	// Free open data structure
	FreeMemH(opendata);

	// Bump progress
	main_bump_progress(prog,progress,0);

	// Build the user menu (needed even if there is none)
	display_build_user_menu();

	// Initialise progress
	SetProgressWindowTags(prog,PW_FileCount,1,PW_FileNum,1,TAG_END);

	// Set library flag for 'Move AppIcons to Tools Menu'
	SetLibraryFlags((env->env->display_options&DISPOPTF_SHIFT_APPICONS)?LIBDF_REDIRECT_TOOLS:0,LIBDF_REDIRECT_TOOLS);

	// Set library flag for borderless icons
	SetLibraryFlags((env->env->desktop_flags&DESKTOPF_NO_BORDERS)?LIBDF_BORDERS_OFF:0,LIBDF_BORDERS_OFF);

	// No icon caching?
	SetLibraryFlags((env->env->desktop_flags&DESKTOPF_NO_CACHE)?LIBDF_NO_CACHING:0,LIBDF_NO_CACHING);

	// Set NewIcons flags
	SetNewIconsFlags(env->env->env_NewIconsFlags,env->env->env_NewIconsPrecision);

	// No custom drag?
	SetLibraryFlags((env->env->desktop_flags&DESKTOPF_NO_CUSTOMDRAG)?LIBDF_NO_CUSTOM_DRAG:0,LIBDF_NO_CUSTOM_DRAG);

	// Thin borders?
	SetLibraryFlags((env->env->display_options&DISPOPTF_THIN_BORDERS)?LIBDF_THIN_BORDERS:0,LIBDF_THIN_BORDERS);

	// Update pathlist environment variable
	env_update_pathlist();

	// Set popup delay
	SetPopUpDelay(env->env->settings.popup_delay);

	// Fix MUFS library
	env_fix_mufs();

	// Assign themes path
	env_fix_themes();

	// Initialise sound events
	InitSoundEvents(TRUE);

	return success;
}
Esempio n. 20
0
// Stop dragging a button
void buttons_stop_drag(Buttons *buttons,short x,short y)
{
	struct Layer *layer;
	struct Window *window;
	ULONG id=0;
	BOOL swap_local=0;
	IPCData *ipc=0;
	BOOL ok=0;

	// Free drag info
	FreeDragInfo(buttons->drag_info);
	buttons->drag_info=0;

	// Nothing selected now
	buttons->editor_sel_col=-1;
	buttons->editor_sel_row=-1;
	buttons->button_sel_button=0;
	IPC_Command(
		buttons->editor,
		BUTTONEDIT_SELECT_BUTTON,
		-1,
		(APTR)-1,
		0,
		0);

	// Invalid coordinates?
	if (x==-1 || y==-1) return;

	// Lock layer
	LockScreenLayer(buttons->window->WScreen);

	// Find which layer we dropped it on
	if (layer=WhichLayer(
		&buttons->window->WScreen->LayerInfo,
		x+buttons->window->LeftEdge,
		y+buttons->window->TopEdge))
	{
		// Does layer have a window?
		if ((window=layer->Window))
		{
			// Is it our own window?
			if (window==buttons->window)
			{
				// Set flag to swap with local button
				swap_local=1;
			}
			else
			{
				// Get window ID
				id=GetWindowID(window);

				// Forbid to get IPC
				Forbid();
				if (!(ipc=(IPCData *)GetWindowAppPort(window)))
					Permit();
			}
		}
	}

	// Unlock layer
	UnlockScreenLayer(buttons->window->WScreen);

	// Got an IPC port?
	if (ipc)
	{
		// Button editor or another button bank?
		if (id==WINDOW_BUTTON_CONFIG || id==WINDOW_BUTTONS || id==WINDOW_FUNCTION_EDITOR)
		{
			Cfg_Button *button;
			Point *pos;

			// Store position (screen relative)
			if (pos=AllocVec(sizeof(Point),0))
			{
				pos->x=x+buttons->window->LeftEdge;
				pos->y=y+buttons->window->TopEdge;
			}

			// Copy current button
			if (button=CopyButton(buttons->button_drag_button,0,-1))
			{
				// Send button
				IPC_Command(ipc,BUTTONEDIT_CLIP_BUTTON,0,button,pos,0);
				ok=1;
			}
		}

		// Permit now we've sent the message
		Permit();
	}

	// Swapping local buttons?
	else
	if (swap_local)
	{
		Cfg_Button *swap;

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

		// Get swap button
		if (swap=button_from_point(buttons,&x,&y))
		{
			// Different button?
			if (swap!=buttons->button_drag_button)
			{
				// Swap buttons
				SwapListNodes(
					&buttons->bank->buttons,
					(struct Node *)buttons->button_drag_button,
					(struct Node *)swap);

				// Redraw buttons
				buttons_show_button(
					buttons,
					swap,
					buttons->drag_col,
					buttons->drag_row,
					swap->current,0);
				buttons_show_button(
					buttons,
					buttons->button_drag_button,
					x,
					y,
					buttons->button_drag_button->current,0);
				buttons->flags|=BUTTONF_CHANGED;
			}
		}

		// Unlock bank
		FreeSemaphore(&buttons->bank->lock);
		ok=1;
	}

	// Failed?
	if (!ok) DisplayBeep(buttons->window->WScreen);
}
Esempio n. 21
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);
}
Esempio n. 22
0
// Edit a filetype
void filetype_edit(
	config_filetypes_data *data,
	FiletypeNode *node,
	short edit_flag)
{
	filetype_ed_data *eddata;

	// Valid node?
	if (!node) return;

	// Check editor is not already up for this node
	if (node->editor)
	{
		// Send activate message
		IPC_Command(node->editor,IPC_ACTIVATE,0,0,0,0);
		return;
	}

	// Allocate data for the editor
	if (!(eddata=AllocVec(sizeof(filetype_ed_data),MEMF_CLEAR)))
		return;

	// Try to copy filetype
	if (!(eddata->type=CopyFiletype(node->type,0)))
	{
		FreeVec(eddata);
		return;
	}

	// Fill out data
	eddata->owner_ipc=data->ipc;
	eddata->node=node;
	eddata->action_lookup=filetype_action_lookup;

	// Supply libraries
	/*eddata->func_startup.dopus_base=DOpusBase;
	eddata->func_startup.dos_base=(struct Library *)DOSBase;
	eddata->func_startup.int_base=(struct Library *)IntuitionBase;
	eddata->func_startup.util_base=(struct Library *)UtilityBase;
	eddata->func_startup.cx_base=CxBase;
	eddata->func_startup.wb_base=WorkbenchBase;
	eddata->func_startup.gfx_base=(struct Library *)GfxBase;
	eddata->func_startup.asl_base=AslBase;
	eddata->func_startup.layers_base=LayersBase;*/

	// Supply locale
	eddata->func_startup.locale=locale;

	// Supply gui data pointers
	eddata->new_win.parent=data->window;
	eddata->new_win.dims=&_filetype_editor_window;
	eddata->new_win.locale=locale;
	eddata->obj_def=_filetype_editor_objects;

	// Supply data pointers for function editor
	eddata->func_startup.win_def=&_function_editor_window;
	eddata->func_startup.obj_def=_function_editor_objects;
	eddata->func_startup.func_labels=_function_type_labels;
	eddata->func_startup.flag_list=_funced_flaglist;
	eddata->func_startup.func_list=data->command_list;
	eddata->func_startup.flags=FUNCEDF_NO_KEY;
	eddata->func_startup.main_owner=data->owner_ipc;

	// Supply data pointers for the fileclass editor
	eddata->class_win=&_fileclass_editor_window;
	eddata->class_obj=_fileclass_editor_objects;
	eddata->class_lookup=fileclass_match_lookup;
	eddata->class_strings=matchtype_labels;
	eddata->edit_flag=edit_flag;

	// Launch editor
	if (!(IPC_Launch(
		&data->proc_list,
		&node->editor,
		"dopus_filetype_editor",
		(ULONG)IPC_NATIVE(FiletypeEditor),
		STACK_DEFAULT,
		(ULONG)eddata,
		(struct Library *)DOSBase)) || !node->editor)
	{
		// Failed; free data
		FreeFiletype(eddata->type);
		FreeVec(eddata);
	}
}
Esempio n. 23
0
void SAVEDS PaletteBox(void)
{
	PaletteBoxData *data;
	struct Window *window;
	IPCData *ipc;

	// Do startup
	if (!(ipc=Local_IPC_ProcStartup((ULONG *)&data,0)))
	{
		Forbid();
		return;
	}

	// Get pen count
	data->pen_count=data->screen_data.pen_count;

	// Open window
	if ((window=palette_box_open(data,data->stuff.stuff1.object_def,data->pen_array,data->pen_array)))
	{
		// Event loop
		FOREVER
		{
			struct IntuiMessage *msg;
			IPCMessage *imsg;
			short break_flag=0;

			// IPC messages
			while ((imsg=(IPCMessage *)GetMsg(ipc->command_port)))
			{
				switch (imsg->command)
				{
					// Quit
					case IPC_QUIT:
						break_flag=1;
						break;

					// Activate
					case IPC_ACTIVATE:
						if (window)
						{
							WindowToFront(window);
							ActivateWindow(window);
						}
						break;

					// Hide
					case IPC_HIDE:
						CloseConfigWindow(window);
						window=0;
						break;

					// Show
					case IPC_SHOW:
						data->newwin.parent=(void *)imsg->data;
						if (!(window=palette_box_open(data,data->stuff.stuff1.object_def,data->pen_array,data->pen_array)))
							break_flag=1;
						break;
				}

				IPC_Reply(imsg);
			}

			// Intuition messages
			if (window)
			{
				while ((msg=GetWindowMsg(window->UserPort)))
				{
					struct IntuiMessage msg_copy;
					msg_copy=*msg;
					ReplyWindowMsg(msg);

					// Close
					if (msg_copy.Class==IDCMP_CLOSEWINDOW)
						break_flag=1;

					// Gadget
					else
					if (msg_copy.Class==IDCMP_GADGETUP)
					{
						short fg,bg;

						// Get foreground and background colours
						fg=GetGadgetValue(OBJLIST(window),GAD_PALETTE_FOREGROUND);
						bg=GetGadgetValue(OBJLIST(window),GAD_PALETTE_BACKGROUND);

						// Fix pens
						if (((struct Library*)IntuitionBase)->lib_Version>=39)
						{
							if (fg>=4 && fg<8) fg=248+fg;
							else
							if (fg>7) fg-=4;
							if (bg>=4 && bg<8) bg=248+bg;
							else
							if (bg>7) bg-=4;
						}
						data->fgpen=fg;
						data->bgpen=bg;

						// Send new colours
						IPC_Command(
							data->owner_ipc,
							BUTTONEDIT_NEW_COLOURS,
							data->fgpen,
							(APTR)data->bgpen,
							0,
							0);
					}

					// Key
					else
					if (msg_copy.Class==IDCMP_RAWKEY)
					{
						// Help?
						if (msg_copy.Code==0x5f &&
							!(msg_copy.Qualifier&VALID_QUALIFIERS))
						{
							// Set busy pointer
							SetWindowBusy(window);

							// Send help command
							IPC_Command(data->main_ipc,IPC_HELP,(1<<31),"Select Colours",0,REPLY_NO_PORT);

							// Clear busy pointer
							ClearWindowBusy(window);
						}
					}
				}
			}

			if (break_flag) break;

			Wait(1<<ipc->command_port->mp_SigBit|
				((window)?1<<window->UserPort->mp_SigBit:0));
		}

		CloseConfigWindow(window);
	}
Esempio n. 24
0
void FunctionEditor(void)
{
	struct IntuiMessage *gmsg,msg;
	int break_flag=0;
	UWORD gadgetid=0;
	ULONG waitbits;
	FuncEdData *data;
	IPCData *ipc;
	NewConfigWindow newwin;
	FunctionStartup *startup=0;
	IPCMessage *submsg;
	int success=0;
	BOOL open_window=1;
	BPTR lock;
	ConfigWindow windims;

	// Do startup
	if (!(ipc=Local_IPC_ProcStartup((ULONG *)&startup, (APTR)&funced_init)))
	{
		funced_cleanup(startup->data);
		return;
	}

	// Get data pointer
	data=startup->data;

	// Lock RAM: and CD to it
	if ((lock=Lock("ram:",ACCESS_READ)))
		lock=CurrentDir(lock);

	// Copy dimensions
	if (startup->flags&FUNCEDF_CENTER)
		windims=_function_editor_window_center;
	else
	if (startup->flags&FUNCEDF_LABEL)
		windims=_function_editor_label_window;
	else
		windims=_function_editor_window;

	// Fill in new window
	newwin.parent=startup->window;
	newwin.dims=&windims;
	newwin.title=(startup->title[0])?startup->title:(char *)GetString(startup->locale,MSG_FUNCED_TITLE);
	newwin.locale=startup->locale;
	newwin.port=0;
	newwin.flags=WINDOW_VISITOR|WINDOW_AUTO_KEYS|WINDOW_REQ_FILL;//|WINDOW_SIZE_BOTTOM;
	newwin.font=0;

	// Build flag list
	funced_build_flaglist(data);
	waitbits=1<<ipc->command_port->mp_SigBit|1<<data->drag.timer->port->mp_SigBit;

	// Event loop
	FOREVER
	{
		// Check drag
		if (config_drag_check(&data->drag))
		{
			// End drag
			functioned_end_drag(data,0);
		}

		// Task message?
		while ((submsg=(IPCMessage *)GetMsg(ipc->command_port)))
		{
			// Close message?
			if (submsg->command==IPC_QUIT)
			{
				// Keep changes?
				success=submsg->flags;

				// Set break flag
				break_flag=1;
			}

			// Activate
			else
			if (submsg->command==IPC_ACTIVATE && data->window)
			{
				WindowToFront(data->window);
				ActivateWindow(data->window);
			}

			// Hide
			else
			if (submsg->command==IPC_HIDE && data->window)
			{
				// Store changes in function
				funced_store_edits(data);

				// End any drag in progress
				functioned_end_drag(data,0);

				// Remove AppWindow
				RemoveAppWindow(data->appwindow);
				data->appwindow=0;

				// Close window
				CloseConfigWindow(data->window);

				// Zero stuff
				data->window=0;
				data->objlist=0;
				waitbits=1<<ipc->command_port->mp_SigBit;
			}

			// Show
			else
			if (submsg->command==IPC_SHOW && !data->window)
			{
				// Set flag to open window
				open_window=1;
				newwin.parent=(struct Window *)submsg->data;
			}

			// Passed-along app message
			else
			if (submsg->command==CFG_APPMESSAGE_PASS)
			{
				funced_appmsg(data,submsg->data);
				ReplyMsg((struct Message *)submsg->data);
			}

			// Update our identity
			else
			if (submsg->command==CFG_NEW_ID)
			{
				data->function->function.func_type=submsg->flags;
				startup->object_flags=(ULONG)submsg->data;
			}

			// Copy a function
			else
			if (submsg->command==FUNCTIONEDIT_COPY_LINE)
			{
				FunctionEntry *entry,*next;

				// Copy function
				functioned_copy_line(
					data,
					(FunctionEntry *)submsg->data,
					0,
					(Point *)submsg->data_free);

				// Free function
				entry=(FunctionEntry *)submsg->data;
				while (entry)
				{
					// Get next
					next=(FunctionEntry *)entry->node;

					// Free entry
					FreeVec(entry);
					entry=next;
				}
			}

			// Clip button
			else
			if (submsg->command==BUTTONEDIT_CLIP_BUTTON)
			{
				Cfg_ButtonFunction *func;

				// Show busy pointer
				SetWindowBusy(data->window);

				// Stop editing
				funced_end_edit(data,data->edit_node,0,0);
				data->edit_node=0;

				// Get first function
				if ((func=(Cfg_ButtonFunction *)
					FindFunctionType(
						(struct List *)&((Cfg_Button *)submsg->data)->function_list,
						FTYPE_LEFT_BUTTON)))
				{
					FunctionEntry dummy;
					Cfg_Instruction *ins;

					// Go through instructions
					for (ins=(Cfg_Instruction *)func->instructions.mlh_Head;
						ins->node.mln_Succ;
						ins=(Cfg_Instruction *)ins->node.mln_Succ)
					{
						// Fill out dummy entry
						dummy.type=ins->type;
						if (ins->string) strcpy(dummy.buffer,ins->string);
						else dummy.buffer[0]=0;

						// Copy function line
						data->edit_node=funced_new_entry(data,0,&dummy);
					}

					// Start editing last line
					funced_start_edit(data);

					// Get flags
					data->function->function.flags=func->function.flags;
					data->function->function.code=func->function.code;
					data->function->function.qual=func->function.qual;
					data->function->function.qual_mask=func->function.qual_mask;
					data->function->function.qual_same=func->function.qual_same;

					// Update flag list
					funced_update_flaglist(data);

					// Update key
					funced_show_key(data);
				}

				// Free button
				FreeButton((Cfg_Button *)submsg->data);

				// Clear busy pointer
				ClearWindowBusy(data->window);
			}

			// Reply the message
			IPC_Reply(submsg);
		}

		// Open window?
		if (open_window)
		{
			// Open window
			if (!(data->window=OpenConfigWindow(&newwin)) ||
				!(data->p_objlist=AddObjectList(
					data->window,
					(startup->flags&FUNCEDF_IMAGE)?_function_editor_image_objects:
						((startup->flags&FUNCEDF_LABEL)?_function_editor_label_objects:
														_function_editor_normal_objects))) ||
				!(data->objlist=AddObjectList(data->window,_function_editor_objects)))
				break;

			// Add use or save button
			AddObjectList(data->window,(startup->flags&FUNCEDF_SAVE)?_function_editor_objects_save:_function_editor_objects_use);

			// Store window for drag
			data->drag.window=data->window;

			// Set window ID
			SetWindowID(data->window,0,WINDOW_FUNCTION_EDITOR,(struct MsgPort *)ipc);

			// Add menus
			AddWindowMenus(data->window,_funced_menus);

			// Make this an AppWindow
			data->appwindow=AddAppWindowA(0,0,data->window,data->appport,0);

			// Get waitbits
			waitbits|=1<<data->window->UserPort->mp_SigBit;
			if (data->appwindow) waitbits|=1<<data->appport->mp_SigBit;

			// Disable key?
			if (startup->flags&FUNCEDF_NO_KEY)
			{
				DisableObject(data->objlist,GAD_FUNCED_KEY,TRUE);
			}

			// Initialise gadgets with function data.
			funced_init_gads(data);
			open_window=0;
		}

		// Intuimessage
		if (data->window)
		{
			while ((gmsg=GetWindowMsg(data->window->UserPort)))
			{
				Att_Node *node;

				// Copy message and reply (unless IDCMPUPDATE)
				msg=*gmsg;
				if (gmsg->Class!=IDCMP_IDCMPUPDATE)
				{
					ReplyWindowMsg(gmsg);
					gmsg=0;
				}

				// Get GadgetID
				if (msg.Class==IDCMP_GADGETDOWN ||
					msg.Class==IDCMP_GADGETUP)
					gadgetid=((struct Gadget *)msg.IAddress)->GadgetID;

				// Look at message
				switch (msg.Class)
				{
					// Key press
					case IDCMP_VANILLAKEY:

						// If editing something, activate string gadget
						if (data->edit_node)
							ActivateStrGad(GADGET(GetObject(data->objlist,GAD_FUNCED_EDIT)),data->window);
						break;


					// Close window
					case IDCMP_CLOSEWINDOW:

						// Set break flag
						break_flag=1;
						break;


					// Mouse move
					case IDCMP_MOUSEMOVE:

						// Handle drag move
						config_drag_move(&data->drag);
						break;


					// Inactive window does menu down
					case IDCMP_INACTIVEWINDOW:
						msg.Code=MENUDOWN;

					// Mouse buttons
					case IDCMP_MOUSEBUTTONS:

						// Valid drag info?
						if (data->drag.drag)
						{
							short ok=-1;

							// Dropped ok?
							if (msg.Code==SELECTUP)
							{
								// Is shift down?
								if (msg.Qualifier&(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT))
									data->drag_shift=1;
								else data->drag_shift=0;

								// Remember last position
								data->drag.drag_x=data->window->WScreen->MouseX;
								data->drag.drag_y=data->window->WScreen->MouseY;
								ok=1;
							}

							// Aborted
							else
							if (msg.Code==MENUDOWN)
							{
								// Set abort
								ok=0;
							}

							// End drag?
							if (ok!=-1) functioned_end_drag(data,ok);
						}
						break;


					// Menu
					case IDCMP_MENUPICK:

						{
							struct MenuItem *item;

							// Get item
							if (!(item=ItemAddress(data->window->MenuStrip,msg.Code)))
								break;

							// Treat as gadget
							gadgetid=MENUID(item);
						}

					// Gadget
					case IDCMP_GADGETUP:
					case IDCMP_GADGETDOWN:

						// Look at gadget ID
						switch (gadgetid)
						{
							// Hotkey
							case GAD_FUNCED_KEY:
								{
									IX ix;
									char *ptr;

									// Get key, see if it's invalid
									if ((ptr=(char *)GetGadgetValue(data->objlist,GAD_FUNCED_KEY)) && *ptr)
									{
										// Try to parse
										if (ParseIX(ptr,&ix))
										{
											// Flash screen
											DisplayBeep(data->window->WScreen);

											// Activate key field again
											ActivateStrGad(GADGET(GetObject(data->objlist,GAD_FUNCED_KEY)),data->window);
										}
										else
										{
											data->function->function.code=ix.ix_Code;
											data->function->function.qual=QualValid(ix.ix_Qualifier);
											data->function->function.qual_mask=ix.ix_QualMask;
											data->function->function.qual_same=ix.ix_QualSame;
										}
									}
								}
								break;


							// Flag selected
							case GAD_FUNCED_FLAGS:

								// Get selected node
								node=Att_FindNode(data->flag_list,msg.Code);

								// Set flag
								data->function->function.flags^=node->data;

								// Check change
								funced_check_flag(&data->function->function.flags,node->data);

								// Update flag list
								funced_update_flaglist(data);
								break;


							// Edit a line
							case GAD_FUNCED_LISTER:

								// Get selected node
								node=Att_FindNode(data->func_display_list,msg.Code);

								// Is this the node we're already editing?
								if (node==data->edit_node) break;

								// If we're editing another one, store its contents
								if (data->edit_node)
									funced_end_edit(data,data->edit_node,0,0);

								// Start editing this entry
								data->edit_node=node;
								funced_start_edit(data);
								break;


							// Return pressed in edit line
							case GAD_FUNCED_EDIT:

								// See if we were editing something
								if (data->edit_node)
								{
									// Stop editing
									funced_end_edit(data,data->edit_node,END_DISABLE,msg.Qualifier);
									data->edit_node=0;
								}
								break;


							// New entry
							case GAD_FUNCED_NEW_ENTRY:
							case GAD_FUNCED_INSERT_ENTRY:

								// Create new entry
								functioned_copy_line(data,0,gadgetid,0);
								break;


							// Delete entry
							case GAD_FUNCED_DELETE_ENTRY:
								// Check we were editing something
								if (!data->edit_node) break;

								// Stop editing (signal delete)
								funced_end_edit(data,data->edit_node,END_DISABLE|END_DELETE,0);
								data->edit_node=0;
								break;


							// Function type
							case GAD_FUNCED_FUNCTION_TYPE:
								// Check we were editing something
								if (!data->edit_node) break;

								// Store type
								((FunctionEntry *)data->edit_node->data)->type=msg.Code;

								// Disable popup button if no functions
								DisableObject(
									data->objlist,
									GAD_FUNCED_EDIT_GLASS,
									(msg.Code==INST_COMMAND && !data->startup->func_list));
								break;


							// Glass gadget
							case GAD_FUNCED_EDIT_GLASS:

								// Check we were editing something
								if (data->edit_node)
								{
									char buffer[256];

									// Put up requester
									if (!(funced_command_req(
										data,
										buffer,
										((FunctionEntry *)data->edit_node->data)->type)))
										break;

									// Insert string in edit line
									funced_edit_insertstring(
										data->objlist,
										GAD_FUNCED_EDIT,
										buffer,
										DOpusBase,(struct Library *)IntuitionBase);
								}
								break;


							// Argument list
							case GAD_FUNCED_EDIT_ARGUMENT:

								// Check we were editing something
								if (data->edit_node)
								{
									char buffer[80];

									// Put up requester
									if (!(funced_command_req(
										data,
										buffer,
										-1))) break;

									// Insert string in edit line
									funced_edit_insertstring(
										data->objlist,
										GAD_FUNCED_EDIT,
										buffer,
										DOpusBase,(struct Library *)IntuitionBase);
								}
								break;


							// Export
							case MENU_FUNCED_EXPORT_ASCII:
							case MENU_FUNCED_EXPORT_CMD:

								// Got file requester?
								if (WINREQUESTER(data->window))
								{
									struct TagItem tags[6];
									struct FileRequester *req=WINREQUESTER(data->window);

									// Show busy pointer
									SetWindowBusy(data->window);

									// File requester tags
									tags[0].ti_Tag=ASLFR_Window;
									tags[0].ti_Data=(ULONG)data->window;
									tags[1].ti_Tag=ASLFR_TitleText;
									tags[1].ti_Data=(ULONG)GetString(startup->locale,MSG_FUNCED_SELECT_FILE);
									tags[2].ti_Tag=ASLFR_Flags1;
									tags[2].ti_Data=FRF_DOSAVEMODE|FRF_PRIVATEIDCMP;
									tags[3].ti_Tag=ASLFR_Flags2;
									tags[3].ti_Data=FRF_REJECTICONS;
									tags[4].ti_Tag=(gadgetid==MENU_FUNCED_EXPORT_CMD)?ASLFR_InitialDrawer:TAG_DONE;
									tags[4].ti_Data=(ULONG)"DOpus5:Commands";
									tags[5].ti_Tag=TAG_DONE;

									// Show filerequester
									if (AslRequest(req,tags))
									{
										// Build filename
										strcpy(data->buffer,req->fr_Drawer);
										AddPart(data->buffer,req->fr_File,256);

										// Store changes in function
										funced_store_edits(data);

										// Do export
										if (gadgetid==MENU_FUNCED_EXPORT_CMD)
											function_export_cmd(data->buffer,0,data->function);
										else
											L_FunctionExportASCII(data->buffer,0,data->function,startup->a4);
									}

									// Remove busy pointer
									ClearWindowBusy(data->window);
								}
								break;


							// Cut/Copy
							case MENU_FUNCED_CUT:
							case MENU_FUNCED_COPY:
								{
									APTR iff;

									// Set busy pointer
									SetWindowBusy(data->window);

									// Open clipboard
									if ((iff=IFFOpen((char *)0,IFF_CLIP_WRITE,ID_OPUS)))
									{
										// Stop editing
										funced_end_edit(data,data->edit_node,END_DISABLE,0);
										data->edit_node=0;

										// Store changes in function
										funced_store_edits(data);

										// Save function
										SaveFunction(iff,data->function);

										// Close clipboard
										IFFClose(iff);
									}

									// Just copy, not cut?
									if (gadgetid==MENU_FUNCED_COPY)
									{
										// Clear busy pointer
										ClearWindowBusy(data->window);
										break;
									}

									// Fall through, paste null function
								}

							// Paste
							case MENU_FUNCED_PASTE:
								{
									Cfg_Function *func=0;

									// Set busy pointer
									SetWindowBusy(data->window);

									// End any edit
									funced_end_edit(data,data->edit_node,END_DISABLE,0);
									data->edit_node=0;

									// Paste?
									if (gadgetid==MENU_FUNCED_PASTE)
									{
										APTR iff;

										// Open clipboard
										if ((iff=IFFOpen((char *)0,IFF_CLIP_READ,ID_OPUS)))
										{
											// Find function
											if (IFFNextChunk(iff,ID_FUNC))
											{
												// Read function
												func=ReadFunction(iff,0,0,0);
											}

											// Close clipboard
											IFFClose(iff);
										}

										// No valid function?
										if (!func)
										{
											// Flash error
											DisplayBeep(data->window->WScreen);
											ClearWindowBusy(data->window);
											break;
										}
									}

									// Detach existing list
									SetGadgetChoices(data->objlist,GAD_FUNCED_FLAGS,(APTR)~0);

									// Clear function list
									Att_RemList(data->function_list,REMLIST_SAVELIST|REMLIST_FREEDATA);

									// Free existing instructions
									FreeInstructionList(data->function);

									// Rebuild display list
									funced_build_display(data);

									// Clear flags
									data->function->function.flags=0;
									funced_update_flaglist(data);

									// Clear key
									data->function->function.code=0xffff;
									SetGadgetValue(data->objlist,GAD_FUNCED_KEY,0);

									// Clear label
									if (startup->flags&FUNCEDF_LABEL)
									{
										data->label[0]=0;
										SetGadgetValue(data->p_objlist,GAD_FUNCED_LABEL,0);
									}

									// Paste function in?
									if (func)
									{
										short type;

										// Save type
										type=data->function->function.func_type;

										// Copy function in
										CopyFunction(func,0,data->function);
										data->function->function.func_type=type;

										// Free copied function
										FreeFunction(func);

										// Initialise gadgets
										funced_init_gads(data);
									}
	
									// Clear busy pointer
									ClearWindowBusy(data->window);
								}
								break;


							// Use
							case GAD_FUNCED_USE:
								success=1;

							// Cancel
							case GAD_FUNCED_CANCEL:
								break_flag=1;
								break;
						}
						break;


					// Key press
					case IDCMP_RAWKEY:

						// Help?
						if (msg.Code==0x5f &&
							!(msg.Qualifier&VALID_QUALIFIERS))	
						{
							// Set busy pointer
							SetWindowBusy(data->window);

							// Send help command
							IPC_Command(startup->main_owner,IPC_HELP,(1<<31),"Function Editor",0,REPLY_NO_PORT);

							// Clear busy pointer
							ClearWindowBusy(data->window);
						}
						break;


					// BOOPSI message
					case IDCMP_IDCMPUPDATE:
						{
							struct TagItem *tags=(struct TagItem *)msg.IAddress;
							short item;

							// Check ID
							if (GetTagData(GA_ID,0,tags)!=GAD_FUNCED_LISTER)
								break;

							// Get item
							if ((item=GetTagData(DLV_DragNotify,-1,tags))!=-1)
							{
								// Start the drag
								config_drag_start(&data->drag,data->func_display_list,item,tags,TRUE);
							}
						}
						break;


					// Ticks
					case IDCMP_INTUITICKS:
						++data->drag.tick_count;
						break;
				}

				// Reply to any outstanding message
				if (gmsg) ReplyWindowMsg(gmsg);
			}
		}

		// AppMessage
		if (data->appwindow)
		{
			struct AppMessage *msg;

			while ((msg=(struct AppMessage *)GetMsg(data->appport)))
			{
				// Make sure window is active
				ActivateWindow(data->window);

				// Handle message
				funced_appmsg(data,msg);
				ReplyMsg((struct Message *)msg);
			}
		}

		// Check break flag
		if (break_flag) break;

		// Wait for message
		Wait(waitbits);
	}

	// Restore CD
	if (lock) UnLock(CurrentDir(lock));

	// Edit successful?
	if (success)
	{
		FunctionReturn ret;

		// Store changes in function
		funced_store_edits(data);

		// Fill out return data
		ret.object=startup->object;
		ret.object_flags=startup->object_flags;
		ret.function=data->function;

		// Send new function back
		IPC_Command(startup->owner_ipc,FUNCTIONEDIT_RETURN,0,&ret,0,REPLY_NO_PORT);
	}

	// End any drag in progress
	functioned_end_drag(data,0);

	// Free edit function
	FreeFunction(data->function);

	// Close window
	RemoveAppWindow(data->appwindow);
	CloseConfigWindow(data->window);

	// Close application port
	if (data->appport)
	{
		struct Message *msg;
		while ((msg=GetMsg(data->appport)))
			ReplyMsg(msg);
		DeleteMsgPort(data->appport);
	}

	// Say goodbye
	IPC_Goodbye(ipc,startup->owner_ipc,startup->object_flags);

	// Delete IPC data
	Forbid();
	IPC_Free(ipc);

	// Free data
	funced_cleanup(data);
	FreeVec(startup);
}
Esempio n. 25
0
// 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;
}
Esempio n. 26
0
// Handle drop on an object
BOOL desktop_drop_on_object(BackdropInfo *info,DOpusAppMessage **msg,BackdropObject *drop_obj,UWORD qual)
{
	char *name;
	short ret=1;

	// Allocate buffer
	if (!(name=AllocVec(1024,0))) return 1;

	// Was it an AppIcon?
	if (drop_obj->type==BDO_APP_ICON)
	{
		// Is the icon busy?
		if (drop_obj->flags&BDOF_BUSY)
		{
			// Flash error
			DisplayBeep(info->window->WScreen);
		}

		// Otherwise, pass message on
		else
		{
			struct MsgPort *port;

			// Turn message into an AppIcon one
			(*msg)->da_Msg.am_Type=MTYPE_APPICON;

			// Get port and info
			port=WB_AppWindowData(
				(struct AppWindow *)drop_obj->misc_data,
				&(*msg)->da_Msg.am_ID,
				&(*msg)->da_Msg.am_UserData);

			// Fix reply port
			(*msg)->da_Msg.am_Message.mn_ReplyPort=GUI->appmsg_port;

			// Send the message on
			PutMsg(port,(struct Message *)*msg);

			// Zero message pointer
			*msg=0;
		}
	}

	// Was it a group?
	else
	if (drop_obj->type==BDO_GROUP)
	{
		short arg;
		GroupData *group;
		BOOL ok=0;

		// Find group if it's open
		lock_listlock(&GUI->group_list,0);
		if (!(group=backdrop_find_group(drop_obj)))
			unlock_listlock(&GUI->group_list);

		// Go through arguments
		for (arg=0;arg<(*msg)->da_Msg.am_NumArgs;arg++)
		{
			// Valid file?
			if ((*msg)->da_Msg.am_ArgList[arg].wa_Name &&
				*(*msg)->da_Msg.am_ArgList[arg].wa_Name)
			{
				// Get filename
				GetWBArgPath(&(*msg)->da_Msg.am_ArgList[arg],name,512);

				// Send add message to group if it's open
				if (group)
				{
					char *copy;

					// Copy name
					if ((copy=AllocVec(strlen(name)+1,0)))
					{
						strcpy(copy,name);
						IPC_Command(group->ipc,GROUP_ADD_ICON,0,0,copy,0);
						ok=1;
					}
				}

				// Otherwise add object to group
				else
				{
					backdrop_group_add_object(drop_obj->name,0,name,-1,-1);
					ok=1;
				}
			}
		}

		// Show error if no ok
		if (!ok) DisplayBeep(GUI->screen_pointer);

		// Unlock process list if it's locked
		if (group) unlock_listlock(&GUI->group_list);
	}

	// Or a project?
	else
	if (drop_obj->icon->do_Type==WBPROJECT)
	{
		// Is it an Opus command?
		if (command_filetype)
		{
			BPTR lock,old;

			// Set failure initially
			ret=0;

			// Get lock on directory
			if ((lock=backdrop_icon_lock(drop_obj)))
			{
				// Go there
				old=CurrentDir(lock);

				// See if it's a command
				if (filetype_match_type(drop_obj->name,command_filetype))
				{
					// Run command with args
					backdrop_object_open(
						info,
						drop_obj,
						0,
						0,
						(*msg)->da_Msg.am_NumArgs,
						(*msg)->da_Msg.am_ArgList);
					ret=1;
				}

				// Restore CD
				CurrentDir(old);
			}
		}

		// Beep if not a command
		if (!ret) DisplayBeep(GUI->screen_pointer);
	}

	// Or a tool?
	else
	if (drop_obj->icon->do_Type==WBTOOL)
	{
		// Run program with args
		backdrop_object_open(
			info,
			drop_obj,
			0,
			0,
			(*msg)->da_Msg.am_NumArgs,
			(*msg)->da_Msg.am_ArgList);
	}


	// Or a disk/directory?
	else
	if (drop_obj->icon->do_Type==WBDISK ||
		drop_obj->icon->do_Type==WBDRAWER ||
		drop_obj->icon->do_Type==WBGARBAGE)
	{
		struct ArgArray *arg_array;

		// Get arg array
		if ((arg_array=AppArgArray(*msg,AAF_ALLOW_DIRS)))
		{
			BPTR lock;

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

			// 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,name,512);
				UnLock(lock);
			}

			// Get destination path
			if ((lock=backdrop_icon_lock(drop_obj)))
			{
				short action;

				// Get path
				DevNameFromLockDopus(lock,name+512,512);
				UnLock(lock);

				// Is object a left-out?
				if (drop_obj->type==BDO_LEFT_OUT)
				{
					// Add left-out name
					AddPart(name+512,drop_obj->name,512);
				}

				// Get filetype action
				if (qual&IEQUALIFIER_CONTROL) action=FTTYPE_CTRL_DRAGDROP;
				else
				if (qual&(IEQUALIFIER_LALT|IEQUALIFIER_RALT)) action=FTTYPE_ALT_DRAGDROP;
				else
				action=FTTYPE_DRAG_DROP;

				// Do filetype action on files
				function_launch(
					FUNCTION_FILETYPE,
					0,
					action,
					FUNCF_DRAG_DROP|FUNCF_ICONS,
					0,0,
					name,name+512,
					arg_array,
					0,
					(Buttons *)CopyAppMessage(*msg,global_memory_pool));
			}
		}
	}
	else ret=0;

	FreeVec(name);
	return ret;
}
Esempio n. 27
0
// Rename some objects
void icon_rename(IPCData *ipc,BackdropInfo *info,BackdropObject *icon)
{
	Att_List *list;
	Att_Node *node;
	BackdropObject *object;
	BOOL save_pos=0;
	BPTR lock=0,old=0;

	// Group?
	if (info->flags&BDIF_GROUP)
	{
		GroupData *group;

		// Get group pointer
		group=(GroupData *)IPCDATA(info->ipc);

		// Build directory name
		lsprintf(info->buffer,"dopus5:groups/%s",group->name);

		// Lock directory
		if (!(lock=Lock(info->buffer,ACCESS_READ)))
			return;

		// Change directory
		old=CurrentDir(lock);
	}

	// Create list
	if (!(list=Att_NewList(0)))
	{
		if (lock) UnLock(CurrentDir(old));
		return;
	}

	// Lock backdrop list
	lock_listlock(&info->objects,0);

	// Go through backdrop list (backwards, just for the hell of it)
	for (object=(BackdropObject *)info->objects.list.lh_TailPred;
		object->node.ln_Pred;
		object=(BackdropObject *)object->node.ln_Pred)
	{
		// Correct type?
		if (object->type!=BDO_APP_ICON && object->type!=BDO_BAD_DISK && !(object->flags&BDOF_CACHE))
		{
			// Selected or supplied?
			if ((!icon && object->state) || icon==object)
			{
				// Add object to list
				Att_NewNode(
					list,
					(object->flags&BDOF_CUSTOM_LABEL)?object->device_name:object->name,
					(ULONG)object,
					0);
				if (icon) break;
			}
		}
	}

	// Unlock backdrop list
	unlock_listlock(&info->objects);

	// Go through list of objects
	for (node=(Att_Node *)list->list.lh_Head;
		node->node.ln_Succ;
		node=(Att_Node *)node->node.ln_Succ)
	{
		char *name,*origname;
		BackdropObject *object;
		short ret,copy=1;
		BOOL retry,fail=0;

		if (!(name=AllocVec(512,0)))
			break;
		origname=name+256;

		// Loop on retries
		do
		{
			// Clear retry flag
			retry=0;

			// Copy name
			strcpy(name,node->node.ln_Name);

			// Build message
			lsprintf(info->buffer,GetString(&locale,MSG_RENAME_DISK),name);

			// Strip trailing colon for assigns
			if (name[(ret=(strlen(name)-1))]==':') name[ret]=0;

			// Copy original name
			strcpy(origname,name);

			// Ask for new name
			if (!(ret=super_request_args(
				info->window,
				info->buffer,
				SRF_BUFFER|SRF_IPC|SRF_PATH_FILTER|SRF_MOUSE_POS,
				name,255,
				ipc,
				GetString(&locale,MSG_OKAY),
				GetString(&locale,(node->node.ln_Succ->ln_Succ)?MSG_SKIP:MSG_CANCEL),
				(node->node.ln_Succ->ln_Succ)?GetString(&locale,MSG_CANCEL):0,0)))
			{
				// Cancel
				fail=1;
				break;
			}

			// Ok to rename?
			else
			if (ret!=2)
			{
				// Lock backdrop list
				lock_listlock(&info->objects,0);

				// Is object still valid?>
				if ((object=find_backdrop_object(info,(BackdropObject *)node->data)))
				{
					// Object in a group?
					if (info->flags&BDIF_GROUP)
					{
						// Must have custom label
						if (object->flags&BDOF_CUSTOM_LABEL)
						{
							// Try to rename object
							if (Rename(object->device_name,name))
							{
								// Store new name
								strcpy(object->device_name,name);
								ret=1;
								copy=0;
							}
						}
					}

					// Assign?
					else
					if (object->flags&BDOF_ASSIGN)
					{
						BPTR lock;

						// Lock the assign
						if ((lock=Lock(object->name,ACCESS_READ)))
						{
							// Assign the new name to it
							while (!(ret=AssignLock(name,lock)))
							{
								// Failed, display requester
								if (!(error_request(
									info->window,
									ERF_MOUSE,
									GetString(&locale,MSG_RENAMING),
									-1,
									object->name,
									":",
									0))) break;
							}

							// Success?
							if (ret)
							{
								// Delete the old assignment
								AssignLock(origname,0);
							}

							// Otherwise free the lock
							else UnLock(lock);
						}
					}

					// Disk?
					else
					if (object->type==BDO_DISK)
					{
						// Try to relabel
						while (!(ret=OriginalRelabel(object->device_name,name)))
						{
							// Failed, display requester
							if (!(error_request(
								info->window,
								ERF_MOUSE,
								GetString(&locale,MSG_RENAMING),
								-1,
								object->name,
								":",
								0))) break;
						}

						// Success?
						if (ret)
						{
							// Pass name change through to things
							notify_disk_name_change(info,object->device_name,name);
						}
					}

					// Group, desktop folder
					else
					if (object->type==BDO_GROUP ||
						(object->type==BDO_LEFT_OUT && object->flags&BDOF_DESKTOP_FOLDER))	
					{
						BPTR old=0,lock;

						// Change directory
						if ((lock=Lock(object->path,ACCESS_READ)))
							old=CurrentDir(lock);

						// Rename file
						if (!(ret=Rename(object->name,name)))
						{
							// Show error requester
							if (error_request(
									info->window,
									ERF_MOUSE,
									GetString(&locale,MSG_RENAMING),
									-1,
									object->name,
									":",
									0))
							{
								// Set flag to retry
								retry=1;
							}
						}

						// Success?
						if (ret)
						{
							GroupData *group;

							// Add .infos on
							strcpy(info->buffer,object->name);
							strcat(info->buffer,".info");
							strcpy(info->buffer+300,name);
							strcat(info->buffer+300,".info");

							// Rename icon
							Rename(info->buffer,info->buffer+300);

							// Group?
							if (object->type==BDO_GROUP)
							{
								// Lock process list
								lock_listlock(&GUI->group_list,0);

								// See if group is open
								if ((group=backdrop_find_group(object)))
								{
									char *name_copy;
		
									// Get a copy of the name
									if ((name_copy=AllocVec(strlen(name)+1,0)))
									{
										// Signal it to update its name
										strcpy(name_copy,name);
										IPC_Command(group->ipc,GROUP_NEW_NAME,0,0,name_copy,0);
									}
								}

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

						// Restore directory
						if (lock) UnLock(CurrentDir(old));
					}

					// Left-out
					else
					if (object->type==BDO_LEFT_OUT)
					{
						leftout_record *left;

						// Lock position list
						lock_listlock(&GUI->positions,0);

						// Look for entry for icon
						for (left=(leftout_record *)&GUI->positions.list.lh_Head;
							left->node.ln_Succ;
							left=(leftout_record *)left->node.ln_Succ)
						{
							// Leftout?
							if (left->node.ln_Type==PTYPE_LEFTOUT)
							{
								// Match this icon?
								if (object->misc_data==(ULONG)left)
								{
									// Store new label
									stccpy(left->icon_label,name,sizeof(left->icon_label));
									save_pos=1;
									break;
								}
							}
						}

						// Unlock position list
						unlock_listlock(&GUI->positions);

						// Store name in icon
						if (object->flags&BDOF_CUSTOM_LABEL)
						{
							strcpy(object->device_name,name);
							ret=1;
							copy=0;
						}
					}

					// Successful?
					if (ret)
					{
						// Erase object
						backdrop_erase_icon(info,object,0);

						// Store new name
						if (copy)
						{
							strcpy(object->name,name);
							if (object->flags&BDOF_ASSIGN) strcat(object->name,":");
						}

						// Show new object
						backdrop_render_object(info,object,BRENDERF_CLIP);
					}
				}

				// Unlock backdrop list
				unlock_listlock(&info->objects);
			}
		} while (retry);

		// Abort?
		FreeVec(name);
		if (fail) break;
	}

	// Free list
	Att_RemList(list,0);

	// Lock backdrop list
	lock_listlock(&info->objects,0);

	// Save any left-outs
	if (save_pos)
	{
		// Lock list
		lock_listlock(&GUI->positions,0);

		// Save list
		SavePositions(&GUI->positions.list,GUI->position_name);

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

	// Unlock backdrop list
	unlock_listlock(&info->objects);

	// Restore CD
	if (lock) UnLock(CurrentDir(old));
}