struct NewMenu *ami_create_menu(struct gui_window_2 *gwin) { int i; gwin->menu = AllocVecTags(sizeof(struct NewMenu) * (AMI_MENU_AREXX_MAX + 1), AVT_ClearWithValue, 0, TAG_DONE); ami_init_menulabs(gwin); ami_menu_scan(ami_tree_get_tree(hotlist_window), gwin); ami_menu_arexx_scan(gwin); gwin = ami_menu_layout(gwin); #if defined(WITH_JS) || defined(WITH_MOZJS) gwin->menu[M_JS].nm_Flags = CHECKIT | MENUTOGGLE; if(nsoption_bool(enable_javascript) == true) gwin->menu[M_JS].nm_Flags |= CHECKED; #endif gwin->menu[M_PRINT].nm_Flags = NM_ITEMDISABLED; gwin->menu[M_IMGFORE].nm_Flags = CHECKIT | MENUTOGGLE; if(nsoption_bool(foreground_images) == true) gwin->menu[M_IMGFORE].nm_Flags |= CHECKED; gwin->menu[M_IMGBACK].nm_Flags = CHECKIT | MENUTOGGLE; if(nsoption_bool(background_images) == true) gwin->menu[M_IMGBACK].nm_Flags |= CHECKED; /* Set up scheduler to refresh the hotlist menu */ if(nsoption_int(menu_refresh) > 0) schedule(nsoption_int(menu_refresh), (void *)ami_menu_refresh, gwin); return(gwin->menu); }
void *ami_misc_allocvec_clear(int size, UBYTE value) { #ifdef __amigaos4__ return AllocVecTags(size, AVT_ClearWithValue, value, TAG_DONE); #else void *mem = AllocVec(size, MEMF_ANY); if (mem) memset(mem, value, size); return mem; #endif }
void ami_file_save_req(int type, struct gui_window_2 *gwin, struct hlcache_handle *object) { char *fname = AllocVecTags(1024, NULL); if(AslRequestTags(savereq, ASLFR_Window, gwin->win, ASLFR_SleepWindow, TRUE, ASLFR_TitleText, messages_get("NetSurf"), ASLFR_Screen, scrn, ASLFR_InitialFile, object ? FilePart(nsurl_access(hlcache_handle_get_url(object))) : "", TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); AddPart(fname, savereq->fr_File, 1024); ami_file_save(type, fname, gwin->win, object, gwin->bw->window->favicon, gwin->bw); } if(fname) FreeVec(fname); }
void ami_init_menulabs(struct gui_window_2 *gwin) { int i; gwin->menutype = AllocVecTags(AMI_MENU_AREXX_MAX + 1, AVT_ClearWithValue, 0, TAG_DONE); for(i=0;i <= AMI_MENU_AREXX_MAX;i++) { gwin->menutype[i] = NM_IGNORE; gwin->menulab[i] = NULL; gwin->menuobj[i] = NULL; } ami_menu_alloc_item(gwin, M_PROJECT, NM_TITLE, "Project", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_NEWWIN, NM_ITEM, "NewWindowNS", 'N', NULL, ami_menu_item_project_newwin, NULL); ami_menu_alloc_item(gwin, M_NEWTAB, NM_ITEM, "NewTab", 'T', NULL, ami_menu_item_project_newtab, NULL); ami_menu_alloc_item(gwin, M_BAR_P1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_OPEN, NM_ITEM, "OpenFile", 'O', NULL, ami_menu_item_project_open, NULL); ami_menu_alloc_item(gwin, M_SAVEAS, NM_ITEM, "SaveAsNS", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_SAVESRC, NM_SUB, "Source", 'S', NULL, ami_menu_item_project_save, (void *)AMINS_SAVE_SOURCE); ami_menu_alloc_item(gwin, M_SAVETXT, NM_SUB, "TextNS", 0, NULL, ami_menu_item_project_save, (void *)AMINS_SAVE_TEXT); ami_menu_alloc_item(gwin, M_SAVECOMP, NM_SUB, "SaveCompNS", 0, NULL, ami_menu_item_project_save, (void *)AMINS_SAVE_COMPLETE); #ifdef WITH_PDF_EXPORT ami_menu_alloc_item(gwin, M_SAVEPDF, NM_SUB, "PDFNS", 0, NULL, ami_menu_item_project_save, (void *)AMINS_SAVE_PDF); #endif ami_menu_alloc_item(gwin, M_SAVEIFF, NM_SUB, "IFF", 0, NULL, ami_menu_item_project_save, (void *)AMINS_SAVE_IFF); ami_menu_alloc_item(gwin, M_BAR_P2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_PRINT, NM_ITEM, "PrintNS", 'P', NULL, ami_menu_item_project_print, NULL); ami_menu_alloc_item(gwin, M_BAR_P3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_CLOSETAB, NM_ITEM, "CloseTab", 'K', NULL, ami_menu_item_project_closetab, NULL); ami_menu_alloc_item(gwin, M_CLOSEWIN, NM_ITEM, "CloseWindow", 0, NULL, ami_menu_item_project_closewin, NULL); ami_menu_alloc_item(gwin, M_BAR_P4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_ABOUT, NM_ITEM, "About", '?', NULL, ami_menu_item_project_about, NULL); ami_menu_alloc_item(gwin, M_BAR_P5, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_QUIT, NM_ITEM, "Quit", 'Q', NULL, ami_menu_item_project_quit, NULL); ami_menu_alloc_item(gwin, M_EDIT, NM_TITLE, "Edit", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_CUT, NM_ITEM, "CutNS", 'X', NULL, ami_menu_item_edit_cut, NULL); ami_menu_alloc_item(gwin, M_COPY, NM_ITEM, "CopyNS", 'C', NULL, ami_menu_item_edit_copy, NULL); ami_menu_alloc_item(gwin, M_PASTE, NM_ITEM, "PasteNS", 'V', NULL, ami_menu_item_edit_paste, NULL); ami_menu_alloc_item(gwin, M_BAR_E1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_SELALL, NM_ITEM, "SelectAllNS", 'A', NULL, ami_menu_item_edit_selectall, NULL); ami_menu_alloc_item(gwin, M_CLEAR, NM_ITEM, "ClearNS", 0, NULL, ami_menu_item_edit_clearsel, NULL); ami_menu_alloc_item(gwin, M_BAR_E2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_UNDO, NM_ITEM, "Undo", 'Z', NULL, ami_menu_item_edit_undo, NULL); ami_menu_alloc_item(gwin, M_REDO, NM_ITEM, "Redo", 'Y', NULL, ami_menu_item_edit_redo, NULL); ami_menu_alloc_item(gwin, M_BROWSER, NM_TITLE, "Browser", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_FIND, NM_ITEM, "FindTextNS", 'F', NULL, ami_menu_item_browser_find, NULL); ami_menu_alloc_item(gwin, M_BAR_B1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_HISTLOCL, NM_ITEM, "HistLocalNS", 0, NULL, ami_menu_item_browser_localhistory, NULL); ami_menu_alloc_item(gwin, M_HISTGLBL, NM_ITEM, "HistGlobalNS", 0, NULL, ami_menu_item_browser_globalhistory, NULL); ami_menu_alloc_item(gwin, M_BAR_B2, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_COOKIES, NM_ITEM, "ShowCookiesNS", 0, NULL, ami_menu_item_browser_cookies, NULL); ami_menu_alloc_item(gwin, M_BAR_B3, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_SCALE, NM_ITEM, "ScaleNS", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_SCALEDEC, NM_SUB, "ScaleDec", '-', NULL, ami_menu_item_browser_scale_decrease, NULL); ami_menu_alloc_item(gwin, M_SCALENRM, NM_SUB, "ScaleNorm", '=', NULL, ami_menu_item_browser_scale_normal, NULL); ami_menu_alloc_item(gwin, M_SCALEDEC, NM_SUB, "ScaleDec", '-', NULL, ami_menu_item_browser_scale_decrease, NULL); ami_menu_alloc_item(gwin, M_SCALEINC, NM_SUB, "ScaleInc", '+', NULL, ami_menu_item_browser_scale_increase, NULL); ami_menu_alloc_item(gwin, M_IMAGES, NM_ITEM, "Images", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_IMGFORE, NM_SUB, "ForeImg", 0, NULL, ami_menu_item_browser_foreimg, NULL); ami_menu_alloc_item(gwin, M_IMGBACK, NM_SUB, "BackImg", 0, NULL, ami_menu_item_browser_backimg, NULL); #if defined(WITH_JS) || defined(WITH_MOZJS) ami_menu_alloc_item(gwin, M_JS, NM_ITEM, "EnableJS", 0, NULL, ami_menu_item_browser_enablejs, NULL); #endif ami_menu_alloc_item(gwin, M_BAR_B4, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_REDRAW, NM_ITEM, "Redraw", 0, NULL, ami_menu_item_browser_redraw, NULL); ami_menu_alloc_item(gwin, M_HOTLIST, NM_TITLE, "Hotlist", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_HLADD, NM_ITEM, "HotlistAdd", 'B', NULL, ami_menu_item_hotlist_add, NULL); ami_menu_alloc_item(gwin, M_HLSHOW, NM_ITEM,"HotlistShowNS",'H', NULL, ami_menu_item_hotlist_show, NULL); ami_menu_alloc_item(gwin, M_BAR_H1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_PREFS, NM_TITLE, "Settings", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_PREDIT, NM_ITEM, "SettingsEdit", 0, NULL, ami_menu_item_settings_edit, NULL); ami_menu_alloc_item(gwin, M_BAR_S1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_SNAPSHOT, NM_ITEM, "SnapshotWindow",0, NULL, ami_menu_item_settings_snapshot, NULL); ami_menu_alloc_item(gwin, M_PRSAVE, NM_ITEM, "SettingsSave", 0, NULL, ami_menu_item_settings_save, NULL); ami_menu_alloc_item(gwin, M_AREXX, NM_TITLE, "ARexx", 0, NULL, NULL, NULL); ami_menu_alloc_item(gwin, M_AREXXEX, NM_ITEM, "ARexxExecute",'E', NULL, ami_menu_item_arexx_execute, NULL); ami_menu_alloc_item(gwin, M_BAR_A1, NM_ITEM, NM_BARLABEL, 0, NULL, NULL, NULL); gwin->menutype[AMI_MENU_AREXX_MAX] = NM_END; }
char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codeset, size_t *text_length) { struct CollectionItem *ci_new = NULL, *ci_next, *ci_curr = ci; size_t len = 0; char *text = NULL, *p; /* Scan the collected chunks to find out the total size. * If they are not in UTF-8, convert the chunks first and create a new CollectionItem list. */ do { switch(codeset) { case 106: len += ci_curr->ci_Size; break; case 0: if(ci_new) { ci_next->ci_Next = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE); ci_next = ci_next->ci_Next; } else { ci_new = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE); ci_next = ci_new; } utf8_from_local_encoding(ci_curr->ci_Data, ci_curr->ci_Size, (char **)&ci_next->ci_Data); ci_next->ci_Size = strlen(ci_next->ci_Data); len += ci_next->ci_Size; break; default: if(ci_new) { ci_next->ci_Next = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE); ci_next = ci_next->ci_Next; } else { ci_new = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE); ci_next = ci_new; } utf8_from_enc(ci_curr->ci_Data, (const char *)ObtainCharsetInfo(DFCS_NUMBER, codeset, DFCS_MIMENAME), ci_curr->ci_Size, (char **)&ci_next->ci_Data, NULL); ci_next->ci_Size = strlen(ci_next->ci_Data); len += ci_next->ci_Size; break; } } while (ci_curr = ci_curr->ci_Next); text = malloc(len); if(text == NULL) return NULL; /* p points to the end of the buffer. This is because the chunks are * in the list in reverse order. */ p = text + len; if(ci_new) { ci_curr = ci_new; } else { ci_curr = ci; } do { p -= ci_curr->ci_Size; memcpy(p, ci_curr->ci_Data, ci_curr->ci_Size); ci_next = ci_curr->ci_Next; if(ci_new) { free(ci_curr->ci_Data); FreeVec(ci_curr); } } while (ci_curr = ci_next); *text_length = len; return text; }