static void load_enums_filter(int which, char *name) { int argc; char **spl = zSplitTclList(name, &argc); int i; if((!spl)||(!argc)||(argc&1)) { status_text("Malformed enums list!\n"); return; } remove_file_filter(which, 0); /* should never happen from GUI, but possible from save files or other weirdness */ for(i=0;i<argc;i+=2) { char *lhs = spl[i]; char *xlt = spl[i+1]; GLOBALS->xl_file_filter[which] = xl_insert(lhs, GLOBALS->xl_file_filter[which], xlt); } free_2(spl); }
/* * DND "drag_data_received" handler. When DNDDataRequestCB() * calls gtk_selection_data_set() to send out the data, this function * receives it and is responsible for handling it. * * This is also the only DND callback function where the given * inputs may reflect those of the drop target so we need to check * if this is the same structure or not. */ static void DNDDataReceivedCB( GtkWidget *widget, GdkDragContext *dc, gint x, gint y, GtkSelectionData *selection_data, guint info, guint t, gpointer data) { gboolean same; GtkWidget *source_widget; if((widget == NULL) || (data == NULL) || (dc == NULL)) return; /* Important, check if we actually got data. Sometimes errors * occure and selection_data will be NULL. */ if(selection_data == NULL) return; if(selection_data->length < 0) return; /* Source and target widgets are the same? */ source_widget = gtk_drag_get_source_widget(dc); same = (source_widget == widget) ? TRUE : FALSE; if(same) { return; } /* Now check if the data format type is one that we support * (remember, data format type, not data type). * * We check this by testing if info matches one of the info * values that we have defined. * * Note that we can also iterate through the atoms in: * GList *glist = dc->targets; * * while(glist != NULL) * { * gchar *name = gdk_atom_name((GdkAtom)glist->data); * * strcmp the name to see if it matches * * one that we support * * * glist = glist->next; * } */ if((info == WAVE_DRAG_TAR_INFO_0) || (info == WAVE_DRAG_TAR_INFO_1) || (info == WAVE_DRAG_TAR_INFO_2)) { int impcnt = 0; ds_Tree *ft = NULL; int argc = 0; char**zs = zSplitTclList((const char *)selection_data->data, &argc); if(zs) { int i; for(i=0;i<argc;i++) { if((!strncmp("net ", zs[i], 4)) || (!strncmp("netBus ", zs[i], 7))) { char *stemp = strdup(zs[i]); char *ss = strchr(stemp, ' ') + 1; char *sl = strrchr(stemp, ' '); char *pnt = ss; if(sl) { *sl = 0; while(*pnt) { if(*pnt == ' ') { *pnt = '.'; } pnt++; } } ft = flattened_mod_list_root; while(ft) { if(!strcmp(ss, ft->fullname)) { if(!ft->dnd_to_import) { ft->dnd_to_import = 1; impcnt++; } break; } ft = ft->next_flat; } free(stemp); } } free(zs); } if(impcnt) { ds_Tree **fta = calloc(impcnt, sizeof(ds_Tree *)); int i = 0; while(ft) { if(ft->dnd_to_import) { ft->dnd_to_import = 0; fta[i++] = ft; if(i == impcnt) break; } ft = ft->next_flat; } for(i=impcnt-1;i>=0;i--) /* reverse list so it is forwards in rtlbrowse */ { bwlogbox(fta[i]->fullname, 640 + 8*8, fta[i], 0); } free(fta); } } }