void desktop_drop(BackdropInfo *info,DOpusAppMessage *msg,UWORD qual) { BackdropObject *drop_obj; short ok=0,x,y; char *name,*source_path; short arg,action=DESKTOP_POPUP_LEFTOUT; struct ArgArray *array=0; struct ArgArrayEntry *aae; BOOL check; // Lock backdrop list lock_listlock(&info->objects,0); // See if we dropped stuff on an object if ((drop_obj=backdrop_get_object(info,msg->da_Msg.am_MouseX,msg->da_Msg.am_MouseY,0))) { // Is shift/alt down? if ((qual&(IEQUALIFIER_LSHIFT|IEQUALIFIER_LALT))==(IEQUALIFIER_LSHIFT|IEQUALIFIER_LALT)) { char pathname[256]; // Get path of first file GetWBArgPath(&msg->da_Msg.am_ArgList[0],pathname,256); // Replace the image backdrop_replace_icon_image(info,pathname,drop_obj); // Reply the message ReplyAppMessage(msg); } // Handle drop on an object else if (desktop_drop_on_object(info,&msg,drop_obj,qual)) { // Reply the message ReplyAppMessage(msg); } // Not dropped else drop_obj=0; } // Unlock backdrop list unlock_listlock(&info->objects); // Dropped on an object? if (drop_obj) return; // Get buffer if (!(name=AllocVec(1024,MEMF_CLEAR))) return; source_path=name+512; // Popup menu? if (environment->env->env_flags&ENVF_DESKTOP_FOLDER) { UWORD res; // Activate the underlying menu ActivateWindow(info->window); // Default action set? if (environment->env->desktop_popup_default>DESKTOP_POPUP_NONE && !(qual&(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT))) { // Use default action action=environment->env->desktop_popup_default; } // Ask user what they want to do else if ((res=DoPopUpMenu(info->window,&GUI->desktop_menu->ph_Menu,0,SELECTDOWN))==(UWORD)-1 || res==MENU_DESKTOP_CANCEL) { // Cancelled FreeVec(name); return; } // Help? else if (res&POPUP_HELPFLAG) { // Do help help_menu_help(res&~POPUP_HELPFLAG,0); // Cancelled FreeVec(name); return; } // Get action else if (res==MENU_DESKTOP_COPY) action=DESKTOP_POPUP_COPY; else if (res==MENU_DESKTOP_MOVE) action=DESKTOP_POPUP_MOVE; } // Set busy pointer SetBusyPointer(info->window); // DOpus message? check=CheckAppMessage(msg); // Go through arguments for (arg=0;arg<msg->da_Msg.am_NumArgs;arg++) { // What operation? switch (action) { // Leave out? case DESKTOP_POPUP_LEFTOUT: // Get path name GetWBArgPath(&msg->da_Msg.am_ArgList[arg],name,512); // Ignore if it's an icon or a disk if (!(isicon(name)) && name[strlen(name)-1]!=':') { short len,perm=0; BackdropObject *icon; // Permanent? if (GUI->flags2&GUIF2_BENIFY) perm=1; // Get position x=msg->da_Msg.am_MouseX; y=msg->da_Msg.am_MouseY; // Drop from DOpus? if (check) { // Adjust position for icon offset x+=msg->da_DragOffset.x+msg->da_DropPos[arg].x; y+=msg->da_DragOffset.y+msg->da_DropPos[arg].y; } // Strip trailing / len=strlen(name)-1; if (name[len]=='/') name[len]=0; // Leave this out if ((icon=backdrop_leave_out(info,name,(perm)?BLOF_PERMANENT:0,x,y))) { // Position it backdrop_place_object(info,icon); // Save for permanent leftout if (perm) backdrop_save_leftouts(info); ok=1; } } break; // Copy/Move case DESKTOP_POPUP_COPY: case DESKTOP_POPUP_MOVE: { BOOL dir=0; // Create ArgArray if needed if (!array && !(array=NewArgArray())) break; // Get path name GetWBArgPath(&msg->da_Msg.am_ArgList[arg],name,512); // Set flag if a directory if (!msg->da_Msg.am_ArgList[arg].wa_Name || !*msg->da_Msg.am_ArgList[arg].wa_Name) dir=1; // Get source path if (!*source_path) { char *ptr; // Copy from name strcpy(source_path,name); // Strip last part if ((ptr=FilePart(source_path))) *ptr=0; } // Create argument if ((aae=NewArgArrayEntry(array,FilePart(name)))) { // Set directory flag if (dir) aae->ae_Flags|=AEF_DIR; // Set OK flag ok=1; } } break; } } // Successful? if (ok) { // Left-outs? if (action==DESKTOP_POPUP_LEFTOUT) { // Refresh backdrop_show_objects(info,BDSF_RECALC); } // Otherwise, launch function else { // Launch the function function_launch( FUNCTION_RUN_FUNCTION_EXTERNAL, (action==DESKTOP_POPUP_COPY)?def_function_copy:def_function_move, 0, FUNCF_ICONS|FUNCF_RESCAN_DESKTOP|FUNCF_DRAG_DROP|FUNCF_COPY_NO_MOVE, 0,0, source_path,environment->env->desktop_location, array, 0, (Buttons *)CopyAppMessage(msg,global_memory_pool)); } } // Otherwise, free array else FreeArgArray(array); // Free buffer FreeVec(name); // Clear busy pointer ClearPointer(info->window); // Reply the message ReplyAppMessage(msg); }
// Cleanup a lister void lister_cleanup(Lister *lister,BOOL bye) { struct Node *node; // Send goodbye message? if (bye) { // Update our position if (!(environment->env->lister_options&LISTEROPTF_SNAPSHOT)) PositionUpdate(lister,0); // Send goodbye message IPC_Goodbye(lister->ipc,&main_ipc,WINDOW_LISTER); } // Is lister iconified? if (lister->appicon) { // Remove AppIcon RemoveAppIcon(lister->appicon); // Free icon FreeDiskObjectCopy(lister->appicon_icon); } // If we still have a progress window, close it lister_progress_off(lister); // Showing a special buffer? if (lister->cur_buffer==lister->special_buffer) { // Return to normal lister->cur_buffer=lister->old_buffer; } // Remove buffer lock if (lister->cur_buffer) { // Get buffer list lock lock_listlock(&GUI->buffer_list,TRUE); // Unlock buffer buffer_clear_lock(lister->cur_buffer,1); // If buffer is empty or buffer count exceeds maximum, free it if (lister->cur_buffer->buf_TotalEntries[0]==0 || GUI->buffer_count>environment->env->settings.max_buffer_count || (environment->env->settings.dir_flags&DIRFLAGS_DISABLE_CACHING)) { // Free buffer lister_free_buffer(lister->cur_buffer); } // Unlock buffer list unlock_listlock(&GUI->buffer_list); } // Free user data while ((node=lister->user_data_list.list.lh_Head)->ln_Succ) { Remove(node); FreeMemH(node); } // Free ports if (lister->app_port) { DOpusAppMessage *msg; while ((msg=(DOpusAppMessage *)GetMsg(lister->app_port))) ReplyAppMessage(msg); DeleteMsgPort(lister->app_port); } // Close font if (lister->font) CloseFont(lister->font); // Free signals if (lister->abort_signal!=-1) FreeSignal(lister->abort_signal); if (lister->hot_name_bit!=-1) FreeSignal(lister->hot_name_bit); // Free timer stuff if (lister->timer_port) { // Close timers FreeTimer(lister->foo_timer); FreeTimer(lister->icon_drag_timer); FreeTimer(lister->busy_timer); FreeTimer(lister->edit_timer); FreeTimer(lister->scroll_timer); // Delete timer port DeleteMsgPort(lister->timer_port); } // Free regions if (lister->title_region) DisposeRegion(lister->title_region); if (lister->refresh_extra) DisposeRegion(lister->refresh_extra); // Free special buffer if (lister->special_buffer) buffer_free(lister->special_buffer); // Free reselection FreeReselect(&lister->reselect); // Free history Att_RemList(lister->path_history,0); // Free popup menu PopUpFreeHandle(lister->lister_tool_menu); // Free toolbar FreeToolBar(lister->toolbar_alloc); // Free IPC data IPC_Free(lister->ipc); // Free lister data lister_free(lister); // Decrement count --main_lister_count; }
// Quit the program void quit(BOOL script) { // If main status window is open, close it if (main_status) { CloseProgressWindow(main_status); main_status=0; } if (GUI) { // Clear 'startup' flag for scripts GUI->flags&=~GUIF_DONE_STARTUP; // Close commodities cx_remove(GUI->cx); // Update environment settings env_update_settings(1); // Stop notify request RemoveNotifyRequest(GUI->notify_req); GUI->notify_req=0; // Is there a hide appicon? if (GUI->hide_appicon) { RemoveAppIcon(GUI->hide_appicon); FreeCachedDiskObject(GUI->hide_diskobject); } // Or an appmenuitem? if (GUI->hide_appitem) RemoveAppMenuItem(GUI->hide_appitem); // Launch shutdown script if (script) RunScript(SCRIPT_SHUTDOWN,0); // Set quit flag GUI->flags|=GUIF_PENDING_QUIT; // Shut the display down close_display(CLOSE_ALL,TRUE); // Send quit notifications quit_notify(); // Stop notifications stop_file_notify(GUI->pattern_notify); stop_file_notify(GUI->font_notify); stop_file_notify(GUI->modules_notify); stop_file_notify(GUI->commands_notify); stop_file_notify(GUI->env_notify); stop_file_notify(GUI->desktop_notify); stop_file_notify(GUI->filetype_notify); // Free application port if (GUI->appmsg_port) { DOpusAppMessage *amsg; RemPort(GUI->appmsg_port); while ((amsg=(DOpusAppMessage *)GetMsg(GUI->appmsg_port))) ReplyAppMessage(amsg); DeleteMsgPort(GUI->appmsg_port); GUI->appmsg_port=0; // Remove public semaphore RemSemaphore((struct SignalSemaphore *)&pub_semaphore); } // Flush IPC port IPC_Flush(&main_ipc); // Close all processes IPC_ListQuit(&GUI->lister_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->group_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->buttons_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->startmenu_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->process_list,&main_ipc,0,TRUE); IPC_ListQuit(&GUI->function_list,&main_ipc,0,TRUE); // Free buffers buffers_clear(0); // Remove all handlers RemFunctionTrap("*","#?"); // Free filetypes FreeMemHandle(GUI->filetype_memory); // Flush the filetype cache ClearFiletypeCache(); // Free lister toolbar FreeToolBar(GUI->toolbar); // Free menus and hotkeys CloseButtonBank(GUI->lister_menu); CloseButtonBank(GUI->hotkeys); // Free user menus CloseButtonBank(GUI->user_menu); FreeVec(GUI->user_menu_data); // Free backdrop list backdrop_free(GUI->backdrop); // Free icons if (GUI->lister_icon) FreeCachedDiskObject(GUI->lister_icon); if (GUI->button_icon) FreeCachedDiskObject(GUI->button_icon); // Free arrow image CloseImage(GUI->toolbar_arrow_image); #ifdef __amigaos3__ FreeVec(arrow_hi_data_chip); FreeVec(arrow_lo_data_chip); FreeVec(small_arrow_chip); FreeVec(big_arrow_chip); #ifndef USE_SCREENTITLE FreeVec(moon_big_data_chip); FreeVec(moon_small_data_chip); #endif FreeVec(command_arrow_chip); FreeVec(parent_arrow_chip); #endif // Free screen signal if (GUI->screen_signal!=-1) FreeSignal(GUI->screen_signal); // Delete notify port if (GUI->notify_port) DeleteMsgPort(GUI->notify_port); // Free position memory FreeMemHandle(GUI->position_memory); // Free command history Att_RemList(GUI->command_history,0); // Delete icon positioning port DeleteMsgPort(GUI->iconpos_port); // Free popup menu PopUpFreeHandle(GUI->desktop_menu); // Clear requester pattern hook in library if (GUI->flags2&GUIF2_BACKFILL_SET) SetReqBackFill(0,0); } // Free scripts FreeScripts(); // Free environment environment_free(environment); // Delete main message ports IPC_Flush(&main_ipc); DeleteMsgPort(main_ipc.command_port); DeleteMsgPort(main_ipc.reply_port); // Pause here for a couple of seconds to let everything clean up Delay(3*50); // Free global data FreeMemHandle(global_memory_pool); // Delete any temporary files delete_temp_files(0); // Free locale data free_locale_data(&locale); // Close input device if (InputBase) { #ifdef __amigaos4__ DropInterface((struct Interface *)IInput); #endif CloseDevice((struct IORequest *)&input_req); } // Close timer device if (TimerBase) { #ifdef __amigaos4__ DropInterface((struct Interface *)ITimer); #endif CloseDevice((struct IORequest *)&timer_req); } // Close console device if (ConsoleDevice) { #ifdef __amigaos4__ DropInterface((struct Interface *)IConsole); #endif CloseDevice((struct IORequest *)&console_req); } // Close libraries #ifdef __amigaos4__ DropInterface((struct Interface *)Imu); #endif CloseLibrary(muBase); #ifndef __amigaos3__ #ifdef __amigaos4__ DropInterface((struct Interface *)INewIcon); #endif CloseLibrary((struct Library *)NewIconBase); #endif #ifdef __amigaos4__ DropInterface((struct Interface *)ICyberGfx); #endif CloseLibrary(CyberGfxBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IAmigaGuide); #endif CloseLibrary(AmigaGuideBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IDataTypes); #endif CloseLibrary(DataTypesBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IAsl); #endif CloseLibrary(AslBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IIcon); #endif CloseLibrary(IconBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IDiskfont); #endif CloseLibrary(DiskfontBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IWorkbench); #endif CloseLibrary(WorkbenchBase); #ifdef __amigaos4__ DropInterface((struct Interface *)ICommodities); #endif CloseLibrary(CxBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IRexxSys); #endif CloseLibrary((struct Library *)RexxSysBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IUtility); #endif CloseLibrary(UtilityBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IGadTools); #endif CloseLibrary(GadToolsBase); #ifdef __amigaos4__ DropInterface((struct Interface *)ILayers); #endif CloseLibrary((struct Library *)LayersBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IGraphics); #endif CloseLibrary((struct Library *)GfxBase); #ifdef __amigaos4__ DropInterface((struct Interface *)IIntuition); #endif CloseLibrary((struct Library *)IntuitionBase); // Restore old current directory? if (old_current_dir) { UnLock(CurrentDir(old_current_dir)); } // Close the dopus5.library #ifdef __amigaos4__ DropInterface((struct Interface *)IDOpus); #endif CloseLibrary(DOpusBase); // Outahere! exit(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); }