On 14 Jun 2009 10:45:43 +0100, Chris Young wrote: > I fixed save_complete by replacing amiga/save_complete.c with > gtk/gtk_save.c and amiga/save_complete.h with the attached (a better > approach is to search through my files for #include > "amiga/save_complete.h" and replace it with #incude > "desktop/save_complete.h" and then delete amiga/save_complete.h) > > There is a minor problem as I don't get an icon for index, I'm just > adding that back in now.
...and here is a version which adds icons to HTML and CSS files (CSS because the filetype of these rarely gets picked up correctly locally) Chris
/* * Copyright 2009 Mark Benjamin <[email protected]> * * This file is part of NetSurf, http://www.netsurf-browser.org/ * * NetSurf is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * NetSurf is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <ctype.h> #include <stdio.h> #include <string.h> #include <libxml/HTMLtree.h> #include "desktop/save_complete.h" #include "utils/utils.h" #include <proto/icon.h> #include <workbench/icon.h> bool save_complete_gui_save(const char *path, const char *filename, struct content *c, int len, char *sourcedata, int type) { int res; int namelen; namelen = strlen(path) + strlen(filename) + 2; char *fullpath = malloc(namelen); if (!fullpath) { warn_user("NoMemory", 0); return false; } snprintf(fullpath, namelen, "%s/%s", path, filename); FILE *f = fopen(fullpath, "w"); /* may need mode 'b' when c != NULL */ free(fullpath); if (f == NULL) return false; res = fwrite(sourcedata, len, 1, f); fclose(f); save_complete_gui_filetype(path, filename, type); if (res != 1) return false; return true; } int save_complete_htmlSaveFileFormat(const char *path, const char *filename, xmlDocPtr cur, const char *encoding, int format) { int ret; int len = strlen(path) + strlen(filename) + 2; char *finame = malloc(len); if (!finame){ warn_user("NoMemory", 0); return -1; } snprintf(finame, len, "%s/%s", path, filename); ret = htmlSaveFileFormat(finame, cur, encoding, format); free(finame); return ret; } bool save_complete_gui_filetype(const char *path, const char *filename, int type) { int ret; char deftype[5]; struct DiskObject *dobj = NULL; int len = strlen(path) + strlen(filename) + 2; char *finame = malloc(len); if (!finame){ warn_user("NoMemory", 0); return -1; } snprintf(finame, len, "%s/%s", path, filename); switch(type) { case 0xfaf: strcpy(deftype,"html"); break; case 0xf79: strcpy(deftype,"css"); break; default: free(finame); return false; break; } dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,deftype, ICONGETA_GetDefaultType,WBPROJECT, TAG_DONE); PutIconTags(finame,dobj, ICONPUTA_NotifyWorkbench,TRUE, TAG_DONE); free(finame); return true; }
