Index: trunk/src/plug_io.c =================================================================== --- trunk/src/plug_io.c (revision 2643) +++ trunk/src/plug_io.c (revision 2644) @@ -145,7 +145,7 @@ static int find_prio_cmp(const void *p1, const void *p2) { const find_t *f1 = p1, *f2 = p2; - return f1->prio > f2->prio; + return f1->prio < f2->prio; } /* Find all plugins that can handle typ/wr and build an ordered list in available[], @@ -155,13 +155,16 @@ { int len = 0; - #define cb_append(pl, pr) \ do { \ if (pr > 0) { \ assert(len < avail_len ); \ available[len].plug = pl; \ - available[len++].prio = pr; \ + if (fmt == NULL) \ + available[len].prio = pl->save_preference_prio; \ + else \ + available[len].prio = pr; \ + len++; \ } \ } while(0) Index: trunk/src/plug_io.h =================================================================== --- trunk/src/plug_io.h (revision 2643) +++ trunk/src/plug_io.h (revision 2644) @@ -47,7 +47,11 @@ reading (if wr == 0) for I/O type typ. Return 0 if not supported or an integer priority if supported. The higher the prio is the more likely the plugin gets the next operation on the file. Base prio should be - 100 for native formats. */ + 100 for native formats. + NOTE: if any format can be chosen for output, the user will have to pick + one; for ordering plugins in that case, the format-neutral + save_preference_prio field is used. + */ int (*fmt_support_prio)(plug_io_t *ctx, plug_iot_t typ, int wr, const char *fmt); /* Attempt to load a pcb design from Filename to Ptr. @@ -74,6 +78,8 @@ const char *default_fmt; const char *description; + + int save_preference_prio; /* all available save plugins are sorted by this before presenting them to the user to choose one */ }; extern plug_io_t *plug_io_chain; Index: trunk/src_plugins/io_kicad_legacy/io_kicad_legacy.c =================================================================== --- trunk/src_plugins/io_kicad_legacy/io_kicad_legacy.c (revision 2643) +++ trunk/src_plugins/io_kicad_legacy/io_kicad_legacy.c (revision 2644) @@ -59,6 +59,7 @@ io_kicad_legacy.write_pcb = io_kicad_legacy_write_pcb; io_kicad_legacy.default_fmt = "kicadl"; io_kicad_legacy.description = "Kicad, legacy format"; + io_kicad_legacy.save_preference_prio = 90; HOOK_REGISTER(plug_io_t, plug_io_chain, &io_kicad_legacy); Index: trunk/src_plugins/io_pcb/io_pcb.c =================================================================== --- trunk/src_plugins/io_pcb/io_pcb.c (revision 2643) +++ trunk/src_plugins/io_pcb/io_pcb.c (revision 2644) @@ -60,6 +60,7 @@ io_pcb.write_pcb = io_pcb_WritePCB; io_pcb.default_fmt = "pcb"; io_pcb.description = "geda/pcb"; + io_pcb.save_preference_prio = 100; HOOK_REGISTER(plug_io_t, plug_io_chain, &io_pcb);