Index: trunk/doc-rnd/TODO =================================================================== --- trunk/doc-rnd/TODO (revision 1578) +++ trunk/doc-rnd/TODO (revision 1579) @@ -14,6 +14,7 @@ - action, all key combinations in tooltip? CLEANUP #5 +- move print.[ch] - BUG: don't use ~/.pcb, use ~/.pcb-rnd; do not hardwire this in the code, make it a config.h setting - libstroke: zoom - cleanup/rewrite resources: Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 1578) +++ trunk/src/Makefile.dep (revision 1579) @@ -239,7 +239,8 @@ ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h mymem.h global.h data.h paths.h plugins.h \ - plug_footprint.h vtlibrary.h compat_fs.h error.h + plug_footprint.h vtlibrary.h compat_fs.h error.h misc.h \ + ../src_3rd/genvector/gds_char.h mymem.h ../src_plugins/fp_wget/fp_wget.o: ../src_plugins/fp_wget/fp_wget.c \ global.h ../config.h ../config.manual.h ../config.auto.h const.h \ ../globalconst.h ../config.h macro.h global_typedefs.h global_objs.h \ @@ -1680,8 +1681,9 @@ vtonpoint.h ../src_3rd/genvector/genvector_impl.h \ ../src_3rd/genvector/genvector_undef.h hid.h global_element.h \ list_element.h data.h file.h mymem.h paths.h plug_footprint.h \ - vtlibrary.h plugins.h ../src_3rd/liblihata/genht/htsp.h \ - ../src_3rd/liblihata/genht/ht.h ../src_3rd/liblihata/genht/ht_inlines.h \ + vtlibrary.h plugins.h pcb-printf.h ../src_3rd/genvector/gds_char.h \ + ../src_3rd/liblihata/genht/htsp.h ../src_3rd/liblihata/genht/ht.h \ + ../src_3rd/liblihata/genht/ht_inlines.h \ ../src_3rd/liblihata/genht/hash.h plug_footprint_host.o: plug_footprint_host.c ../config.h \ ../config.manual.h ../config.auto.h global.h const.h ../globalconst.h \ Index: trunk/src/plug_footprint.c =================================================================== --- trunk/src/plug_footprint.c (revision 1578) +++ trunk/src/plug_footprint.c (revision 1579) @@ -33,6 +33,7 @@ #include "paths.h" #include "plug_footprint.h" #include "plugins.h" +#include "pcb-printf.h" #include #include @@ -112,7 +113,7 @@ fctx->backend->fclose(fctx->backend, f, fctx); } -library_t *fp_append_entry(library_t *parent, const char *dirname, const char *name, fp_type_t type, void *tags[]) +library_t *fp_append_entry(library_t *parent, const char *name, fp_type_t type, void *tags[]) { library_t *entry; /* Pointer to individual menu entry */ size_t len; @@ -122,28 +123,16 @@ if (entry == NULL) return NULL; - /* - * entry->AllocatedMemory points to abs path to the footprint. - * entry->ListEntry points to fp name itself. - */ - len = strlen(dirname) + strlen("/") + strlen(name) + 8; - entry->data.fp.full_path = malloc(len); - strcpy(entry->data.fp.full_path, dirname); - strcat(entry->data.fp.full_path, PCB_DIR_SEPARATOR_S); - - /* store pointer to start of footprint name */ - entry->name = entry->data.fp.full_path + strlen(entry->data.fp.full_path); - entry->dontfree_name = 1; - - /* Now place footprint name into AllocatedMemory */ - strcat(entry->data.fp.full_path, name); - if (type == PCB_FP_PARAMETRIC) - strcat(entry->data.fp.full_path, "()"); + entry->name = pcb_strdup_printf("%s()", name); + else + entry->name = strdup(name); entry->type = LIB_FOOTPRINT; entry->data.fp.type = type; entry->data.fp.tags = tags; + entry->data.fp.loc_info = NULL; + entry->data.fp.backend_data = NULL; } library_t *fp_lib_search_len(library_t *dir, const char *name, int name_len) @@ -185,7 +174,6 @@ l->name = strndup(name, name_len); else l->name = strdup(name); - l->dontfree_name = 0; l->parent = parent; return l; Index: trunk/src/plug_footprint.h =================================================================== --- trunk/src/plug_footprint.h (revision 1578) +++ trunk/src/plug_footprint.h (revision 1579) @@ -81,7 +81,7 @@ const char *fp_get_library_shell(void); /* Append a menu entry in the tree */ -library_t *fp_append_entry(library_t *parent, const char *dirname, const char *name, fp_type_t type, void *tags[]); +library_t *fp_append_entry(library_t *parent, const char *name, fp_type_t type, void *tags[]); /* walk through all lib paths and build the library menu */ int fp_read_lib_all(void); Index: trunk/src/vtlibrary.h =================================================================== --- trunk/src/vtlibrary.h (revision 1578) +++ trunk/src/vtlibrary.h (revision 1579) @@ -54,8 +54,7 @@ /* An element of a library: either a directory or a footprint */ struct library_s { - char *name; /* the string for the selection box */ - int dontfree_name; /* do not free(->name) if non-zero */ + char *name; /* visible name */ library_type_t type; library_t *parent; @@ -64,8 +63,7 @@ vtlib_t children; } dir; struct { /* type == LIB_FOOTPRINT */ - char *full_path; - char *loc_info; /* allocated*/ + char *loc_info; void *backend_data; fp_type_t type; void **tags; /* an array of void * tag IDs; last tag ID is NULL */ Index: trunk/src_plugins/fp_fs/fp_fs.c =================================================================== --- trunk/src_plugins/fp_fs/fp_fs.c (revision 1578) +++ trunk/src_plugins/fp_fs/fp_fs.c (revision 1579) @@ -45,6 +45,7 @@ #include "plug_footprint.h" #include "compat_fs.h" #include "error.h" +#include "misc.h" static fp_type_t pcb_fp_file_type(const char *fn, void ***tags); @@ -78,6 +79,7 @@ static int list_cb(void *cookie, const char *subdir, const char *name, fp_type_t type, void *tags[]) { list_st_t *l = (list_st_t *) cookie; + library_t *e; if (type == PCB_FP_DIR) { list_dir_t *d; @@ -93,7 +95,8 @@ } l->children++; - fp_append_entry(l->menu, subdir, name, type, tags); + e = fp_append_entry(l->menu, name, type, tags); + e->data.fp.loc_info = Concat(subdir, "/", name, NULL); return 0; } @@ -215,7 +218,8 @@ { list_st_t l; list_dir_t *d, *nextd; - char working_[MAXPATHLEN + 1], *visible_subdir; + char working_[MAXPATHLEN + 1]; + const char *visible_subdir; char *working; /* String holding abs path to working dir */ int menuidx; Index: trunk/src_plugins/fp_wget/gedasymbols.c =================================================================== --- trunk/src_plugins/fp_wget/gedasymbols.c (revision 1578) +++ trunk/src_plugins/fp_wget/gedasymbols.c (revision 1579) @@ -138,7 +138,9 @@ /* add to the database */ l = fp_mkdir_p(vpath.array); - fp_append_entry(l, vpath.array, fn, PCB_FP_FILE, NULL); + l = fp_append_entry(l, fn, PCB_FP_FILE, NULL); + fn[-1] = '/'; + l->data.fp.loc_info = strdup(vpath.array); } fp_wget_close(&f, &fctx); Index: trunk/src_plugins/hid_gtk/gui-library-window.c =================================================================== --- trunk/src_plugins/hid_gtk/gui-library-window.c (revision 1578) +++ trunk/src_plugins/hid_gtk/gui-library-window.c (revision 1579) @@ -399,7 +399,7 @@ if (name == NULL) { if ((entry == NULL) || (entry->type != LIB_FOOTPRINT)) return; - fullp = entry->data.fp.full_path; + fullp = entry->data.fp.loc_info; } if (LoadElementToBuffer(PASTEBUFFER, name == NULL ? fullp : name)) SetMode(PASTEBUFFER_MODE); @@ -424,6 +424,8 @@ } } } + g_string_append(pt, "\nLocation:\n "); + g_string_append(pt, entry->data.fp.loc_info); g_string_append(pt, "\n"); gtk_label_set_text(GTK_LABEL(library_window->preview_text), g_string_free(pt, FALSE)); } Index: trunk/src_plugins/hid_lesstif/library.c =================================================================== --- trunk/src_plugins/hid_lesstif/library.c (revision 1578) +++ trunk/src_plugins/hid_lesstif/library.c (revision 1579) @@ -70,7 +70,7 @@ char *args; library_t *e = picks.array[last_pick]; e = &e->data.dir.children.array[cbs->item_position - 1]; - if (LoadElementToBuffer(PASTEBUFFER, e->data.fp.full_path)) + if (LoadElementToBuffer(PASTEBUFFER, e->data.fp.loc_info)) SetMode(PASTEBUFFER_MODE); }